Bug 601715 Cleanup of migration code. r=Neil
authorEdmund Wong <ewong@pw-wspx.org>
Mon, 25 Apr 2011 01:34:56 +0800
changeset 7607 2801b5ea8e0448d8680c6a03c7485b6008c37f73
parent 7606 33f66df662a5f4f08723ce5b06b1a8025e8de06b
child 7608 2e67f19621cdafd034bb3f49b4cc46270dd7861c
push idunknown
push userunknown
push dateunknown
reviewersNeil
bugs601715
Bug 601715 Cleanup of migration code. r=Neil
suite/profile/migration/src/nsNetscapeProfileMigratorBase.cpp
suite/profile/migration/src/nsSeamonkeyProfileMigrator.cpp
suite/profile/migration/src/nsThunderbirdProfileMigrator.cpp
--- a/suite/profile/migration/src/nsNetscapeProfileMigratorBase.cpp
+++ b/suite/profile/migration/src/nsNetscapeProfileMigratorBase.cpp
@@ -69,17 +69,17 @@ regerr2nsresult(REGERR errCode)
     case REGERR_PARAM:
     case REGERR_BADTYPE:
     case REGERR_BADNAME:
       return NS_ERROR_INVALID_ARG;
 
     case REGERR_MEMORY:
       return NS_ERROR_OUT_OF_MEMORY;
   }
-  return NS_ERROR_FAILURE;
+  return NS_ERROR_FILE_NOT_FOUND;
 }
 
 NS_IMPL_ISUPPORTS2(nsNetscapeProfileMigratorBase, nsISuiteProfileMigrator,
                    nsITimerCallback)
 
 
 ///////////////////////////////////////////////////////////////////////////////
 // nsITimerCallback
@@ -746,17 +746,17 @@ nsresult
 nsNetscapeProfileMigratorBase::GetFileValue(nsIPrefBranch* aPrefBranch, const char* aRelPrefName, const char* aPrefName, nsILocalFile** aReturnFile)
 {
   nsCString prefValue;
   nsCOMPtr<nsILocalFile> theFile;
   nsresult rv = aPrefBranch->GetCharPref(aRelPrefName, getter_Copies(prefValue));
   if (NS_SUCCEEDED(rv)) {
     // The pref has the format: [ProfD]a/b/c
     if (!StringBeginsWith(prefValue, NS_LITERAL_CSTRING("[ProfD]")))
-      return NS_ERROR_FAILURE;
+      return NS_ERROR_FILE_NOT_FOUND;
 
     rv = NS_NewNativeLocalFile(EmptyCString(), PR_TRUE, getter_AddRefs(theFile));
     if (NS_FAILED(rv))
       return rv;
 
     rv = theFile->SetRelativeDescriptor(mSourceProfile, Substring(prefValue, 7));
     if (NS_FAILED(rv))
       return rv;
--- a/suite/profile/migration/src/nsSeamonkeyProfileMigrator.cpp
+++ b/suite/profile/migration/src/nsSeamonkeyProfileMigrator.cpp
@@ -83,22 +83,23 @@ nsSeamonkeyProfileMigrator::Migrate(PRUi
                                     nsIProfileStartup* aStartup,
                                     const PRUnichar* aProfile)
 {
   nsresult rv = NS_OK;
   PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE;
 
   if (!mTargetProfile) {
     GetProfilePath(aStartup, getter_AddRefs(mTargetProfile));
-    if (!mTargetProfile) return NS_ERROR_FAILURE;
+    if (!mTargetProfile)
+      return NS_ERROR_FILE_NOT_FOUND;
   }
   if (!mSourceProfile) {
     GetSourceProfile(aProfile);
     if (!mSourceProfile)
-      return NS_ERROR_FAILURE;
+      return NS_ERROR_FILE_NOT_FOUND;
   }
 
   NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
 
   if (aItems & nsISuiteProfileMigrator::HOMEPAGEDATA)
     COPY_DATA(CopyHomePageData, aReplace,
               nsISuiteProfileMigrator::HOMEPAGEDATA);
 
--- a/suite/profile/migration/src/nsThunderbirdProfileMigrator.cpp
+++ b/suite/profile/migration/src/nsThunderbirdProfileMigrator.cpp
@@ -82,21 +82,23 @@ nsThunderbirdProfileMigrator::Migrate(PR
                                       nsIProfileStartup* aStartup,
                                       const PRUnichar* aProfile)
 {
   nsresult rv = NS_OK;
   PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE;
 
   if (!mTargetProfile) {
     GetProfilePath(aStartup, getter_AddRefs(mTargetProfile));
-    if (!mTargetProfile) return NS_ERROR_FAILURE;
+    if (!mTargetProfile)
+      return NS_ERROR_FILE_NOT_FOUND;
   }
   if (!mSourceProfile) {
     GetSourceProfile(aProfile);
-    if (!mSourceProfile) return NS_ERROR_FAILURE;
+    if (!mSourceProfile)
+      return NS_ERROR_FILE_NOT_FOUND;
   }
 
   NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
 
   COPY_DATA(CopyPreferences,  aReplace, nsISuiteProfileMigrator::SETTINGS);
   COPY_DATA(CopyCookies,      aReplace, nsISuiteProfileMigrator::COOKIES);
   COPY_DATA(CopyHistory,      aReplace, nsISuiteProfileMigrator::HISTORY);
   COPY_DATA(CopyPasswords,    aReplace, nsISuiteProfileMigrator::PASSWORDS);
@@ -261,17 +263,17 @@ nsThunderbirdProfileMigrator::FillProfil
 #elif defined(XP_OS2)
 #define REGISTRY_FILE "registry.dat"
   fileLocator->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile),
                    getter_AddRefs(thunderbirdData));
   
   thunderbirdData->Append(NS_LITERAL_STRING("Thunderbird"));
 #else
   // On other OS just abort
-  return NS_ERROR_FAILURE;
+  return NS_ERROR_FILE_NOT_FOUND;
 #endif
 
   // Try profiles.ini first
   nsresult rv = GetProfileDataFromProfilesIni(thunderbirdData,
                                               mProfileNames,
                                               mProfileLocations);
 
   if (rv != NS_ERROR_FILE_NOT_FOUND)