From 5b0cf01e35cb714e71aa2ed4ba7cf4ea4ec00756 Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Thu, 3 May 2007 18:32:43 +0000 Subject: [PATCH] remove nsMessengerMigrator, sr=mscott 379068 git-svn-id: svn://10.0.0.236/trunk@225541 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/base/build/nsMsgFactory.cpp | 6 -- .../prefs/resources/content/AccountWizard.js | 3 +- .../prefs/resources/content/accountUtils.js | 26 ++------- .../base/public/nsIMsgAccountManager.idl | 5 +- mozilla/mailnews/base/public/nsMsgBaseCID.h | 12 ---- mozilla/mailnews/base/src/Makefile.in | 2 - .../mailnews/base/src/nsMsgAccountManager.cpp | 57 +++++++++++++++++++ mozilla/mailnews/base/util/nsMsgUtils.h | 2 - mozilla/mailnews/build/nsMailModule.cpp | 6 -- .../mailnews/import/oexpress/nsOESettings.cpp | 8 +-- .../import/outlook/src/nsOutlookSettings.cpp | 9 +-- .../import/resources/content/importDialog.js | 6 +- mozilla/mailnews/import/src/nsImportMail.cpp | 8 +-- mozilla/mailnews/news/src/nsNntpService.cpp | 16 ------ 14 files changed, 72 insertions(+), 94 deletions(-) diff --git a/mozilla/mailnews/base/build/nsMsgFactory.cpp b/mozilla/mailnews/base/build/nsMsgFactory.cpp index 0df61a8a219..9ff837b8799 100644 --- a/mozilla/mailnews/base/build/nsMsgFactory.cpp +++ b/mozilla/mailnews/base/build/nsMsgFactory.cpp @@ -64,7 +64,6 @@ #include "nsMsgMailSession.h" #include "nsMsgAccount.h" #include "nsMsgAccountManager.h" -#include "nsMessengerMigrator.h" #include "nsMsgIdentity.h" #include "nsMsgIncomingServer.h" #include "nsMsgFolderDataSource.h" @@ -136,7 +135,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlListenerManager) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgMailSession, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMessenger) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgAccountManager, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMessengerMigrator, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgAccount) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgIdentity) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgFolderDataSource, Init) @@ -257,10 +255,6 @@ static const nsModuleComponentInfo gComponents[] = { NS_MSGACCOUNTMANAGER_CONTRACTID, nsMsgAccountManagerConstructor, }, - { "Messenger Migrator", NS_MESSENGERMIGRATOR_CID, - NS_MESSENGERMIGRATOR_CONTRACTID, - nsMessengerMigratorConstructor, - }, { "Messenger User Account", NS_MSGACCOUNT_CID, NS_MSGACCOUNT_CONTRACTID, nsMsgAccountConstructor, diff --git a/mozilla/mailnews/base/prefs/resources/content/AccountWizard.js b/mozilla/mailnews/base/prefs/resources/content/AccountWizard.js index cc24375dfc9..ffe84e7d3b1 100644 --- a/mozilla/mailnews/base/prefs/resources/content/AccountWizard.js +++ b/mozilla/mailnews/base/prefs/resources/content/AccountWizard.js @@ -625,8 +625,7 @@ function verifyLocalFoldersAccount() { // dump("Creating local mail account\n"); // creates a copy of the identity you pass in - messengerMigrator = Components.classes["@mozilla.org/messenger/migrator;1"].getService(Components.interfaces.nsIMessengerMigrator); - messengerMigrator.createLocalMailAccount(false /* false, since we are not migrating */); + am.createLocalMailAccount(); try { localMailServer = am.localFoldersServer; } diff --git a/mozilla/mailnews/base/prefs/resources/content/accountUtils.js b/mozilla/mailnews/base/prefs/resources/content/accountUtils.js index 250c54256b4..1d4bf96dba1 100644 --- a/mozilla/mailnews/base/prefs/resources/content/accountUtils.js +++ b/mozilla/mailnews/base/prefs/resources/content/accountUtils.js @@ -38,7 +38,6 @@ // The gReturnmycall is used as a global variable that is set during a callback. var gReturnmycall=false; var accountManagerContractID = "@mozilla.org/messenger/account-manager;1"; -var messengerMigratorContractID = "@mozilla.org/messenger/migrator;1"; var gAnyValidIdentity = false; //If there are no valid identities for any account // returns the first account with an invalid server or identity @@ -166,22 +165,8 @@ function verifyAccounts(wizardcallback) if (!adminUrl) newProfile = false; } - if ((newProfile && !accountCount) || accountCount == invalidAccounts.length) { - try { - var messengerMigrator = Components.classes[messengerMigratorContractID].getService(Components.interfaces.nsIMessengerMigrator); - messengerMigrator.UpgradePrefs(); - // if there is a callback mechanism then inform parent window to shut itself down - if (wizardcallback){ - state = false; - WizCallback(state); - } - ret = false; - } - catch (ex) { - // upgrade prefs failed, so open account wizard - openWizard = true; - } - } + if ((newProfile && !accountCount) || accountCount == invalidAccounts.length) + openWizard = true; //We are doing openWizard if MessengerMigration returns some kind of error //(including those cases where there is nothing to migrate). @@ -195,7 +180,7 @@ function verifyAccounts(wizardcallback) if (openWizard || prefillAccount || ((!gAnyValidIdentity) && wizardcallback)) { MsgAccountWizard(); - ret = false; + ret = false; } else { @@ -211,10 +196,7 @@ function verifyAccounts(wizardcallback) // we didn't create the MsgAccountWizard - we need to verify that local folders exists. if (!localFoldersExists) - { - messengerMigrator = Components.classes["@mozilla.org/messenger/migrator;1"].getService(Components.interfaces.nsIMessengerMigrator); - messengerMigrator.createLocalMailAccount(false /* false, since we are not migrating */); - } + am.createLocalMailAccount(); } // This will only succeed on SeaMonkey windows builds diff --git a/mozilla/mailnews/base/public/nsIMsgAccountManager.idl b/mozilla/mailnews/base/public/nsIMsgAccountManager.idl index a34c9f798e7..b89341ab852 100644 --- a/mozilla/mailnews/base/public/nsIMsgAccountManager.idl +++ b/mozilla/mailnews/base/public/nsIMsgAccountManager.idl @@ -47,7 +47,7 @@ interface nsIMsgFolderCache; interface nsIFolderListener; -[scriptable, uuid(0dc74b96-c2fc-4ce0-baed-c6f03c69026e)] +[scriptable, uuid(8129D2AD-6093-479D-884C-D8E79FA29B46)] interface nsIMsgAccountManager : nsISupports { nsIMsgAccount createAccount(); @@ -171,6 +171,9 @@ interface nsIMsgAccountManager : nsISupports { * this will allow you to get */ attribute nsIMsgIncomingServer localFoldersServer; + // Create the account for that special server. + void createLocalMailAccount(); + /* load accounts kicks off the creation of all accounts. You do not need * to call this and all accounts should be loaded lazily if you use any * of the above. diff --git a/mozilla/mailnews/base/public/nsMsgBaseCID.h b/mozilla/mailnews/base/public/nsMsgBaseCID.h index 9aa399ca79d..4a1da10c907 100644 --- a/mozilla/mailnews/base/public/nsMsgBaseCID.h +++ b/mozilla/mailnews/base/public/nsMsgBaseCID.h @@ -101,18 +101,6 @@ 0xd2876e50, 0xe62c, 0x11d2, \ {0xb7, 0xfc, 0x0, 0x80, 0x5f, 0x5, 0xff, 0xa5 }} -// -// nsMessengerMigrator -// -#define NS_MESSENGERMIGRATOR_CONTRACTID \ - "@mozilla.org/messenger/migrator;1" - -#define NS_MESSENGERMIGRATOR_CID \ -{ /* 54818d98-1dd2-11b2-82aa-a9197f997503 */ \ - 0x54818d98, 0x1dd2, 0x11b2, \ - { 0x82, 0xaa, 0xa9, 0x19, 0x7f, 0x99, 0x75, 0x03}} - - // // nsMsgIdentity diff --git a/mozilla/mailnews/base/src/Makefile.in b/mozilla/mailnews/base/src/Makefile.in index e923cafa6bd..d8ede40e897 100644 --- a/mozilla/mailnews/base/src/Makefile.in +++ b/mozilla/mailnews/base/src/Makefile.in @@ -49,7 +49,6 @@ MOZILLA_INTERNAL_API = 1 REQUIRES = xpcom \ alerts \ - xpcom_obsolete \ string \ necko \ dom \ @@ -108,7 +107,6 @@ CPPSRCS = \ nsMsgFolderCompactor.cpp \ nsMsgStatusFeedback.cpp \ nsMsgWindow.cpp \ - nsMessengerMigrator.cpp \ nsMsgServiceProvider.cpp \ nsSubscribeDataSource.cpp \ nsSubscribableServer.cpp \ diff --git a/mozilla/mailnews/base/src/nsMsgAccountManager.cpp b/mozilla/mailnews/base/src/nsMsgAccountManager.cpp index 262dcd955aa..9aee57c8d62 100644 --- a/mozilla/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mozilla/mailnews/base/src/nsMsgAccountManager.cpp @@ -72,6 +72,7 @@ #include "nsIMsgBiffManager.h" #include "nsIMsgPurgeService.h" #include "nsIObserverService.h" +#include "nsINoIncomingServer.h" #include "nsIMsgMailSession.h" #include "nsIDirectoryService.h" #include "nsAppDirectoryServiceDefs.h" @@ -2432,6 +2433,62 @@ NS_IMETHODIMP nsMsgAccountManager::GetLocalFoldersServer(nsIMsgIncomingServer ** rv = SetLocalFoldersServer(*aServer); return rv; } + +NS_IMETHODIMP +nsMsgAccountManager::CreateLocalMailAccount() +{ + // create the server + nsCOMPtr server; + nsresult rv = CreateIncomingServer("nobody", + "Local Folders", + "none", getter_AddRefs(server)); + NS_ENSURE_SUCCESS(rv,rv); + + // we don't want "nobody at Local Folders" to show up in the + // folder pane, so we set the pretty name to "Local Folders" + server->SetPrettyName(NS_LITERAL_STRING("Local Folders").get()); + + nsCOMPtr noServer; + noServer = do_QueryInterface(server, &rv); + if (NS_FAILED(rv)) return rv; + + // create the directory structure for old 4.x "Local Mail" + // under /Mail/Local Folders or + // <"mail.directory" pref>/Local Folders + nsCOMPtr mailDir; + nsCOMPtr localFile; + PRBool dirExists; + + // we want /Mail + rv = NS_GetSpecialDirectory(NS_APP_MAIL_50_DIR, getter_AddRefs(mailDir)); + if (NS_FAILED(rv)) return rv; + localFile = do_QueryInterface(mailDir); + + rv = mailDir->Exists(&dirExists); + if (NS_SUCCEEDED(rv) && !dirExists) + rv = mailDir->Create(nsIFile::DIRECTORY_TYPE, 0775); + if (NS_FAILED(rv)) return rv; + + // set the default local path for "none" + rv = server->SetDefaultLocalPath(localFile); + if (NS_FAILED(rv)) return rv; + + // Create an account when valid server values are established. + // This will keep the status of accounts sane by avoiding the addition of incomplete accounts. + nsCOMPtr account; + rv = CreateAccount(getter_AddRefs(account)); + if (NS_FAILED(rv)) return rv; + + // notice, no identity for local mail + // hook the server to the account + // after we set the server's local path + // (see bug #66018) + account->SetIncomingServer(server); + + // remember this as the local folders server + return SetLocalFoldersServer(server); +} + // nsIUrlListener methods NS_IMETHODIMP diff --git a/mozilla/mailnews/base/util/nsMsgUtils.h b/mozilla/mailnews/base/util/nsMsgUtils.h index 57eaaa1d675..7330f7afbd2 100644 --- a/mozilla/mailnews/base/util/nsMsgUtils.h +++ b/mozilla/mailnews/base/util/nsMsgUtils.h @@ -45,8 +45,6 @@ #include "nsCOMPtr.h" #include "MailNewsTypes2.h" -class nsFileSpec; -class nsIFileSpec; class nsILocalFile; class nsIPrefBranch; class nsIMsgFolder; diff --git a/mozilla/mailnews/build/nsMailModule.cpp b/mozilla/mailnews/build/nsMailModule.cpp index ca6b62ceb7b..8b2fc444936 100644 --- a/mozilla/mailnews/build/nsMailModule.cpp +++ b/mozilla/mailnews/build/nsMailModule.cpp @@ -67,7 +67,6 @@ #include "nsMsgMailSession.h" #include "nsMsgAccount.h" #include "nsMsgAccountManager.h" -#include "nsMessengerMigrator.h" #include "nsMsgIdentity.h" #include "nsMsgIncomingServer.h" #include "nsMsgFolderDataSource.h" @@ -302,7 +301,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlListenerManager) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgMailSession, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMessenger) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgAccountManager, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMessengerMigrator, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgAccount) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgIdentity) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgFolderDataSource, Init) @@ -678,10 +676,6 @@ static const nsModuleComponentInfo gComponents[] = { NS_MSGACCOUNTMANAGER_CONTRACTID, nsMsgAccountManagerConstructor, }, - { "Messenger Migrator", NS_MESSENGERMIGRATOR_CID, - NS_MESSENGERMIGRATOR_CONTRACTID, - nsMessengerMigratorConstructor, - }, { "Messenger User Account", NS_MSGACCOUNT_CID, NS_MSGACCOUNT_CONTRACTID, nsMsgAccountConstructor, diff --git a/mozilla/mailnews/import/oexpress/nsOESettings.cpp b/mozilla/mailnews/import/oexpress/nsOESettings.cpp index 42ab6cc5f30..a923ba0d271 100644 --- a/mozilla/mailnews/import/oexpress/nsOESettings.cpp +++ b/mozilla/mailnews/import/oexpress/nsOESettings.cpp @@ -61,7 +61,6 @@ #include "nsOEStringBundle.h" #include "OEDebugLog.h" #include "nsIPop3IncomingServer.h" -#include "nsIMessengerMigrator.h" class OESettings { public: @@ -426,13 +425,8 @@ PRBool OESettings::DoPOP3Server( nsIMsgAccountManager *pMgr, HKEY hKey, char *pS // if the other import modules end up needing to do this too. // if Local Folders does not exist already, create it - nsCOMPtr messengerMigrator = do_GetService(NS_MESSENGERMIGRATOR_CONTRACTID, &rv); - if (NS_FAILED(rv)) { - IMPORT_LOG0( "*** Failed to create messenger migrator!\n"); - return PR_FALSE; - } - rv = messengerMigrator->CreateLocalMailAccount(PR_FALSE); + rv = pMgr->CreateLocalMailAccount(); if (NS_FAILED(rv)) { IMPORT_LOG0( "*** Failed to create Local Folders!\n"); return PR_FALSE; diff --git a/mozilla/mailnews/import/outlook/src/nsOutlookSettings.cpp b/mozilla/mailnews/import/outlook/src/nsOutlookSettings.cpp index 0f27da88570..aa0443702f0 100644 --- a/mozilla/mailnews/import/outlook/src/nsOutlookSettings.cpp +++ b/mozilla/mailnews/import/outlook/src/nsOutlookSettings.cpp @@ -61,7 +61,6 @@ #include "nsOutlookStringBundle.h" #include "OutlookDebugLog.h" #include "nsIPop3IncomingServer.h" -#include "nsIMessengerMigrator.h" #include "nsMsgI18N.h" class OutlookSettings { @@ -381,13 +380,7 @@ PRBool OutlookSettings::DoPOP3Server( nsIMsgAccountManager *pMgr, HKEY hKey, cha // XXX: We may need to move this local folder creation code to the generic nsImportSettings code // if the other import modules end up needing to do this too. // if Local Folders does not exist already, create it - nsCOMPtr messengerMigrator = do_GetService(NS_MESSENGERMIGRATOR_CONTRACTID, &rv); - if (NS_FAILED(rv)) { - IMPORT_LOG0( "*** Failed to create messenger migrator!\n"); - return PR_FALSE; - } - - rv = messengerMigrator->CreateLocalMailAccount(PR_FALSE); + rv = pMgr->CreateLocalMailAccount(); if (NS_FAILED(rv)) { IMPORT_LOG0( "*** Failed to create Local Folders!\n"); return PR_FALSE; diff --git a/mozilla/mailnews/import/resources/content/importDialog.js b/mozilla/mailnews/import/resources/content/importDialog.js index 90d60850d78..07c10c72da1 100644 --- a/mozilla/mailnews/import/resources/content/importDialog.js +++ b/mozilla/mailnews/import/resources/content/importDialog.js @@ -479,9 +479,9 @@ function ShowImportResultsRaw(title, results, good) // import "mail" and "settings" var checkLocalFolder = (top.progressInfo.importType == 'mail' || top.progressInfo.importType == 'settings') ? true : false; if (good && checkLocalFolder && !top.progressInfo.localFolderExists) { - var messengerMigrator = Components.classes["@mozilla.org/messenger/migrator;1"].getService(Components.interfaces.nsIMessengerMigrator); - if (messengerMigrator) - messengerMigrator.createLocalMailAccount(false); + var am = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager); + if (am) + am.createLocalMailAccount(); } } diff --git a/mozilla/mailnews/import/src/nsImportMail.cpp b/mozilla/mailnews/import/src/nsImportMail.cpp index b634b58d7b1..a369738907e 100644 --- a/mozilla/mailnews/import/src/nsImportMail.cpp +++ b/mozilla/mailnews/import/src/nsImportMail.cpp @@ -62,7 +62,6 @@ #include "nsXPIDLString.h" #include "nsIMsgAccountManager.h" -#include "nsIMessengerMigrator.h" #include "nsIMsgMailSession.h" #include "nsMsgBaseCID.h" #include "nsIMsgFolder.h" @@ -1008,12 +1007,7 @@ PRBool nsImportGenericMail::CreateFolder( nsIMsgFolder **ppFolder) // if Local Folders does not exist already, create it if (NS_FAILED(rv) || !server) { - nsCOMPtr messengerMigrator = do_GetService(NS_MESSENGERMIGRATOR_CONTRACTID, &rv); - if (NS_FAILED(rv)) { - IMPORT_LOG0( "*** Failed to create messenger migrator!\n"); - return PR_FALSE; - } - rv = messengerMigrator->CreateLocalMailAccount(PR_FALSE); + rv = accMgr->CreateLocalMailAccount(); if (NS_FAILED(rv)) { IMPORT_LOG0( "*** Failed to create Local Folders!\n"); return PR_FALSE; diff --git a/mozilla/mailnews/news/src/nsNntpService.cpp b/mozilla/mailnews/news/src/nsNntpService.cpp index 4e9ae850cf4..e9a4aa59995 100644 --- a/mozilla/mailnews/news/src/nsNntpService.cpp +++ b/mozilla/mailnews/news/src/nsNntpService.cpp @@ -97,8 +97,6 @@ #define PREF_NETWORK_HOSTS_NNTP_SERVER "network.hosts.nntp_server" #define PREF_MAIL_ROOT_NNTP "mail.root.nntp" // old - for backward compatibility only #define PREF_MAIL_ROOT_NNTP_REL "mail.root.nntp-rel" - -static NS_DEFINE_CID(kMessengerMigratorCID, NS_MESSENGERMIGRATOR_CID); nsNntpService::nsNntpService() { @@ -1105,20 +1103,6 @@ nsNntpService::GetProtocolForUri(nsIURI *aUri, nsIMsgWindow *aMsgWindow, nsINNTP rv = accountManager->GetAccounts(getter_AddRefs(accounts)); if (NS_FAILED(rv)) return rv; - PRUint32 accountCount; - rv = accounts->Count(&accountCount); - if (NS_FAILED(rv)) return rv; - - if (accountCount == 0) - { - nsCOMPtr messengerMigrator = do_GetService(kMessengerMigratorCID, &rv); - if (NS_FAILED(rv)) return rv; - if (!messengerMigrator) return NS_ERROR_FAILURE; - - // migration can fail; - messengerMigrator->UpgradePrefs(); - } - // news:group becomes news://group, so we have three types of urls: // news://group (autosubscribing without a host) // news://host/group (autosubscribing with a host)