Checking pref tree for remotely administered prefs now, and now auto-check

RemoteAdmin checkbox on following page if any are found.  Fixes bug 13657.
This commit is contained in:
mitchf%netscape.com 2002-07-23 17:26:22 +00:00
parent 3336d70572
commit cdb62d91aa
3 changed files with 72 additions and 2 deletions

View File

@ -918,6 +918,17 @@ BOOL CInterpret::interpret(CString cmds, WIDGET *curWidget)
userAgent++;
}
}
else if (strcmp(pcmd, "CheckRemoteAdminsFound") == 0)
{
CString remoteAdminPrefFound = GetGlobal("RemoteAdminPrefFound");
if (remoteAdminPrefFound)
{
WIDGET* w = findWidget("RemoteAdmin");
if (w)
((CButton*)w->control)->SetCheck(atoi(remoteAdminPrefFound));
}
}
else if (strcmp(pcmd, "ValidateRemoteAdmin") == 0)
{
// if checkbox is set, then there must be a URL.
@ -1433,7 +1444,12 @@ BOOL CInterpret::interpret(CString cmds, WIDGET *curWidget)
((CPrefEditView*)w->control)->SetFocus();
}
else if (strcmp(pcmd, "CheckRemoteAdmins") == 0)
{
WIDGET *w = findWidget(parms);
if (w->type == "PrefsTree")
((CPrefEditView*)w->control)->CheckForRemoteAdmins();
}
else if (strcmp(pcmd, "CheckCustPage1Settings") == 0)
{
CString str;

View File

@ -14,6 +14,7 @@
#include "DlgFind.h"
#include "DlgAdd.h"
#include "Encoding.h"
#include "globals.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -402,6 +403,8 @@ BOOL CPrefEditView::LoadTreeControl()
XML_ParserFree(parser);
CheckForRemoteAdmins();
free(buffer);
return TRUE;
@ -788,7 +791,9 @@ void CPrefEditView::EditSelectedPrefsItem()
imageIndexSel = imageIndex = bm_lockedPad;
treeCtrl.SetItemImage(hTreeCtrlItem, imageIndex, imageIndexSel);
CheckForRemoteAdmins();
}
}
@ -869,3 +874,50 @@ void CPrefEditView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
CTreeView::OnKeyDown(nChar, nRepCnt, nFlags);
}
}
// Check to see if any of the prefs were marked for remote admin
// if any have, set the global RemoteAdminFound to true
void CPrefEditView::CheckForRemoteAdmins()
{
CTreeCtrl &treeCtrl = GetTreeCtrl();
HTREEITEM hRoot = treeCtrl.GetRootItem();
if (IsRemoteAdministered(hRoot))
SetGlobal("RemoteAdminPrefFound","1");
else
SetGlobal("RemoteAdminPrefFound","0");
}
// Given a tree item, returns TRUE if it or any children are remote
// administered
bool CPrefEditView::IsRemoteAdministered(HTREEITEM hItem)
{
if(!hItem)
return FALSE;
// Get the pref name associated with this tree ctrl item.
CTreeCtrl &treeCtrl = GetTreeCtrl();
CPrefElement* pe = (CPrefElement*)treeCtrl.GetItemData(hItem);
if (pe && pe->IsRemoteAdmin())
return TRUE;
bool bRemoted = FALSE;
HTREEITEM hChild = treeCtrl.GetChildItem(hItem);
if(hChild)
bRemoted = IsRemoteAdministered(hChild);
if(bRemoted == FALSE)
{
HTREEITEM hSibling = treeCtrl.GetNextSiblingItem(hItem);
if(hSibling)
bRemoted = IsRemoteAdministered(hSibling);
}
return bRemoted;
}

View File

@ -34,6 +34,7 @@ public:
void DoFindFirst(); // open the Find Pref dialog
void DoFindNext(); // find next item
void DoAdd(); // open the Add Pref dialog
void CheckForRemoteAdmins(); // see if any prefs were marked remote admin
// These are only for the XML parser to call.
void startElement(const char *name, const char **atts);
@ -95,6 +96,7 @@ private:
HTREEITEM FindTreeItemFromPrefname(HTREEITEM hItem, CString& rstrPrefName);
HTREEITEM InsertPrefElement(CPrefElement* pe, HTREEITEM group);
HTREEITEM AddPref(CString& rstrPrefName, CString& rstrPrefDesc, CString& rstrPrefType);
bool IsRemoteAdministered(HTREEITEM hItem);
BOOL LoadTreeControl();
void WriteXMLItem(FILE* fp, int iLevel, HTREEITEM hItem);