зеркало из https://github.com/mozilla/gecko-dev.git
fix for #18064, r=alecf, a=choffman.
only create the local mail account if the user migrates from imap, or if the user creates an imap server and they don't have a local mail account.
This commit is contained in:
Родитель
1ac4b75dcc
Коммит
7a5278d0a4
|
@ -238,6 +238,26 @@ function createAccount(hash) {
|
|||
account.incomingServer = server;
|
||||
account.addIdentity(identity);
|
||||
|
||||
// if we are creating an IMAP account,
|
||||
// check if there already is a "none" account. (aka "Local Mail")
|
||||
// if not, create it.
|
||||
if (serverType == "imap") {
|
||||
var localMailServer = null;
|
||||
try {
|
||||
// look for anything that is of type "none".
|
||||
// "none" is the type for "Local Mail"
|
||||
localMailServer = am.findServer("","","none");
|
||||
}
|
||||
catch (ex) {
|
||||
localMailServer = null;
|
||||
}
|
||||
|
||||
if (!localMailServer) {
|
||||
// creates a copy of the identity you pass in
|
||||
am.createLocalMailAccount(identity);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (ex) {
|
||||
|
|
|
@ -119,7 +119,10 @@ interface nsIMsgAccountManager : nsISupports {
|
|||
void WriteToFolderCache(in nsIMsgFolderCache folderCache);
|
||||
|
||||
void CloseCachedConnections();
|
||||
|
||||
/* search for 4.x mailnews prefs, and migrate to 5.0 prefs */
|
||||
void UpgradePrefs();
|
||||
|
||||
void createLocalMailAccount(in nsIMsgIdentity identity);
|
||||
};
|
||||
|
||||
|
|
|
@ -454,11 +454,9 @@ nsresult
|
|||
nsMsgAccountManager::CreateIncomingServer(const char* type,
|
||||
nsIMsgIncomingServer **_retval)
|
||||
{
|
||||
|
||||
if (!_retval) return NS_ERROR_NULL_POINTER;
|
||||
const char *key = getUniqueKey("server", &m_incomingServers);
|
||||
return createKeyedServer(key, type, _retval);
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1161,17 +1159,11 @@ nsMsgAccountManager::UpgradePrefs()
|
|||
#ifdef DEBUG_ACCOUNTMANAGER
|
||||
printf("FAIL: don't proceed with migration.\n");
|
||||
#endif
|
||||
// but before we do that, create the default Local Mail Account
|
||||
rv = CreateLocalMailAccount(nsnull /* no identity yet */);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create the Local Mail account");
|
||||
// return NS_ERROR_FAILURE because we failed to upgrade the pref.js
|
||||
// by returning a failure code, this will case the Account Wizard
|
||||
// to be automatically opened.
|
||||
return NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
}
|
||||
#ifdef DEBUG_ACCOUNTMANAGER
|
||||
else {
|
||||
printf("PASS: proceed with migration.\n");
|
||||
printf("PASS: proceed with migration.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1196,10 +1188,6 @@ nsMsgAccountManager::UpgradePrefs()
|
|||
if ( oldMailType == POP_4X_MAIL_TYPE) {
|
||||
// in 4.x, you could only have one pop account
|
||||
rv = MigratePopAccount(identity);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// you got to have one, so we just create it here.
|
||||
rv = CreateLocalMailAccount(identity);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else if (oldMailType == IMAP_4X_MAIL_TYPE) {
|
||||
|
@ -1492,7 +1480,7 @@ nsMsgAccountManager::Convert4XUri(const char *old_uri, const char *default_folde
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsMsgAccountManager::CreateLocalMailAccount(nsIMsgIdentity *identity)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -2391,7 +2379,7 @@ nsMsgAccountManager::FindServer(const char* username,
|
|||
nsresult rv;
|
||||
nsCOMPtr<nsISupportsArray> servers;
|
||||
|
||||
#ifdef DEBUG_ACCOUNTMANAGER_
|
||||
#ifdef DEBUG_ACCOUNTMANAGER
|
||||
printf("FindServer(%s,%s,%s,??)\n", username,hostname,type);
|
||||
#endif
|
||||
|
||||
|
@ -2399,10 +2387,16 @@ nsMsgAccountManager::FindServer(const char* username,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
findServerEntry serverInfo;
|
||||
serverInfo.hostname = hostname;
|
||||
|
||||
// "" acts as the wild card.
|
||||
|
||||
// hostname might be blank, pass "" instead
|
||||
serverInfo.hostname = hostname ? hostname : "";
|
||||
// username might be blank, pass "" instead
|
||||
serverInfo.username = username ? username : "";
|
||||
serverInfo.type = type;
|
||||
// type might be blank, pass "" instead
|
||||
serverInfo.type = type ? type : "";
|
||||
|
||||
serverInfo.server = *aResult = nsnull;
|
||||
|
||||
servers->EnumerateForwards(findServer, (void *)&serverInfo);
|
||||
|
@ -2485,24 +2479,21 @@ nsMsgAccountManager::findServer(nsISupports *aElement, void *data)
|
|||
rv = server->GetUsername(getter_Copies(thisUsername));
|
||||
if (NS_FAILED(rv)) return PR_TRUE;
|
||||
|
||||
|
||||
nsXPIDLCString thisType;
|
||||
rv = server->GetType(getter_Copies(thisType));
|
||||
if (NS_FAILED(rv)) return PR_TRUE;
|
||||
|
||||
if (PL_strcasecmp(entry->hostname, thisHostname)==0 &&
|
||||
PL_strcmp(entry->type, thisType)==0) {
|
||||
// if we aren't looking for a username, don't compare. we have a match
|
||||
if (PL_strcmp(entry->username,"")==0) {
|
||||
entry->server = server;
|
||||
return PR_FALSE; // stop on first find
|
||||
}
|
||||
else {
|
||||
if (PL_strcmp(entry->username, thisUsername)==0) {
|
||||
entry->server = server;
|
||||
return PR_FALSE; // stop on first find
|
||||
}
|
||||
}
|
||||
// treat "" as a wild card, so if the caller passed in "" for the desired attribute
|
||||
// treat it as a match
|
||||
PRBool checkType = PL_strcmp(entry->type, "");
|
||||
PRBool checkHostname = PL_strcmp(entry->hostname,"");
|
||||
PRBool checkUsername = PL_strcmp(entry->username,"");
|
||||
if ((!checkType || (PL_strcmp(entry->type, thisType)==0)) &&
|
||||
(!checkHostname || (PL_strcasecmp(entry->hostname, thisHostname)==0)) &&
|
||||
(!checkUsername || (PL_strcmp(entry->username, thisUsername)==0)))
|
||||
{
|
||||
entry->server = server;
|
||||
return PR_FALSE; // stop on first find
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
|
|
|
@ -160,7 +160,6 @@ private:
|
|||
|
||||
nsresult MigratePopAccount(nsIMsgIdentity *identity);
|
||||
|
||||
nsresult CreateLocalMailAccount(nsIMsgIdentity *identity);
|
||||
nsresult MigrateLocalMailAccount(nsIMsgIdentity *identity);
|
||||
nsresult MigrateOldPopPrefs(nsIMsgIncomingServer *server, const char *hostname);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "nsMsgBaseCID.h"
|
||||
#include "nsIArena.h"
|
||||
|
||||
static NS_DEFINE_CID(kMorkCID, NS_MORK_CID);
|
||||
static NS_DEFINE_CID(kMorkCID, NS_MORK_CID);
|
||||
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
|
||||
const char *kFoldersScope = "ns:msg:db:row:scope:folders:all"; // scope for all folders table
|
||||
|
@ -49,6 +49,7 @@ public:
|
|||
|
||||
// } ===== end nsIMdbHeap methods =====
|
||||
nsresult Init();
|
||||
virtual ~FolderCachePool() {};
|
||||
protected:
|
||||
nsCOMPtr <nsIArena> m_arena;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче