Bug 1614846 - Remove nsIArray use in nsIMsgAccountManager.allServers. r=mkmelin

--HG--
extra : histedit_source : 46d8ceb77a0e906928f6c6b904d5046922dc9a79
This commit is contained in:
Ben Campbell 2020-03-28 07:53:42 +13:00
Родитель 3e215bcf1b
Коммит 24d3883902
30 изменённых файлов: 140 добавлений и 260 удалений

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

@ -6,9 +6,6 @@
var { PluralForm } = ChromeUtils.import(
"resource://gre/modules/PluralForm.jsm"
);
var { fixIterator } = ChromeUtils.import(
"resource:///modules/iteratorUtils.jsm"
);
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { MailServices } = ChromeUtils.import(
"resource:///modules/MailServices.jsm"
@ -969,14 +966,7 @@ function getServerThatCanHaveFilters() {
// If it cannot, check all accounts to find a server
// that can have filters.
let allServers = MailServices.accounts.allServers;
for (let currentServer of fixIterator(allServers, Ci.nsIMsgIncomingServer)) {
if (currentServer.canHaveFilters) {
return currentServer;
}
}
return null;
return MailServices.accounts.allServers.find(server => server.canHaveFilters);
}
function onFilterClick(event) {

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

@ -2315,10 +2315,7 @@ var gFolderTreeView = {
get _enumerateFolders() {
let folders = [];
for (let server of fixIterator(
MailServices.accounts.allServers,
Ci.nsIMsgIncomingServer
)) {
for (let server of MailServices.accounts.allServers) {
// Skip deferred accounts
if (
server instanceof Ci.nsIPop3IncomingServer &&

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

@ -1349,8 +1349,7 @@ function IsSendUnsentMsgsEnabled(unsentMsgsFolder) {
function IsSubscribeEnabled() {
// If there are any IMAP or News servers, we can show the dialog any time and
// it will properly show those.
let servers = MailServices.accounts.allServers;
for (let server of fixIterator(servers, Ci.nsIMsgIncomingServer)) {
for (let server of MailServices.accounts.allServers) {
if (server.type == "imap" || server.type == "nntp") {
return true;
}
@ -1496,11 +1495,8 @@ function CanRenameDeleteJunkMail(aFolderUri) {
// Go through junk mail settings for all servers and see if the folder is set/used by anyone.
try {
var allServers = accountManager.allServers;
for (var i = 0; i < allServers.length; i++) {
var currentServer = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
var settings = currentServer.spamSettings;
for (let server of MailServices.accounts.allServers) {
var settings = server.spamSettings;
// If junk mail control or move junk mail to folder option is disabled then
// allow the folder to be removed/renamed since the folder is not used in this case.
if (!settings.level || !settings.moveOnSpam) {

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

@ -206,23 +206,20 @@ function OpenMessageForMessageId(messageId) {
// if message id not found in current folder search in all folders
if (!messageHeader) {
let allServers = MailServices.accounts.allServers;
messageHeader = SearchForMessageIdInSubFolder(
startServer.rootFolder,
messageId
);
for (let i = 0; i < allServers.length && !messageHeader; i++) {
let currentServer = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
for (let server of MailServices.accounts.allServers) {
if (
currentServer &&
startServer != currentServer &&
currentServer.canSearchMessages &&
!currentServer.isDeferredTo
server &&
startServer != server &&
server.canSearchMessages &&
!server.isDeferredTo
) {
messageHeader = SearchForMessageIdInSubFolder(
currentServer.rootFolder,
server.rootFolder,
messageId
);
}

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

@ -1863,38 +1863,30 @@ function MsgPauseUpdates(aMenuitem) {
function MsgGetMessagesForAllServers(defaultServer) {
// now log into any server
try {
var allServers = accountManager.allServers;
// Array of arrays of servers for a particular folder.
var pop3DownloadServersArray = [];
// Parallel array of folders to download to...
var localFoldersToDownloadTo = [];
var pop3Server;
for (let i = 0; i < allServers.length; ++i) {
var currentServer = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
if (
currentServer.protocolInfo.canLoginAtStartUp &&
currentServer.loginAtStartUp
) {
for (let server of accountManager.allServers) {
if (server.protocolInfo.canLoginAtStartUp && server.loginAtStartUp) {
if (
defaultServer &&
defaultServer.equals(currentServer) &&
defaultServer.equals(server) &&
!defaultServer.isDeferredTo &&
defaultServer.rootFolder == defaultServer.rootMsgFolder
) {
// skip, already opened
} else if (
currentServer.type == "pop3" &&
currentServer.downloadOnBiff
) {
} else if (server.type == "pop3" && server.downloadOnBiff) {
CoalesceGetMsgsForPop3ServersByDestFolder(
currentServer,
server,
pop3DownloadServersArray,
localFoldersToDownloadTo
);
pop3Server = currentServer.QueryInterface(Ci.nsIPop3IncomingServer);
pop3Server = server.QueryInterface(Ci.nsIPop3IncomingServer);
} else {
// Check to see if there are new messages on the server
currentServer.performBiff(msgWindow);
server.performBiff(msgWindow);
}
}
}
@ -2725,9 +2717,7 @@ function IsMailFolderSelected() {
}
function IsGetNewMessagesEnabled() {
let allServers = accountManager.allServers;
for (let i = 0; i < allServers.length; ++i) {
let server = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
for (let server of accountManager.allServers) {
if (server.type == "none") {
continue;
}
@ -2951,29 +2941,27 @@ function CoalesceGetMsgsForPop3ServersByDestFolder(
function GetMessagesForAllAuthenticatedAccounts() {
// now log into any server
try {
var allServers = accountManager.allServers;
// Array of arrays of servers for a particular folder.
var pop3DownloadServersArray = [];
// parallel array of folders to download to...
var localFoldersToDownloadTo = [];
var pop3Server;
for (let i = 0; i < allServers.length; ++i) {
var currentServer = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
for (let server of accountManager.allServers) {
if (
currentServer.protocolInfo.canGetMessages &&
!currentServer.passwordPromptRequired
server.protocolInfo.canGetMessages &&
!server.passwordPromptRequired
) {
if (currentServer.type == "pop3") {
if (server.type == "pop3") {
CoalesceGetMsgsForPop3ServersByDestFolder(
currentServer,
server,
pop3DownloadServersArray,
localFoldersToDownloadTo
);
pop3Server = currentServer.QueryInterface(Ci.nsIPop3IncomingServer);
pop3Server = server.QueryInterface(Ci.nsIPop3IncomingServer);
} else {
// get new messages on the server for imap or rss
GetMessagesForInboxOnServer(currentServer);
GetMessagesForInboxOnServer(server);
}
}
}

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

@ -1471,13 +1471,9 @@ function MigrateFolderViews() {
"mail.folder.views.version"
);
if (!folderViewsVersion) {
var servers = accountManager.allServers;
var server;
var inbox;
for (var index = 0; index < servers.length; index++) {
server = servers.queryElementAt(index, Ci.nsIMsgIncomingServer);
for (let server of accountManager.allServers) {
if (server) {
inbox = MailUtils.getInboxFolder(server);
let inbox = MailUtils.getInboxFolder(server);
if (inbox) {
inbox.setFlag(Ci.nsMsgFolderFlags.Favorite);
}

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

@ -501,9 +501,7 @@ var MailMigrator = {
_migrateRSS() {
// Find all the RSS IncomingServers.
let rssServers = [];
let allServers = MailServices.accounts.allServers;
for (let i = 0; i < allServers.length; i++) {
let server = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
for (let server of MailServices.accounts.allServers) {
if (server && server.type == "rss") {
rssServers.push(server);
}

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

@ -30,8 +30,7 @@ var MailUtils = {
* open (the folder tree wouldn't have been initialized yet).
*/
discoverFolders() {
let servers = MailServices.accounts.allServers;
for (let server of fixIterator(servers, Ci.nsIMsgIncomingServer)) {
for (let server of MailServices.accounts.allServers) {
// Bug 466311 Sometimes this can throw file not found, we're unsure
// why, but catch it and log the fact.
try {

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

@ -302,13 +302,11 @@ var SearchSupport = {
* once iteration across all folders is complete.
*/
*_foldersToIndexGenerator() {
let servers = MailServices.accounts.allServers;
// Stores whether we're after the last folder indexed or before that --
// if the last folder indexed is empty, this needs to be true initially
let afterLastFolderIndexed = this._lastFolderIndexedUri.length == 0;
for (var server of fixIterator(servers, Ci.nsIMsgIncomingServer)) {
for (let server of MailServices.accounts.allServers) {
let allFolders = server.rootFolder.descendants;
this._log.debug(
"in find next folder, lastFolderIndexedUri = " +

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

@ -516,9 +516,7 @@ function checkDirectoryIsUsable(aLocalPath) {
}
// Check that no other account has this same or dependent local directory.
let allServers = MailServices.accounts.allServers;
for (let server of fixIterator(allServers, Ci.nsIMsgIncomingServer)) {
for (let server of MailServices.accounts.allServers) {
if (server.key == currentAccount.incomingServer.key) {
continue;
}

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

@ -95,7 +95,7 @@ interface nsIMsgAccountManager : nsISupports {
/* list of all servers in all accounts, except for hidden and IM servers
* array of nsIMsgIncomingServer
*/
readonly attribute nsIArray allServers;
readonly attribute Array<nsIMsgIncomingServer> allServers;
/* summary of summary files folder cache */
readonly attribute nsIMsgFolderCache folderCache;

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

@ -11,9 +11,6 @@
const EXPORTED_SYMBOLS = ["PeriodicFilterManager"];
const { fixIterator } = ChromeUtils.import(
"resource:///modules/iteratorUtils.jsm"
);
const { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/Log4moz.jsm");
const { MailServices } = ChromeUtils.import(
"resource:///modules/MailServices.jsm"
@ -50,8 +47,7 @@ var PeriodicFilterManager = {
init() {
log.info("PeriodicFilterManager init()");
// set the next filter time
let servers = MailServices.accounts.allServers;
for (let server of fixIterator(servers, Ci.nsIMsgIncomingServer)) {
for (let server of MailServices.accounts.allServers) {
let nowTime = parseInt(Date.now() / 60000);
// Make sure that the last filter time of all servers was in the past.
let lastFilterTime = server.getIntValue("lastFilterTime");
@ -89,9 +85,8 @@ var PeriodicFilterManager = {
return;
}
this._running = true;
let servers = MailServices.accounts.allServers;
let nowTime = parseInt(Date.now() / 60000);
for (let server of fixIterator(servers, Ci.nsIMsgIncomingServer)) {
for (let server of MailServices.accounts.allServers) {
if (!server.canHaveFilters) {
continue;
}

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

@ -114,22 +114,17 @@ NewMailNotificationService.prototype = {
_initUnreadCount() {
let total = 0;
let allServers = MailServices.accounts.allServers;
for (let i = 0; i < allServers.length; i++) {
let currentServer = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
for (let server of MailServices.accounts.allServers) {
this._log.debug(
"NMNS_initUnread: server " +
currentServer.prettyName +
" type " +
currentServer.type
"NMNS_initUnread: server " + server.prettyName + " type " + server.type
);
// Don't bother counting RSS or NNTP servers
let type = currentServer.type;
let type = server.type;
if (type == "rss" || type == "nntp") {
continue;
}
let rootFolder = currentServer.rootFolder;
let rootFolder = server.rootFolder;
if (rootFolder) {
total += this._countUnread(rootFolder);
}

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

@ -895,14 +895,12 @@ nsMsgAccountManager::GetAllIdentities(
}
NS_IMETHODIMP
nsMsgAccountManager::GetAllServers(nsIArray **_retval) {
nsMsgAccountManager::GetAllServers(
nsTArray<RefPtr<nsIMsgIncomingServer>> &servers) {
servers.Clear();
nsresult rv = LoadAccounts();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMutableArray> servers(
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
nsCOMPtr<nsIMsgIncomingServer> &server = iter.Data();
if (!server) continue;
@ -918,12 +916,10 @@ nsMsgAccountManager::GetAllServers(nsIArray **_retval) {
}
if (!type.EqualsLiteral("im")) {
servers->AppendElement(server);
servers.AppendElement(server);
}
}
servers.forget(_retval);
return rv;
return NS_OK;
}
nsresult nsMsgAccountManager::LoadAccounts() {
@ -2946,21 +2942,15 @@ nsresult nsMsgAccountManager::RemoveVFListenerForVF(nsIMsgFolder *virtualFolder,
NS_IMETHODIMP nsMsgAccountManager::GetAllFolders(nsIArray **aAllFolders) {
NS_ENSURE_ARG_POINTER(aAllFolders);
nsCOMPtr<nsIArray> servers;
nsresult rv = GetAllServers(getter_AddRefs(servers));
NS_ENSURE_SUCCESS(rv, rv);
uint32_t numServers = 0;
rv = servers->GetLength(&numServers);
nsTArray<RefPtr<nsIMsgIncomingServer>> allServers;
nsresult rv = GetAllServers(allServers);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMutableArray> allFolders(
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
uint32_t i;
for (i = 0; i < numServers; i++) {
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(servers, i);
for (auto server : allServers) {
if (server) {
nsCOMPtr<nsIMsgFolder> rootFolder;
server->GetRootFolder(getter_AddRefs(rootFolder));

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

@ -127,13 +127,11 @@ nsresult nsMsgPurgeService::PerformPurge() {
NS_ENSURE_SUCCESS(rv, rv);
bool keepApplyingRetentionSettings = true;
nsCOMPtr<nsIArray> allServers;
rv = accountManager->GetAllServers(getter_AddRefs(allServers));
if (NS_SUCCEEDED(rv) && allServers) {
uint32_t numServers;
rv = allServers->GetLength(&numServers);
nsTArray<RefPtr<nsIMsgIncomingServer>> allServers;
rv = accountManager->GetAllServers(allServers);
if (NS_SUCCEEDED(rv)) {
MOZ_LOG(MsgPurgeLogModule, mozilla::LogLevel::Info,
("%d servers", numServers));
("%d servers", (int)allServers.Length()));
nsCOMPtr<nsIMsgFolder> folderToPurge;
PRIntervalTime startTime = PR_IntervalNow();
int32_t purgeIntervalToUse = 0;
@ -147,10 +145,10 @@ nsresult nsMsgPurgeService::PerformPurge() {
// to apply retention settings, and since
// nsIMsgFolder::ApplyRetentionSettings will close any db's it opens, this
// code won't leave db's open.
for (uint32_t serverIndex = 0; serverIndex < numServers; serverIndex++) {
nsCOMPtr<nsIMsgIncomingServer> server =
do_QueryElementAt(allServers, serverIndex, &rv);
if (NS_SUCCEEDED(rv) && server) {
for (uint32_t serverIndex = 0; serverIndex < allServers.Length();
serverIndex++) {
nsCOMPtr<nsIMsgIncomingServer> server(allServers[serverIndex]);
if (server) {
if (keepApplyingRetentionSettings) {
nsCOMPtr<nsIMsgFolder> rootFolder;
rv = server->GetRootFolder(getter_AddRefs(rootFolder));

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

@ -48,11 +48,9 @@ add_task(async function() {
// Setup done. Now check that things are as we expect.
let allServers = [...fixIterator(mgr.allServers, Ci.nsIMsgIncomingServer)];
// At this point we should have 3 accounts and servers (imap, pop, local).
Assert.equal(mgr.accounts.length, 3);
Assert.equal(allServers.length, 3);
Assert.equal(mgr.allServers.length, 3);
// The identities we explicitly created.
Assert.equal(mgr.allIdentities.length, 3);

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

@ -1694,12 +1694,10 @@ nsresult nsMsgDBFolder::HandleAutoCompactEvent(nsIMsgWindow *aWindow) {
nsCOMPtr<nsIMsgAccountManager> accountMgr =
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIArray> allServers;
rv = accountMgr->GetAllServers(getter_AddRefs(allServers));
nsTArray<RefPtr<nsIMsgIncomingServer>> allServers;
rv = accountMgr->GetAllServers(allServers);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t numServers = 0, serverIndex = 0;
rv = allServers->GetLength(&numServers);
int32_t offlineSupportLevel;
uint32_t numServers = allServers.Length();
if (numServers > 0) {
nsCOMPtr<nsIMutableArray> folderArray =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
@ -1710,10 +1708,9 @@ nsresult nsMsgDBFolder::HandleAutoCompactEvent(nsIMsgWindow *aWindow) {
int64_t totalExpungedBytes = 0;
int64_t offlineExpungedBytes = 0;
int64_t localExpungedBytes = 0;
uint32_t serverIndex = 0;
do {
nsCOMPtr<nsIMsgIncomingServer> server =
do_QueryElementAt(allServers, serverIndex, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgIncomingServer> server(allServers[serverIndex]);
nsCOMPtr<nsIMsgPluggableStore> msgStore;
rv = server->GetMsgStore(getter_AddRefs(msgStore));
NS_ENSURE_SUCCESS(rv, rv);
@ -1724,6 +1721,7 @@ nsresult nsMsgDBFolder::HandleAutoCompactEvent(nsIMsgWindow *aWindow) {
nsCOMPtr<nsIMsgFolder> rootFolder;
rv = server->GetRootFolder(getter_AddRefs(rootFolder));
if (NS_SUCCEEDED(rv) && rootFolder) {
int32_t offlineSupportLevel;
rv = server->GetOfflineSupportLevel(&offlineSupportLevel);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIArray> allDescendents;
@ -1933,15 +1931,11 @@ nsMsgDBFolder::MatchOrChangeFilterDestination(nsIMsgFolder *newFolder,
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIArray> allServers;
rv = accountMgr->GetAllServers(getter_AddRefs(allServers));
nsTArray<RefPtr<nsIMsgIncomingServer>> allServers;
rv = accountMgr->GetAllServers(allServers);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t numServers;
rv = allServers->GetLength(&numServers);
for (uint32_t serverIndex = 0; serverIndex < numServers; serverIndex++) {
nsCOMPtr<nsIMsgIncomingServer> server =
do_QueryElementAt(allServers, serverIndex);
for (auto server : allServers) {
if (server) {
bool canHaveFilters;
rv = server->GetCanHaveFilters(&canHaveFilters);

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

@ -1983,22 +1983,17 @@ nsresult nsMsgIncomingServer::GetDeferredServers(
nsCOMPtr<nsIMsgAccount> thisAccount;
accountManager->FindAccountForServer(destServer, getter_AddRefs(thisAccount));
if (thisAccount) {
nsCOMPtr<nsIArray> allServers;
nsCString accountKey;
thisAccount->GetKey(accountKey);
accountManager->GetAllServers(getter_AddRefs(allServers));
if (allServers) {
uint32_t serverCount;
allServers->GetLength(&serverCount);
for (uint32_t i = 0; i < serverCount; i++) {
nsCOMPtr<nsIPop3IncomingServer> server(
do_QueryElementAt(allServers, i));
if (server) {
nsCString deferredToAccount;
server->GetDeferredToAccount(deferredToAccount);
if (deferredToAccount.Equals(accountKey))
aServers.AppendElement(server);
}
nsTArray<RefPtr<nsIMsgIncomingServer>> allServers;
accountManager->GetAllServers(allServers);
for (auto server : allServers) {
nsCOMPtr<nsIPop3IncomingServer> popServer(do_QueryInterface(server));
if (!popServer) {
nsCString deferredToAccount;
popServer->GetDeferredToAccount(deferredToAccount);
if (deferredToAccount.Equals(accountKey))
aServers.AppendElement(popServer);
}
}
}
@ -2013,23 +2008,17 @@ NS_IMETHODIMP nsMsgIncomingServer::GetIsDeferredTo(bool *aIsDeferredTo) {
nsCOMPtr<nsIMsgAccount> thisAccount;
accountManager->FindAccountForServer(this, getter_AddRefs(thisAccount));
if (thisAccount) {
nsCOMPtr<nsIArray> allServers;
nsCString accountKey;
thisAccount->GetKey(accountKey);
accountManager->GetAllServers(getter_AddRefs(allServers));
if (allServers) {
uint32_t serverCount;
allServers->GetLength(&serverCount);
for (uint32_t i = 0; i < serverCount; i++) {
nsCOMPtr<nsIMsgIncomingServer> server(
do_QueryElementAt(allServers, i));
if (server) {
nsCString deferredToAccount;
server->GetCharValue("deferred_to_account", deferredToAccount);
if (deferredToAccount.Equals(accountKey)) {
*aIsDeferredTo = true;
return NS_OK;
}
nsTArray<RefPtr<nsIMsgIncomingServer>> allServers;
accountManager->GetAllServers(allServers);
for (auto server : allServers) {
if (server) {
nsCString deferredToAccount;
server->GetCharValue("deferred_to_account", deferredToAccount);
if (deferredToAccount.Equals(accountKey)) {
*aIsDeferredTo = true;
return NS_OK;
}
}
}

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

@ -375,28 +375,21 @@ nsSmtpServer::GetPassword(nsAString &aPassword) {
if (!incomingServerToUse && useMatchingDomainServer &&
(dotPos = hostName.FindChar('.')) != kNotFound) {
hostName.Cut(0, dotPos);
nsCOMPtr<nsIArray> allServers;
accountManager->GetAllServers(getter_AddRefs(allServers));
if (allServers) {
uint32_t count = 0;
allServers->GetLength(&count);
uint32_t i;
for (i = 0; i < count; i++) {
nsCOMPtr<nsIMsgIncomingServer> server =
do_QueryElementAt(allServers, i);
if (server) {
nsCString serverUserName;
nsCString serverHostName;
server->GetRealUsername(serverUserName);
server->GetRealHostName(serverHostName);
if (serverUserName.Equals(userName)) {
int32_t serverDotPos = serverHostName.FindChar('.');
if (serverDotPos != kNotFound) {
serverHostName.Cut(0, serverDotPos);
if (serverHostName.Equals(hostName)) {
incomingServerToUse = server;
break;
}
nsTArray<RefPtr<nsIMsgIncomingServer>> allServers;
accountManager->GetAllServers(allServers);
for (auto server : allServers) {
if (server) {
nsCString serverUserName;
nsCString serverHostName;
server->GetRealUsername(serverUserName);
server->GetRealHostName(serverHostName);
if (serverUserName.Equals(userName)) {
int32_t serverDotPos = serverHostName.FindChar('.');
if (serverDotPos != kNotFound) {
serverHostName.Cut(0, serverDotPos);
if (serverHostName.Equals(hostName)) {
incomingServerToUse = server;
break;
}
}
}

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

@ -123,9 +123,7 @@ var FeedUtils = {
*/
getAllRssServerRootFolders() {
let rssRootFolders = [];
let allServers = MailServices.accounts.allServers;
for (let i = 0; i < allServers.length; i++) {
let server = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
for (let server of MailServices.accounts.allServers) {
if (server && server.type == "rss") {
rssRootFolders.push(server.rootFolder);
}

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

@ -111,7 +111,7 @@ nsImapOfflineSync::OnStopRunningUrl(nsIURI *url, nsresult exitCode) {
bool nsImapOfflineSync::AdvanceToNextServer() {
nsresult rv = NS_OK;
if (!m_allServers) {
if (m_allServers.IsEmpty()) {
NS_ASSERTION(!m_currentServer, "this shouldn't be set");
m_currentServer = nullptr;
nsCOMPtr<nsIMsgAccountManager> accountManager =
@ -120,25 +120,24 @@ bool nsImapOfflineSync::AdvanceToNextServer() {
"couldn't get account mgr");
if (!accountManager || NS_FAILED(rv)) return false;
rv = accountManager->GetAllServers(getter_AddRefs(m_allServers));
rv = accountManager->GetAllServers(m_allServers);
NS_ENSURE_SUCCESS(rv, false);
}
uint32_t serverIndex = 0;
if (m_currentServer) {
rv = m_allServers->IndexOf(0, m_currentServer, &serverIndex);
if (NS_FAILED(rv)) serverIndex = -1;
// Move to the next server
++serverIndex;
serverIndex = m_allServers.IndexOf(m_currentServer);
if (serverIndex == m_allServers.NoIndex) {
serverIndex = 0;
} else {
// Move to the next server
++serverIndex;
}
}
m_currentServer = nullptr;
uint32_t numServers;
m_allServers->GetLength(&numServers);
nsCOMPtr<nsIMsgFolder> rootFolder;
while (serverIndex < numServers) {
nsCOMPtr<nsIMsgIncomingServer> server(
do_QueryElementAt(m_allServers, serverIndex));
while (serverIndex < m_allServers.Length()) {
nsCOMPtr<nsIMsgIncomingServer> server(m_allServers[serverIndex]);
serverIndex++;
nsCOMPtr<nsINntpIncomingServer> newsServer = do_QueryInterface(server);
@ -997,24 +996,16 @@ nsImapOfflineDownloader::~nsImapOfflineDownloader() {}
nsresult nsImapOfflineDownloader::ProcessNextOperation() {
nsresult rv = NS_OK;
if (!m_mailboxupdatesStarted) {
m_mailboxupdatesStarted = true;
// Update the INBOX first so the updates on the remaining
// folders pickup the results of any filter moves.
nsCOMPtr<nsIMsgAccountManager> accountManager =
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
m_mailboxupdatesStarted = true;
nsCOMPtr<nsIArray> servers;
rv = accountManager->GetAllServers(getter_AddRefs(servers));
if (NS_FAILED(rv)) return rv;
}
if (!m_mailboxupdatesFinished) {
if (AdvanceToNextServer()) {
nsCOMPtr<nsIMsgFolder> rootMsgFolder;
m_currentServer->GetRootFolder(getter_AddRefs(rootMsgFolder));
nsCOMPtr<nsIMsgFolder> inbox;
if (rootMsgFolder) {
// Update the INBOX first so the updates on the remaining
// folders pickup the results of any filter moves.
rootMsgFolder->GetFolderWithFlags(nsMsgFolderFlags::Inbox,
getter_AddRefs(inbox));
if (inbox) {
@ -1053,7 +1044,7 @@ nsresult nsImapOfflineDownloader::ProcessNextOperation() {
}
return ProcessNextOperation(); // recurse and do next server.
}
m_allServers = nullptr;
m_allServers.Clear();
m_mailboxupdatesFinished = true;
}

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

@ -65,7 +65,7 @@ class nsImapOfflineSync : public nsIUrlListener,
nsCOMPtr<nsIMsgFolder> m_currentFolder;
nsCOMPtr<nsIMsgFolder> m_singleFolderToUpdate;
nsCOMPtr<nsIMsgWindow> m_window;
nsCOMPtr<nsIArray> m_allServers;
nsTArray<RefPtr<nsIMsgIncomingServer>> m_allServers;
nsCOMPtr<nsIArray> m_allFolders;
nsCOMPtr<nsIMsgIncomingServer> m_currentServer;
nsCOMPtr<nsISimpleEnumerator> m_serverEnumerator;

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

@ -327,31 +327,31 @@ nsMsgDownloadAllNewsgroups::OnStopRunningUrl(nsIURI *url, nsresult exitCode) {
bool nsMsgDownloadAllNewsgroups::AdvanceToNextServer() {
nsresult rv;
if (!m_allServers) {
if (m_allServers.IsEmpty()) {
nsCOMPtr<nsIMsgAccountManager> accountManager =
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
NS_ASSERTION(accountManager && NS_SUCCEEDED(rv),
"couldn't get account mgr");
if (!accountManager || NS_FAILED(rv)) return false;
rv = accountManager->GetAllServers(getter_AddRefs(m_allServers));
rv = accountManager->GetAllServers(m_allServers);
NS_ENSURE_SUCCESS(rv, false);
}
uint32_t serverIndex = 0;
if (m_currentServer) {
rv = m_allServers->IndexOf(0, m_currentServer, &serverIndex);
if (NS_FAILED(rv)) serverIndex = -1;
++serverIndex;
serverIndex = m_allServers.IndexOf(m_currentServer);
if (serverIndex == m_allServers.NoIndex) {
serverIndex = 0;
} else {
++serverIndex;
}
}
m_currentServer = nullptr;
uint32_t numServers;
m_allServers->GetLength(&numServers);
uint32_t numServers = m_allServers.Length();
nsCOMPtr<nsIMsgFolder> rootFolder;
while (serverIndex < numServers) {
nsCOMPtr<nsIMsgIncomingServer> server =
do_QueryElementAt(m_allServers, serverIndex);
nsCOMPtr<nsIMsgIncomingServer> server(m_allServers[serverIndex]);
serverIndex++;
nsCOMPtr<nsINntpIncomingServer> newsServer = do_QueryInterface(server);

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

@ -124,7 +124,7 @@ class nsMsgDownloadAllNewsgroups : public nsIUrlListener {
nsCOMPtr<nsIMsgFolder> m_currentFolder;
nsCOMPtr<nsIMsgWindow> m_window;
nsCOMPtr<nsIArray> m_allServers;
nsTArray<RefPtr<nsIMsgIncomingServer>> m_allServers;
nsCOMPtr<nsIArray> m_allFolders;
nsCOMPtr<nsIMsgIncomingServer> m_currentServer;
nsCOMPtr<nsISimpleEnumerator> m_serverEnumerator;

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

@ -610,8 +610,8 @@ nsresult nsNntpService::FindServerWithNewsgroup(nsCString &host,
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIArray> servers;
rv = accountManager->GetAllServers(getter_AddRefs(servers));
nsTArray<RefPtr<nsIMsgIncomingServer>> servers;
rv = accountManager->GetAllServers(servers);
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(mozilla::IsUtf8(groupName), "newsgroup is not in UTF-8");
@ -620,21 +620,15 @@ nsresult nsNntpService::FindServerWithNewsgroup(nsCString &host,
// this only looks at the list of subscribed newsgroups.
// fix to use the hostinfo.dat information
uint32_t length;
rv = servers->GetLength(&length);
NS_ENSURE_SUCCESS(rv, rv);
for (uint32_t i = 0; i < length; ++i) {
nsCOMPtr<nsINntpIncomingServer> newsserver(
do_QueryElementAt(servers, i, &rv));
if (NS_FAILED(rv)) continue;
for (auto server : servers) {
nsCOMPtr<nsINntpIncomingServer> newsserver = do_QueryInterface(server);
if (!newsserver) {
continue;
}
bool containsGroup = false;
rv = newsserver->ContainsNewsgroup(groupName, &containsGroup);
if (containsGroup) {
nsCOMPtr<nsIMsgIncomingServer> server(do_QueryInterface(newsserver, &rv));
NS_ENSURE_SUCCESS(rv, rv);
return server->GetHostName(host);
}
}
@ -951,8 +945,8 @@ nsresult nsNntpService::GetServerForUri(nsIURI *aUri,
// Grab all servers for if this is a no-authority URL. This also loads
// accounts if they haven't been loaded, i.e., we're running this straight
// from the command line
nsCOMPtr<nsIArray> servers;
rv = accountManager->GetAllServers(getter_AddRefs(servers));
nsTArray<RefPtr<nsIMsgIncomingServer>> servers;
rv = accountManager->GetAllServers(servers);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUri, &rv);

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

@ -523,13 +523,8 @@ function getServerThatCanHaveFilters()
// if it cannot, check all accounts to find a server
// that can have filters
var allServers = MailServices.accounts.allServers;
var numServers = allServers.length;
for (var index = 0; index < numServers; index++)
for (let currentServer of MailServices.accounts.allServers)
{
var currentServer =
allServers.queryElementAt(index, Ci.nsIMsgIncomingServer);
if (currentServer.canHaveFilters)
return currentServer;
}

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

@ -847,9 +847,7 @@ function IsSubscribeEnabled()
{
// If there are any IMAP or News servers, we can show the dialog any time and
// it will properly show those.
let servers = accountManager.allServers;
for (let server of fixIterator(servers,
Ci.nsIMsgIncomingServer)) {
for (let server of accountManager.allServers) {
if (server.type == "imap" || server.type == "nntp")
return true;
}

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

@ -570,14 +570,11 @@ function OpenMessageForMessageId(messageId)
{
var accountManager = Cc["@mozilla.org/messenger/account-manager;1"]
.getService(Ci.nsIMsgAccountManager);
var allServers = accountManager.allServers;
messageHeader = SearchForMessageIdInSubFolder(startServer.rootFolder, messageId);
for (var i = 0; i < allServers.length && !messageHeader; i++)
for (let currentServer of accountManager.allServers)
{
var currentServer =
allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
if (currentServer && startServer != currentServer &&
currentServer.canSearchMessages && !currentServer.isDeferredTo)
{

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

@ -67,9 +67,8 @@ function MailTasksGetMessagesForAllServers(aBiff, aMsgWindow, aDefaultServer)
// parallel array of folders to download to...
var localFoldersToDownloadTo = [];
var pop3Server = null;
for (let i = 0; i < allServers.length; ++i)
for (let currentServer of allServers)
{
let currentServer = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
if (currentServer)
{
if (aBiff)

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

@ -23,8 +23,7 @@ var MailUtils =
{
let accountManager = Cc["@mozilla.org/messenger/account-manager;1"]
.getService(Ci.nsIMsgAccountManager);
let servers = accountManager.allServers;
for (let server of fixIterator(servers, Ci.nsIMsgIncomingServer))
for (let server of accountManager.allServers)
server.rootFolder.subFolders;
},