step 2 of divorce the mailnews migration code from the account manager

This commit is contained in:
sspitzer%netscape.com 2000-01-15 09:00:46 +00:00
Родитель 02b304a755
Коммит a8927fd2e9
12 изменённых файлов: 46 добавлений и 1893 удалений

Просмотреть файл

@ -89,6 +89,19 @@
0xd2876e50, 0xe62c, 0x11d2, \ 0xd2876e50, 0xe62c, 0x11d2, \
{0xb7, 0xfc, 0x0, 0x80, 0x5f, 0x5, 0xff, 0xa5 }} {0xb7, 0xfc, 0x0, 0x80, 0x5f, 0x5, 0xff, 0xa5 }}
//
// nsMessengerMigrator
//
#define NS_MESSENGERMIGRATOR_PROGID \
"component://netscape/messenger/migrator"
#define NS_MESSENGERMIGRATOR_CID \
{ /* 54818d98-1dd2-11b2-82aa-a9197f997503 */ \
0x54818d98, 0x1dd2, 0x11b2, \
{ 0x82, 0xaa, 0xa9, 0x19, 0x7f, 0x99, 0x75, 0x03}}
// //
// nsMsgIdentity // nsMsgIdentity
// //

Просмотреть файл

@ -48,6 +48,7 @@
#include "nsMsgMailSession.h" #include "nsMsgMailSession.h"
#include "nsMsgAccount.h" #include "nsMsgAccount.h"
#include "nsMsgAccountManager.h" #include "nsMsgAccountManager.h"
#include "nsMessengerMigrator.h"
#include "nsMsgIdentity.h" #include "nsMsgIdentity.h"
#include "nsMsgIncomingServer.h" #include "nsMsgIncomingServer.h"
#include "nsMessageViewDataSource.h" #include "nsMessageViewDataSource.h"
@ -95,6 +96,8 @@ static NS_DEFINE_CID(kMsgIncomingServerCID, NS_MSGINCOMINGSERVER_CID);
// account manager RDF stuff // account manager RDF stuff
static NS_DEFINE_CID(kMsgAccountManagerDataSourceCID, NS_MSGACCOUNTMANAGERDATASOURCE_CID); static NS_DEFINE_CID(kMsgAccountManagerDataSourceCID, NS_MSGACCOUNTMANAGERDATASOURCE_CID);
// migrator stuff
static NS_DEFINE_CID(kMessengerMigratorCID, NS_MESSENGERMIGRATOR_CID);
// search and filter stuff // search and filter stuff
static NS_DEFINE_CID(kMsgSearchSessionCID, NS_MSGSEARCHSESSION_CID); static NS_DEFINE_CID(kMsgSearchSessionCID, NS_MSGSEARCHSESSION_CID);
static NS_DEFINE_CID(kMsgFilterServiceCID, NS_MSGFILTERSERVICE_CID); static NS_DEFINE_CID(kMsgFilterServiceCID, NS_MSGFILTERSERVICE_CID);
@ -127,6 +130,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlListenerManager)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgMailSession, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgMailSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMessenger) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMessenger)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgAccountManager, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgAccountManager, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMessengerMigrator, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgAccount) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgAccount)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgIdentity) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgIdentity)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgFolderDataSource, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgFolderDataSource, Init)
@ -165,6 +169,7 @@ protected:
nsCOMPtr<nsIGenericFactory> mMsgMailSessionFactory; nsCOMPtr<nsIGenericFactory> mMsgMailSessionFactory;
nsCOMPtr<nsIGenericFactory> mMessengerFactory; nsCOMPtr<nsIGenericFactory> mMessengerFactory;
nsCOMPtr<nsIGenericFactory> mMsgAccountManagerFactory; nsCOMPtr<nsIGenericFactory> mMsgAccountManagerFactory;
nsCOMPtr<nsIGenericFactory> mMessengerMigratorFactory;
nsCOMPtr<nsIGenericFactory> mMsgAccountFactory; nsCOMPtr<nsIGenericFactory> mMsgAccountFactory;
nsCOMPtr<nsIGenericFactory> mMsgIdentityFactory; nsCOMPtr<nsIGenericFactory> mMsgIdentityFactory;
nsCOMPtr<nsIGenericFactory> mMsgFolderDataSourceFactory; nsCOMPtr<nsIGenericFactory> mMsgFolderDataSourceFactory;
@ -213,6 +218,7 @@ void nsMsgBaseModule::Shutdown()
mMsgMailSessionFactory = null_nsCOMPtr(); mMsgMailSessionFactory = null_nsCOMPtr();
mMessengerFactory = null_nsCOMPtr(); mMessengerFactory = null_nsCOMPtr();
mMsgAccountManagerFactory = null_nsCOMPtr(); mMsgAccountManagerFactory = null_nsCOMPtr();
mMessengerMigratorFactory = null_nsCOMPtr();
mMsgAccountFactory = null_nsCOMPtr(); mMsgAccountFactory = null_nsCOMPtr();
mMsgIdentityFactory = null_nsCOMPtr(); mMsgIdentityFactory = null_nsCOMPtr();
mMsgFolderDataSourceFactory = null_nsCOMPtr(); mMsgFolderDataSourceFactory = null_nsCOMPtr();
@ -285,6 +291,12 @@ NS_IMETHODIMP nsMsgBaseModule::GetClassObject(nsIComponentManager *aCompMgr,
rv = NS_NewGenericFactory(getter_AddRefs(mMsgAccountManagerFactory), &nsMsgAccountManagerConstructor); rv = NS_NewGenericFactory(getter_AddRefs(mMsgAccountManagerFactory), &nsMsgAccountManagerConstructor);
fact = mMsgAccountManagerFactory; fact = mMsgAccountManagerFactory;
} }
else if (aClass.Equals(kMessengerMigratorCID))
{
if (!mMessengerMigratorFactory)
rv = NS_NewGenericFactory(getter_AddRefs(mMessengerMigratorFactory), &nsMessengerMigratorConstructor);
fact = mMessengerMigratorFactory;
}
else if (aClass.Equals(kMsgAccountCID)) else if (aClass.Equals(kMsgAccountCID))
{ {
if (!mMsgAccountFactory) if (!mMsgAccountFactory)
@ -395,6 +407,8 @@ static Components gComponents[] = {
NS_MESSENGER_PROGID }, NS_MESSENGER_PROGID },
{ "Messenger Account Manager", &kMsgAccountManagerCID, { "Messenger Account Manager", &kMsgAccountManagerCID,
NS_MSGACCOUNTMANAGER_PROGID }, NS_MSGACCOUNTMANAGER_PROGID },
{ "Messenger Migrator", &kMessengerMigratorCID,
NS_MESSENGERMIGRATOR_PROGID },
{ "Messenger User Account", &kMsgAccountCID, { "Messenger User Account", &kMsgAccountCID,
NS_MSGACCOUNT_PROGID }, NS_MSGACCOUNT_PROGID },
{ "Messenger User Identity", &kMsgIdentityCID, { "Messenger User Identity", &kMsgIdentityCID,

Просмотреть файл

@ -272,7 +272,8 @@ function createAccount(hash) {
if (!localMailServer) { if (!localMailServer) {
// dump("Creating local mail account\n"); // dump("Creating local mail account\n");
// creates a copy of the identity you pass in // creates a copy of the identity you pass in
am.createLocalMailAccount(identity, false); messengerMigrator = Components.classes["component://netscape/messenger/migrator"].getService(Components.interfaces.nsIMessengerMigrator);
messengerMigrator.createLocalMailAccount(identity, false);
// find the local mail server that we just created // find the local mail server that we just created
localMailServer = am.FindServer("","","none"); localMailServer = am.FindServer("","","none");

Просмотреть файл

@ -71,6 +71,7 @@ XPIDLSRCS = \
nsIMsgRDFDataSource.idl \ nsIMsgRDFDataSource.idl \
nsIIncomingServerListener.idl \ nsIIncomingServerListener.idl \
nsIMsgHdr.idl \ nsIMsgHdr.idl \
nsIMessengerMigrator.idl \
$(NULL) $(NULL)
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -32,6 +32,7 @@ XPIDLSRCS = \
.\nsIMessageView.idl \ .\nsIMessageView.idl \
.\nsIMsgAccount.idl \ .\nsIMsgAccount.idl \
.\nsIMsgAccountManager.idl \ .\nsIMsgAccountManager.idl \
.\nsIMessengerMigrator.idl \
.\nsIMsgFolder.idl \ .\nsIMsgFolder.idl \
.\nsIMsgFolderCache.idl \ .\nsIMsgFolderCache.idl \
.\nsIMsgFolderCacheElement.idl \ .\nsIMsgFolderCacheElement.idl \

Просмотреть файл

@ -138,14 +138,9 @@ interface nsIMsgAccountManager : nsISupports {
void CloseCachedConnections(); void CloseCachedConnections();
/* search for 4.x mailnews prefs, and migrate to 5.0 prefs */
void UpgradePrefs();
void AddIncomingServerListener(in nsIIncomingServerListener serverListener); void AddIncomingServerListener(in nsIIncomingServerListener serverListener);
void RemoveIncomingServerListener(in nsIIncomingServerListener serverListener); void RemoveIncomingServerListener(in nsIIncomingServerListener serverListener);
void NotifyServerLoaded(in nsIMsgIncomingServer server); void NotifyServerLoaded(in nsIMsgIncomingServer server);
void NotifyServerUnloaded(in nsIMsgIncomingServer server); void NotifyServerUnloaded(in nsIMsgIncomingServer server);
void createLocalMailAccount(in nsIMsgIdentity identity, in boolean migrating);
}; };

Просмотреть файл

@ -26,6 +26,7 @@ var statusFeedbackProgID = "component://netscape/messenger/statusfeedback";
var messageViewProgID = "component://netscape/messenger/messageview"; var messageViewProgID = "component://netscape/messenger/messageview";
var mailSessionProgID = "component://netscape/messenger/services/session"; var mailSessionProgID = "component://netscape/messenger/services/session";
var accountManagerProgID = "component://netscape/messenger/account-manager"; var accountManagerProgID = "component://netscape/messenger/account-manager";
var messengerMigratorProgID = "component://netscape/messenger/migrator";
var prefProgID = "component://netscape/preferences"; var prefProgID = "component://netscape/preferences";
var msgWindowProgID = "component://netscape/messenger/msgwindow"; var msgWindowProgID = "component://netscape/messenger/msgwindow";
@ -227,8 +228,9 @@ function verifyAccounts() {
if (accounts.Count() > 0) return; if (accounts.Count() > 0) return;
try { try {
messengerMigrator = Components.classes[messengerMigratorProgID].getService(Components.interfaces.nsIMessengerMigrator);
dump("attempt to UpgradePrefs. If that fails, open the account wizard.\n"); dump("attempt to UpgradePrefs. If that fails, open the account wizard.\n");
am.UpgradePrefs(); messengerMigrator.UpgradePrefs();
refreshFolderPane(); refreshFolderPane();
} }
catch (ex) { catch (ex) {

Просмотреть файл

@ -53,6 +53,7 @@ CPPSRCS = \
nsMsgStatusFeedback.cpp \ nsMsgStatusFeedback.cpp \
nsMessageView.cpp \ nsMessageView.cpp \
nsMsgWindow.cpp \ nsMsgWindow.cpp \
nsMessengerMigrator.cpp \
$(NULL) $(NULL)
EXPORTS = \ EXPORTS = \
@ -76,6 +77,7 @@ EXPORTS = \
nsMsgStatusFeedback.h \ nsMsgStatusFeedback.h \
nsMessageView.h \ nsMessageView.h \
nsMsgWindow.h \ nsMsgWindow.h \
nsMessengerMigrator.h \
$(NULL) $(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib. # we don't want the shared lib, but we want to force the creation of a static lib.

Просмотреть файл

@ -49,6 +49,7 @@ EXPORTS= \
nsMsgStatusFeedback.h \ nsMsgStatusFeedback.h \
nsMessageView.h \ nsMessageView.h \
nsMsgWindow.h \ nsMsgWindow.h \
nsMessengerMigrator.h \
$(NULL) $(NULL)
@ -80,6 +81,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsMsgStatusFeedback.obj \ .\$(OBJDIR)\nsMsgStatusFeedback.obj \
.\$(OBJDIR)\nsMessageView.obj \ .\$(OBJDIR)\nsMessageView.obj \
.\$(OBJDIR)\nsMsgWindow.obj \ .\$(OBJDIR)\nsMsgWindow.obj \
.\$(OBJDIR)\nsMessengerMigrator.obj \
$(NULL) $(NULL)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -30,41 +30,6 @@
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
/*
* some platforms (like Windows and Mac) use a map file, because of
* file name length limitations.
*/
#if defined(XP_UNIX) || defined(XP_BEOS)
/* in 4.x, the prefix was ".newsrc-", in 5.0, the profile migrator code copies the newsrc files from
* ~/.newsrc-* to ~/.mozilla/<profile>/News/newsrc-*
*/
#define NEWSRC_FILE_PREFIX_5x "newsrc-"
#else
#define USE_NEWSRC_MAP_FILE
// in the fat file, the hostname is prefix by this string:
#define PSUEDO_NAME_PREFIX "newsrc-"
#if defined(XP_PC)
#define NEWS_FCC_DEFAULT_TO_IMAP_SENT
#define NEWS_FAT_FILE_NAME "fat"
/*
* on the PC, the fat file stores absolute paths to the newsrc files
* on the Mac, the fat file stores relative paths to the newsrc files
*/
#define NEWS_FAT_STORES_ABSOLUTE_NEWSRC_FILE_PATHS 1
#elif defined(XP_MAC)
#define NEWS_FAT_FILE_NAME "NewsFAT"
#else
#error dont_know_what_your_news_fat_file_is
#endif /* XP_PC, XP_MAC */
#endif /* XP_UNIX || XP_BEOS */
#ifdef XP_UNIX
#define HAVE_MOVEMAIL 1
#endif /* HAVE_MOVEMAIL */
class nsMsgAccountManager class nsMsgAccountManager
: public nsIMsgAccountManager, : public nsIMsgAccountManager,
public nsIObserver, public nsIObserver,
@ -88,8 +53,6 @@ public:
private: private:
PRBool m_accountsLoaded; PRBool m_accountsLoaded;
PRBool m_alreadySetNntpDefaultLocalPath;
PRBool m_alreadySetImapDefaultLocalPath;
nsCOMPtr <nsIMsgFolderCache> m_msgFolderCache; nsCOMPtr <nsIMsgFolderCache> m_msgFolderCache;
nsISupportsArray *m_accounts; nsISupportsArray *m_accounts;
@ -174,44 +137,13 @@ private:
static PRBool writeFolderCache(nsHashKey *aKey, void *aData, void *closure); static PRBool writeFolderCache(nsHashKey *aKey, void *aData, void *closure);
static PRBool closeCachedConnections(nsHashKey *aKey, void *aData, void *closure); static PRBool closeCachedConnections(nsHashKey *aKey, void *aData, void *closure);
// methods for migration / upgrading
nsresult MigrateIdentity(nsIMsgIdentity *identity);
nsresult MigrateSmtpServer(nsISmtpServer *server);
nsresult CopyIdentity(nsIMsgIdentity *srcIdentity, nsIMsgIdentity *destIdentity);
nsresult SetMailCopiesAndFolders(nsIMsgIdentity *identity, const char *username, const char *hostname);
nsresult SetNewsCopiesAndFolders(nsIMsgIdentity *identity);
nsresult MigrateImapAccounts(nsIMsgIdentity *identity);
nsresult MigrateImapAccount(nsIMsgIdentity *identity, const char *hostAndPort);
nsresult MigrateOldImapPrefs(nsIMsgIncomingServer *server, const char *hostAndPort);
nsresult MigratePopAccount(nsIMsgIdentity *identity);
#ifdef HAVE_MOVEMAIL
nsresult MigrateMovemailAccount(nsIMsgIdentity *identity);
#endif /* HAVE_MOVEMAIL */
nsresult MigrateLocalMailAccount(nsIMsgIdentity *identity);
nsresult MigrateOldMailPrefs(nsIMsgIncomingServer *server);
nsresult MigrateNewsAccounts(nsIMsgIdentity *identity);
nsresult MigrateNewsAccount(nsIMsgIdentity *identity, const char *hostAndPort, nsFileSpec &newsrcfile, nsFileSpec &newsHostsDir);
nsresult MigrateOldNntpPrefs(nsIMsgIncomingServer *server, const char *hostAndPort, nsFileSpec &newsrcfile);
nsresult ProceedWithMigration();
static char *getUniqueKey(const char* prefix, nsHashtable *hashTable); static char *getUniqueKey(const char* prefix, nsHashtable *hashTable);
static char *getUniqueAccountKey(const char* prefix, static char *getUniqueAccountKey(const char* prefix,
nsISupportsArray *accounts); nsISupportsArray *accounts);
nsresult Convert4XUri(const char *old_uri, PRBool for_news, const char *aUsername, const char *aHostname, const char *default_folder_name, char **new_uri);
nsresult SetSendLaterUriPref(nsIMsgIncomingServer *server); nsresult SetSendLaterUriPref(nsIMsgIncomingServer *server);
nsresult getPrefService(); nsresult getPrefService();
nsIPref *m_prefs; nsIPref *m_prefs;
PRInt32 m_oldMailType;
}; };

Просмотреть файл

@ -21,6 +21,8 @@
var accountManagerProgID = "component://netscape/messenger/account-manager"; var accountManagerProgID = "component://netscape/messenger/account-manager";
var accountManager = Components.classes[accountManagerProgID].getService(Components.interfaces.nsIMsgAccountManager); var accountManager = Components.classes[accountManagerProgID].getService(Components.interfaces.nsIMsgAccountManager);
var messengerMigratorProgID = "component://netscape/messenger/migrator";
var msgComposeService = Components.classes["component://netscape/messengercompose"].getService(); var msgComposeService = Components.classes["component://netscape/messengercompose"].getService();
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService); msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
var msgCompose = null; var msgCompose = null;
@ -281,7 +283,8 @@ function MigratePrefsIfNecessary()
if (accounts.Count() > 0) return; if (accounts.Count() > 0) return;
try { try {
accountManager.UpgradePrefs(); messengerMigrator = Components.classes[messengerMigratorProgID].getService(Components.interfaces.nsIMessengerMigrator);
messengerMigrator.UpgradePrefs();
} }
catch (ex) { catch (ex) {
var alertText = Bundle.GetStringFromName("noIdentities"); var alertText = Bundle.GetStringFromName("noIdentities");