зеркало из https://github.com/mozilla/gecko-dev.git
Bug 283223: don't create a dummy account if we nsMsgAccountManager::GetAccount
doesn't find an existing one. r=bienvenu.
This commit is contained in:
Родитель
792de4e982
Коммит
1f8b673987
|
@ -186,6 +186,12 @@ function onAdvanced()
|
||||||
var identity = account.defaultIdentity;
|
var identity = account.defaultIdentity;
|
||||||
var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
|
var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
|
||||||
account = accountManager.getAccount(serverSettings.deferredToAccount);
|
account = accountManager.getAccount(serverSettings.deferredToAccount);
|
||||||
|
if (!account)
|
||||||
|
{
|
||||||
|
throw "UNEXPECTED: deferredToAccount '" +
|
||||||
|
serverSettings.deferredToAccount + "' not found!";
|
||||||
|
}
|
||||||
|
|
||||||
if (identity.fccFolder == (pop3Server.serverURI + "/Sent"))
|
if (identity.fccFolder == (pop3Server.serverURI + "/Sent"))
|
||||||
identity.fccFolder = account.incomingServer.serverURI + "/Sent";
|
identity.fccFolder = account.incomingServer.serverURI + "/Sent";
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,9 @@ interface nsIFolderListener;
|
||||||
interface nsIMsgAccountManager : nsISupports {
|
interface nsIMsgAccountManager : nsISupports {
|
||||||
|
|
||||||
nsIMsgAccount createAccount();
|
nsIMsgAccount createAccount();
|
||||||
|
/*
|
||||||
|
* Return the account with the provided key, or null if none found.
|
||||||
|
*/
|
||||||
nsIMsgAccount getAccount(in string key);
|
nsIMsgAccount getAccount(in string key);
|
||||||
|
|
||||||
void removeAccount(in nsIMsgAccount account);
|
void removeAccount(in nsIMsgAccount account);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
|
@ -788,9 +788,10 @@ nsMsgAccountManager::GetDefaultAccount(nsIMsgAccount * *aDefaultAccount)
|
||||||
nsXPIDLCString defaultKey;
|
nsXPIDLCString defaultKey;
|
||||||
rv = m_prefs->GetCharPref(PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT, getter_Copies(defaultKey));
|
rv = m_prefs->GetCharPref(PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT, getter_Copies(defaultKey));
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv))
|
||||||
GetAccount(defaultKey, getter_AddRefs(m_defaultAccount));
|
GetAccount(defaultKey, getter_AddRefs(m_defaultAccount));
|
||||||
} else {
|
|
||||||
|
if (!m_defaultAccount) {
|
||||||
PRUint32 index;
|
PRUint32 index;
|
||||||
PRBool foundValidDefaultAccount = PR_FALSE;
|
PRBool foundValidDefaultAccount = PR_FALSE;
|
||||||
for (index = 0; index < count; index++) {
|
for (index = 0; index < count; index++) {
|
||||||
|
@ -816,12 +817,14 @@ nsMsgAccountManager::GetDefaultAccount(nsIMsgAccount * *aDefaultAccount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundValidDefaultAccount) {
|
if (!foundValidDefaultAccount) {
|
||||||
// get the first account and use it.
|
// get the first account and use it.
|
||||||
// we need to fix this scenario.
|
// we need to fix this scenario.
|
||||||
|
NS_WARNING("No valid default account found, just using first (FIXME)");
|
||||||
nsCOMPtr<nsIMsgAccount> firstAccount;
|
nsCOMPtr<nsIMsgAccount> firstAccount;
|
||||||
rv = m_accounts->QueryElementAt(0, NS_GET_IID(nsIMsgAccount),
|
m_accounts->QueryElementAt(0, NS_GET_IID(nsIMsgAccount),
|
||||||
(void **)getter_AddRefs(firstAccount));
|
(void **)getter_AddRefs(firstAccount));
|
||||||
|
|
||||||
SetDefaultAccount(firstAccount);
|
SetDefaultAccount(firstAccount);
|
||||||
}
|
}
|
||||||
|
@ -1434,36 +1437,40 @@ nsMsgAccountManager::LoadAccounts()
|
||||||
if (!accountList || !accountList[0])
|
if (!accountList || !accountList[0])
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
/* parse accountList and run loadAccount on each string, comma-separated */
|
/* parse accountList and run loadAccount on each string, comma-separated */
|
||||||
nsCOMPtr<nsIMsgAccount> account;
|
nsCOMPtr<nsIMsgAccount> account;
|
||||||
char *newStr;
|
char *newStr;
|
||||||
char *rest = accountList.BeginWriting();
|
char *rest = accountList.BeginWriting();
|
||||||
nsCAutoString str;
|
nsCAutoString str;
|
||||||
|
|
||||||
char *token = nsCRT::strtok(rest, ",", &newStr);
|
for (char *token = nsCRT::strtok(rest, ",", &newStr);
|
||||||
while (token) {
|
token;
|
||||||
str = token;
|
token = nsCRT::strtok(newStr, ",", &newStr))
|
||||||
str.StripWhitespace();
|
{
|
||||||
|
str = token;
|
||||||
|
str.StripWhitespace();
|
||||||
|
|
||||||
if (!str.IsEmpty())
|
if (str.IsEmpty() ||
|
||||||
rv = GetAccount(str.get(), getter_AddRefs(account));
|
NS_FAILED(createKeyedAccount(str.get(), getter_AddRefs(account))) ||
|
||||||
|
!account) {
|
||||||
// force load of accounts (need to find a better way to do this
|
NS_WARNING("unexpected entry in account list; prefs corrupt?");
|
||||||
nsCOMPtr<nsISupportsArray> identities;
|
continue;
|
||||||
account->GetIdentities(getter_AddRefs(identities));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
|
||||||
account->GetIncomingServer(getter_AddRefs(server));
|
|
||||||
|
|
||||||
token = nsCRT::strtok(newStr, ",", &newStr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
// force load of accounts (need to find a better way to do this)
|
||||||
|
nsCOMPtr<nsISupportsArray> identities;
|
||||||
|
account->GetIdentities(getter_AddRefs(identities));
|
||||||
|
|
||||||
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||||
|
account->GetIncomingServer(getter_AddRefs(server));
|
||||||
|
}
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv))
|
nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||||
mailSession->AddFolderListener(this, nsIFolderListener::added | nsIFolderListener::removed);
|
|
||||||
/* finished loading accounts */
|
if (NS_SUCCEEDED(rv))
|
||||||
return NS_OK;
|
mailSession->AddFolderListener(this, nsIFolderListener::added | nsIFolderListener::removed);
|
||||||
|
/* finished loading accounts */
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
|
@ -1666,13 +1673,13 @@ nsMsgAccountManager::GetAccount(const char* key,
|
||||||
|
|
||||||
m_accounts->EnumerateForwards(findAccountByKey, (void *)&findEntry);
|
m_accounts->EnumerateForwards(findAccountByKey, (void *)&findEntry);
|
||||||
|
|
||||||
if (findEntry.account) {
|
if (findEntry.account)
|
||||||
NS_ADDREF(*_retval = findEntry.account);
|
NS_ADDREF(*_retval = findEntry.account);
|
||||||
return NS_OK;
|
else
|
||||||
}
|
*_retval = nsnull;
|
||||||
|
|
||||||
// not found, create on demand
|
// not found, create on demand
|
||||||
return createKeyedAccount(key, _retval);
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -2735,7 +2742,7 @@ NS_IMETHODIMP VirtualFolderChangeListener::OnHdrDeleted(nsIMsgDBHdr *aHdrDeleted
|
||||||
nsCOMPtr <nsIMsgDatabase> virtDatabase;
|
nsCOMPtr <nsIMsgDatabase> virtDatabase;
|
||||||
nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
|
nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
|
||||||
|
|
||||||
nsresult rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
|
rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
|
||||||
PRBool msgHdrIsRead;
|
PRBool msgHdrIsRead;
|
||||||
aHdrDeleted->GetIsRead(&msgHdrIsRead);
|
aHdrDeleted->GetIsRead(&msgHdrIsRead);
|
||||||
if (!msgHdrIsRead)
|
if (!msgHdrIsRead)
|
||||||
|
@ -2961,7 +2968,7 @@ NS_IMETHODIMP nsMsgAccountManager::SaveVirtualFolders()
|
||||||
{
|
{
|
||||||
PRUint32 count = 0;
|
PRUint32 count = 0;
|
||||||
allServers->Count(&count);
|
allServers->Count(&count);
|
||||||
PRInt32 i;
|
PRUint32 i;
|
||||||
nsCOMPtr <nsIOutputStream> outputStream;
|
nsCOMPtr <nsIOutputStream> outputStream;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -2988,7 +2995,7 @@ NS_IMETHODIMP nsMsgAccountManager::SaveVirtualFolders()
|
||||||
WriteLineToOutputStream("version=", "1", outputStream);
|
WriteLineToOutputStream("version=", "1", outputStream);
|
||||||
|
|
||||||
}
|
}
|
||||||
for (PRInt32 folderIndex = 0; folderIndex < vfCount; folderIndex++)
|
for (PRUint32 folderIndex = 0; folderIndex < vfCount; folderIndex++)
|
||||||
{
|
{
|
||||||
nsCOMPtr <nsIRDFResource> folderRes (do_QueryElementAt(virtualFolders, folderIndex));
|
nsCOMPtr <nsIRDFResource> folderRes (do_QueryElementAt(virtualFolders, folderIndex));
|
||||||
nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryInterface(folderRes);
|
nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryInterface(folderRes);
|
||||||
|
|
|
@ -1673,6 +1673,11 @@ function GenericSendMessage( msgType )
|
||||||
// check if the user tries to send a message to a newsgroup through a mail account
|
// check if the user tries to send a message to a newsgroup through a mail account
|
||||||
var currentAccountKey = getCurrentAccountKey();
|
var currentAccountKey = getCurrentAccountKey();
|
||||||
var account = gAccountManager.getAccount(currentAccountKey);
|
var account = gAccountManager.getAccount(currentAccountKey);
|
||||||
|
if (!account)
|
||||||
|
{
|
||||||
|
throw "UNEXPECTED: currentAccountKey '" + currentAccountKey +
|
||||||
|
"' has no matching account!";
|
||||||
|
}
|
||||||
var servertype = account.incomingServer.type;
|
var servertype = account.incomingServer.type;
|
||||||
|
|
||||||
if (servertype != "nntp" && msgCompFields.newsgroups != "")
|
if (servertype != "nntp" && msgCompFields.newsgroups != "")
|
||||||
|
|
Загрузка…
Ссылка в новой задаче