mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 11:27:49 +00:00
Fix system-pref service from bug 281414 (s/nsIPrefBranchInternal/nsIPrefBranch2/), r=blizzard
This commit is contained in:
parent
831e5a7b2e
commit
311203ed0c
@ -214,7 +214,7 @@ sysPrefDeleteObserver(void *aElement, void *aData) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsSystemPrefService, nsIPrefBranch, nsIPrefBranchInternal)
|
||||
NS_IMPL_ISUPPORTS2(nsSystemPrefService, nsIPrefBranch, nsIPrefBranch2)
|
||||
|
||||
/* public */
|
||||
nsSystemPrefService::nsSystemPrefService()
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranchInternal.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
|
||||
class GConfProxy;
|
||||
|
||||
@ -56,12 +56,12 @@ class GConfProxy;
|
||||
// on the gconf platform.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsSystemPrefService : public nsIPrefBranchInternal
|
||||
class nsSystemPrefService : public nsIPrefBranch2
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPREFBRANCH
|
||||
NS_DECL_NSIPREFBRANCHINTERNAL
|
||||
NS_DECL_NSIPREFBRANCH2
|
||||
|
||||
nsSystemPrefService();
|
||||
virtual ~nsSystemPrefService();
|
||||
|
@ -146,16 +146,11 @@ nsSystemPref::Observe(nsISupports *aSubject,
|
||||
if (!nsCRT::strcmp(aTopic, NS_PREFSERVICE_READ_TOPIC_ID)) {
|
||||
SYSPREF_LOG(("Observed: %s\n", aTopic));
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
nsCOMPtr<nsIPrefService> prefService =
|
||||
nsCOMPtr<nsIPrefBranch2> prefBranch =
|
||||
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;
|
||||
|
||||
rv = prefBranch->GetBoolPref(sSysPrefString, &mEnabled);
|
||||
if (NS_FAILED(rv)) {
|
||||
SYSPREF_LOG(("...FAil to Get %s\n", sSysPrefString));
|
||||
@ -170,9 +165,7 @@ nsSystemPref::Observe(nsISupports *aSubject,
|
||||
}
|
||||
|
||||
// listen on its changes
|
||||
nsCOMPtr<nsIPrefBranchInternal>
|
||||
prefBranchInternal(do_QueryInterface(prefBranch));
|
||||
rv = prefBranchInternal->AddObserver(sSysPrefString, this, PR_TRUE);
|
||||
rv = prefBranch->AddObserver(sSysPrefString, this, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
SYSPREF_LOG(("...FAil to add observer for %s\n", sSysPrefString));
|
||||
return rv;
|
||||
@ -192,16 +185,11 @@ nsSystemPref::Observe(nsISupports *aSubject,
|
||||
SYSPREF_LOG(("++++++ Notify: topic=%s data=%s\n",
|
||||
aTopic, NS_ConvertUCS2toUTF8(aData).get()));
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
nsCOMPtr<nsIPrefService> prefService =
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
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) {
|
||||
@ -255,11 +243,6 @@ nsSystemPref::UseSystemPrefs()
|
||||
mSysPrefs[index].SetPrefName(sSysPrefList[index]);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal>
|
||||
sysPrefBranchInternal(do_QueryInterface(mSysPrefService));
|
||||
if (!sysPrefBranchInternal)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
for (PRIntn index = 0; index < sysPrefCount; ++index) {
|
||||
// save mozilla prefs
|
||||
SaveMozDefaultPref(mSysPrefs[index].prefName,
|
||||
@ -269,8 +252,8 @@ nsSystemPref::UseSystemPrefs()
|
||||
// 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);
|
||||
mSysPrefService->AddObserver(mSysPrefs[index].prefName,
|
||||
this, PR_TRUE);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -285,13 +268,9 @@ nsSystemPref::ReadSystemPref(const char *aPrefName)
|
||||
if (!mSysPrefService)
|
||||
return NS_ERROR_FAILURE;
|
||||
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));
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -348,11 +327,6 @@ nsSystemPref::UseMozillaPrefs()
|
||||
if (!mSysPrefService)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal>
|
||||
sysPrefBranchInternal(do_QueryInterface(mSysPrefService));
|
||||
if (!sysPrefBranchInternal)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRIntn sysPrefCount= sizeof(sSysPrefList) / sizeof(sSysPrefList[0]);
|
||||
for (PRIntn index = 0; index < sysPrefCount; ++index) {
|
||||
// restore mozilla default value and free string memory if needed
|
||||
@ -360,8 +334,8 @@ nsSystemPref::UseMozillaPrefs()
|
||||
&mSysPrefs[index].defaultValue,
|
||||
mSysPrefs[index].isLocked);
|
||||
SYSPREF_LOG(("stop listening on %s\n", mSysPrefs[index].prefName));
|
||||
sysPrefBranchInternal->RemoveObserver(mSysPrefs[index].prefName,
|
||||
this);
|
||||
mSysPrefService->RemoveObserver(mSysPrefs[index].prefName,
|
||||
this);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -382,13 +356,9 @@ nsSystemPref::SaveMozDefaultPref(const char *aPrefName,
|
||||
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));
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -444,13 +414,9 @@ nsSystemPref::RestoreMozDefaultPref(const char *aPrefName,
|
||||
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));
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
|
||||
#include <nsIObserver.h>
|
||||
|
||||
@ -97,7 +97,7 @@ private:
|
||||
MozPrefValue *aPrefVal,
|
||||
PRBool aLocked);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> mSysPrefService;
|
||||
nsCOMPtr<nsIPrefBranch2> mSysPrefService;
|
||||
PRBool mEnabled; // system pref is enabled or not
|
||||
SysPrefItem *mSysPrefs;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user