зеркало из https://github.com/mozilla/pjs.git
Bug 202388 runtime switch between system prefs and mozilla prefs.
sr=alecf.
This commit is contained in:
Родитель
2506546a81
Коммит
fb2d2f7d0b
|
@ -7,3 +7,6 @@
|
|||
|
||||
{"network.proxy.http", "/system/http_proxy/host"},
|
||||
{"network.proxy.http_port", "/system/http_proxy/port"},
|
||||
{"network.proxy.ftp", "/system/ftp_proxy/host"},
|
||||
{"network.proxy.ftp_port", "/system/ftp_proxy/port"},
|
||||
{"config.use_system_prefs.accessibility", "/desktop/gnome/interface/accessibility"},
|
||||
|
|
|
@ -591,7 +591,7 @@ GConfProxy::~GConfProxy()
|
|||
mInitialized = PR_FALSE;
|
||||
|
||||
if (mGConfLib) {
|
||||
PR_UnloadLibrary(mGConfLib);
|
||||
// PR_UnloadLibrary(mGConfLib);
|
||||
mGConfLib = nsnull;
|
||||
}
|
||||
if (mObservers) {
|
||||
|
|
|
@ -44,28 +44,62 @@
|
|||
|
||||
#include "nsSystemPrefLog.h"
|
||||
#include "nsSystemPrefService.h"
|
||||
#include "nsString2.h"
|
||||
|
||||
const char sSysPrefString[] = "config.use_system_prefs";
|
||||
union MozPrefValue {
|
||||
char * stringVal;
|
||||
PRInt32 intVal;
|
||||
PRBool boolVal;
|
||||
};
|
||||
|
||||
struct SysPrefItem {
|
||||
const char *prefName; // mozilla pref string name
|
||||
MozPrefValue defaultValue; // store the mozilla default value
|
||||
PRBool isLocked; // store the mozilla lock status
|
||||
SysPrefItem() {
|
||||
prefName = nsnull;
|
||||
defaultValue.intVal = 0;
|
||||
isLocked = PR_FALSE;
|
||||
}
|
||||
void SetPrefName(const char *aPrefName) {
|
||||
prefName = aPrefName;
|
||||
}
|
||||
};
|
||||
|
||||
// all prefs that mozilla need to read from host system if they are available
|
||||
static const char* sSysPrefList[] = {
|
||||
static const char *sSysPrefList[] = {
|
||||
"network.proxy.http",
|
||||
"network.proxy.http_port",
|
||||
"network.proxy.ftp",
|
||||
"network.proxy.ftp_port",
|
||||
"config.use_system_prefs.accessibility",
|
||||
};
|
||||
|
||||
PRLogModuleInfo *gSysPrefLog = NULL;
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsSystemPref, nsIObserver, nsISupportsWeakReference)
|
||||
|
||||
nsSystemPref::nsSystemPref()
|
||||
nsSystemPref::nsSystemPref():
|
||||
mSysPrefService(nsnull),
|
||||
mEnabled(PR_FALSE),
|
||||
mSysPrefs(nsnull)
|
||||
{
|
||||
mSysPrefService = nsnull;
|
||||
}
|
||||
|
||||
nsSystemPref::~nsSystemPref()
|
||||
{
|
||||
mSysPrefService = nsnull;
|
||||
mEnabled = PR_FALSE;
|
||||
delete [] mSysPrefs;
|
||||
}
|
||||
|
||||
nsresult nsSystemPref::Init(void)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsSystemPref::Init
|
||||
// Setup log and listen on NS_PREFSERVICE_READ_TOPIC_ID from pref service
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
nsresult
|
||||
nsSystemPref::Init(void)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -85,19 +119,22 @@ nsresult nsSystemPref::Init(void)
|
|||
return(rv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSystemPref::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsSystemPref::Observe
|
||||
// Observe notifications from mozilla pref system and system prefs (if enabled)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NS_IMETHODIMP
|
||||
nsSystemPref::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!aTopic)
|
||||
return NS_OK;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// if we are notified by pref service
|
||||
// check the system pref settings, and read prefs from system
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// check the system pref settings
|
||||
if (!nsCRT::strcmp(aTopic, NS_PREFSERVICE_READ_TOPIC_ID)) {
|
||||
SYSPREF_LOG(("Observed: %s\n", aTopic));
|
||||
|
||||
|
@ -111,30 +148,72 @@ NS_IMETHODIMP nsSystemPref::Observe(nsISupports *aSubject,
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRBool enabled = PR_FALSE;
|
||||
rv = prefBranch->GetBoolPref("config.system-pref", &enabled);
|
||||
rv = prefBranch->GetBoolPref(sSysPrefString, &mEnabled);
|
||||
if (NS_FAILED(rv)) {
|
||||
SYSPREF_LOG(("...FAil to Get config.system-pref\n"));
|
||||
SYSPREF_LOG(("...FAil to Get %s\n", sSysPrefString));
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
SYSPREF_LOG(("...Config config.system-pref is disabled\n"));
|
||||
// if there is no system pref service, assume nothing happen to us
|
||||
mSysPrefService = do_GetService(NS_SYSTEMPREF_SERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || !mSysPrefService) {
|
||||
SYSPREF_LOG(("...No System Pref Service\n"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mSysPrefService = do_GetService(NS_SYSTEMPREF_SERVICE_CONTRACTID, &rv);
|
||||
if (mSysPrefService)
|
||||
rv = ReadSystemPrefs();
|
||||
// listen on its changes
|
||||
nsCOMPtr<nsIPrefBranchInternal>
|
||||
prefBranchInternal(do_QueryInterface(prefBranch));
|
||||
rv = prefBranchInternal->AddObserver(sSysPrefString, this, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
SYSPREF_LOG(("...FAil to add observer for %s\n", sSysPrefString));
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!mEnabled) {
|
||||
SYSPREF_LOG(("%s is disabled\n", sSysPrefString));
|
||||
return NS_OK;
|
||||
}
|
||||
SYSPREF_LOG(("%s is enabled\n", sSysPrefString));
|
||||
rv = UseSystemPrefs();
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// sSysPrefString value was changed, update ...
|
||||
else if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) &&
|
||||
NS_ConvertUTF8toUCS2(sSysPrefString).Equals(aData)) {
|
||||
SYSPREF_LOG(("++++++ Notify: topic=%s data=%s\n",
|
||||
aTopic, NS_ConvertUCS2toUTF8(aData).get()));
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
nsCOMPtr<nsIPrefService> prefService =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = prefService->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRBool enabled = mEnabled;
|
||||
rv = prefBranch->GetBoolPref(sSysPrefString, &mEnabled);
|
||||
if (enabled != mEnabled) {
|
||||
if (mEnabled)
|
||||
//read prefs from system
|
||||
rv = UseSystemPrefs();
|
||||
else
|
||||
//roll back to mozilla prefs
|
||||
rv = UseMozillaPrefs();
|
||||
}
|
||||
}
|
||||
|
||||
// if the system pref notify us that some pref has been changed by user
|
||||
// outside mozilla. We need to read it again.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
else if (!nsCRT::strcmp(aTopic, NS_SYSTEMPREF_PREFCHANGE_TOPIC_ID) &&
|
||||
aData) {
|
||||
SYSPREF_LOG(("======in Notify topic=%s data=%s\n", aTopic, aData));
|
||||
ReadSystemPref(NS_ConvertUCS2toUTF8(aData).get());
|
||||
NS_ASSERTION(mEnabled == PR_TRUE, "Should not listen when disabled");
|
||||
SYSPREF_LOG(("====== System Pref Notify topic=%s data=%s\n",
|
||||
aTopic, (char*)aData));
|
||||
rv = ReadSystemPref(NS_LossyConvertUCS2toASCII(aData).get());
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
|
@ -144,35 +223,56 @@ NS_IMETHODIMP nsSystemPref::Observe(nsISupports *aSubject,
|
|||
|
||||
/* private */
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Read all the prefs in the table, listen for their changes in
|
||||
// system pref service.
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
nsresult nsSystemPref::ReadSystemPrefs()
|
||||
////////////////////////////////////////////////////////////////
|
||||
// nsSystemPref::UseSystemPrefs
|
||||
// Read all the prefs in the table from system, listen for their
|
||||
// changes in system pref service.
|
||||
////////////////////////////////////////////////////////////////
|
||||
nsresult
|
||||
nsSystemPref::UseSystemPrefs()
|
||||
{
|
||||
SYSPREF_LOG(("\n====Now Use system prefs==\n"));
|
||||
nsresult rv = NS_OK;
|
||||
if (!mSysPrefService)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!mSysPrefService) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRInt16 sysPrefCount= sizeof(sSysPrefList) / sizeof(sSysPrefList[0]);
|
||||
|
||||
if (!mSysPrefs) {
|
||||
mSysPrefs = new SysPrefItem[sysPrefCount];
|
||||
if (!mSysPrefs)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
for (PRInt16 index = 0; index < sysPrefCount; ++index)
|
||||
mSysPrefs[index].SetPrefName(sSysPrefList[index]);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal>
|
||||
sysPrefBranchInternal(do_QueryInterface(mSysPrefService));
|
||||
if (!sysPrefBranchInternal)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt16 sysPrefLen= sizeof(sSysPrefList) / sizeof(sSysPrefList[0]);
|
||||
for (PRInt16 index = 0; index < sysPrefLen; ++index) {
|
||||
ReadSystemPref(sSysPrefList[index]);
|
||||
SYSPREF_LOG(("Add Listener on %s\n", sSysPrefList[index]));
|
||||
sysPrefBranchInternal->AddObserver(sSysPrefList[index],
|
||||
for (PRInt16 index = 0; index < sysPrefCount; ++index) {
|
||||
// save mozilla prefs
|
||||
SaveMozDefaultPref(mSysPrefs[index].prefName,
|
||||
&mSysPrefs[index].defaultValue,
|
||||
&mSysPrefs[index].isLocked);
|
||||
|
||||
// get the system prefs
|
||||
ReadSystemPref(mSysPrefs[index].prefName);
|
||||
SYSPREF_LOG(("Add Listener on %s\n", mSysPrefs[index].prefName));
|
||||
sysPrefBranchInternal->AddObserver(mSysPrefs[index].prefName,
|
||||
this, PR_TRUE);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// nsSystemPref::ReadSystemPref
|
||||
// Read a pref value from system pref service, and lock it in mozilla.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
nsresult nsSystemPref::ReadSystemPref(const char *aPrefName)
|
||||
nsresult
|
||||
nsSystemPref::ReadSystemPref(const char *aPrefName)
|
||||
{
|
||||
if (!mSysPrefService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -189,17 +289,16 @@ nsresult nsSystemPref::ReadSystemPref(const char *aPrefName)
|
|||
|
||||
SYSPREF_LOG(("about to read aPrefName %s\n", aPrefName));
|
||||
|
||||
PRBool isLocked;
|
||||
prefBranch->PrefIsLocked(aPrefName, &isLocked);
|
||||
if (isLocked)
|
||||
prefBranch->UnlockPref(aPrefName);
|
||||
prefBranch->UnlockPref(aPrefName);
|
||||
|
||||
PRInt32 prefType = nsIPrefBranch::PREF_INVALID;
|
||||
nsXPIDLCString strValue;
|
||||
PRInt32 intValue = 0;
|
||||
PRInt32 prefType = nsIPrefBranch::PREF_INVALID;
|
||||
PRBool boolValue = PR_FALSE;
|
||||
|
||||
rv = prefBranch->GetPrefType(aPrefName, &prefType);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
switch (prefType) {
|
||||
case nsIPrefBranch::PREF_STRING:
|
||||
mSysPrefService->GetCharPref(aPrefName, getter_Copies(strValue));
|
||||
|
@ -226,3 +325,165 @@ nsresult nsSystemPref::ReadSystemPref(const char *aPrefName)
|
|||
prefBranch->LockPref(aPrefName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// nsSystemPref::UseMozillaPrefs
|
||||
// Restore mozilla default prefs, remove system pref listeners
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
nsresult
|
||||
nsSystemPref::UseMozillaPrefs()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
SYSPREF_LOG(("\n====Now rollback to Mozilla prefs==\n"));
|
||||
|
||||
// if we did not use system prefs, do nothing
|
||||
if (!mSysPrefService)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal>
|
||||
sysPrefBranchInternal(do_QueryInterface(mSysPrefService));
|
||||
if (!sysPrefBranchInternal)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt16 sysPrefCount= sizeof(sSysPrefList) / sizeof(sSysPrefList[0]);
|
||||
for (PRInt16 index = 0; index < sysPrefCount; ++index) {
|
||||
// restore mozilla default value and free string memory if needed
|
||||
RestoreMozDefaultPref(mSysPrefs[index].prefName,
|
||||
&mSysPrefs[index].defaultValue,
|
||||
mSysPrefs[index].isLocked);
|
||||
SYSPREF_LOG(("stop listening on %s\n", mSysPrefs[index].prefName));
|
||||
sysPrefBranchInternal->RemoveObserver(mSysPrefs[index].prefName,
|
||||
this);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsSystemPref::RestoreMozDefaultPref
|
||||
// Save the saved mozilla default value.
|
||||
// It is also responsible for allocate the string memory when needed, because
|
||||
// this method know what type of value is stored.
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
nsresult
|
||||
nsSystemPref::SaveMozDefaultPref(const char *aPrefName,
|
||||
MozPrefValue *aPrefValue,
|
||||
PRBool *aLocked)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPrefName);
|
||||
NS_ENSURE_ARG_POINTER(aPrefValue);
|
||||
NS_ENSURE_ARG_POINTER(aLocked);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefService> prefService =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefService->GetDefaultBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
SYSPREF_LOG(("Save Mozilla value for %s\n", aPrefName));
|
||||
|
||||
PRInt32 prefType = nsIPrefBranch::PREF_INVALID;
|
||||
nsXPIDLCString strValue;
|
||||
|
||||
rv = prefBranch->GetPrefType(aPrefName, &prefType);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
switch (prefType) {
|
||||
case nsIPrefBranch::PREF_STRING:
|
||||
prefBranch->GetCharPref(aPrefName,
|
||||
getter_Copies(strValue));
|
||||
SYSPREF_LOG(("Mozilla value is %s", strValue.get()));
|
||||
|
||||
if (aPrefValue->stringVal)
|
||||
PL_strfree(aPrefValue->stringVal);
|
||||
aPrefValue->stringVal = PL_strdup(strValue.get());
|
||||
break;
|
||||
case nsIPrefBranch::PREF_INT:
|
||||
prefBranch->GetIntPref(aPrefName, &aPrefValue->intVal);
|
||||
SYSPREF_LOG(("Mozilla value is %d\n", aPrefValue->intVal));
|
||||
|
||||
break;
|
||||
case nsIPrefBranch::PREF_BOOL:
|
||||
prefBranch->GetBoolPref(aPrefName, &aPrefValue->boolVal);
|
||||
SYSPREF_LOG(("Mozilla value is %s\n",
|
||||
aPrefValue->boolVal ? "TRUE" : "FALSE"));
|
||||
|
||||
break;
|
||||
default:
|
||||
SYSPREF_LOG(("Fail to Read Mozilla value for it\n"));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = prefBranch->PrefIsLocked(aPrefName, aLocked);
|
||||
SYSPREF_LOG((" (%s).\n", aLocked ? "Locked" : "NOT Locked"));
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsSystemPref::RestoreMozDefaultPref
|
||||
// Restore the saved mozilla default value to pref service.
|
||||
// It is also responsible for free the string memory when needed, because
|
||||
// this method know what type of value is stored.
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
nsresult
|
||||
nsSystemPref::RestoreMozDefaultPref(const char *aPrefName,
|
||||
MozPrefValue *aPrefValue,
|
||||
PRBool aLocked)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPrefName);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefService> prefService =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefService->GetDefaultBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
SYSPREF_LOG(("Restore Mozilla value for %s\n", aPrefName));
|
||||
|
||||
PRInt32 prefType = nsIPrefBranch::PREF_INVALID;
|
||||
rv = prefBranch->GetPrefType(aPrefName, &prefType);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// unlock, if it is locked
|
||||
prefBranch->UnlockPref(aPrefName);
|
||||
|
||||
switch (prefType) {
|
||||
case nsIPrefBranch::PREF_STRING:
|
||||
prefBranch->SetCharPref(aPrefName,
|
||||
aPrefValue->stringVal);
|
||||
SYSPREF_LOG(("Mozilla value is %s\n", aPrefValue->stringVal));
|
||||
|
||||
PL_strfree(aPrefValue->stringVal);
|
||||
aPrefValue->stringVal = nsnull;
|
||||
|
||||
break;
|
||||
case nsIPrefBranch::PREF_INT:
|
||||
prefBranch->SetIntPref(aPrefName, aPrefValue->intVal);
|
||||
SYSPREF_LOG(("Mozilla value is %d\n", aPrefValue->intVal));
|
||||
|
||||
break;
|
||||
case nsIPrefBranch::PREF_BOOL:
|
||||
prefBranch->SetBoolPref(aPrefName, aPrefValue->boolVal);
|
||||
SYSPREF_LOG(("Mozilla value is %s\n",
|
||||
aPrefValue->boolVal ? "TRUE" : "FALSE"));
|
||||
|
||||
break;
|
||||
default:
|
||||
SYSPREF_LOG(("Fail to Restore Mozilla value for it\n"));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// restore its old lock status
|
||||
if (aLocked)
|
||||
prefBranch->LockPref(aPrefName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,9 @@
|
|||
|
||||
#include <nsIObserver.h>
|
||||
|
||||
union MozPrefValue;
|
||||
struct SysPrefItem;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// nsSystemPref, as an extension of mozilla pref service, reads some mozilla
|
||||
|
@ -81,9 +84,22 @@ public:
|
|||
nsresult Init(void);
|
||||
|
||||
private:
|
||||
nsresult ReadSystemPrefs();
|
||||
// funcs used to load system prefs and save mozilla default prefs
|
||||
nsresult UseSystemPrefs();
|
||||
nsresult ReadSystemPref(const char *aPrefName);
|
||||
nsresult SaveMozDefaultPref(const char *aPrefName,
|
||||
MozPrefValue *aPrefVal,
|
||||
PRBool *aLocked);
|
||||
|
||||
// funcs used to load mozilla default prefs
|
||||
nsresult UseMozillaPrefs();
|
||||
nsresult RestoreMozDefaultPref(const char *aPrefName,
|
||||
MozPrefValue *aPrefVal,
|
||||
PRBool aLocked);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> mSysPrefService;
|
||||
PRBool mEnabled; // system pref is enabled or not
|
||||
SysPrefItem *mSysPrefs;
|
||||
};
|
||||
|
||||
#define NS_SYSTEMPREF_CID \
|
||||
|
|
|
@ -866,3 +866,10 @@ pref("privacy.popups.sound_url", "");
|
|||
pref("privacy.popups.statusbar_icon_enabled", true);
|
||||
pref("privacy.popups.prefill_whitelist", false);
|
||||
pref("privacy.popups.remove_blacklist", true);
|
||||
|
||||
// whether use prefs from system
|
||||
pref("config.use_system_prefs", false);
|
||||
|
||||
// if the system has enabled accessibility
|
||||
pref("config.use_system_prefs.accessibility", false);
|
||||
|
||||
|
|
|
@ -52,7 +52,12 @@ function nsPrefWindow( frame_id )
|
|||
|
||||
this.cancelHandlers = [];
|
||||
this.okHandlers = [];
|
||||
|
||||
|
||||
// if there is a system pref switch
|
||||
this.pagePrefChanged = false;
|
||||
// the set of pages, which are updated after a system pref switch
|
||||
this.pagePrefUpdated = [];
|
||||
|
||||
// set up window
|
||||
this.onload();
|
||||
}
|
||||
|
@ -253,7 +258,10 @@ nsPrefWindow.prototype =
|
|||
break;
|
||||
}
|
||||
|
||||
if( value != this.getPref( preftype, itemObject.prefstring ) )
|
||||
// the pref is not saved, if the pref value is not
|
||||
// changed or the pref is locked.
|
||||
if( !this.getPrefIsLocked(itemObject.prefstring) &&
|
||||
(value != this.getPref( preftype, itemObject.prefstring)))
|
||||
{
|
||||
this.setPref( preftype, itemObject.prefstring, value );
|
||||
}
|
||||
|
@ -313,9 +321,15 @@ nsPrefWindow.prototype =
|
|||
var header = document.getElementById("header");
|
||||
header.setAttribute("title",
|
||||
window.frames[this.contentFrame].document.documentElement.getAttribute("headertitle"));
|
||||
if( !(aPageTag in this.wsm.dataManager.pageData) )
|
||||
|
||||
// update widgets states when it is first loaded, or there are
|
||||
// system pref switch. (i.e., to refect the changed lock status).
|
||||
if(!(aPageTag in this.wsm.dataManager.pageData) ||
|
||||
(this.pagePrefChanged && (!(aPageTag in this.pagePrefUpdated))))
|
||||
{
|
||||
var prefElements = window.frames[this.contentFrame].document.getElementsByAttribute( "prefstring", "*" );
|
||||
if (this.pagePrefChanged)
|
||||
this.pagePrefUpdated[aPageTag] = [];
|
||||
this.wsm.dataManager.pageData[aPageTag] = [];
|
||||
for( var i = 0; i < prefElements.length; i++ )
|
||||
{
|
||||
|
|
|
@ -35,11 +35,12 @@
|
|||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
var panel = "chrome://communicator/content/pref/pref-advanced.xul";
|
||||
var _elementIDs = ["advancedJavaAllow", "advancedMailFTP", "advancedMailFTPAddress"];
|
||||
var _elementIDs = ["advancedJavaAllow", "advancedMailFTP", "advancedMailFTPAddress", "systemPrefCheck"];
|
||||
|
||||
function Startup() {
|
||||
ftpCheck(false);
|
||||
turboCheck();
|
||||
sysPrefCheck();
|
||||
}
|
||||
|
||||
function ftpCheck(setFocus) {
|
||||
|
@ -132,6 +133,27 @@
|
|||
nativeAppSupport.isServerMode = parent.isTurboEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
function sysPrefCheck() {
|
||||
var frame = document.getElementById("systemPrefs");
|
||||
try {
|
||||
var appShell = Components.classes["@mozilla.org/system-preference-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
frame.setAttribute("hidden", "true");
|
||||
return;
|
||||
}
|
||||
frame.setAttribute("hidden", "false");
|
||||
}
|
||||
|
||||
function sysPrefUpdate() {
|
||||
var checkObj = document.getElementById("systemPrefCheck");
|
||||
var prefstring = checkObj.getAttribute( "prefstring" );
|
||||
parent.hPrefWindow.pref.SetBoolPref(prefstring, checkObj.checked);
|
||||
parent.hPrefWindow.pagePrefChanged = true;
|
||||
parent.hPrefWindow.pagePrefUpdated = [];
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
||||
|
@ -165,7 +187,16 @@
|
|||
</vbox>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
<groupbox id="systemPrefs">
|
||||
<caption id="systemPrefCaption" label="&systemPrefCaption.label;"/>
|
||||
<vbox id="systemPrefBox" align="start">
|
||||
<checkbox id="systemPrefCheck" label="&systemPrefCheck.label;" accesskey="&systemPrefCheck.accesskey;"
|
||||
prefstring="config.use_system_prefs"
|
||||
oncommand="sysPrefUpdate();"/>
|
||||
<vbox class="indent" flex="1">
|
||||
<description>&systemPrefDescription.label;</description>
|
||||
</vbox>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
|
||||
</page>
|
||||
|
||||
|
||||
|
|
|
@ -26,3 +26,8 @@
|
|||
<!ENTITY jvm.name "Version">
|
||||
<!ENTITY jvm.home "Path">
|
||||
|
||||
<!ENTITY systemPrefCaption.label "System Preferences">
|
||||
<!ENTITY systemPrefCheck.label "Use Preferences from System">
|
||||
<!ENTITY systemPrefCheck.accesskey "s">
|
||||
<!ENTITY systemPrefDescription.label "Check this item to inherit preferences from the system. The system settings will override the &brandShortName; preferences">
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче