Bug 1612239 - Remove nsIArray usage from nsIMsgFolder.getFoldersWithFlags(). r=mkmelin
This commit is contained in:
Родитель
e8cc4c6395
Коммит
adf336206c
|
@ -1311,10 +1311,7 @@ var gFolderTreeView = {
|
|||
aFolderFlag
|
||||
);
|
||||
if (foldersWithFlag.length > 0) {
|
||||
for (let folderWithFlag of fixIterator(
|
||||
foldersWithFlag,
|
||||
Ci.nsIMsgFolder
|
||||
)) {
|
||||
for (let folderWithFlag of foldersWithFlag) {
|
||||
folders.push(folderWithFlag);
|
||||
// Add sub-folders of Sent and Archive to the result.
|
||||
if (
|
||||
|
|
|
@ -323,8 +323,7 @@ IMIncomingServer.prototype = {
|
|||
descendants: [],
|
||||
getFlag: () => false,
|
||||
getFolderWithFlags: aFlags => null,
|
||||
getFoldersWithFlags: aFlags =>
|
||||
Cc["@mozilla.org/array;1"].createInstance(Ci.nsIArray),
|
||||
getFoldersWithFlags: aFlags => [],
|
||||
get subFolders() {
|
||||
return EmptyEnumerator;
|
||||
},
|
||||
|
|
|
@ -432,16 +432,7 @@ interface nsIMsgFolder : nsISupports {
|
|||
* @return An array of folders that have the specified flags set.
|
||||
* The array may have zero elements.
|
||||
*/
|
||||
nsIArray getFoldersWithFlags(in unsigned long flags);
|
||||
|
||||
/**
|
||||
* Lists the folders that have the specified flag set.
|
||||
*
|
||||
* @param flags The flag(s) to check for.
|
||||
* @param folders The array in which to append the found folder(s).
|
||||
*/
|
||||
void listFoldersWithFlags(in unsigned long flags,
|
||||
in nsIMutableArray folders);
|
||||
Array<nsIMsgFolder> getFoldersWithFlags(in unsigned long flags);
|
||||
|
||||
/**
|
||||
* Check if this folder (or one of its ancestors) is special.
|
||||
|
|
|
@ -2733,17 +2733,13 @@ NS_IMETHODIMP nsMsgAccountManager::SaveVirtualFolders() {
|
|||
nsCOMPtr<nsIMsgFolder> rootFolder;
|
||||
server->GetRootFolder(getter_AddRefs(rootFolder));
|
||||
if (rootFolder) {
|
||||
nsCOMPtr<nsIArray> virtualFolders;
|
||||
nsresult rv = rootFolder->GetFoldersWithFlags(
|
||||
nsMsgFolderFlags::Virtual, getter_AddRefs(virtualFolders));
|
||||
nsTArray<RefPtr<nsIMsgFolder>> virtualFolders;
|
||||
nsresult rv = rootFolder->GetFoldersWithFlags(nsMsgFolderFlags::Virtual,
|
||||
virtualFolders);
|
||||
if (NS_FAILED(rv)) {
|
||||
continue;
|
||||
}
|
||||
uint32_t vfCount;
|
||||
virtualFolders->GetLength(&vfCount);
|
||||
for (uint32_t folderIndex = 0; folderIndex < vfCount; folderIndex++) {
|
||||
nsCOMPtr<nsIMsgFolder> msgFolder(
|
||||
do_QueryElementAt(virtualFolders, folderIndex));
|
||||
for (auto msgFolder : virtualFolders) {
|
||||
nsCOMPtr<nsIMsgDatabase> db;
|
||||
nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
|
||||
rv = msgFolder->GetDBFolderInfoAndDB(
|
||||
|
|
|
@ -4027,32 +4027,24 @@ NS_IMETHODIMP nsMsgDBFolder::GetFolderWithFlags(uint32_t aFlags,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBFolder::GetFoldersWithFlags(uint32_t aFlags,
|
||||
nsIArray **aResult) {
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_IMETHODIMP nsMsgDBFolder::GetFoldersWithFlags(
|
||||
uint32_t aFlags, nsTArray<RefPtr<nsIMsgFolder>> &aResult) {
|
||||
aResult.Clear();
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMutableArray> array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Ensure initialisation of mSubFolders.
|
||||
nsCOMPtr<nsISimpleEnumerator> dummy;
|
||||
GetSubFolders(getter_AddRefs(dummy));
|
||||
|
||||
ListFoldersWithFlags(aFlags, array);
|
||||
array.forget(aResult);
|
||||
return NS_OK;
|
||||
if ((mFlags & aFlags) == aFlags) {
|
||||
aResult.AppendElement(this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBFolder::ListFoldersWithFlags(uint32_t aFlags,
|
||||
nsIMutableArray *aFolders) {
|
||||
NS_ENSURE_ARG_POINTER(aFolders);
|
||||
if ((mFlags & aFlags) == aFlags)
|
||||
aFolders->AppendElement(static_cast<nsIMsgFolder *>(this));
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> dummy;
|
||||
GetSubFolders(getter_AddRefs(dummy)); // initialize mSubFolders
|
||||
|
||||
int32_t count = mSubFolders.Count();
|
||||
for (int32_t i = 0; i < count; ++i)
|
||||
mSubFolders[i]->ListFoldersWithFlags(aFlags, aFolders);
|
||||
|
||||
// Recurse down through children.
|
||||
for (auto child : mSubFolders) {
|
||||
nsTArray<RefPtr<nsIMsgFolder>> subMatches;
|
||||
child->GetFoldersWithFlags(aFlags, subMatches);
|
||||
aResult.AppendElements(subMatches);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1371,19 +1371,14 @@ NS_IMETHODIMP nsImapIncomingServer::DiscoveryDone() {
|
|||
// Verify there is only one trash folder. Another might be present if
|
||||
// the trash name has been changed. Or we might be a gmail server and
|
||||
// want to switch to gmail's trash folder.
|
||||
nsCOMPtr<nsIArray> trashFolders;
|
||||
nsTArray<RefPtr<nsIMsgFolder>> trashFolders;
|
||||
rv = rootMsgFolder->GetFoldersWithFlags(nsMsgFolderFlags::Trash,
|
||||
getter_AddRefs(trashFolders));
|
||||
trashFolders);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && trashFolders) {
|
||||
uint32_t numFolders;
|
||||
trashFolders->GetLength(&numFolders);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoString trashName;
|
||||
if (NS_SUCCEEDED(GetTrashFolderName(trashName))) {
|
||||
for (uint32_t i = 0; i < numFolders; i++) {
|
||||
nsCOMPtr<nsIMsgFolder> trashFolder(
|
||||
do_QueryElementAt(trashFolders, i));
|
||||
if (trashFolder) {
|
||||
for (auto trashFolder : trashFolders) {
|
||||
// If we're a gmail server, we clear the trash flags from folder(s)
|
||||
// without the kImapXListTrash flag. For normal servers, we clear
|
||||
// the trash folder flag if the folder name doesn't match the
|
||||
|
@ -1416,7 +1411,7 @@ NS_IMETHODIMP nsImapIncomingServer::DiscoveryDone() {
|
|||
trashName.Equals(nameUnicode)) {
|
||||
continue;
|
||||
}
|
||||
if (numFolders == 1) {
|
||||
if (trashFolders.Length() == 1) {
|
||||
// We got here because the preferred trash folder does not
|
||||
// exist, but a folder got discovered to be the trash folder.
|
||||
SetUnicharValue(PREF_TRASH_FOLDER_PATH, nameUnicode);
|
||||
|
@ -1430,7 +1425,6 @@ NS_IMETHODIMP nsImapIncomingServer::DiscoveryDone() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool usingSubscription = true;
|
||||
GetUsingSubscription(&usingSubscription);
|
||||
|
|
Загрузка…
Ссылка в новой задаче