diff --git a/mozilla/caps/idl/nsIPrincipal.idl b/mozilla/caps/idl/nsIPrincipal.idl index a55fb103c18..c5c2b256db1 100644 --- a/mozilla/caps/idl/nsIPrincipal.idl +++ b/mozilla/caps/idl/nsIPrincipal.idl @@ -44,8 +44,6 @@ struct JSPrincipals; %} -interface nsIPref; - [ptr] native JSPrincipals(JSPrincipals); [uuid(ff9313d0-25e1-11d2-8160-006008119d7a)] diff --git a/mozilla/caps/src/nsBasePrincipal.cpp b/mozilla/caps/src/nsBasePrincipal.cpp index cf9bbc6f2e2..1c8fd220596 100644 --- a/mozilla/caps/src/nsBasePrincipal.cpp +++ b/mozilla/caps/src/nsBasePrincipal.cpp @@ -26,7 +26,6 @@ #include "nsString.h" #include "nsReadableUtils.h" #include "plstr.h" -#include "nsIPref.h" #include "nsCRT.h" ////////////////////////// diff --git a/mozilla/caps/src/nsCodebasePrincipal.cpp b/mozilla/caps/src/nsCodebasePrincipal.cpp index bdb5bb8f39d..f1671f83f31 100644 --- a/mozilla/caps/src/nsCodebasePrincipal.cpp +++ b/mozilla/caps/src/nsCodebasePrincipal.cpp @@ -45,7 +45,8 @@ #include "nsIURL.h" #include "nsIJARURI.h" #include "nsCOMPtr.h" -#include "nsIPref.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "nsXPIDLString.h" #include "nsReadableUtils.h" #include "nsCRT.h" @@ -111,13 +112,12 @@ nsCodebasePrincipal::CanEnableCapability(const char *capability, if (!mTrusted) { static char pref[] = "signed.applets.codebase_principal_support"; - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); - if (NS_FAILED(rv)) - return NS_ERROR_FAILURE; - PRBool enabled; - if (NS_FAILED(prefs->GetBoolPref(pref, &enabled)) || !enabled) - { + nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (!prefBranch) + return NS_ERROR_FAILURE; + PRBool enabled; + if (NS_FAILED(prefBranch->GetBoolPref(pref, &enabled)) || !enabled) + { // Deny unless subject is executing from file: or resource: PRBool isFile = PR_FALSE; PRBool isRes = PR_FALSE; diff --git a/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp b/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp index 4664310141e..5462566a381 100644 --- a/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp +++ b/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp @@ -40,7 +40,8 @@ #include "nsIDOMWindowInternal.h" #include "nsIDOMEventTarget.h" #include "nsIDOMNSEvent.h" -#include "nsIPref.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "nsIRegistry.h" #include "nsString.h" @@ -222,11 +223,11 @@ NS_IMETHODIMP nsAccessProxy::OnStateChange(nsIWebProgress *aWebProgress, if ((aStateFlags & (STATE_STOP|STATE_START)) && (aStateFlags & STATE_IS_DOCUMENT)) { // Test for built in text to speech or braille display usage preference // If so, attach event handlers to window. If not, don't. - nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID)); + nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); nsXPIDLCString textToSpeechEngine, brailleDisplayEngine; - if (prefs) { - prefs->CopyCharPref("accessibility.usetexttospeech", getter_Copies(textToSpeechEngine)); - prefs->CopyCharPref("accessibility.usebrailledisplay", getter_Copies(brailleDisplayEngine)); + if (prefBranch) { + prefBranch->GetCharPref("accessibility.usetexttospeech", getter_Copies(textToSpeechEngine)); + prefBranch->GetCharPref("accessibility.usebrailledisplay", getter_Copies(brailleDisplayEngine)); } if ((textToSpeechEngine && *textToSpeechEngine) || (brailleDisplayEngine && *brailleDisplayEngine)) { diff --git a/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.cpp b/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.cpp index 7e38953266d..005c2733c28 100644 --- a/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.cpp +++ b/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.cpp @@ -42,9 +42,12 @@ ///////////////////////////////////////////////////// // // This file implements the nsScriptablePeer object -// The naive methods of this class are supposed to +// The native methods of this class are supposed to // be callable from JavaScript // +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" + #include "plugin.h" @@ -306,11 +309,11 @@ char* URLName; NS_IMETHODIMP nsScriptablePeer::SetBoolPref(const PRUnichar *aPrefName, PRBool aVal) { - nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID)); - if (prefs) { + nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (prefBranch) { nsCString prefName; prefName.AssignWithConversion(aPrefName); - prefs->SetBoolPref(prefName.get(), aVal); + prefBranch->SetBoolPref(prefName.get(), aVal); return NS_OK; } else { return NS_ERROR_FAILURE; diff --git a/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.h b/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.h index 2352b940800..01e4779e95f 100644 --- a/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.h +++ b/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.h @@ -56,7 +56,6 @@ #include "nsMemory.h" #include "nsNetUtil.h" #include "nsString.h" -#include "nsIPref.h" class nsPluginInstance; @@ -107,4 +106,4 @@ protected: }; -#endif \ No newline at end of file +#endif diff --git a/mozilla/extensions/layout-debug/plugin/plugin.cpp b/mozilla/extensions/layout-debug/plugin/plugin.cpp index 266c98fa930..ceab49740f7 100644 --- a/mozilla/extensions/layout-debug/plugin/plugin.cpp +++ b/mozilla/extensions/layout-debug/plugin/plugin.cpp @@ -46,7 +46,6 @@ #include "nsMemory.h" #include "nsNetUtil.h" #include "nsString.h" -#include "nsIPref.h" // service manager which will give the access to all public browser services // we will use memory service as an illustration diff --git a/mozilla/extensions/layout-debug/src/nsDebugObject.cpp b/mozilla/extensions/layout-debug/src/nsDebugObject.cpp index b473d40f41b..97b7de47234 100644 --- a/mozilla/extensions/layout-debug/src/nsDebugObject.cpp +++ b/mozilla/extensions/layout-debug/src/nsDebugObject.cpp @@ -62,7 +62,6 @@ #include "nsLayoutCID.h" #include "nsNetUtil.h" #include "nsIFile.h" -#include "nsIPref.h" NS_IMPL_ISUPPORTS1(nsDebugObject, nsIDebugObject) diff --git a/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp b/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp index b473d40f41b..97b7de47234 100644 --- a/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp +++ b/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp @@ -62,7 +62,6 @@ #include "nsLayoutCID.h" #include "nsNetUtil.h" #include "nsIFile.h" -#include "nsIPref.h" NS_IMPL_ISUPPORTS1(nsDebugObject, nsIDebugObject) diff --git a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp index d55eed9247d..45a461dea3e 100644 --- a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp +++ b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp @@ -28,13 +28,15 @@ #include "nscore.h" #include "nsCOMPtr.h" #include "nsString.h" +#include "nsXPIDLString.h" #include "plstr.h" #include "nsReadableUtils.h" #include "prlog.h" #include "nsMemory.h" #include "nsIServiceManager.h" -#include "nsIPref.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "nsIPrincipal.h" #include "nsIDocument.h" @@ -47,7 +49,6 @@ #define MAXCOL 4096 // Maximum columns in line buffer static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_IID(kILineTermIID, MOZILINETERM_IID); static NS_DEFINE_IID(kILineTermAuxIID, MOZILINETERMAUX_IID); @@ -139,15 +140,13 @@ NS_IMETHODIMP mozLineTerm::ArePrefsSecure(PRBool *_retval) *_retval = PR_FALSE; - nsIPref* prefService; - nsServiceManager::GetService(kPrefServiceCID, NS_GET_IID(nsIPref), - (nsISupports**) &prefService); - if (!prefService) + nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); + if (!prefBranch) return NS_ERROR_FAILURE; // Check if Components JS object is secure PRBool checkXPC; - result = prefService->GetBoolPref("security.checkxpconnect", &checkXPC); + result = prefBranch->GetBoolPref("security.checkxpconnect", &checkXPC); if (NS_FAILED(result)) return NS_ERROR_FAILURE; @@ -163,33 +162,30 @@ NS_IMETHODIMP mozLineTerm::ArePrefsSecure(PRBool *_retval) nsCAutoString secString ("security.policy."); /* Get global policy name. */ - char *policyStr; + nsXPIDLCString policyStr; - result = prefService->CopyCharPref("javascript.security_policy", &policyStr); - if (NS_SUCCEEDED(result) && policyStr) { + result = prefBranch->GetCharPref("javascript.security_policy", + getter_Copies(policyStr)); + if (NS_SUCCEEDED(result) && !policyStr.IsEmpty()) { secString.Append(policyStr); - nsMemory::Free(policyStr); } else { secString.Append("default"); } secString.Append(".htmldocument.cookie"); - char* prefStr = ToNewCString(secString); - XMLT_LOG(mozLineTerm::ArePrefsSecure,32, ("prefStr=%s\n", prefStr)); + XMLT_LOG(mozLineTerm::ArePrefsSecure,32, ("prefStr=%s\n", secString.get())); - char *secLevelString; - result = prefService->CopyCharPref(prefStr, &secLevelString); - nsMemory::Free(prefStr); + nsXPIDLCString secLevelString; + result = prefBranch->GetCharPref(secString.get(), getter_Copies(secLevelString)); - if (NS_FAILED(result) || !secLevelString) + if (NS_FAILED(result)) return NS_ERROR_FAILURE; XMLT_LOG(mozLineTerm::ArePrefsSecure,32, - ("secLevelString=%s\n", secLevelString)); + ("secLevelString=%s\n", secLevelString.get())); - *_retval = (PL_strcmp(secLevelString, "sameOrigin") == 0); - nsMemory::Free(secLevelString); + *_retval = secLevelString.Equals(NS_LITERAL_CSTRING("sameOrigin")); if (!(*_retval)) { XMLT_ERROR("mozLineTerm::ArePrefsSecure: Error - Please add the line\n" diff --git a/mozilla/htmlparser/src/nsViewSourceHTML.cpp b/mozilla/htmlparser/src/nsViewSourceHTML.cpp index a68c066c882..64bcf7412f2 100644 --- a/mozilla/htmlparser/src/nsViewSourceHTML.cpp +++ b/mozilla/htmlparser/src/nsViewSourceHTML.cpp @@ -79,7 +79,8 @@ #include "nsIHTMLContentSink.h" #include "nsHTMLTokenizer.h" #include "nsHTMLEntities.h" -#include "nsIPref.h" +#include "nsIPrefService.h" +#include "nsIPrefBranch.h" #include "nsUnicharUtils.h" #include "COtherDTD.h" @@ -344,14 +345,14 @@ CViewSourceHTML::CViewSourceHTML() : mFilename(), mTags(), mErrors() { mPopupTag = VIEW_SOURCE_POPUP; mSyntaxHighlight = PR_FALSE; mWrapLongLines = PR_FALSE; - nsCOMPtr thePrefsService(do_GetService(NS_PREF_CONTRACTID)); - if (thePrefsService) { + nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (prefBranch) { PRBool temp; nsresult rv; - rv = thePrefsService->GetBoolPref("view_source.syntax_highlight", &temp); + rv = prefBranch->GetBoolPref("view_source.syntax_highlight", &temp); mSyntaxHighlight = NS_SUCCEEDED(rv) ? temp : PR_TRUE; - rv = thePrefsService->GetBoolPref("view_source.wrap_long_lines", &temp); + rv = prefBranch->GetBoolPref("view_source.wrap_long_lines", &temp); mWrapLongLines = NS_SUCCEEDED(rv) ? temp : PR_FALSE; } diff --git a/mozilla/intl/locale/src/os2/nsCollationOS2.cpp b/mozilla/intl/locale/src/os2/nsCollationOS2.cpp index 69b548ebf88..84e9d5f5383 100644 --- a/mozilla/intl/locale/src/os2/nsCollationOS2.cpp +++ b/mozilla/intl/locale/src/os2/nsCollationOS2.cpp @@ -39,7 +39,6 @@ #include "nsIOS2Locale.h" #include "nsCOMPtr.h" #include "nsFileSpec.h" /* for nsAutoString */ -#include "nsIPref.h" NS_IMPL_ISUPPORTS1(nsCollationOS2, nsICollation) diff --git a/mozilla/intl/locale/src/unix/nsCollationUnix.cpp b/mozilla/intl/locale/src/unix/nsCollationUnix.cpp index 5cbdcee5018..6e16b340a2a 100644 --- a/mozilla/intl/locale/src/unix/nsCollationUnix.cpp +++ b/mozilla/intl/locale/src/unix/nsCollationUnix.cpp @@ -47,7 +47,9 @@ #include "nsIPlatformCharset.h" #include "nsIPosixLocale.h" #include "nsCOMPtr.h" -#include "nsIPref.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" +#include "nsIPrefLocalizedString.h" #include "nsUnicharUtils.h" #include "nsCRT.h" //#define DEBUG_UNIX_COLLATION @@ -90,15 +92,18 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) nsresult res; - nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID); - if (prefs) { - PRUnichar *prefValue; - res = prefs->GetLocalizedUnicharPref("intl.collationOption", &prefValue); - if (NS_SUCCEEDED(res)) { + nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); + if (prefBranch) { + nsCOMPtr prefLocalString; + res = prefBranch->GetComplexValue("intl.collationOption", + NS_GET_IID(nsIPrefLocalizedString), + getter_AddRefs(prefLocalString)); + if (NS_SUCCEEDED(res) && prefLocalString) { + nsXPIDLString prefValue; + prefLocalString->GetData(getter_Copies(prefValue)); mUseCodePointOrder = - nsDependentString(prefValue).Equals(NS_LITERAL_STRING("useCodePointOrder"), - nsCaseInsensitiveStringComparator()); - nsMemory::Free(prefValue); + prefValue.Equals(NS_LITERAL_STRING("useCodePointOrder"), + nsCaseInsensitiveStringComparator()); } } diff --git a/mozilla/intl/uconv/ucvja/nsJapaneseToUnicode.cpp b/mozilla/intl/uconv/ucvja/nsJapaneseToUnicode.cpp index 66a6d223ab9..9a37bef7dc4 100644 --- a/mozilla/intl/uconv/ucvja/nsJapaneseToUnicode.cpp +++ b/mozilla/intl/uconv/ucvja/nsJapaneseToUnicode.cpp @@ -39,7 +39,8 @@ #include "nsUCSupport.h" -#include "nsIPref.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "japanese.map" @@ -57,10 +58,10 @@ void nsJapaneseToUnicode::setMapMode() mMapIndex = gIndex; - nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID); - if (!prefs) return; + nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); + if (!prefBranch) return; nsXPIDLCString prefMap; - res = prefs->GetCharPref("intl.jis0208.map", getter_Copies(prefMap)); + res = prefBranch->GetCharPref("intl.jis0208.map", getter_Copies(prefMap)); if (!NS_SUCCEEDED(res)) return; nsCaseInsensitiveCStringComparator comparator; if ( prefMap.Equals(NS_LITERAL_CSTRING("cp932"), comparator) ) { diff --git a/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp b/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp index a68c066c882..64bcf7412f2 100644 --- a/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp +++ b/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp @@ -79,7 +79,8 @@ #include "nsIHTMLContentSink.h" #include "nsHTMLTokenizer.h" #include "nsHTMLEntities.h" -#include "nsIPref.h" +#include "nsIPrefService.h" +#include "nsIPrefBranch.h" #include "nsUnicharUtils.h" #include "COtherDTD.h" @@ -344,14 +345,14 @@ CViewSourceHTML::CViewSourceHTML() : mFilename(), mTags(), mErrors() { mPopupTag = VIEW_SOURCE_POPUP; mSyntaxHighlight = PR_FALSE; mWrapLongLines = PR_FALSE; - nsCOMPtr thePrefsService(do_GetService(NS_PREF_CONTRACTID)); - if (thePrefsService) { + nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (prefBranch) { PRBool temp; nsresult rv; - rv = thePrefsService->GetBoolPref("view_source.syntax_highlight", &temp); + rv = prefBranch->GetBoolPref("view_source.syntax_highlight", &temp); mSyntaxHighlight = NS_SUCCEEDED(rv) ? temp : PR_TRUE; - rv = thePrefsService->GetBoolPref("view_source.wrap_long_lines", &temp); + rv = prefBranch->GetBoolPref("view_source.wrap_long_lines", &temp); mWrapLongLines = NS_SUCCEEDED(rv) ? temp : PR_FALSE; } diff --git a/mozilla/view/src/nsViewFactory.cpp b/mozilla/view/src/nsViewFactory.cpp index 5888e839dc0..f1b1de8ea72 100644 --- a/mozilla/view/src/nsViewFactory.cpp +++ b/mozilla/view/src/nsViewFactory.cpp @@ -49,7 +49,6 @@ #include "nsScrollPortView.h" #include "nsIModule.h" -#include "nsIPref.h" #include "nsViewManager.h" diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index b5ee33a9b0c..9a111078713 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -54,7 +54,8 @@ #include "nsIEventQueueService.h" #include "nsIServiceManager.h" #include "nsGUIEvent.h" -#include "nsIPref.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "nsRegion.h" #include "nsInt64.h" @@ -612,10 +613,10 @@ PRBool DoDoubleBuffering(void) static PRBool doDoublebuffering = PR_TRUE; /* Double-buffering is ON by default */ if (!gotDoublebufferPrefs) { - nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID); - if (prefs) { + nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); + if (prefBranch) { PRBool val; - if (NS_SUCCEEDED(prefs->GetBoolPref("viewmanager.do_doublebuffering", &val))) { + if (NS_SUCCEEDED(prefBranch->GetBoolPref("viewmanager.do_doublebuffering", &val))) { doDoublebuffering = val; } } diff --git a/mozilla/webshell/tests/viewer/nsViewerApp.cpp b/mozilla/webshell/tests/viewer/nsViewerApp.cpp index 076faeb7920..30dab31b0fe 100644 --- a/mozilla/webshell/tests/viewer/nsViewerApp.cpp +++ b/mozilla/webshell/tests/viewer/nsViewerApp.cpp @@ -119,7 +119,6 @@ extern nsresult NS_NewXPBaseWindowFactory(nsIFactory** aFactory); static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_IID(kAppShellCID, NS_APPSHELL_CID); -static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); static NS_DEFINE_IID(kXPBaseWindowCID, NS_XPBASE_WINDOW_CID); static NS_DEFINE_IID(kCookieServiceCID, NS_COOKIESERVICE_CID); @@ -210,9 +209,7 @@ nsViewerApp::Destroy() NS_RELEASE(mCrawler); } - if (nsnull != mPrefs) { - NS_RELEASE(mPrefs); - } + NS_IF_RELEASE(mPrefService); } class nsTestFormProcessor : public nsIFormProcessor { @@ -326,12 +323,11 @@ nsViewerApp::Initialize(int argc, char** argv) mAppShell->SetDispatchListener((nsDispatchListener*) this); // Load preferences - rv = nsComponentManager::CreateInstance(kPrefCID, NULL, kIPrefIID, - (void **) &mPrefs); + rv = CallGetService(NS_PREFSERVICE_CONTRACTID, &mPrefService); if (NS_OK != rv) { return rv; } - mPrefs->ReadUserPrefs(nsnull); + mPrefService->ReadUserPrefs(nsnull); // Finally process our arguments rv = ProcessArguments(argc, argv); diff --git a/mozilla/webshell/tests/viewer/nsViewerApp.h b/mozilla/webshell/tests/viewer/nsViewerApp.h index b958855c41e..53dcc0e4476 100644 --- a/mozilla/webshell/tests/viewer/nsViewerApp.h +++ b/mozilla/webshell/tests/viewer/nsViewerApp.h @@ -44,7 +44,7 @@ #include "nsWebCrawler.h" class nsIEventQueueService; -class nsIPref; +class nsIPrefService; class nsBrowserWindow; class nsViewerApp : public nsISupports, public nsDispatchListener @@ -84,7 +84,7 @@ protected: void Destroy(); nsIAppShell* mAppShell; - nsIPref* mPrefs; + nsIPrefService* mPrefService; nsString mStartURL; PRBool mDoPurify; PRBool mLoadTestFromFile; diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.h b/mozilla/webshell/tests/viewer/nsXPBaseWindow.h index 067c4aeb19e..ff4b4b6c6c8 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.h +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.h @@ -52,7 +52,6 @@ class nsViewerApp; class nsIPresShell; -class nsIPref; /** * diff --git a/mozilla/xpinstall/src/nsInstall.cpp b/mozilla/xpinstall/src/nsInstall.cpp index 4241d7ff038..7eaa28bcc25 100644 --- a/mozilla/xpinstall/src/nsInstall.cpp +++ b/mozilla/xpinstall/src/nsInstall.cpp @@ -42,7 +42,8 @@ #include "nsDirectoryService.h" #include "nsDirectoryServiceDefs.h" -#include "nsIPref.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "prmem.h" #include "plstr.h" @@ -2403,43 +2404,22 @@ nsInstall::GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName } -static NS_DEFINE_IID(kPrefsIID, NS_IPREF_IID); -static NS_DEFINE_IID(kPrefsCID, NS_PREF_CID); - void nsInstall::CurrentUserNode(nsString& userRegNode) { - char *profname; - nsIPref * prefs; + nsXPIDLCString profname; + nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); - nsresult rv = nsServiceManager::GetService(kPrefsCID, - kPrefsIID, - (nsISupports**) &prefs); - - - if ( NS_SUCCEEDED(rv) ) + if ( prefBranch ) { - rv = prefs->CopyCharPref("profile.name", &profname); - - if ( NS_FAILED(rv) ) - { - PR_FREEIF(profname); // Allocated by PREF_CopyCharPref - profname = NULL; - } - - NS_RELEASE(prefs); - } - else - { - profname = NULL; + prefBranch->GetCharPref("profile.name", getter_Copies(profname)); } userRegNode.Assign(NS_LITERAL_STRING("/Netscape/Users/")); - if (profname != nsnull) + if ( !profname.IsEmpty() ) { userRegNode.AppendWithConversion(profname); userRegNode.Append(NS_LITERAL_STRING("/")); - PR_FREEIF(profname); } } diff --git a/mozilla/xpinstall/src/nsInstallTrigger.cpp b/mozilla/xpinstall/src/nsInstallTrigger.cpp index 886bff570bb..167d336abec 100644 --- a/mozilla/xpinstall/src/nsInstallTrigger.cpp +++ b/mozilla/xpinstall/src/nsInstallTrigger.cpp @@ -48,7 +48,8 @@ #include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObjectOwner.h" -#include "nsIPref.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" @@ -66,9 +67,6 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kIInstallTrigger_IID, NS_IDOMINSTALLTRIGGERGLOBAL_IID); static NS_DEFINE_IID(kIInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID); -static NS_DEFINE_IID(kPrefsIID, NS_IPREF_IID); -static NS_DEFINE_IID(kPrefsCID, NS_PREF_CID); - nsInstallTrigger::nsInstallTrigger() { mScriptObject = nsnull; @@ -172,23 +170,16 @@ nsInstallTrigger::HandleContent(const char * aContentType, NS_IMETHODIMP nsInstallTrigger::UpdateEnabled(PRBool* aReturn) { - nsIPref * prefs; + nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); - nsresult rv = nsServiceManager::GetService(kPrefsCID, - kPrefsIID, - (nsISupports**) &prefs); - - - if ( NS_SUCCEEDED(rv) ) + if ( prefBranch ) { - rv = prefs->GetBoolPref( (const char*) XPINSTALL_ENABLE_PREF, aReturn); + nsresult rv = prefBranch->GetBoolPref( (const char*) XPINSTALL_ENABLE_PREF, aReturn); if (NS_FAILED(rv)) { *aReturn = PR_FALSE; } - - NS_RELEASE(prefs); } else { diff --git a/mozilla/xpinstall/src/nsUpdateNotification.cpp b/mozilla/xpinstall/src/nsUpdateNotification.cpp index ca62be9cbbc..2b3596ca0f9 100644 --- a/mozilla/xpinstall/src/nsUpdateNotification.cpp +++ b/mozilla/xpinstall/src/nsUpdateNotification.cpp @@ -38,7 +38,8 @@ #include "nsRDFCID.h" #include "nsIRDFXMLSink.h" -#include "nsIPref.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "nsISoftwareUpdate.h" #define NC_RDF_NAME "http://home.netscape.com/NC-rdf#name" @@ -57,9 +58,6 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID); -static NS_DEFINE_IID(kPrefsIID, NS_IPREF_IID); -static NS_DEFINE_IID(kPrefsCID, NS_PREF_CID); - nsIRDFResource* nsXPINotifierImpl::kXPI_NotifierSources = nsnull; nsIRDFResource* nsXPINotifierImpl::kXPI_NotifierPackages = nsnull; @@ -122,19 +120,13 @@ nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn) { *aReturn = PR_FALSE; + nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); - nsIPref * prefs; - nsresult rv = nsServiceManager::GetService(kPrefsCID, - kPrefsIID, - (nsISupports**) &prefs); - - - - if ( NS_SUCCEEDED(rv) ) + if ( prefBranch ) { PRBool value; // check to see if we are on. - rv = prefs->GetBoolPref( (const char*) XPINSTALL_NOTIFICATIONS_ENABLE, &value); + nsresult rv = prefBranch->GetBoolPref( (const char*) XPINSTALL_NOTIFICATIONS_ENABLE, &value); if (NS_SUCCEEDED(rv) && value) { @@ -149,15 +141,15 @@ nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn) PRInt32 lastTime = 0; - rv = prefs->GetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, &intervalHours); + rv = prefBranch->GetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, &intervalHours); if (NS_FAILED(rv)) { intervalHours = 7*24; // default at once a week - rv = prefs->SetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, intervalHours); + rv = prefBranch->SetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, intervalHours); } - rv = prefs->GetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, &lastTime); + rv = prefBranch->GetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, &lastTime); now = PR_Now(); @@ -166,7 +158,7 @@ nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn) if (NS_FAILED(rv) || lastTime == 0) { - rv = prefs->SetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, nowSec); + rv = prefBranch->SetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, nowSec); return NS_OK; } @@ -174,8 +166,6 @@ nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn) { *aReturn = PR_TRUE; } - - NS_RELEASE(prefs); } }