From 9e7597ee4177b93427efd9a7f2bf670dc9c94280 Mon Sep 17 00:00:00 2001 From: "bsmedberg%covad.net" Date: Wed, 23 Feb 2005 16:15:37 +0000 Subject: [PATCH] Fix system-pref service from bug 281414 (s/nsIPrefBranchInternal/nsIPrefBranch2/), r=blizzard git-svn-id: svn://10.0.0.236/trunk@169645 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/gconf/nsSystemPrefService.cpp | 2 +- .../src/gconf/nsSystemPrefService.h | 6 +- .../pref/system-pref/src/nsSystemPref.cpp | 58 ++++--------------- .../pref/system-pref/src/nsSystemPref.h | 4 +- 4 files changed, 18 insertions(+), 52 deletions(-) diff --git a/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp b/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp index 120bb79db47..efac6dd21b8 100644 --- a/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp +++ b/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp @@ -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() diff --git a/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.h b/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.h index 2ab09085d90..59107c59b03 100644 --- a/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.h +++ b/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.h @@ -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(); diff --git a/mozilla/extensions/pref/system-pref/src/nsSystemPref.cpp b/mozilla/extensions/pref/system-pref/src/nsSystemPref.cpp index 240c37ea7cc..82dc4566e10 100644 --- a/mozilla/extensions/pref/system-pref/src/nsSystemPref.cpp +++ b/mozilla/extensions/pref/system-pref/src/nsSystemPref.cpp @@ -146,16 +146,11 @@ nsSystemPref::Observe(nsISupports *aSubject, if (!nsCRT::strcmp(aTopic, NS_PREFSERVICE_READ_TOPIC_ID)) { SYSPREF_LOG(("Observed: %s\n", aTopic)); - nsCOMPtr prefBranch; - nsCOMPtr prefService = + nsCOMPtr 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 - 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 prefBranch; - nsCOMPtr prefService = + nsCOMPtr 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 - 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 prefService = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; nsCOMPtr 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 - 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 prefService = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - nsCOMPtr prefBranch; - rv = prefService->GetDefaultBranch(nsnull, getter_AddRefs(prefBranch)); + nsCOMPtr 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 prefService = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - nsCOMPtr prefBranch; - rv = prefService->GetDefaultBranch(nsnull, getter_AddRefs(prefBranch)); + nsCOMPtr prefBranch = + do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/extensions/pref/system-pref/src/nsSystemPref.h b/mozilla/extensions/pref/system-pref/src/nsSystemPref.h index 32ab14deb4d..9bc3e871748 100644 --- a/mozilla/extensions/pref/system-pref/src/nsSystemPref.h +++ b/mozilla/extensions/pref/system-pref/src/nsSystemPref.h @@ -50,7 +50,7 @@ #include "nsIServiceManager.h" #include "nsWeakReference.h" #include "nsIPrefService.h" -#include "nsIPrefBranch.h" +#include "nsIPrefBranch2.h" #include @@ -97,7 +97,7 @@ private: MozPrefValue *aPrefVal, PRBool aLocked); - nsCOMPtr mSysPrefService; + nsCOMPtr mSysPrefService; PRBool mEnabled; // system pref is enabled or not SysPrefItem *mSysPrefs; };