From 1f7222ed99e111f63c863263368b44d375ba0e39 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Sat, 24 Sep 2011 16:25:20 +0200 Subject: [PATCH] Bug 679352 - Remove libreg (Part 1: Clean nsProfileMigrator). r=bsmedberg --- .../migration/src/nsProfileMigrator.cpp | 129 ------------------ .../migration/src/nsProfileMigrator.h | 6 - toolkit/profile/nsIProfileMigrator.idl | 13 -- toolkit/xre/nsAppRunner.cpp | 36 ----- 4 files changed, 184 deletions(-) diff --git a/browser/components/migration/src/nsProfileMigrator.cpp b/browser/components/migration/src/nsProfileMigrator.cpp index eed326f5ee2..27dbd40cb42 100644 --- a/browser/components/migration/src/nsProfileMigrator.cpp +++ b/browser/components/migration/src/nsProfileMigrator.cpp @@ -56,7 +56,6 @@ #include "nsDirectoryServiceDefs.h" #include "nsServiceManagerUtils.h" -#include "NSReg.h" #include "nsStringAPI.h" #include "nsUnicharUtils.h" #ifdef XP_WIN @@ -69,18 +68,6 @@ #include "nsAutoPtr.h" -#ifndef MAXPATHLEN -#ifdef PATH_MAX -#define MAXPATHLEN PATH_MAX -#elif defined(_MAX_PATH) -#define MAXPATHLEN _MAX_PATH -#elif defined(CCHMAXPATH) -#define MAXPATHLEN CCHMAXPATH -#else -#define MAXPATHLEN 1024 -#endif -#endif - /////////////////////////////////////////////////////////////////////////////// // nsIProfileMigrator @@ -144,15 +131,6 @@ nsProfileMigrator::Migrate(nsIProfileStartup* aStartup) getter_AddRefs(migrateWizard)); } -NS_IMETHODIMP -nsProfileMigrator::Import() -{ - if (ImportRegistryProfiles(NS_LITERAL_CSTRING("Firefox"))) - return NS_OK; - - return NS_ERROR_FAILURE; -} - /////////////////////////////////////////////////////////////////////////////// // nsProfileMigrator @@ -267,110 +245,3 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsACString& aKey, #endif return NS_ERROR_FAILURE; } - -PRBool -nsProfileMigrator::ImportRegistryProfiles(const nsACString& aAppName) -{ - nsresult rv; - - nsCOMPtr profileSvc - (do_GetService(NS_PROFILESERVICE_CONTRACTID)); - NS_ENSURE_TRUE(profileSvc, PR_FALSE); - - nsCOMPtr dirService - (do_GetService("@mozilla.org/file/directory_service;1")); - NS_ENSURE_TRUE(dirService, PR_FALSE); - - nsCOMPtr regFile; -#ifdef XP_WIN - rv = dirService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), - getter_AddRefs(regFile)); - NS_ENSURE_SUCCESS(rv, PR_FALSE); - regFile->AppendNative(aAppName); - regFile->AppendNative(NS_LITERAL_CSTRING("registry.dat")); -#elif defined(XP_MACOSX) - rv = dirService->Get(NS_MAC_USER_LIB_DIR, NS_GET_IID(nsILocalFile), - getter_AddRefs(regFile)); - NS_ENSURE_SUCCESS(rv, PR_FALSE); - regFile->AppendNative(aAppName); - regFile->AppendNative(NS_LITERAL_CSTRING("Application Registry")); -#elif defined(XP_OS2) - rv = dirService->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), - getter_AddRefs(regFile)); - NS_ENSURE_SUCCESS(rv, PR_FALSE); - regFile->AppendNative(aAppName); - regFile->AppendNative(NS_LITERAL_CSTRING("registry.dat")); -#else - rv = dirService->Get(NS_UNIX_HOME_DIR, NS_GET_IID(nsILocalFile), - getter_AddRefs(regFile)); - NS_ENSURE_SUCCESS(rv, PR_FALSE); - nsCAutoString dotAppName; - ToLowerCase(aAppName, dotAppName); - dotAppName.Insert('.', 0); - - regFile->AppendNative(dotAppName); - regFile->AppendNative(NS_LITERAL_CSTRING("appreg")); -#endif - - nsCAutoString path; - rv = regFile->GetNativePath(path); - NS_ENSURE_SUCCESS(rv, PR_FALSE); - - if (NR_StartupRegistry()) - return PR_FALSE; - - PRBool migrated = PR_FALSE; - HREG reg = nsnull; - RKEY profiles = 0; - REGENUM enumstate = 0; - char profileName[MAXREGNAMELEN]; - - if (NR_RegOpen(path.get(), ®)) - goto cleanup; - - if (NR_RegGetKey(reg, ROOTKEY_COMMON, "Profiles", &profiles)) - goto cleanup; - - while (!NR_RegEnumSubkeys(reg, profiles, &enumstate, - profileName, MAXREGNAMELEN, REGENUM_CHILDREN)) { -#ifdef DEBUG_bsmedberg - printf("Found profile %s.\n", profileName); -#endif - - RKEY profile = 0; - if (NR_RegGetKey(reg, profiles, profileName, &profile)) { - NS_ERROR("Could not get the key that was enumerated."); - continue; - } - - char profilePath[MAXPATHLEN]; - if (NR_RegGetEntryString(reg, profile, "directory", - profilePath, MAXPATHLEN)) - continue; - - nsCOMPtr profileFile - (do_CreateInstance("@mozilla.org/file/local;1")); - if (!profileFile) - continue; - -#if defined (XP_MACOSX) - rv = profileFile->SetPersistentDescriptor(nsDependentCString(profilePath)); -#else - NS_ConvertUTF8toUTF16 widePath(profilePath); - rv = profileFile->InitWithPath(widePath); -#endif - if (NS_FAILED(rv)) continue; - - nsCOMPtr tprofile; - profileSvc->CreateProfile(profileFile, nsnull, - nsDependentCString(profileName), - getter_AddRefs(tprofile)); - migrated = PR_TRUE; - } - -cleanup: - if (reg) - NR_RegClose(reg); - NR_ShutdownRegistry(); - return migrated; -} diff --git a/browser/components/migration/src/nsProfileMigrator.h b/browser/components/migration/src/nsProfileMigrator.h index ee0b52fa1e0..43d38ea7650 100644 --- a/browser/components/migration/src/nsProfileMigrator.h +++ b/browser/components/migration/src/nsProfileMigrator.h @@ -58,12 +58,6 @@ protected: nsresult GetDefaultBrowserMigratorKey(nsACString& key, nsCOMPtr& bpm); - - /** - * Import profiles from ~/.firefox/ - * @return PR_TRUE if any profiles imported. - */ - PRBool ImportRegistryProfiles(const nsACString& aAppName); }; #endif diff --git a/toolkit/profile/nsIProfileMigrator.idl b/toolkit/profile/nsIProfileMigrator.idl index ac31671f217..4d23acd9105 100644 --- a/toolkit/profile/nsIProfileMigrator.idl +++ b/toolkit/profile/nsIProfileMigrator.idl @@ -72,19 +72,6 @@ interface nsIProfileStartup : nsISupports [scriptable, uuid(24ce8b9d-b7ff-4279-aef4-26e158f03e34)] interface nsIProfileMigrator : nsISupports { - /** - * Import existing profile paths. When the app is started the first - * time, if there are no INI-style profiles, appstartup will call - * this method to import any registry- style profiles that may - * exist. When this method is called, there is no event queue - * service and this method should not attempt to use the network or - * show any GUI. - * - * @note You don't actually have to move the profile data. Just call - * nsIToolkitProfileService.create on the existing profile path(s). - */ - void import(); - /** * Do profile migration. * diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 4dd0249a52a..4240b81b845 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -1861,35 +1861,6 @@ ShowProfileManager(nsIToolkitProfileService* aProfileSvc, return LaunchChild(aNative); } -static nsresult -ImportProfiles(nsIToolkitProfileService* aPService, - nsINativeAppSupport* aNative) -{ - nsresult rv; - - SaveToEnv("XRE_IMPORT_PROFILES=1"); - - // try to import old-style profiles - { // scope XPCOM - ScopedXPCOMStartup xpcom; - rv = xpcom.Initialize(); - if (NS_SUCCEEDED(rv)) { -#ifdef XP_MACOSX - CommandLineServiceMac::SetupMacCommandLine(gRestartArgc, gRestartArgv, PR_TRUE); -#endif - - nsCOMPtr migrator - (do_GetService(NS_PROFILEMIGRATOR_CONTRACTID)); - if (migrator) { - migrator->Import(); - } - } - } - - aPService->Flush(); - return LaunchChild(aNative); -} - // Pick a profile. We need to end up with a profile lock. // // 1) check for -profile @@ -2041,12 +2012,6 @@ SelectProfile(nsIProfileLock* *aResult, nsINativeAppSupport* aNative, rv = profileSvc->GetProfileCount(&count); NS_ENSURE_SUCCESS(rv, rv); - if (gAppData->flags & NS_XRE_ENABLE_PROFILE_MIGRATOR) { - if (!count && !EnvHasValue("XRE_IMPORT_PROFILES")) { - return ImportProfiles(profileSvc, aNative); - } - } - ar = CheckArg("p", PR_FALSE, &arg); if (ar == ARG_BAD) { ar = CheckArg("osint"); @@ -3468,7 +3433,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) SaveToEnv("XRE_PROFILE_LOCAL_PATH="); SaveToEnv("XRE_PROFILE_NAME="); SaveToEnv("XRE_START_OFFLINE="); - SaveToEnv("XRE_IMPORT_PROFILES="); SaveToEnv("NO_EM_RESTART="); SaveToEnv("XUL_APP_FILE="); SaveToEnv("XRE_BINARY_PATH=");