Skip to content

Commit

Permalink
Checking pref tree for remotely administered prefs now, and now auto-…
Browse files Browse the repository at this point in the history
…check

RemoteAdmin checkbox on following page if any are found.  Fixes bug 13657.
  • Loading branch information
mitchf%netscape.com committed Jul 23, 2002
1 parent 3336d70 commit cdb62d9
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
18 changes: 17 additions & 1 deletion cck/driver/interpret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
54 changes: 53 additions & 1 deletion cck/driver/prefeditview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "DlgFind.h"
#include "DlgAdd.h"
#include "Encoding.h"
#include "globals.h"

#ifdef _DEBUG
#define new DEBUG_NEW
Expand Down Expand Up @@ -402,6 +403,8 @@ BOOL CPrefEditView::LoadTreeControl()

XML_ParserFree(parser);

CheckForRemoteAdmins();

free(buffer);
return TRUE;

Expand Down Expand Up @@ -788,7 +791,9 @@ void CPrefEditView::EditSelectedPrefsItem()
imageIndexSel = imageIndex = bm_lockedPad;

treeCtrl.SetItemImage(hTreeCtrlItem, imageIndex, imageIndexSel);


CheckForRemoteAdmins();

}
}

Expand Down Expand Up @@ -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;

}
2 changes: 2 additions & 0 deletions cck/driver/prefeditview.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CPrefEditView : public CTreeView
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);
Expand Down Expand Up @@ -95,6 +96,7 @@ class CPrefEditView : public CTreeView
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);
Expand Down

0 comments on commit cdb62d9

Please sign in to comment.