зеркало из https://github.com/mozilla/gecko-dev.git
cleanup of some of the migration code. this is needed before we properly fix #36249
This commit is contained in:
Родитель
871baea0d9
Коммит
87e01e9e26
|
@ -28,6 +28,7 @@ interface nsIWebShellWindow;
|
|||
|
||||
#define NS_PROFILEMIGRATION_PROGID "component://netscape/profile/migration"
|
||||
#define NS_PREFCONVERTER_PROGID "component://netscape/migration/pref-converter"
|
||||
#define NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_MAILNEWS, 1)
|
||||
|
||||
%}
|
||||
|
||||
|
@ -37,7 +38,8 @@ interface nsIPrefMigration: nsISupports
|
|||
void AddProfilePaths(in string oldProfilePathStr, in string newProfilePathStr);
|
||||
void ProcessPrefs(in boolean showProgressAsModalWindow);
|
||||
void ProcessPrefsFromJS();
|
||||
void GetError(out PRUint32 error);
|
||||
/* will raise an exception from JS if there was an error */
|
||||
void GetError();
|
||||
|
||||
/**
|
||||
* this should be in a seperate interface
|
||||
|
|
|
@ -31,20 +31,18 @@ function onLoad(oldProfilePath, newProfilePath) {
|
|||
//dialog.current = document.getElementByID( "xpi.currentlyprocessing");
|
||||
//dialog.newWindow = document.getElementById( "dialog.newWindow" );
|
||||
|
||||
var retval;
|
||||
|
||||
dump("start of pref migration\n");
|
||||
var prefmigrator = Components.classes['component://netscape/profile/migration'].createInstance(Components.interfaces.nsIPrefMigration);
|
||||
if (prefmigrator)
|
||||
{
|
||||
dump("----- Migrating prefs\n");
|
||||
retval = prefmigrator.ProcessPrefsFromJS();
|
||||
dump("----- Migrating prefs done " + retval + "\n" );
|
||||
try {
|
||||
prefmigrator.ProcessPrefsFromJS();
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to migrate: ex="+ ex + "\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dump("----- ERROR Migrating prefs failed create instances failed\n");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -251,6 +251,7 @@ nsPrefMigration::GetInstance()
|
|||
nsPrefMigration::nsPrefMigration() : m_prefs(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mErrorCode = NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -369,6 +370,10 @@ extern "C" void ProfileMigrationController(void *data)
|
|||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("failed to migrate properly. err=%d\n",rv);
|
||||
}
|
||||
|
||||
NS_WITH_SERVICE(nsIProxyObjectManager, pIProxyObjectManager, kProxyObjectManagerCID, &rv);
|
||||
if(NS_FAILED(rv))
|
||||
return;
|
||||
|
@ -393,8 +398,11 @@ nsPrefMigration::WindowCloseCallback()
|
|||
nsCOMPtr<nsIWebShellWindow> progressWindow(do_QueryInterface(mPMProgressWindow));
|
||||
if(progressWindow)
|
||||
progressWindow->Close();
|
||||
|
||||
return NS_OK;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("end of pref migration\n");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -414,10 +422,9 @@ nsPrefMigration::ProcessPrefsFromJS() // called via js so that we can have prog
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefMigration::GetError(PRUint32 *error)
|
||||
nsPrefMigration::GetError()
|
||||
{
|
||||
*error = mErrorCode;
|
||||
return NS_OK;
|
||||
return mErrorCode;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -827,7 +834,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newProfilePath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalRequired)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE;
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -840,7 +847,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newIMAPLocalMailPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalRequired)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
else if (serverType == POP_4X_MAIL_TYPE)
|
||||
|
@ -848,7 +855,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newPOPMailPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalRequired)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_MOVEMAIL
|
||||
|
@ -857,7 +864,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newMOVEMAILMailPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalRequired)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_MOVEMAIL */
|
||||
|
@ -869,7 +876,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newProfilePath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalProfileSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -881,12 +888,12 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newProfilePath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalRequired)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
newNewsPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalNewsSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -897,14 +904,14 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newProfilePath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalRequired)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
if (serverType == IMAP_4X_MAIL_TYPE)
|
||||
{
|
||||
newIMAPMailPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalMailSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
else if (serverType == POP_4X_MAIL_TYPE)
|
||||
|
@ -912,7 +919,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newPOPMailPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalMailSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_MOVEMAIL
|
||||
|
@ -921,7 +928,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newMOVEMAILMailPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalMailSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_MOVEMAIL */
|
||||
|
@ -939,7 +946,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newIMAPMailPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalMailSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
else if (serverType == POP_4X_MAIL_TYPE)
|
||||
|
@ -947,7 +954,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newPOPMailPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalMailSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_MOVEMAIL
|
||||
|
@ -956,7 +963,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newPOPMailPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalMailSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_MOVEMAIL */
|
||||
|
@ -969,13 +976,13 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
|||
newNewsPath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalNewsSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
|
||||
newProfilePath->GetFileSpec(&tempSpec);
|
||||
if(NS_FAILED(CheckForSpace(tempSpec, totalProfileSize)))
|
||||
{
|
||||
return NOT_ENOUGH_SPACE; /* Need error code for not enough space */
|
||||
return NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE;
|
||||
}
|
||||
}
|
||||
} /* else */
|
||||
|
@ -1370,7 +1377,7 @@ nsPrefMigration::GetDriveName(nsFileSpec inputPath, char**driveName)
|
|||
* requiredSpace - The space needed on the new profile drive
|
||||
*
|
||||
* RETURNS: NS_OK if enough space is available
|
||||
* NOT_ENOUGH_SPACE (error -200) if there is not enough space
|
||||
* NS_ERROR_NOT_ENOUGH_SPACE_TO_MIGRATE if there is not enough space
|
||||
*
|
||||
* Todo: you may want to change this proto from a float to a int64.
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
|
|
@ -84,12 +84,7 @@ class nsPrefMigration: public nsIPrefMigration
|
|||
nsresult ProcessPrefsCallback(const char* oldProfilePathStr, const char * newProfilePathStr);
|
||||
void WaitForThread();
|
||||
|
||||
PRUint32 mErrorCode;
|
||||
|
||||
enum
|
||||
{
|
||||
NOT_ENOUGH_SPACE = 200
|
||||
};
|
||||
nsresult mErrorCode;
|
||||
|
||||
private:
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче