diff --git a/mailnews/base/src/nsMsgAccountManagerDS.cpp b/mailnews/base/src/nsMsgAccountManagerDS.cpp index a10ebd918cc..870d0611d3c 100644 --- a/mailnews/base/src/nsMsgAccountManagerDS.cpp +++ b/mailnews/base/src/nsMsgAccountManagerDS.cpp @@ -897,12 +897,8 @@ nsMsgAccountManagerDataSource::createServerResources(nsISupports *element, // add the resource to the array nsCOMPtr serverResource = do_QueryInterface(serverFolder); - if(!serverResource) - return PR_TRUE; - - rv = servers->AppendElement(serverResource); - if (NS_FAILED(rv)) return PR_TRUE; - + if(serverResource) + (void) servers->AppendElement(serverResource); return PR_TRUE; } diff --git a/mailnews/local/public/nsIPop3IncomingServer.idl b/mailnews/local/public/nsIPop3IncomingServer.idl index 8969e841f88..e7eddddefaa 100644 --- a/mailnews/local/public/nsIPop3IncomingServer.idl +++ b/mailnews/local/public/nsIPop3IncomingServer.idl @@ -54,6 +54,8 @@ interface nsIPop3IncomingServer : nsISupports { void addUidlToMarkDeleted(in string aUidl); void markMessagesDeleted(in boolean aDeleteMsgs); attribute boolean authenticated; + /* account to which this server defers storage, for global inbox */ + attribute string deferredToAccount; }; diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp index 6aa296ece27..3c53e8525fd 100644 --- a/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mailnews/local/src/nsLocalMailFolder.cpp @@ -2235,7 +2235,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetNewMessages(nsIMsgWindow *aWindow, nsIUrl nsCOMPtr inbox; nsCOMPtr rootFolder; - rv = GetRootFolder(getter_AddRefs(rootFolder)); + rv = server->GetRootMsgFolder(getter_AddRefs(rootFolder)); if(NS_SUCCEEDED(rv) && rootFolder) { PRUint32 numFolders; @@ -2982,7 +2982,7 @@ nsMsgLocalMailFolder::MarkMsgsOnPop3Server(nsISupportsArray *aMessages, PRBool a PRUint32 srcCount; aMessages->Count(&srcCount); - for (PRInt32 i = 0; header && (i < srcCount); i++) + for (PRInt32 i = 0; i < srcCount; i++) { /* get uidl for this message */ uidl = nsnull; diff --git a/mailnews/local/src/nsPop3IncomingServer.cpp b/mailnews/local/src/nsPop3IncomingServer.cpp index 12be948eb8b..1e7d2b47cda 100644 --- a/mailnews/local/src/nsPop3IncomingServer.cpp +++ b/mailnews/local/src/nsPop3IncomingServer.cpp @@ -53,6 +53,7 @@ #include "nsIFileSpec.h" #include "nsPop3Protocol.h" #include "nsIMsgLocalMailFolder.h" +#include "nsIMsgAccountManager.h" static NS_DEFINE_CID(kCPop3ServiceCID, NS_POP3SERVICE_CID); @@ -105,6 +106,10 @@ NS_IMPL_SERVERPREF_INT(nsPop3IncomingServer, "num_days_to_leave_on_server") +NS_IMPL_SERVERPREF_STR(nsPop3IncomingServer, + DeferredToAccount, + "deferred_to_account") + //NS_IMPL_GETSET(nsPop3IncomingServer, Authenticated, PRBool, m_authenticated); NS_IMETHODIMP nsPop3IncomingServer::GetAuthenticated(PRBool *aAuthenticated) @@ -142,6 +147,42 @@ nsPop3IncomingServer::GetLocalStoreType(char **type) return NS_OK; } + +NS_IMETHODIMP +nsPop3IncomingServer::GetRootMsgFolder(nsIMsgFolder **aRootMsgFolder) +{ + NS_ENSURE_ARG_POINTER(aRootMsgFolder); + nsresult rv = NS_OK; + if (!m_rootMsgFolder) + { + nsXPIDLCString deferredToAccount; + GetDeferredToAccount(getter_Copies(deferredToAccount)); + if (deferredToAccount.IsEmpty()) + { + rv = CreateRootFolder(); + m_rootMsgFolder = m_rootFolder; + } + else + { + nsCOMPtr accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv,rv); + nsCOMPtr account; + rv = accountManager->GetAccount(deferredToAccount, getter_AddRefs(account)); + if (account) + { + nsCOMPtr incomingServer; + rv = account->GetIncomingServer(getter_AddRefs(incomingServer)); + // make sure we're not deferred to ourself... + if (incomingServer && incomingServer != this) + rv = incomingServer->GetRootMsgFolder(getter_AddRefs(m_rootMsgFolder)); + } + } + } + + NS_IF_ADDREF(*aRootMsgFolder = m_rootMsgFolder); + return rv; +} + NS_IMETHODIMP nsPop3IncomingServer::PerformBiff(nsIMsgWindow *aMsgWindow) { nsresult rv; diff --git a/mailnews/local/src/nsPop3IncomingServer.h b/mailnews/local/src/nsPop3IncomingServer.h index f09a9f41f0b..117ad4f4d3b 100644 --- a/mailnews/local/src/nsPop3IncomingServer.h +++ b/mailnews/local/src/nsPop3IncomingServer.h @@ -64,10 +64,12 @@ public: NS_IMETHOD GetCanBeDefaultServer(PRBool *canBeDefaultServer); NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages); NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel); + NS_IMETHOD GetRootMsgFolder(nsIMsgFolder **aRootMsgFolder); private: PRUint32 m_capabilityFlags; PRBool m_authenticated; nsCOMPtr m_runningProtocol; + nsCOMPtr m_rootMsgFolder; nsCStringArray m_uidlsToMarkDeleted; }; diff --git a/mailnews/local/src/nsPop3Sink.cpp b/mailnews/local/src/nsPop3Sink.cpp index 1c0fb30d958..92c95264fb4 100644 --- a/mailnews/local/src/nsPop3Sink.cpp +++ b/mailnews/local/src/nsPop3Sink.cpp @@ -167,21 +167,9 @@ nsPop3Sink::BeginMailDelivery(PRBool uidlDownload, nsIMsgWindow *aMsgWindow, PRB else return NS_MSG_FOLDER_BUSY; - if (uidlDownload) - { - nsCOMPtr path; - m_folder->GetPath(getter_AddRefs(path)); - path->GetFileSpec(&fileSpec); - } - else - { - nsCOMPtr mailDirectory; - rv = server->GetLocalPath(getter_AddRefs(mailDirectory)); - if (NS_FAILED(rv)) return rv; - - mailDirectory->GetFileSpec(&fileSpec); - fileSpec += "Inbox"; - } + nsCOMPtr path; + m_folder->GetPath(getter_AddRefs(path)); + path->GetFileSpec(&fileSpec); m_outFileStream = new nsIOFileStream(fileSpec /*, PR_CREATE_FILE */); // The following (!m_outFileStream etc) was added to make sure that we don't write somewhere