Bug #267865 --> Virtual folders parented off of IMAP sub folders are forgotten on subsequent launches.

Call LoadVirtualFolders after our folder hierarchy has been created in the UI.

sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2004-11-23 06:39:47 +00:00
Родитель 38fa42a069
Коммит b7cf1a5075
5 изменённых файлов: 17 добавлений и 7 удалений

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

@ -786,6 +786,7 @@ function delayedOnLoadMessenger()
InitPanes();
accountManager.setSpecialFolders();
accountManager.loadVirtualFolders();
accountManager.addIncomingServerListener(gThreePaneIncomingServerListener);
AddToSession();

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

@ -176,6 +176,8 @@ interface nsIMsgAccountManager : nsISupports {
void setSpecialFolders();
void loadVirtualFolders();
/* unload accounts frees all the account manager data structures */
void UnloadAccounts();

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

@ -669,6 +669,7 @@ function OnLoadMessenger()
InitPanes();
accountManager.setSpecialFolders();
accountManager.loadVirtualFolders();
accountManager.addIncomingServerListener(gThreePaneIncomingServerListener);
AddToSession();

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

@ -162,7 +162,8 @@ nsMsgAccountManager::nsMsgAccountManager() :
m_cleanupInboxInProgress(PR_FALSE),
m_haveShutdown(PR_FALSE),
m_shutdownInProgress(PR_FALSE),
m_userAuthenticated(PR_FALSE)
m_userAuthenticated(PR_FALSE),
m_loadingVirtualFolders(PR_FALSE)
{
}
@ -1457,8 +1458,6 @@ nsMsgAccountManager::LoadAccounts()
token = nsCRT::strtok(newStr, ",", &newStr);
}
LoadVirtualFolders();
nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
@ -2827,13 +2826,15 @@ nsresult nsMsgAccountManager::GetVirtualFoldersFile(nsCOMPtr<nsILocalFile>& file
return rv;
}
nsresult nsMsgAccountManager::LoadVirtualFolders()
NS_IMETHODIMP nsMsgAccountManager::LoadVirtualFolders()
{
nsCOMPtr <nsILocalFile> file;
GetVirtualFoldersFile(file);
if (!file)
return NS_ERROR_FAILURE;
m_loadingVirtualFolders = PR_TRUE;
nsresult rv;
nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
if (msgDBService)
@ -2895,9 +2896,11 @@ nsresult nsMsgAccountManager::LoadVirtualFolders()
rv = db->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
else
continue;
rv = parentFolder->AddSubfolder(currentFolderNameStr, getter_AddRefs(childFolder));
parentFolder->AddSubfolder(currentFolderNameStr, getter_AddRefs(childFolder));
virtualFolder->SetFlag(MSG_FOLDER_FLAG_VIRTUAL);
if (childFolder)
parentFolder->NotifyItemAdded(childFolder);
}
}
}
@ -2940,6 +2943,9 @@ nsresult nsMsgAccountManager::LoadVirtualFolders()
}
}
}
m_loadingVirtualFolders = PR_FALSE;
return rv;
}
@ -3036,7 +3042,7 @@ NS_IMETHODIMP nsMsgAccountManager::OnItemAdded(nsIRDFResource *parentItem, nsISu
folder->GetFlags(&folderFlags);
nsresult rv = NS_OK;
// need to make sure this isn't happening during loading of virtualfolders.dat
if (folderFlags & MSG_FOLDER_FLAG_VIRTUAL)
if (folderFlags & MSG_FOLDER_FLAG_VIRTUAL && !m_loadingVirtualFolders)
{
// When a new virtual folder is added, need to create a db Listener for it.
nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);

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

@ -101,6 +101,7 @@ private:
PRBool m_haveShutdown;
PRBool m_shutdownInProgress;
PRBool m_userAuthenticated;
PRBool m_loadingVirtualFolders;
/* we call FindServer() a lot. so cache the last server found */
nsCOMPtr <nsIMsgIncomingServer> m_lastFindServerResult;
@ -203,7 +204,6 @@ private:
// handle virtual folders
nsresult GetVirtualFoldersFile(nsCOMPtr<nsILocalFile>& file);
nsresult LoadVirtualFolders();
nsresult WriteLineToOutputStream(const char *prefix, const char * line, nsIOutputStream *outputStream);
static void getUniqueKey(const char* prefix,