diff --git a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp index 29f346c7320..f1d2c74da34 100644 --- a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp +++ b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp @@ -308,7 +308,7 @@ void nsCharsetConverterManager::FillInfoArrays() res = base->QueryInterface(kRegistryNodeIID, (void**)&node); if (NS_FAILED(res)) goto done1; - res = node->GetName(&name); + res = node->GetNameUTF8(&name); if (NS_FAILED(res)) goto done1; ci = new nsConverterInfo(); @@ -487,7 +487,7 @@ nsresult nsCharsetConverterManager::GetRegistryEnumeration( res = base->QueryInterface(kRegistryNodeIID, (void**)&node); if (NS_FAILED(res)) goto done1; - res = node->GetName(&name); + res = node->GetNameUTF8(&name); if (NS_FAILED(res)) goto done1; s = new nsString("charsetDetector."); diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeXULEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeXULEmitter.cpp index e7dfab17e03..16eb4858a38 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeXULEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeXULEmitter.cpp @@ -188,7 +188,7 @@ nsMimeXULEmitter::BuildListOfStatusProviders() return rv; nsXPIDLCString name; - rv = node->GetName(getter_Copies(name)); + rv = node->GetNameUTF8(getter_Copies(name)); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/modules/libreg/xpcom/nsIRegistry.idl b/mozilla/modules/libreg/xpcom/nsIRegistry.idl index b7153431b19..cec8c550766 100644 --- a/mozilla/modules/libreg/xpcom/nsIRegistry.idl +++ b/mozilla/modules/libreg/xpcom/nsIRegistry.idl @@ -85,14 +85,16 @@ interface nsIRegistry : nsISupports [scriptable, uuid(D1B54831-AC07-11d2-805E-00600811A9C3)] interface nsIRegistryNode : nsISupports { - readonly attribute string name; + readonly attribute string nameUTF8; + readonly attribute wstring name; readonly attribute nsRegistryKey key; }; [scriptable,uuid(5316C380-B2F8-11d2-A374-0080C6F80E4B)] interface nsIRegistryValue : nsISupports { - readonly attribute string name; + readonly attribute wstring name; + readonly attribute string nameUTF8; readonly attribute unsigned long type; readonly attribute PRUint32 length; }; diff --git a/mozilla/modules/libreg/xpcom/nsRegistry.cpp b/mozilla/modules/libreg/xpcom/nsRegistry.cpp index 7d925b11042..f72d8a42ca4 100644 --- a/mozilla/modules/libreg/xpcom/nsRegistry.cpp +++ b/mozilla/modules/libreg/xpcom/nsRegistry.cpp @@ -42,6 +42,8 @@ #define PR_Unlock(x) (void)0 #endif +PRUnichar widestrFormat[] = { PRUnichar('%'),PRUnichar('s'),PRUnichar(0)}; + /*-------------------------------- nsRegistry ---------------------------------- | This class implements the nsIRegistry interface using the functions | | provided by libreg (as declared in mozilla/modules/libreg/include/NSReg.h). | @@ -614,8 +616,7 @@ NS_IMETHODIMP nsRegistry::GetString(nsRegistryKey baseKey, const PRUnichar *valn rv = GetStringUTF8( baseKey, utf8name, &tmpstr ); if (NS_SUCCEEDED(rv)) { - nsString tmpfmt("%s"); - *_retval = nsTextFormatter::smprintf( tmpfmt.GetUnicode(), tmpstr ); + *_retval = nsTextFormatter::smprintf( widestrFormat, tmpstr ); nsCRT::free(tmpstr); if ( *_retval == nsnull ) rv = NS_ERROR_OUT_OF_MEMORY; @@ -1396,7 +1397,19 @@ nsRegistryNode::~nsRegistryNode() | If we haven't fetched it yet, get the name of the corresponding subkey now, | | using NR_RegEnumSubkeys. | ------------------------------------------------------------------------------*/ -NS_IMETHODIMP nsRegistryNode::GetName( char **result ) { +NS_IMETHODIMP nsRegistryNode::GetName( PRUnichar **result ) { + if (result == nsnull) return NS_ERROR_NULL_POINTER; + // Make sure there is a place to put the result. + *result = nsTextFormatter::smprintf( widestrFormat, mName ); + if ( !*result ) return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + +/*-------------------------- nsRegistryNode::GetNameUTF8 ----------------------- +| If we haven't fetched it yet, get the name of the corresponding subkey now, | +| using NR_RegEnumSubkeys. | +------------------------------------------------------------------------------*/ +NS_IMETHODIMP nsRegistryNode::GetNameUTF8( char **result ) { if (result == nsnull) return NS_ERROR_NULL_POINTER; // Make sure there is a place to put the result. *result = nsCRT::strdup( mName ); @@ -1441,7 +1454,31 @@ nsRegistryValue::~nsRegistryValue() /*------------------------- nsRegistryValue::GetName --------------------------- | See nsRegistryNode::GetName; we use NR_RegEnumEntries in this case. | ------------------------------------------------------------------------------*/ -NS_IMETHODIMP nsRegistryValue::GetName( char **result ) { +NS_IMETHODIMP nsRegistryValue::GetName( PRUnichar **result ) { + nsresult rv = NS_OK; + // Make sure we have a place to put the result. + if( result ) { + // Ensure we've got the info we need. + rv = getInfo(); + if( rv == NS_OK || rv == NS_ERROR_REG_NO_MORE ) { + // worked, return actual result. + *result = nsTextFormatter::smprintf( widestrFormat, mName ); + if ( *result ) { + rv = NS_OK; + } else { + rv = NS_ERROR_OUT_OF_MEMORY; + } + } + } else { + rv = NS_ERROR_NULL_POINTER; + } + return rv; +} + +/*------------------------- nsRegistryValue::GetNameUTF8 ----------------------- +| See nsRegistryNode::GetName; we use NR_RegEnumEntries in this case. | +------------------------------------------------------------------------------*/ +NS_IMETHODIMP nsRegistryValue::GetNameUTF8( char **result ) { nsresult rv = NS_OK; // Make sure we have a place to put the result. if( result ) { diff --git a/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp b/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp index 3cfe0c1c0e4..673ff261e9e 100644 --- a/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp +++ b/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp @@ -132,7 +132,7 @@ nsStreamConverterService::BuildGraph() { if (NS_FAILED(rv)) return rv; char *name = nsnull; - rv = node->GetName(&name); + rv = node->GetNameUTF8(&name); if (NS_FAILED(rv)) return rv; nsCString actualProgID(NS_ISTREAMCONVERTER_KEY); diff --git a/mozilla/profile/src/nsProfileAccess.cpp b/mozilla/profile/src/nsProfileAccess.cpp index cf65cfc3c60..11449ee0f48 100644 --- a/mozilla/profile/src/nsProfileAccess.cpp +++ b/mozilla/profile/src/nsProfileAccess.cpp @@ -373,7 +373,7 @@ nsProfileAccess::FillProfileInfo() nsXPIDLCString NCHavePregInfo; char* directory = nsnull; - rv = node->GetName( getter_Copies(profile) ); + rv = node->GetNameUTF8( getter_Copies(profile) ); if (NS_FAILED(rv)) return rv; if (profile) @@ -689,7 +689,7 @@ nsProfileAccess::UpdateRegistry() nsXPIDLCString isMigrated; nsXPIDLCString directory; - rv = node->GetName( getter_Copies(profile) ); + rv = node->GetNameUTF8( getter_Copies(profile) ); if (NS_FAILED(rv)) return rv; PRInt32 index = 0; @@ -848,7 +848,7 @@ nsProfileAccess::Get4xProfileInfo(const char *registryName) if (NS_FAILED(rv)) return rv; char *profile = nsnull; - rv = node->GetName(&profile); + rv = node->GetNameUTF8(&profile); if (NS_FAILED(rv)) return rv; PRBool exists = PR_FALSE;; diff --git a/mozilla/xpcom/components/nsCategoryManager.cpp b/mozilla/xpcom/components/nsCategoryManager.cpp index 72c6741dd60..e292847b5e7 100644 --- a/mozilla/xpcom/components/nsCategoryManager.cpp +++ b/mozilla/xpcom/components/nsCategoryManager.cpp @@ -196,7 +196,7 @@ nsCategoryManager::initialize() keys->CurrentItem(getter_AddRefs(supportsNode)); nsCOMPtr registryNode = do_QueryInterface(supportsNode); - registryNode->GetName(getter_Copies(categoryName)); + registryNode->GetNameUTF8(getter_Copies(categoryName)); registryNode->GetKey(&categoryKey); } @@ -211,7 +211,7 @@ nsCategoryManager::initialize() values->CurrentItem(getter_AddRefs(supportsValue)); nsCOMPtr registryValue = do_QueryInterface(supportsValue); - registryValue->GetName(getter_Copies(entryName)); + registryValue->GetNameUTF8(getter_Copies(entryName)); } nsXPIDLCString value; diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 90cf68bc1a6..7fb5c5b6926 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -67,14 +67,14 @@ PRLogModuleInfo* nsComponentManagerLog = NULL; // Common Key Names const char xpcomKeyName[]="software/mozilla/XPCOM"; -const char classesKeyName[]="classes"; -const char classIDKeyName[]="CLSID"; +const char classesKeyName[]="progID"; +const char classIDKeyName[]="classID"; const char componentsKeyName[]="components"; const char componentLoadersKeyName[]="componentLoaders"; const char xpcomComponentsKeyName[]="software/mozilla/XPCOM/components"; // Common Value Names -const char classIDValueName[]="CLSID"; +const char classIDValueName[]="ClassID"; const char versionValueName[]="VersionString"; const char lastModValueName[]="LastModTimeStamp"; const char fileSizeValueName[]="FileSize"; @@ -800,7 +800,7 @@ nsresult nsComponentManagerImpl::PlatformPrePopulateRegistry() // Get library name nsXPIDLCString cidString; - rv = node->GetName(getter_Copies(cidString)); + rv = node->GetNameUTF8(getter_Copies(cidString)); if (NS_FAILED(rv)) continue; // Get key associated with library @@ -854,7 +854,7 @@ nsresult nsComponentManagerImpl::PlatformPrePopulateRegistry() // Get the progid string nsXPIDLCString progidString; - rv = node->GetName(getter_Copies(progidString)); + rv = node->GetNameUTF8(getter_Copies(progidString)); if (NS_FAILED(rv)) continue; // Get cid string @@ -2074,7 +2074,7 @@ nsComponentManagerImpl::AutoRegister(PRInt32 when, nsIFile *inDirSpec) continue; nsXPIDLCString type; - rv = node->GetName(getter_Copies(type)); + rv = node->GetNameUTF8(getter_Copies(type)); if (NS_FAILED(rv)) continue; diff --git a/mozilla/xpcom/components/nsComponentManager.h b/mozilla/xpcom/components/nsComponentManager.h index 002bfdab2b3..48f4ff7a4e5 100644 --- a/mozilla/xpcom/components/nsComponentManager.h +++ b/mozilla/xpcom/components/nsComponentManager.h @@ -169,9 +169,9 @@ protected: * alpha0.60 : xpcom 2.0 landing * alpha0.70 : using nsIFileSpec. PRTime -> PRUint32 * alpha0.90 : using nsIComponentLoader, abs:/rel:/lib:, shaver-cleanup - * alpha0.91 : restructured registry keys + * alpha0.92 : restructured registry keys */ -#define NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING "alpha0.91" +#define NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING "alpha0.92" //////////////////////////////////////////////////////////////////////////////// /** diff --git a/mozilla/xpcom/components/nsIRegistry.idl b/mozilla/xpcom/components/nsIRegistry.idl index b7153431b19..cec8c550766 100644 --- a/mozilla/xpcom/components/nsIRegistry.idl +++ b/mozilla/xpcom/components/nsIRegistry.idl @@ -85,14 +85,16 @@ interface nsIRegistry : nsISupports [scriptable, uuid(D1B54831-AC07-11d2-805E-00600811A9C3)] interface nsIRegistryNode : nsISupports { - readonly attribute string name; + readonly attribute string nameUTF8; + readonly attribute wstring name; readonly attribute nsRegistryKey key; }; [scriptable,uuid(5316C380-B2F8-11d2-A374-0080C6F80E4B)] interface nsIRegistryValue : nsISupports { - readonly attribute string name; + readonly attribute wstring name; + readonly attribute string nameUTF8; readonly attribute unsigned long type; readonly attribute PRUint32 length; }; diff --git a/mozilla/xpcom/components/nsNativeComponentLoader.cpp b/mozilla/xpcom/components/nsNativeComponentLoader.cpp index a3ef1929b6b..72ef2c0969f 100644 --- a/mozilla/xpcom/components/nsNativeComponentLoader.cpp +++ b/mozilla/xpcom/components/nsNativeComponentLoader.cpp @@ -194,7 +194,7 @@ nsNativeComponentLoader::Init(nsIComponentManager *aCompMgr, nsISupports *aReg) // Get library name nsXPIDLCString library; - rv = node->GetName(getter_Copies(library)); + rv = node->GetNameUTF8(getter_Copies(library)); if (NS_FAILED(rv)) continue; // Get key associated with library diff --git a/mozilla/xpcom/components/nsRegistry.cpp b/mozilla/xpcom/components/nsRegistry.cpp index 7d925b11042..f72d8a42ca4 100644 --- a/mozilla/xpcom/components/nsRegistry.cpp +++ b/mozilla/xpcom/components/nsRegistry.cpp @@ -42,6 +42,8 @@ #define PR_Unlock(x) (void)0 #endif +PRUnichar widestrFormat[] = { PRUnichar('%'),PRUnichar('s'),PRUnichar(0)}; + /*-------------------------------- nsRegistry ---------------------------------- | This class implements the nsIRegistry interface using the functions | | provided by libreg (as declared in mozilla/modules/libreg/include/NSReg.h). | @@ -614,8 +616,7 @@ NS_IMETHODIMP nsRegistry::GetString(nsRegistryKey baseKey, const PRUnichar *valn rv = GetStringUTF8( baseKey, utf8name, &tmpstr ); if (NS_SUCCEEDED(rv)) { - nsString tmpfmt("%s"); - *_retval = nsTextFormatter::smprintf( tmpfmt.GetUnicode(), tmpstr ); + *_retval = nsTextFormatter::smprintf( widestrFormat, tmpstr ); nsCRT::free(tmpstr); if ( *_retval == nsnull ) rv = NS_ERROR_OUT_OF_MEMORY; @@ -1396,7 +1397,19 @@ nsRegistryNode::~nsRegistryNode() | If we haven't fetched it yet, get the name of the corresponding subkey now, | | using NR_RegEnumSubkeys. | ------------------------------------------------------------------------------*/ -NS_IMETHODIMP nsRegistryNode::GetName( char **result ) { +NS_IMETHODIMP nsRegistryNode::GetName( PRUnichar **result ) { + if (result == nsnull) return NS_ERROR_NULL_POINTER; + // Make sure there is a place to put the result. + *result = nsTextFormatter::smprintf( widestrFormat, mName ); + if ( !*result ) return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + +/*-------------------------- nsRegistryNode::GetNameUTF8 ----------------------- +| If we haven't fetched it yet, get the name of the corresponding subkey now, | +| using NR_RegEnumSubkeys. | +------------------------------------------------------------------------------*/ +NS_IMETHODIMP nsRegistryNode::GetNameUTF8( char **result ) { if (result == nsnull) return NS_ERROR_NULL_POINTER; // Make sure there is a place to put the result. *result = nsCRT::strdup( mName ); @@ -1441,7 +1454,31 @@ nsRegistryValue::~nsRegistryValue() /*------------------------- nsRegistryValue::GetName --------------------------- | See nsRegistryNode::GetName; we use NR_RegEnumEntries in this case. | ------------------------------------------------------------------------------*/ -NS_IMETHODIMP nsRegistryValue::GetName( char **result ) { +NS_IMETHODIMP nsRegistryValue::GetName( PRUnichar **result ) { + nsresult rv = NS_OK; + // Make sure we have a place to put the result. + if( result ) { + // Ensure we've got the info we need. + rv = getInfo(); + if( rv == NS_OK || rv == NS_ERROR_REG_NO_MORE ) { + // worked, return actual result. + *result = nsTextFormatter::smprintf( widestrFormat, mName ); + if ( *result ) { + rv = NS_OK; + } else { + rv = NS_ERROR_OUT_OF_MEMORY; + } + } + } else { + rv = NS_ERROR_NULL_POINTER; + } + return rv; +} + +/*------------------------- nsRegistryValue::GetNameUTF8 ----------------------- +| See nsRegistryNode::GetName; we use NR_RegEnumEntries in this case. | +------------------------------------------------------------------------------*/ +NS_IMETHODIMP nsRegistryValue::GetNameUTF8( char **result ) { nsresult rv = NS_OK; // Make sure we have a place to put the result. if( result ) { diff --git a/mozilla/xpcom/tools/registry/regExport.cpp b/mozilla/xpcom/tools/registry/regExport.cpp index 53ad0b78b4e..6ab37f24a2a 100644 --- a/mozilla/xpcom/tools/registry/regExport.cpp +++ b/mozilla/xpcom/tools/registry/regExport.cpp @@ -165,7 +165,7 @@ void display( nsIRegistry *reg, nsRegistryKey root, const char *rootName ) { if ( rv == NS_OK ) { // Get node name. char *name; - rv = node->GetName( &name ); + rv = node->GetNameUTF8( &name ); // Test result. if ( rv == NS_OK ) { // Build complete name. @@ -238,7 +238,7 @@ static void displayValues( nsIRegistry *reg, nsRegistryKey root ) { if ( rv == NS_OK ) { // Get node name. char *name; - rv = value->GetName( &name ); + rv = value->GetNameUTF8( &name ); // Test result. if ( rv == NS_OK ) { // Print name: diff --git a/mozilla/xpfe/appshell/src/nsAppShellService.cpp b/mozilla/xpfe/appshell/src/nsAppShellService.cpp index 5d44d189f53..5df6c3ae023 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellService.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellService.cpp @@ -282,7 +282,7 @@ nsAppShellService::EnumerateComponents( EnumeratorMemberFunction function ) { if ( NS_SUCCEEDED( rv ) ) { // Get node name. char *name; - rv = node->GetName( &name ); + rv = node->GetNameUTF8( &name ); if ( NS_SUCCEEDED( rv ) ) { // If this is a CID of a component; apply function to it. nsCID cid; diff --git a/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp b/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp index 2f5bcbb1661..d9a86291c66 100644 --- a/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp +++ b/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp @@ -97,9 +97,10 @@ nsresult NS_AutoregisterComponents() #endif extern "C" void -NS_SetupRegistry_1() +NS_SetupRegistry_1( PRBool needAutoreg ) { - NS_AutoregisterComponents(); + if ( needAutoreg ) + NS_AutoregisterComponents(); /* * Call the standard NS_SetupRegistry() implemented in diff --git a/mozilla/xpfe/components/regviewer/nsRegistryDataSource.cpp b/mozilla/xpfe/components/regviewer/nsRegistryDataSource.cpp index c31af9da563..5c32617d99f 100644 --- a/mozilla/xpfe/components/regviewer/nsRegistryDataSource.cpp +++ b/mozilla/xpfe/components/regviewer/nsRegistryDataSource.cpp @@ -639,7 +639,7 @@ nsRegistryDataSource::ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator return NS_ERROR_UNEXPECTED; nsXPIDLCString valueStr; - rv = value->GetName(getter_Copies(valueStr)); + rv = value->GetNameUTF8(getter_Copies(valueStr)); if (NS_FAILED(rv)) return rv; nsCAutoString propertyStr(kValuePrefix); @@ -771,7 +771,7 @@ nsRegistryDataSource::SubkeyEnumerator::ConvertRegistryNodeToResource(nsISupport if (NS_FAILED(rv)) return rv; nsXPIDLCString path; - rv = node->GetName(getter_Copies(path)); + rv = node->GetNameUTF8(getter_Copies(path)); if (NS_FAILED(rv)) return rv; nsCAutoString newURI(rootURI); diff --git a/mozilla/xpinstall/src/nsInstall.cpp b/mozilla/xpinstall/src/nsInstall.cpp index 05b68d68e57..92a957c0680 100644 --- a/mozilla/xpinstall/src/nsInstall.cpp +++ b/mozilla/xpinstall/src/nsInstall.cpp @@ -838,22 +838,37 @@ nsInstall::FinalizeInstall(PRInt32* aReturn) } } - if ( result != SUCCESS ) + if ( result == SUCCESS ) + { + if ( rebootNeeded ) + *aReturn = SaveError( REBOOT_NEEDED ); + + // XXX for now all successful installs will trigger an Autoreg. + // We eventually want to do this only when flagged. + HREG reg; + if ( REGERR_OK == NR_RegOpen("", ®) ) + { + RKEY xpiRoot; + REGERR err; + err = NR_RegAddKey(reg,ROOTKEY_COMMON,XPI_ROOT_KEY,&xpiRoot); + if ( err == REGERR_OK ) + NR_RegSetEntryString(reg, xpiRoot, XPI_AUTOREG_VAL, "no"); + } + } + else *aReturn = SaveError( result ); - else if ( rebootNeeded ) - *aReturn = SaveError( REBOOT_NEEDED ); if (mNotifier) { mNotifier->FinalStatus(mInstallURL.GetUnicode(), *aReturn); mStatusSent = PR_TRUE; } - } + } else { // no actions queued: don't register the package version // and no need for user confirmation - + if (mNotifier) { mNotifier->FinalStatus(mInstallURL.GetUnicode(), *aReturn); @@ -861,8 +876,7 @@ nsInstall::FinalizeInstall(PRInt32* aReturn) } } - if((result == nsInstall::SUCCESS) || (result == REBOOT_NEEDED)) - CleanUp(); + CleanUp(); return NS_OK; } diff --git a/mozilla/xpinstall/src/nsInstallFile.cpp b/mozilla/xpinstall/src/nsInstallFile.cpp index 8189feb4de6..3aa12f1b27f 100644 --- a/mozilla/xpinstall/src/nsInstallFile.cpp +++ b/mozilla/xpinstall/src/nsInstallFile.cpp @@ -75,6 +75,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall, *error = nsInstall::SUCCESS; /* Check for existence of the newer version */ +#if 0 // XXX need to re-implement force mode in the opposite sense char* qualifiedRegNameString = inComponentName.ToNewCString(); @@ -132,6 +133,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall, } Recycle(qualifiedRegNameString); +#endif nsFileSpec* tmp = folderSpec->GetFileSpec(); if (!tmp) @@ -266,7 +268,10 @@ PRInt32 nsInstallFile::Complete() if ( 0 == err || nsInstall::REBOOT_NEEDED == err ) { - RegisterInVersionRegistry(); + // XXX Don't register individual files for now -- crucial performance + // speed up on the Mac, and we'll switch uninstall schemes after beta + + // RegisterInVersionRegistry(); } return err; diff --git a/mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp b/mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp index 38aaff75743..c9b20222818 100644 --- a/mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp +++ b/mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp @@ -59,7 +59,11 @@ NS_IMETHODIMP nsLoggingProgressNotifier::BeforeJavascriptEvaluation(const PRUnichar *URL) { nsSpecialSystemDirectory logFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); +#ifdef XP_MAC + logFile += "Install Log"; +#else logFile += "install.log"; +#endif mLogStream = new nsOutputFileStream(logFile, PR_WRONLY | PR_CREATE_FILE | PR_APPEND, 0744 ); if (!mLogStream) diff --git a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp index 4d175d6bef8..829c1625a82 100644 --- a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp +++ b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp @@ -33,6 +33,7 @@ #include "nspr.h" #include "prlock.h" +#include "NSReg.h" #include "VerReg.h" #include "nsSpecialSystemDirectory.h" @@ -49,6 +50,7 @@ #include "nsIAppShellComponent.h" #include "nsIRegistry.h" +#include "nsBuildID.h" /* For Javascript Namespace Access */ #include "nsDOMCID.h" @@ -74,16 +76,18 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_IID(kIScriptNameSetRegistryIID, NS_ISCRIPTNAMESETREGISTRY_IID); -static NS_DEFINE_IID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID); +static NS_DEFINE_CID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID); static NS_DEFINE_IID(kIScriptExternalNameSetIID, NS_ISCRIPTEXTERNALNAMESET_IID); static NS_DEFINE_IID(kISoftwareUpdate_IID, NS_ISOFTWAREUPDATE_IID); static NS_DEFINE_IID(kIInstallTrigger_IID, NS_IDOMINSTALLTRIGGERGLOBAL_IID); -static NS_DEFINE_IID(kInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID); +static NS_DEFINE_CID(kInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID); static NS_DEFINE_IID(kIInstallVersion_IID, NS_IDOMINSTALLVERSION_IID); -static NS_DEFINE_IID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID); +static NS_DEFINE_CID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID); + +static NS_DEFINE_CID(knsRegistryCID, NS_REGISTRY_CID); nsSoftwareUpdate* nsSoftwareUpdate::mInstance = nsnull; @@ -309,18 +313,84 @@ nsSoftwareUpdate::InstallJarCallBack() NS_IMETHODIMP -nsSoftwareUpdate::StartupTasks( PRBool* outAutoreg ) +nsSoftwareUpdate::StartupTasks( PRBool *needAutoreg ) { - if (outAutoreg) *outAutoreg = PR_FALSE; + PRBool autoReg = PR_FALSE; + RKEY xpiRoot; + REGERR err; + + *needAutoreg = PR_TRUE; + + // First do any left-over file replacements and deletes + + // NOTE: we leave the registry open until later to prevent + // having to load and unload it many times at startup if ( REGERR_OK == NR_RegOpen("", &mReg) ) { // XXX get a return val and if not all replaced autoreg again later PerformScheduledTasks(mReg); + + // now look for an autoreg flag left behind by XPInstall + err = NR_RegGetKey( mReg, ROOTKEY_COMMON, XPI_ROOT_KEY, &xpiRoot); + if ( err == REGERR_OK ) + { + char buf[8]; + err = NR_RegGetEntryString( mReg, xpiRoot, XPI_AUTOREG_VAL, + buf, sizeof(buf) ); + + if ( err == REGERR_OK && !strcmp( buf, "yes" ) ) + autoReg = PR_TRUE; + } } + // Also check for build number changes + nsresult rv; + PRInt32 buildID = 0; + nsRegistryKey idKey = 0; + nsCOMPtr reg = do_GetService(knsRegistryCID,&rv); + if (NS_SUCCEEDED(rv)) + { + rv = reg->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry); + if (NS_SUCCEEDED(rv)) + { + rv = reg->GetSubtree(nsIRegistry::Common,XPCOM_KEY,&idKey); + if (NS_SUCCEEDED(rv)) + { + rv = reg->GetInt( idKey, XPI_AUTOREG_VAL, &buildID ); + } + } + } - return NS_OK; + // Autoregister if we found the XPInstall flag, the stored BuildID + // is not the actual BuildID, or if we couldn't get the BuildID + if ( autoReg || NS_FAILED(rv) || buildID != NS_BUILD_ID ) + { + rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup,0); + + if (NS_SUCCEEDED(rv)) + { + *needAutoreg = PR_FALSE; + + // Now store back into the registries so we don't do this again + if ( autoReg ) + NR_RegSetEntryString( mReg, xpiRoot, XPI_AUTOREG_VAL, "no" ); + + if ( buildID != NS_BUILD_ID && idKey != 0 ) + reg->SetInt( idKey, XPI_AUTOREG_VAL, NS_BUILD_ID ); + } + } + else + { + //We don't need to autoreg, we're up to date + *needAutoreg = PR_FALSE; +#ifdef DEBUG + // debug (developer) builds should always autoreg + *needAutoreg = PR_TRUE; +#endif + } + + return rv; } @@ -396,6 +466,11 @@ nsSoftwareUpdate::StubInitialize(nsIFileSpec *aDir) mProgramDir = aDir; NS_ADDREF(mProgramDir); + // make sure registry updates go to the right place + nsFileSpec instDir; + if (NS_SUCCEEDED( aDir->GetFileSpec( &instDir ) ) ) + VR_SetRegDirectory( instDir.GetNativePathCString() ); + // Create the logfile observer nsLoggingProgressNotifier *logger = new nsLoggingProgressNotifier(); RegisterNotifier(logger); diff --git a/mozilla/xpinstall/src/nsSoftwareUpdate.h b/mozilla/xpinstall/src/nsSoftwareUpdate.h index 04d6714ea4d..1c5a14425bd 100644 --- a/mozilla/xpinstall/src/nsSoftwareUpdate.h +++ b/mozilla/xpinstall/src/nsSoftwareUpdate.h @@ -22,6 +22,10 @@ class nsInstallInfo; #include "nsPIXPIStubHook.h" #include "nsTopProgressNotifier.h" +#define XPI_ROOT_KEY "software/mozilla/xpinstall" +#define XPI_AUTOREG_VAL "Autoreg" +#define XPCOM_KEY "software/mozilla/XPCOM" + class nsSoftwareUpdate: public nsIAppShellComponent, public nsISoftwareUpdate, public nsPIXPIStubHook @@ -52,7 +56,7 @@ class nsSoftwareUpdate: public nsIAppShellComponent, NS_IMETHOD InstallJarCallBack(); NS_IMETHOD GetMasterNotifier(nsIXPINotifier **notifier); NS_IMETHOD SetActiveNotifier(nsIXPINotifier *notifier); - NS_IMETHOD StartupTasks( PRBool* outAutoreg ); + NS_IMETHOD StartupTasks( PRBool* needAutoreg ); /** StubInitialize() is private for the Install Wizard. * The mStubLockout property makes sure this is only called