remove nsMessengerMigrator, sr=mscott 379068

git-svn-id: svn://10.0.0.236/trunk@225541 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bienvenu%nventure.com 2007-05-03 18:32:43 +00:00
parent eac3e75659
commit 5b0cf01e35
14 changed files with 72 additions and 94 deletions

View File

@ -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,

View File

@ -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;
}

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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 \

View File

@ -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<nsIMsgIncomingServer> 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<nsINoIncomingServer> noServer;
noServer = do_QueryInterface(server, &rv);
if (NS_FAILED(rv)) return rv;
// create the directory structure for old 4.x "Local Mail"
// under <profile dir>/Mail/Local Folders or
// <"mail.directory" pref>/Local Folders
nsCOMPtr <nsIFile> mailDir;
nsCOMPtr <nsILocalFile> localFile;
PRBool dirExists;
// we want <profile>/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<nsIMsgAccount> 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

View File

@ -45,8 +45,6 @@
#include "nsCOMPtr.h"
#include "MailNewsTypes2.h"
class nsFileSpec;
class nsIFileSpec;
class nsILocalFile;
class nsIPrefBranch;
class nsIMsgFolder;

View File

@ -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,

View File

@ -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 <nsIMessengerMigrator> 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;

View File

@ -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 <nsIMessengerMigrator> 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;

View File

@ -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();
}
}

View File

@ -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 <nsIMessengerMigrator> 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;

View File

@ -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 <nsIMessengerMigrator> 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)