number of params. 02 Jan 2002
Added
useradded attribute 28 Jan 2002
+Added the
MANAGE element.
24 Jan 2002
+Removed elements
INSTALLATIONFILE and
PREFFILE. Changed
processPrefsTree() number of params.
02 Jan 2002
Removed
choose attribute.
13 Dec 2001
Original version.
11 Dec 2001
Steve Meredith
@@ -16,22 +18,45 @@ The name of the XML file is specified in the .ini section for the PrefsTree
Widget. The default file must be located in the same directory as the
WIZARDMACHINE.EXE
. When used, a copy of the file is saved in the working config directory.
This copy contains the changes made by the CCK/Factory user, and is used
-by the install builder to write preferences in the install image. A SCRIPT.IB
-entry must be made in order for it process the .XML file:
processPrefsTree(,browser.xpi,bin/netscp6.cfg)
-. Note that spaces are not allowed between the parameters. For details on
+by the install builder to write preferences in the install image. A
SCRIPT.IB
+entry must be made in order for it process the .XML file:
processPrefsTree(,browser.xpi,bin/netscp6.cfg). Note that spaces are not allowed between the parameters. For details on
adding a PrefsTree control to wizard pages, see the document
PrefsTree.htm
+
A Note on Prefs
The XML described herein contains elements for prefs and elements to control how they are
+grouped in a UI. It was specifically designed for use in this
Pref Editor
+tree control, but a complete representation of prefs in XML could be useful
+in other ways. But for this use, the only prefs which should be included
+in this file are prefs which can be set in advance and saved to a .cfg or .jsc file.
+Note that this excludes some prefs which might be found in a profile
prefs.js
+, such as those prefs which define specific mail and news accounts, servers,
+and identities. These pref names are generated on the fly by the client.
+If this XML is to be expanded for use in other ways, for example as described
+in
Bugzilla bug 17199
+, new tags could be added to each pref to indicate whether or not it could
+be set in advance and stored in a .cfg file. The Pref Editor would have to
+be modified to respect this new information and only present the appropriate
+prefs for editting. Otherwise, any new elements and attributes are ignored
+as long as the basic structure of the file remains valid (
<PREF>s are grouped within
<PREFSGROUP>s) and the required attributes and subelements exist.
+
+The following prefs should not be placed into this XML file for use in the
+prefs editor because they are handled outside the prefs editor, and used
+to point to the file created by the install builder and prefs editor.
+
+ - autoadmin.global_config_url
+ - autoadmin.append_emailaddr
+ - autoadmin.offline_failover
+
Who This Document is For
+
You will need to understand the structure of the XML file if you want to
-add or remove prefs to the Pref Editor or change how they are grouped.
+add or remove prefs to the Pref Editor or change how they are grouped.
Conventions
For XML item tags, we use ALL CAPS. For attribute names, we use lower case.
“true” and “false” are also written in lower case. Generally, for PREF items,
the attributes are those things about the pref which are fixed, and use elements
for thing the CCK/Factory app will change. The exception is for
<CHOICES>, which are difficult to represent as attributes, so these are elements.
-
General Structure
-
Example 1
+
General Structure
Example 1
The simplest file that may exist consists of one group containing one pref.
<?xml version="1.0"?>
@@ -106,19 +131,19 @@ Each <PREFSGROUP> element will make a new level of hierarchy in t
- Attribute
+ | Attribute
|
- Example
+ | Example
|
- Description
+ | Description
|
- uiname
+ | uiname
|
- uiname="Netscape Preferences"
+ | uiname="Netscape Preferences"
|
- This is the name of the group as it appears in the tree control.
+ | This is the name of the group as it appears in the tree control.
|
@@ -130,36 +155,36 @@ the user can edit.These elements must be contained in some <PREFSGROUP>
- Attribute
+ | Attribute
|
- Example
+ | Example
|
- Description
+ | Description
|
- uiname
+ | uiname
|
- uiname="Open Browser on Startup"
+ | uiname="Open Browser on Startup"
|
- This is the name of the pref as is appears in the
+ | This is the name of the pref as is appears in the
tree control. It doesn't have to be the name of the pref--it should be something
easy for the user to understand.
|
- prefname
+ | prefname
|
- prefname="general.startup.browser" |
- This is the real name of the pref as it is used by the Netscape client products.
+ | prefname="general.startup.browser" |
+ This is the real name of the pref as it is used by the Netscape client products.
|
- type
+ | type
|
- type="bool"
+ | type="bool"
|
- Must be one of int, bool, or string. This determines how the pref will be edited in the Pref Editor and how it is written to the prefs file in the install image.
+ | Must be one of int, bool, or string. This determines how the pref will be edited in the Pref Editor and how it is written to the prefs file in the install image.
bool Pref Editor user allowed to select “true” or “false”
from a drop-down. No quotes are used when writing the pref in the pref file.
@@ -172,23 +197,36 @@ For example, pref("general.startup.browser", true);
|
- lockable
+ | lockable
|
- lockable="true"
+ | lockable="true"
|
- Determines whether or not the Pref Editor user can change the lock state the pref.
+ | Determines whether or not the Pref Editor user can change the lock state the pref.
|
- description
+ | description
|
- description="When the application starts, open a browser window."
+ | description="When the application starts, open a browser window."
|
- This is some text which further describes the pref
+ | This is some text which further describes the pref
to the Pref Editor user. It appears when the user selected the pref for editing.
-Any text which helps the user under the pref should go here.
+Any text which helps the user under the pref should go here.
+ There is space in the editor for maybe 125 characters or so. Of course,
+you can edit the dialog resource to hold more if this becomes a limitation.
+ |
+
+ useradded
+ |
+ useradded="true"
+ |
+ This pref is added by the Pref Editor for all new
+prefs added by the user via the UI. It is normally not present, and is assumed
+to be false if missing. User added prefs are deletable via the Pref Editor
+UI.
|
+
<CHOICES>
@@ -207,27 +245,27 @@ This element appears in <CHOICES> elements to describe one item o
- Attribute
+ | Attribute
|
- Example
+ | Example
|
- Description
+ | Description
|
- uiname
+ | uiname
|
- uiname="Blank Page"
+ | uiname="Blank Page"
|
- The text of this choice in the list box for this choice.
+ | The text of this choice in the list box for this choice.
|
- value
+ | value
|
- value="0"
+ | value="0"
|
- The value saved in the <VALUE> element for the <PREF> when the pref is edit and this choice is selected in the list box. The type of the value must be correct for the enclosing <PREF> element.
+ | The value saved in the <VALUE> element for the <PREF> when the pref is edit and this choice is selected in the list box. The type of the value must be correct for the enclosing <PREF> element.
|
@@ -236,5 +274,9 @@ This element appears in <CHOICES> elements to describe one item o
of type. This gets modified when the user edits the pref. Note that the modified
file is saved to the working config directory.
<LOCKED>
One and only one must appear in a <PREF> element. This is true or false, depending on whether the pref is locked or not. If locked, prefs are written as lockPref() instead of pref(). See also <PREF lockable="true">.
-
+<MANAGE>
+This pref is added by the pref editor, and is normally absent in a prefs
+XML file until it has been processed by the prefs editor. If the <MANAGE>
+ tag is present, and its value is true, then this pref will be written to
+the output prefs file when the XML is processed by the install builder app.
\ No newline at end of file
diff --git a/mozilla/cck/driver/WizardMachine.aps b/mozilla/cck/driver/WizardMachine.aps
index 550004acdb6..65390e3cfac 100644
Binary files a/mozilla/cck/driver/WizardMachine.aps and b/mozilla/cck/driver/WizardMachine.aps differ
diff --git a/mozilla/cck/driver/WizardMachine.rc b/mozilla/cck/driver/WizardMachine.rc
index 09caa77a4ba..48a24e5a06d 100644
--- a/mozilla/cck/driver/WizardMachine.rc
+++ b/mozilla/cck/driver/WizardMachine.rc
@@ -516,6 +516,15 @@ BEGIN
MENUITEM "&Find Pref\tCtrl+F", ID_FINDPREF
MENUITEM "Find &Next Pref\tF3", ID_FINDNEXTPREF
END
+ POPUP "UserAddedItemSubMenu"
+ BEGIN
+ MENUITEM "&Edit Pref", ID_EDITPREFITEM
+ MENUITEM "&Add Pref", ID_ADDPREF
+ MENUITEM "&Delete Pref", ID_DELPREF
+ MENUITEM SEPARATOR
+ MENUITEM "&Find Pref\tCtrl+F", ID_FINDPREF
+ MENUITEM "Find &Next\tF3", ID_FINDNEXTPREF
+ END
END
diff --git a/mozilla/cck/driver/prefeditview.cpp b/mozilla/cck/driver/prefeditview.cpp
index 00d21bb6b89..86e4f9917b6 100644
--- a/mozilla/cck/driver/prefeditview.cpp
+++ b/mozilla/cck/driver/prefeditview.cpp
@@ -27,6 +27,10 @@ const int bm_lockedPad = 2;
const int bm_unlockedPad = 3;
const int bm_unlockedPadGray = 4;
+// submenus
+const int menu_pref = 0;
+const int menu_group = 1;
+const int menu_userAddedPref = 2;
/////////////////////////////////////////////////////////////////////////////
// CPrefEditView
@@ -42,6 +46,7 @@ BEGIN_MESSAGE_MAP(CPrefEditView, CTreeView)
ON_COMMAND(ID_FINDPREF, OnFindPref)
ON_COMMAND(ID_FINDNEXTPREF, OnFindNextPref)
ON_COMMAND(ID_ADDPREF, OnAddPref)
+ ON_COMMAND(ID_DELPREF, OnDelPref)
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -610,8 +615,10 @@ void CPrefEditView::OnFindNextPref()
// User added prefs go into the root group.
HTREEITEM CPrefEditView::AddPref(CString& rstrPrefName, CString& rstrPrefDesc, CString& rstrPrefType)
{
- // Modify it.
+ // Create it.
CPrefElement* newPref = new CPrefElement(rstrPrefName, rstrPrefDesc, rstrPrefType);
+
+ newPref->SetUserAdded(TRUE);
// Add it to the tree.
CTreeCtrl &treeCtrl = GetTreeCtrl();
@@ -664,6 +671,28 @@ void CPrefEditView::OnAddPref()
}
+// Delete the user-added pref.
+void CPrefEditView::OnDelPref()
+{
+ CTreeCtrl &treeCtrl = GetTreeCtrl();
+ HTREEITEM hTreeCtrlItem = treeCtrl.GetSelectedItem();
+
+ // Can't edit a pref group--only a pref (leaf).
+ if (treeCtrl.ItemHasChildren(hTreeCtrlItem))
+ return;
+
+ // If user added-pref, delete the CPrefElement that was created with new.
+ CPrefElement* pe = (CPrefElement*)treeCtrl.GetItemData(hTreeCtrlItem);
+ ASSERT(pe); // There must be a CPrefElement object for each pref in the tree.
+ if ((pe == NULL) || !pe->IsUserAdded())
+ return;
+
+ delete pe;
+
+ // Remove item from the tree.
+ treeCtrl.DeleteItem(hTreeCtrlItem);
+}
+
// Open the edit dialog box for the selected pref item. A pref should be selected,
// not a group.
void CPrefEditView::EditSelectedPrefsItem()
@@ -759,9 +788,21 @@ void CPrefEditView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
int submenu;
if (!treeCtrl.ItemHasChildren(hTreeCtrlItem)) // no children == leaf node == pref
- submenu = 0;
+ {
+ CPrefElement* pe = (CPrefElement*)treeCtrl.GetItemData(hTreeCtrlItem);
+ ASSERT(pe); // there must be a CPrefElement object for each leaf node.
+ if (!pe)
+ return;
+
+ if (pe->IsUserAdded())
+ submenu = menu_userAddedPref;
+ else
+ submenu = menu_pref;
+ }
else
- submenu = 1;
+ {
+ submenu = menu_group;
+ }
ShowPopupMenu(pt, submenu);
}
@@ -782,6 +823,11 @@ void CPrefEditView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
OnFindPref();
}
+ else if (nChar == VK_DELETE)
+ {
+ OnDelPref();
+ }
+
else
{
CTreeView::OnKeyDown(nChar, nRepCnt, nFlags);
diff --git a/mozilla/cck/driver/prefeditview.h b/mozilla/cck/driver/prefeditview.h
index 73b1a3c4982..9fc47f04dac 100644
--- a/mozilla/cck/driver/prefeditview.h
+++ b/mozilla/cck/driver/prefeditview.h
@@ -68,6 +68,7 @@ protected:
afx_msg void OnFindPref();
afx_msg void OnFindNextPref();
afx_msg void OnAddPref();
+ afx_msg void OnDelPref();
afx_msg void OnRclick(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
diff --git a/mozilla/cck/driver/resource.h b/mozilla/cck/driver/resource.h
index 4fdf10c91a5..6e015e250d3 100644
--- a/mozilla/cck/driver/resource.h
+++ b/mozilla/cck/driver/resource.h
@@ -58,13 +58,14 @@
#define ID_FINDPREF 32774
#define ID_FINDNEXTPREF 32776
#define ID_ADDPREF 32777
+#define ID_DELPREF 32778
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 148
-#define _APS_NEXT_COMMAND_VALUE 32778
+#define _APS_NEXT_COMMAND_VALUE 32779
#define _APS_NEXT_CONTROL_VALUE 1020
#define _APS_NEXT_SYMED_VALUE 101
#endif
diff --git a/mozilla/cck/prefs/prefselement.cpp b/mozilla/cck/prefs/prefselement.cpp
index de680857ded..f09a9f69451 100644
--- a/mozilla/cck/prefs/prefselement.cpp
+++ b/mozilla/cck/prefs/prefselement.cpp
@@ -49,6 +49,7 @@ void CPrefElement::ReInit()
m_bLocked = FALSE;
m_bLockable = TRUE;
m_bManage = FALSE;
+ m_bUserAdded = FALSE;
m_iChoices = 0;
}
@@ -143,6 +144,8 @@ void CPrefElement::startElement(const char* name, const char** atts)
m_bLockable = (stricmp(attrVal, "true") == 0);
else if (stricmp(attrName, "description") == 0)
m_strDescription = attrVal;
+ else if (stricmp(attrName, "useradded") == 0)
+ m_bUserAdded = (stricmp(attrVal, "true") == 0);
}
}
@@ -316,9 +319,9 @@ CString CPrefElement::XML(int iIndentSize, int iIndentLevel)
int iIndentSpaces = iIndentSize * iIndentLevel;
CString strRet;
- strRet.Format("%*s\n",
+ strRet.Format("%*s\n",
iIndentSpaces, " ", GetUIName(), GetPrefName(), GetPrefType(),
- IsLockable()?"true":"false", GetPrefDescription());
+ IsLockable()?"true":"false", GetPrefDescription(), IsUserAdded()?"true":"false");
CString strTmp;
if (IsChoose())
diff --git a/mozilla/cck/prefs/prefselement.h b/mozilla/cck/prefs/prefselement.h
index 479729b3546..524ebf01611 100644
--- a/mozilla/cck/prefs/prefselement.h
+++ b/mozilla/cck/prefs/prefselement.h
@@ -26,6 +26,8 @@ public:
void SetLocked(BOOL bLocked) { m_bLocked = bLocked; };
BOOL IsManage() { return m_bManage; };
void SetManage(BOOL bManage) { m_bManage = bManage; };
+ BOOL IsUserAdded() { return m_bUserAdded; };
+ void SetUserAdded(BOOL bUserAdded) { m_bUserAdded = bUserAdded; };
CString GetUIName() { return m_strUIName; };
CString GetPrefValue() { return m_strPrefValue; };
void SetPrefValue(CString strValue);
@@ -59,6 +61,7 @@ private:
BOOL m_bLocked;
BOOL m_bLockable;
BOOL m_bManage;
+ BOOL m_bUserAdded;
CString m_astrChoiceName[MAX_CHOICES+1]; // Array of possible choice names. Last is empty string.
CString m_astrChoiceVal[MAX_CHOICES+1]; // Matching values for the above names.