зеркало из https://github.com/mozilla/pjs.git
rename some methods to be more consistent
make all accesses to the account manager kick off LoadPrefs so they can be loaded on demand don't forget to clean up the accounts in the hash table during destruction
This commit is contained in:
Родитель
edfdbc6470
Коммит
6731a86d38
|
@ -32,15 +32,15 @@ interface nsISupportsArray;
|
||||||
interface nsIMsgAccountManager : nsISupports {
|
interface nsIMsgAccountManager : nsISupports {
|
||||||
|
|
||||||
/* createAccount creates a new account and assigns a new accountKey */
|
/* createAccount creates a new account and assigns a new accountKey */
|
||||||
nsIMsgAccount createAccount(in nsIMsgIncomingServer server,
|
nsIMsgAccount CreateAccount(in nsIMsgIncomingServer server,
|
||||||
in nsIMsgIdentity identity);
|
in nsIMsgIdentity identity);
|
||||||
|
|
||||||
/* similar to createAccount, but we already know the account key */
|
/* similar to createAccount, but we already know the account key */
|
||||||
nsIMsgAccount createAccountWithKey(in nsIMsgIncomingServer server,
|
nsIMsgAccount CreateAccountWithKey(in nsIMsgIncomingServer server,
|
||||||
in nsIMsgIdentity identity,
|
in nsIMsgIdentity identity,
|
||||||
in string accountKey);
|
in string accountKey);
|
||||||
|
|
||||||
void addAccount(in nsIMsgAccount account);
|
void AddAccount(in nsIMsgAccount account);
|
||||||
|
|
||||||
/* account list stuff */
|
/* account list stuff */
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsXPIDLString.h"
|
#include "nsXPIDLString.h"
|
||||||
#include "nsIMsgBiffManager.h"
|
#include "nsIMsgBiffManager.h"
|
||||||
|
#include "nscore.h"
|
||||||
|
|
||||||
#include "nsCRT.h" // for nsCRT::strtok
|
#include "nsCRT.h" // for nsCRT::strtok
|
||||||
|
|
||||||
|
@ -83,18 +84,19 @@ public:
|
||||||
|
|
||||||
/* nsIMsgAccount createAccount (in nsIMsgIncomingServer server,
|
/* nsIMsgAccount createAccount (in nsIMsgIncomingServer server,
|
||||||
in nsIMsgIdentity identity); */
|
in nsIMsgIdentity identity); */
|
||||||
NS_IMETHOD createAccount(nsIMsgIncomingServer *server,
|
NS_IMETHOD CreateAccount(nsIMsgIncomingServer *server,
|
||||||
nsIMsgIdentity *identity,
|
nsIMsgIdentity *identity,
|
||||||
nsIMsgAccount **_retval) ;
|
nsIMsgAccount **_retval) ;
|
||||||
|
|
||||||
/* nsIMsgAccount addAccount (in nsIMsgIncomingServer server,
|
/* nsIMsgAccount AddAccount (in nsIMsgIncomingServer server,
|
||||||
in nsIMsgIdentity identity, in string accountKey); */
|
in nsIMsgIdentity identity, in string accountKey); */
|
||||||
NS_IMETHOD createAccountWithKey(nsIMsgIncomingServer *server,
|
NS_IMETHOD CreateAccountWithKey(nsIMsgIncomingServer *server,
|
||||||
nsIMsgIdentity *identity,
|
nsIMsgIdentity *identity,
|
||||||
const char *accountKey,
|
const char *accountKey,
|
||||||
nsIMsgAccount **_retval) ;
|
nsIMsgAccount **_retval) ;
|
||||||
|
|
||||||
NS_IMETHOD addAccount(nsIMsgAccount *account);
|
NS_IMETHOD AddAccount(nsIMsgAccount *account);
|
||||||
|
NS_IMETHOD RemoveAccount(nsIMsgAccount *account);
|
||||||
|
|
||||||
/* attribute nsIMsgAccount defaultAccount; */
|
/* attribute nsIMsgAccount defaultAccount; */
|
||||||
NS_IMETHOD GetDefaultAccount(nsIMsgAccount * *aDefaultAccount) ;
|
NS_IMETHOD GetDefaultAccount(nsIMsgAccount * *aDefaultAccount) ;
|
||||||
|
@ -125,10 +127,12 @@ public:
|
||||||
nsISupportsArray **_retval);
|
nsISupportsArray **_retval);
|
||||||
|
|
||||||
//Add/remove an account to/from the Biff Manager if it has Biff turned on.
|
//Add/remove an account to/from the Biff Manager if it has Biff turned on.
|
||||||
nsresult addAccountToBiff(nsIMsgAccount *account);
|
nsresult AddAccountToBiff(nsIMsgAccount *account);
|
||||||
nsresult removeAccountFromBiff(nsIMsgAccount *account);
|
nsresult RemoveAccountFromBiff(nsIMsgAccount *account);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
PRBool m_accountsLoaded;
|
||||||
|
|
||||||
nsHashtable *m_accounts;
|
nsHashtable *m_accounts;
|
||||||
nsCOMPtr<nsIMsgAccount> m_defaultAccount;
|
nsCOMPtr<nsIMsgAccount> m_defaultAccount;
|
||||||
|
|
||||||
|
@ -148,6 +152,9 @@ private:
|
||||||
static PRBool hashTableFindFirst(nsHashKey *aKey, void *aData,
|
static PRBool hashTableFindFirst(nsHashKey *aKey, void *aData,
|
||||||
void *closure);
|
void *closure);
|
||||||
|
|
||||||
|
static PRBool hashTableRemoveAccount(nsHashKey *aKey, void *aData,
|
||||||
|
void *closure);
|
||||||
|
|
||||||
static PRBool findIdentitiesForServer(nsHashKey *aKey,
|
static PRBool findIdentitiesForServer(nsHashKey *aKey,
|
||||||
void *aData, void *closure);
|
void *aData, void *closure);
|
||||||
static PRBool findServersForIdentity (nsHashKey *aKey,
|
static PRBool findServersForIdentity (nsHashKey *aKey,
|
||||||
|
@ -160,7 +167,7 @@ private:
|
||||||
static PRBool findServerByName(nsISupports *aElement, void *data);
|
static PRBool findServerByName(nsISupports *aElement, void *data);
|
||||||
|
|
||||||
nsresult upgradePrefs();
|
nsresult upgradePrefs();
|
||||||
nsIMsgAccount *LoadAccount(char *accountKey);
|
nsIMsgAccount *LoadAccount(nsString& accountKey);
|
||||||
|
|
||||||
nsIPref *m_prefs;
|
nsIPref *m_prefs;
|
||||||
};
|
};
|
||||||
|
@ -169,6 +176,7 @@ private:
|
||||||
NS_IMPL_ISUPPORTS(nsMsgAccountManager, GetIID());
|
NS_IMPL_ISUPPORTS(nsMsgAccountManager, GetIID());
|
||||||
|
|
||||||
nsMsgAccountManager::nsMsgAccountManager() :
|
nsMsgAccountManager::nsMsgAccountManager() :
|
||||||
|
m_accountsLoaded(PR_FALSE),
|
||||||
m_defaultAccount(null_nsCOMPtr()),
|
m_defaultAccount(null_nsCOMPtr()),
|
||||||
m_prefs(0)
|
m_prefs(0)
|
||||||
{
|
{
|
||||||
|
@ -178,49 +186,53 @@ nsMsgAccountManager::nsMsgAccountManager() :
|
||||||
|
|
||||||
nsMsgAccountManager::~nsMsgAccountManager()
|
nsMsgAccountManager::~nsMsgAccountManager()
|
||||||
{
|
{
|
||||||
|
// release the default account
|
||||||
|
m_defaultAccount=nsnull;
|
||||||
|
|
||||||
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID, m_prefs);
|
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID, m_prefs);
|
||||||
m_accounts->Enumerate(hashTableRemoveAccountFromBiff, this);
|
m_accounts->Enumerate(hashTableRemoveAccountFromBiff, this);
|
||||||
|
m_accounts->Enumerate(hashTableRemoveAccount, this);
|
||||||
delete m_accounts;
|
delete m_accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* generate a relevant, understandable key from the given server and
|
* generate a relevant, understandable key from the given server and
|
||||||
* identity, make sure it's unique, then pass to addAccount
|
* identity, make sure it's unique, then pass to AddAccount
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgAccountManager::createAccount(nsIMsgIncomingServer *server,
|
nsMsgAccountManager::CreateAccount(nsIMsgIncomingServer *server,
|
||||||
nsIMsgIdentity *identity,
|
nsIMsgIdentity *identity,
|
||||||
nsIMsgAccount **_retval)
|
nsIMsgAccount **_retval)
|
||||||
{
|
{
|
||||||
const char *key = "default";
|
const char *key = "default";
|
||||||
|
|
||||||
return createAccountWithKey(server, identity, key, _retval);
|
return CreateAccountWithKey(server, identity, key, _retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nsIMsgAccount addAccount (in nsIMsgIncomingServer server, in nsIMsgIdentity
|
/* nsIMsgAccount AddAccount (in nsIMsgIncomingServer server, in nsIMsgIdentity
|
||||||
identity, in string accountKey); */
|
identity, in string accountKey); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgAccountManager::createAccountWithKey(nsIMsgIncomingServer *server,
|
nsMsgAccountManager::CreateAccountWithKey(nsIMsgIncomingServer *server,
|
||||||
nsIMsgIdentity *identity,
|
nsIMsgIdentity *identity,
|
||||||
const char *accountKey,
|
const char *accountKey,
|
||||||
nsIMsgAccount **_retval)
|
nsIMsgAccount **_retval)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIMsgAccount* account=nsnull;
|
nsCOMPtr<nsIMsgAccount> account=nsnull;
|
||||||
|
|
||||||
rv = nsComponentManager::CreateInstance(kMsgAccountCID,
|
rv = nsComponentManager::CreateInstance(kMsgAccountCID,
|
||||||
nsnull,
|
nsnull,
|
||||||
nsIMsgAccount::GetIID(),
|
nsIMsgAccount::GetIID(),
|
||||||
(void **)&account);
|
(void **)getter_AddRefs(account));
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
rv = account->SetIncomingServer(server);
|
rv = account->SetIncomingServer(server);
|
||||||
rv = account->addIdentity(identity);
|
rv = account->addIdentity(identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
account->SetKey((char *)accountKey);
|
account->SetKey(NS_CONST_CAST(char*, accountKey));
|
||||||
rv = addAccount(account);
|
rv = AddAccount(account);
|
||||||
|
|
||||||
// pointer has already been addreffed by CreateInstance
|
// pointer has already been addreffed by CreateInstance
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
|
@ -231,8 +243,12 @@ nsMsgAccountManager::createAccountWithKey(nsIMsgIncomingServer *server,
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgAccountManager::addAccount(nsIMsgAccount *account)
|
nsMsgAccountManager::AddAccount(nsIMsgAccount *account)
|
||||||
{
|
{
|
||||||
|
nsresult rv;
|
||||||
|
rv = LoadAccounts();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsXPIDLCString accountKey;
|
nsXPIDLCString accountKey;
|
||||||
account->GetKey(getter_Copies(accountKey));
|
account->GetKey(getter_Copies(accountKey));
|
||||||
nsCStringKey key(accountKey);
|
nsCStringKey key(accountKey);
|
||||||
|
@ -241,7 +257,6 @@ nsMsgAccountManager::addAccount(nsIMsgAccount *account)
|
||||||
printf("Adding account %s\n", (const char *)accountKey);
|
printf("Adding account %s\n", (const char *)accountKey);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (m_accounts->Exists(&key))
|
if (m_accounts->Exists(&key))
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
|
@ -253,12 +268,12 @@ nsMsgAccountManager::addAccount(nsIMsgAccount *account)
|
||||||
if (m_accounts->Count() == 1)
|
if (m_accounts->Count() == 1)
|
||||||
m_defaultAccount = dont_QueryInterface(account);
|
m_defaultAccount = dont_QueryInterface(account);
|
||||||
|
|
||||||
addAccountToBiff(account);
|
AddAccountToBiff(account);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsMsgAccountManager::addAccountToBiff(nsIMsgAccount *account)
|
nsMsgAccountManager::AddAccountToBiff(nsIMsgAccount *account)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||||
|
@ -284,7 +299,7 @@ nsMsgAccountManager::addAccountToBiff(nsIMsgAccount *account)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsMsgAccountManager::removeAccountFromBiff(nsIMsgAccount *account)
|
nsresult nsMsgAccountManager::RemoveAccountFromBiff(nsIMsgAccount *account)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||||
|
@ -310,10 +325,29 @@ nsresult nsMsgAccountManager::removeAccountFromBiff(nsIMsgAccount *account)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMsgAccountManager::RemoveAccount(nsIMsgAccount *aAccount)
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
rv = LoadAccounts();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
nsHashKey *key = findAccount(aAccount);
|
||||||
|
if (!key) return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
|
NS_RELEASE(aAccount);
|
||||||
|
m_accounts->Remove(key);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* get the default account. If no default account, pick the first account */
|
/* get the default account. If no default account, pick the first account */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgAccountManager::GetDefaultAccount(nsIMsgAccount * *aDefaultAccount)
|
nsMsgAccountManager::GetDefaultAccount(nsIMsgAccount * *aDefaultAccount)
|
||||||
{
|
{
|
||||||
|
nsresult rv;
|
||||||
|
rv = LoadAccounts();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
if (!aDefaultAccount) return NS_ERROR_NULL_POINTER;
|
if (!aDefaultAccount) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
if (!m_defaultAccount) {
|
if (!m_defaultAccount) {
|
||||||
|
@ -353,6 +387,8 @@ nsMsgAccountManager::SetDefaultAccount(nsIMsgAccount * aDefaultAccount)
|
||||||
nsHashKey *
|
nsHashKey *
|
||||||
nsMsgAccountManager::findAccount(nsIMsgAccount *aAccount)
|
nsMsgAccountManager::findAccount(nsIMsgAccount *aAccount)
|
||||||
{
|
{
|
||||||
|
if (!aAccount) return nsnull;
|
||||||
|
|
||||||
findAccountEntry entry = {aAccount, PR_FALSE, nsnull };
|
findAccountEntry entry = {aAccount, PR_FALSE, nsnull };
|
||||||
|
|
||||||
m_accounts->Enumerate(hashTableFindAccount, (void *)&entry);
|
m_accounts->Enumerate(hashTableFindAccount, (void *)&entry);
|
||||||
|
@ -414,19 +450,39 @@ PRBool nsMsgAccountManager::hashTableRemoveAccountFromBiff(nsHashKey *aKey, void
|
||||||
nsIMsgAccount* account = (nsIMsgAccount *)aData;
|
nsIMsgAccount* account = (nsIMsgAccount *)aData;
|
||||||
nsMsgAccountManager *accountManager = (nsMsgAccountManager*)closure;
|
nsMsgAccountManager *accountManager = (nsMsgAccountManager*)closure;
|
||||||
|
|
||||||
accountManager->removeAccountFromBiff(account);
|
accountManager->RemoveAccountFromBiff(account);
|
||||||
|
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enumeration for removing accounts from the account manager
|
||||||
|
PRBool
|
||||||
|
nsMsgAccountManager::hashTableRemoveAccount(nsHashKey *aKey, void *aData,
|
||||||
|
void*closure)
|
||||||
|
{
|
||||||
|
// COM cleanup
|
||||||
|
nsIMsgAccount* account = (nsIMsgAccount*)aData;
|
||||||
|
NS_RELEASE(account);
|
||||||
|
|
||||||
|
// remove from hashtable
|
||||||
|
nsMsgAccountManager* accountManager = (nsMsgAccountManager*) closure;
|
||||||
|
accountManager->m_accounts->Remove(aKey);
|
||||||
|
|
||||||
|
return PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* readonly attribute nsISupportsArray accounts; */
|
/* readonly attribute nsISupportsArray accounts; */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgAccountManager::GetAccounts(nsISupportsArray **_retval)
|
nsMsgAccountManager::GetAccounts(nsISupportsArray **_retval)
|
||||||
{
|
{
|
||||||
|
nsresult rv;
|
||||||
|
rv = LoadAccounts();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsCOMPtr<nsISupportsArray> accounts;
|
nsCOMPtr<nsISupportsArray> accounts;
|
||||||
NS_NewISupportsArray(getter_AddRefs(accounts));
|
NS_NewISupportsArray(getter_AddRefs(accounts));
|
||||||
|
|
||||||
m_accounts->Enumerate(addAccountsToArray, (void *)accounts);
|
m_accounts->Enumerate(addAccountsToArray, (void *)accounts);
|
||||||
|
|
||||||
*_retval = accounts;
|
*_retval = accounts;
|
||||||
|
@ -487,8 +543,11 @@ NS_IMETHODIMP
|
||||||
nsMsgAccountManager::GetAllIdentities(nsISupportsArray **_retval)
|
nsMsgAccountManager::GetAllIdentities(nsISupportsArray **_retval)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsISupportsArray *identities;
|
rv = LoadAccounts();
|
||||||
rv = NS_NewISupportsArray(&identities);
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
nsCOMPtr<nsISupportsArray> identities;
|
||||||
|
rv = NS_NewISupportsArray(getter_AddRefs(identities));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// convert hash table->nsISupportsArray of identities
|
// convert hash table->nsISupportsArray of identities
|
||||||
|
@ -497,6 +556,7 @@ nsMsgAccountManager::GetAllIdentities(nsISupportsArray **_retval)
|
||||||
// convert nsISupportsArray->nsISupportsArray
|
// convert nsISupportsArray->nsISupportsArray
|
||||||
// when do we free the nsISupportsArray?
|
// when do we free the nsISupportsArray?
|
||||||
*_retval = identities;
|
*_retval = identities;
|
||||||
|
NS_ADDREF(*_retval);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,6 +565,9 @@ NS_IMETHODIMP
|
||||||
nsMsgAccountManager::GetAllServers(nsISupportsArray **_retval)
|
nsMsgAccountManager::GetAllServers(nsISupportsArray **_retval)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
rv = LoadAccounts();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsISupportsArray *servers;
|
nsISupportsArray *servers;
|
||||||
rv = NS_NewISupportsArray(&servers);
|
rv = NS_NewISupportsArray(&servers);
|
||||||
|
|
||||||
|
@ -523,23 +586,31 @@ nsMsgAccountManager::LoadAccounts()
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
NS_IF_RELEASE(m_prefs);
|
// for now safeguard multiple calls to this function
|
||||||
|
if (m_accountsLoaded)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
m_accountsLoaded = PR_TRUE;
|
||||||
|
// get the prefs service
|
||||||
|
if (!m_prefs) {
|
||||||
rv = nsServiceManager::GetService(kPrefServiceCID,
|
rv = nsServiceManager::GetService(kPrefServiceCID,
|
||||||
nsIPref::GetIID(),
|
nsIPref::GetIID(),
|
||||||
(nsISupports**)&m_prefs);
|
(nsISupports**)&m_prefs);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
}
|
||||||
|
|
||||||
char *accountList = nsnull;
|
// mail.accountmanager.accounts is the main entry point for all accounts
|
||||||
rv = m_prefs->CopyCharPref("mail.accountmanager.accounts", &accountList);
|
nsXPIDLCString accountList;
|
||||||
|
rv = m_prefs->CopyCharPref("mail.accountmanager.accounts",
|
||||||
|
getter_Copies(accountList));
|
||||||
|
|
||||||
if (NS_FAILED(rv) || !accountList || !accountList[0]) {
|
if (NS_FAILED(rv) || !accountList || !accountList[0]) {
|
||||||
// create default bogus accounts
|
// create default bogus accounts
|
||||||
printf("No accounts. I'll try to migrate 4.x prefs..\n");
|
printf("No accounts. I'll try to migrate 4.x prefs..\n");
|
||||||
rv = upgradePrefs();
|
rv = upgradePrefs();
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
/* parse accountList and run loadAccount on each string, comma-separated */
|
/* parse accountList and run loadAccount on each string, comma-separated */
|
||||||
#ifdef DEBUG_sspitzer
|
#ifdef DEBUG_sspitzer
|
||||||
printf("accountList = %s\n", accountList);
|
printf("accountList = %s\n", accountList);
|
||||||
|
@ -547,7 +618,7 @@ nsMsgAccountManager::LoadAccounts()
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgAccount> account;
|
nsCOMPtr<nsIMsgAccount> account;
|
||||||
char *token = nsnull;
|
char *token = nsnull;
|
||||||
char *rest = accountList;
|
char *rest = NS_CONST_CAST(char*,(const char*)accountList);
|
||||||
nsString str("",eOneByte);
|
nsString str("",eOneByte);
|
||||||
|
|
||||||
token = nsCRT::strtok(rest, ",", &rest);
|
token = nsCRT::strtok(rest, ",", &rest);
|
||||||
|
@ -559,14 +630,12 @@ nsMsgAccountManager::LoadAccounts()
|
||||||
#ifdef DEBUG_sspitzer
|
#ifdef DEBUG_sspitzer
|
||||||
printf("accountKey = %s\n", str.GetBuffer());
|
printf("accountKey = %s\n", str.GetBuffer());
|
||||||
#endif
|
#endif
|
||||||
account = getter_AddRefs(LoadAccount((char *)str.GetBuffer()));
|
account = getter_AddRefs(LoadAccount(str));
|
||||||
if (account) {
|
if (account) {
|
||||||
addAccount(account);
|
AddAccount(account);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
PR_Free(accountList);
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
}
|
|
||||||
str = "";
|
str = "";
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_sspitzer
|
#ifdef DEBUG_sspitzer
|
||||||
|
@ -578,16 +647,14 @@ nsMsgAccountManager::LoadAccounts()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finished loading accounts */
|
/* finished loading accounts */
|
||||||
PR_Free(accountList);
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIMsgAccount *
|
nsIMsgAccount *
|
||||||
nsMsgAccountManager::LoadAccount(char *accountKey)
|
nsMsgAccountManager::LoadAccount(nsString& accountKey)
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("Loading preferences for account: %s\n", accountKey);
|
printf("Loading preferences for account: %s\n", accountKey.GetBuffer());
|
||||||
|
|
||||||
nsIMsgAccount *account = nsnull;
|
nsIMsgAccount *account = nsnull;
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
@ -601,7 +668,7 @@ nsMsgAccountManager::LoadAccount(char *accountKey)
|
||||||
|
|
||||||
if (NS_FAILED(rv)) return nsnull;
|
if (NS_FAILED(rv)) return nsnull;
|
||||||
|
|
||||||
account->SetKey(accountKey);
|
account->SetKey(NS_CONST_CAST(char*,accountKey.GetBuffer()));
|
||||||
|
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
@ -652,7 +719,7 @@ nsMsgAccountManager::upgradePrefs()
|
||||||
|
|
||||||
account->SetIncomingServer(server);
|
account->SetIncomingServer(server);
|
||||||
account->addIdentity(identity);
|
account->addIdentity(identity);
|
||||||
addAccount(account);
|
AddAccount(account);
|
||||||
|
|
||||||
// now upgrade all the prefs
|
// now upgrade all the prefs
|
||||||
char *oldstr;
|
char *oldstr;
|
||||||
|
@ -833,6 +900,9 @@ nsMsgAccountManager::GetIdentitiesForServer(nsIMsgIncomingServer *server,
|
||||||
nsISupportsArray **_retval)
|
nsISupportsArray **_retval)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
rv = LoadAccounts();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsCOMPtr<nsISupportsArray> identities;
|
nsCOMPtr<nsISupportsArray> identities;
|
||||||
rv = NS_NewISupportsArray(getter_AddRefs(identities));
|
rv = NS_NewISupportsArray(getter_AddRefs(identities));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
@ -883,6 +953,9 @@ nsMsgAccountManager::GetServersForIdentity(nsIMsgIdentity *identity,
|
||||||
{
|
{
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
rv = LoadAccounts();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsCOMPtr<nsISupportsArray> servers;
|
nsCOMPtr<nsISupportsArray> servers;
|
||||||
rv = NS_NewISupportsArray(getter_AddRefs(servers));
|
rv = NS_NewISupportsArray(getter_AddRefs(servers));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче