From 47e39cb52cafabb5215e99590e5b711e54065d82 Mon Sep 17 00:00:00 2001 From: "bienvenu%netscape.com" Date: Fri, 17 Dec 1999 03:06:42 +0000 Subject: [PATCH] fix 19229, imap hierarchy separator,r=jefft,a=chofmann --- mailnews/db/msgdb/public/nsDBFolderInfo.h | 57 +------- mailnews/db/msgdb/public/nsIDBFolderInfo.idl | 2 + mailnews/db/msgdb/src/nsDBFolderInfo.cpp | 10 +- mailnews/db/msgdb/src/nsMsgDatabase.cpp | 23 ++-- mailnews/imap/public/nsIImapServerSink.idl | 2 +- mailnews/imap/src/nsImapIncomingServer.cpp | 12 +- mailnews/imap/src/nsImapMailFolder.cpp | 68 +++++++++- mailnews/imap/src/nsImapMailFolder.h | 4 + mailnews/imap/src/nsImapProtocol.cpp | 3 +- mailnews/imap/src/nsImapProxyEvent.cpp | 5 +- mailnews/imap/src/nsImapService.cpp | 134 ++++++++++--------- mailnews/imap/src/nsImapService.h | 3 +- 12 files changed, 180 insertions(+), 143 deletions(-) diff --git a/mailnews/db/msgdb/public/nsDBFolderInfo.h b/mailnews/db/msgdb/public/nsDBFolderInfo.h index c13fc11862e..11aacbd8e66 100644 --- a/mailnews/db/msgdb/public/nsDBFolderInfo.h +++ b/mailnews/db/msgdb/public/nsDBFolderInfo.h @@ -51,62 +51,7 @@ public: NS_DECL_ISUPPORTS // interface methods. - NS_IMETHOD GetFlags(PRInt32 *result); - NS_IMETHOD SetFlags(PRInt32 flags); - NS_IMETHOD OrFlags(PRInt32 flags, PRInt32 *result); - NS_IMETHOD AndFlags(PRInt32 flags, PRInt32 *result); - NS_IMETHOD SetHighWater(nsMsgKey highWater, PRBool force) ; - NS_IMETHOD SetHighWater(nsMsgKey aHighWater); - NS_IMETHOD GetHighWater(nsMsgKey *result) ; - NS_IMETHOD SetExpiredMark(nsMsgKey expiredKey); - NS_IMETHOD GetExpiredMark(nsMsgKey *aExpiredMark); - NS_IMETHOD ChangeNumNewMessages(PRInt32 delta); - NS_IMETHOD ChangeNumMessages(PRInt32 delta); - NS_IMETHOD ChangeNumVisibleMessages(PRInt32 delta); - NS_IMETHOD GetNumNewMessages(PRInt32 *result) ; - NS_IMETHOD GetNumMessages(PRInt32 *result) ; - NS_IMETHOD GetNumVisibleMessages(PRInt32 *result) ; - NS_IMETHOD SetNumMessages(PRInt32 aNumMessages); - NS_IMETHOD SetNumNewMessages(PRInt32 aNumNewMessages); - NS_IMETHOD SetNumVisibleMessages(PRInt32 aNumVisibleMessages); - NS_IMETHOD GetImapUidValidity(PRInt32 *result) ; - NS_IMETHOD SetImapUidValidity(PRInt32 uidValidity) ; - NS_IMETHOD GetImapTotalPendingMessages(PRInt32 *result) ; - NS_IMETHOD GetImapUnreadPendingMessages(PRInt32 *result) ; - NS_IMETHOD SetImapTotalPendingMessages(PRInt32 totalPending) ; - NS_IMETHOD SetImapUnreadPendingMessages(PRInt32 unreadPending) ; - NS_IMETHOD GetCharacterSet(nsString *result) ; - NS_IMETHOD SetCharacterSet(nsString *charSet) ; - NS_IMETHOD GetCharPtrCharacterSet(char **result); - - NS_IMETHOD GetLocale(nsString *result) ; - NS_IMETHOD SetLocale(nsString *locale) ; - - NS_IMETHOD SetMailboxName(nsString *newBoxName); - NS_IMETHOD GetMailboxName(nsString *boxName); - - NS_IMETHOD SetVersion(PRUint32 version) ; - NS_IMETHOD GetVersion(PRUint32 *result); - - NS_IMETHOD GetLastMessageLoaded(nsMsgKey *result); - NS_IMETHOD SetLastMessageLoaded(nsMsgKey lastLoaded); - - NS_IMETHOD GetFolderSize(PRUint32 *size); - NS_IMETHOD SetFolderSize(PRUint32 size); - NS_IMETHOD GetFolderDate(PRUint32 *date); - NS_IMETHOD SetFolderDate(PRUint32 date); - - NS_IMETHOD ChangeExpungedBytes(PRInt32 delta); - - NS_IMETHOD GetProperty(const char *propertyName, nsString *resultProperty); - NS_IMETHOD SetProperty(const char *propertyName, nsString *propertyStr); - NS_IMETHOD GetCharPtrProperty(const char *propertyName, char **resultProperty); - NS_IMETHOD SetUint32Property(const char *propertyName, PRUint32 propertyValue); - NS_IMETHOD GetUint32Property(const char *propertyName, PRUint32 *propertyValue); - - NS_IMETHOD SetKnownArtsSet(nsString *newsArtSet); - NS_IMETHOD GetKnownArtsSet(nsString *newsArtSet); - + NS_DECL_NSIDBFOLDERINFO // create the appropriate table and row in a new db. nsresult AddToNewMDB(); // accessor methods. diff --git a/mailnews/db/msgdb/public/nsIDBFolderInfo.idl b/mailnews/db/msgdb/public/nsIDBFolderInfo.idl index 1eb1f6e89f7..07c638786d4 100644 --- a/mailnews/db/msgdb/public/nsIDBFolderInfo.idl +++ b/mailnews/db/msgdb/public/nsIDBFolderInfo.idl @@ -50,8 +50,10 @@ interface nsIDBFolderInfo : nsISupports { attribute unsigned long Version; attribute long ImapTotalPendingMessages; attribute long ImapUnreadPendingMessages; + attribute wchar IMAPHierarchySeparator; void ChangeExpungedBytes(in long delta); + void GetCharPtrProperty(in string propertyName, out string resultProperty); void SetUint32Property(in string propertyName, in unsigned long propertyValue); unsigned long GetUint32Property(in string propertyName); diff --git a/mailnews/db/msgdb/src/nsDBFolderInfo.cpp b/mailnews/db/msgdb/src/nsDBFolderInfo.cpp index a52dc205926..c3c7a3bba58 100644 --- a/mailnews/db/msgdb/src/nsDBFolderInfo.cpp +++ b/mailnews/db/msgdb/src/nsDBFolderInfo.cpp @@ -564,14 +564,18 @@ NS_IMETHODIMP nsDBFolderInfo::SetLocale(nsString *locale) } -PRInt16 nsDBFolderInfo::GetIMAPHierarchySeparator() +NS_IMETHODIMP nsDBFolderInfo::GetIMAPHierarchySeparator(PRUnichar *hierarchySeparator) { - return m_IMAPHierarchySeparator; + if (!hierarchySeparator) + return NS_ERROR_NULL_POINTER; + *hierarchySeparator = m_IMAPHierarchySeparator; + return NS_OK; } -void nsDBFolderInfo::SetIMAPHierarchySeparator(PRInt16 hierarchySeparator) +NS_IMETHODIMP nsDBFolderInfo::SetIMAPHierarchySeparator(PRUnichar hierarchySeparator) { m_IMAPHierarchySeparator = hierarchySeparator; + return NS_OK; } NS_IMETHODIMP diff --git a/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mailnews/db/msgdb/src/nsMsgDatabase.cpp index 6bc07724ef4..f2de08b2a52 100644 --- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -977,17 +977,22 @@ NS_IMETHODIMP nsMsgDatabase::DeleteMessages(nsMsgKeyArray* nsMsgKeys, nsIDBChang nsMsgKey key = nsMsgKeys->ElementAt(kindex); nsIMsgDBHdr *msgHdr = NULL; - err = GetMsgHdrForKey(key, &msgHdr); - if (NS_FAILED(err)) + PRBool hasKey; + + if (NS_SUCCEEDED(ContainsKey(key, &hasKey)) && hasKey) { - err = NS_MSG_MESSAGE_NOT_FOUND; - break; + err = GetMsgHdrForKey(key, &msgHdr); + if (NS_FAILED(err)) + { + err = NS_MSG_MESSAGE_NOT_FOUND; + break; + } + if (msgHdr) + err = DeleteHeader(msgHdr, instigator, kindex % 300 == 0, PR_TRUE); + NS_IF_RELEASE(msgHdr); + if (err != NS_OK) + break; } - if (msgHdr) - err = DeleteHeader(msgHdr, instigator, kindex % 300 == 0, PR_TRUE); - NS_IF_RELEASE(msgHdr); - if (err != NS_OK) - break; } Commit(nsMsgDBCommitType::kSmallCommit); return err; diff --git a/mailnews/imap/public/nsIImapServerSink.idl b/mailnews/imap/public/nsIImapServerSink.idl index 6ba49d817b5..4b8f773affc 100644 --- a/mailnews/imap/public/nsIImapServerSink.idl +++ b/mailnews/imap/public/nsIImapServerSink.idl @@ -26,7 +26,7 @@ [scriptable, uuid(8ec49a08-5cb0-11d3-a52c-0060b0fc04b7)] interface nsIImapServerSink : nsISupports { - void PossibleImapMailbox(in string folderPath); + void PossibleImapMailbox(in string folderPath, in wchar hierarchyDelim, in long boxFlags); void DiscoveryDone(); void OnlineFolderDelete(in string aFolderName); void OnlineFolderCreateFailed(in string aFolderName); diff --git a/mailnews/imap/src/nsImapIncomingServer.cpp b/mailnews/imap/src/nsImapIncomingServer.cpp index ab264533b1d..8f515b37cf7 100644 --- a/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mailnews/imap/src/nsImapIncomingServer.cpp @@ -533,7 +533,7 @@ nsImapIncomingServer::CloseCachedConnections() } // nsIImapServerSink impl -NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath) +NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath, PRUnichar hierarchyDelimiter, PRInt32 boxFlags) { nsresult rv; PRBool found = PR_FALSE; @@ -592,14 +592,18 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath) if (!found) { hostFolder->CreateClientSubfolderInfo(folderPath); + a_nsIFolder->GetChildWithURI(uri, PR_TRUE, getter_AddRefs(child)); } - else + if (child) { nsCOMPtr imapFolder = do_QueryInterface(child); if (imapFolder) + { imapFolder->SetVerifiedAsOnlineFolder(PR_TRUE); - } - + imapFolder->SetHierarchyDelimiter(hierarchyDelimiter); + imapFolder->SetBoxFlags(boxFlags); + } + } return NS_OK; } diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 76b467e067d..0ac9bf1235e 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -48,7 +48,7 @@ #include "nsIMsgCopyService.h" #include "nsICopyMsgStreamListener.h" #include "nsImapStringBundle.h" - +#include "nsIMsgFolderCacheElement.h" #include "nsIMsgStatusFeedback.h" #include "nsIMsgFilter.h" @@ -96,6 +96,8 @@ nsImapMailFolder::nsImapMailFolder() : pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(m_eventQueue)); m_moveCoalescer = nsnull; + m_boxFlags = 0; + m_hierarchyDelimiter = kOnlineHierarchySeparatorUnknown; } @@ -662,6 +664,40 @@ NS_IMETHODIMP nsImapMailFolder::SetVerifiedAsOnlineFolder(PRBool aVerifiedAsOnli return NS_OK; } +NS_IMETHODIMP nsImapMailFolder::SetHierarchyDelimiter(PRUnichar aHierarchyDelimiter) +{ + m_hierarchyDelimiter = aHierarchyDelimiter; + return NS_OK; +} + +NS_IMETHODIMP nsImapMailFolder::GetHierarchyDelimiter(PRUnichar *aHierarchyDelimiter) +{ + if (!aHierarchyDelimiter) + return NS_ERROR_NULL_POINTER; + *aHierarchyDelimiter = m_hierarchyDelimiter; + return NS_OK; +} + +NS_IMETHODIMP nsImapMailFolder::SetBoxFlags(PRInt32 aBoxFlags) +{ + m_boxFlags = aBoxFlags; + if (m_boxFlags & kNoinferiors) + mFlags |= MSG_FOLDER_FLAG_IMAP_NOINFERIORS; + else + mFlags &= ~MSG_FOLDER_FLAG_IMAP_NOINFERIORS; + + return NS_OK; +} + +NS_IMETHODIMP nsImapMailFolder::GetBoxFlags(PRInt32 *aBoxFlags) +{ + if (!aBoxFlags) + return NS_ERROR_NULL_POINTER; + *aBoxFlags = m_boxFlags; + return NS_OK; +} + + NS_IMETHODIMP nsImapMailFolder::GetExplicitlyVerify(PRBool *aExplicitlyVerify) { if (!aExplicitlyVerify) @@ -884,9 +920,7 @@ NS_IMETHODIMP nsImapMailFolder::GetCanCreateSubfolders(PRBool *aResult) { NS_ENSURE_ARG_POINTER(aResult); - // if it's the Inbox, then you can't create a subfolder. - // yes, I know this isn't true for all IMAP servers, but it works for now - *aResult = !(mFlags & MSG_FOLDER_FLAG_INBOX); + *aResult = !(mFlags & MSG_FOLDER_FLAG_IMAP_NOINFERIORS); return NS_OK; } @@ -961,6 +995,27 @@ nsImapMailFolder::MarkAllMessagesRead(void) return rv; } +NS_IMETHODIMP nsImapMailFolder::ReadFromFolderCacheElem(nsIMsgFolderCacheElement *element) +{ + nsresult rv = nsMsgDBFolder::ReadFromFolderCacheElem(element); + PRInt32 hierarchyDelimiter = kOnlineHierarchySeparatorUnknown; + + element->GetInt32Property("boxFlags", &m_boxFlags); + if (NS_SUCCEEDED(element->GetInt32Property("hierDelim", &hierarchyDelimiter))) + m_hierarchyDelimiter = (PRUnichar) hierarchyDelimiter; + return rv; +} + +NS_IMETHODIMP nsImapMailFolder::WriteToFolderCacheElem(nsIMsgFolderCacheElement *element) +{ + nsresult rv = nsMsgDBFolder::WriteToFolderCacheElem(element); + element->SetInt32Property("boxFlags", m_boxFlags); + element->SetInt32Property("hierDelim", (PRInt32) m_hierarchyDelimiter); + return rv; +} + + + NS_IMETHODIMP nsImapMailFolder::MarkMessagesFlagged(nsISupportsArray *messages, PRBool markFlagged) { @@ -3017,10 +3072,11 @@ nsImapMailFolder::PercentProgress(nsIImapProtocol* aProtocol, { nsCOMPtr feedback; mailnewsUrl->GetStatusFeedback(getter_AddRefs(feedback)); - if (feedback && aInfo->message) + if (feedback) { feedback->ShowProgress(aInfo->percent); - feedback->ShowStatusString(aInfo->message); + if (aInfo->message) + feedback->ShowStatusString(aInfo->message); } } } diff --git a/mailnews/imap/src/nsImapMailFolder.h b/mailnews/imap/src/nsImapMailFolder.h index e71c5f84302..22c7abfde50 100644 --- a/mailnews/imap/src/nsImapMailFolder.h +++ b/mailnews/imap/src/nsImapMailFolder.h @@ -144,6 +144,8 @@ public: NS_IMETHOD MarkMessagesFlagged(nsISupportsArray *messages, PRBool markFlagged); NS_IMETHOD DeleteSubFolders(nsISupportsArray *folders); + NS_IMETHOD ReadFromFolderCacheElem(nsIMsgFolderCacheElement *element); + NS_IMETHOD WriteToFolderCacheElem(nsIMsgFolderCacheElement *element); virtual nsresult GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsIMsgDatabase **db); @@ -339,6 +341,8 @@ protected: PRMonitor *m_appendMsgMonitor; PRBool m_verifiedAsOnlineFolder; PRBool m_explicitlyVerify; // whether or not we need to explicitly verify this through LIST + PRUnichar m_hierarchyDelimiter; + PRInt32 m_boxFlags; }; diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp index 46c007ff4d8..925efab2491 100644 --- a/mailnews/imap/src/nsImapProtocol.cpp +++ b/mailnews/imap/src/nsImapProtocol.cpp @@ -3824,7 +3824,8 @@ nsImapProtocol::DiscoverMailboxSpec(mailbox_spec * adoptedBoxSpec) if (m_imapServerSink) { - m_imapServerSink->PossibleImapMailbox(boxNameCopy); + m_imapServerSink->PossibleImapMailbox(boxNameCopy, + adoptedBoxSpec->hierarchySeparator, adoptedBoxSpec->box_flags); // WaitForFEEventCompletion(); PRBool useSubscription = PR_FALSE; diff --git a/mailnews/imap/src/nsImapProxyEvent.cpp b/mailnews/imap/src/nsImapProxyEvent.cpp index 0f2ee13fed5..c58ea3d51dd 100644 --- a/mailnews/imap/src/nsImapProxyEvent.cpp +++ b/mailnews/imap/src/nsImapProxyEvent.cpp @@ -1840,12 +1840,13 @@ ProgressStatusProxyEvent::ProgressStatusProxyEvent( nsImapMiscellaneousSinkProxyEvent(aProxy) { m_statusMsgId = aMsgId; - m_extraInfo = nsCRT::strdup(extraInfo); + m_extraInfo = (extraInfo) ? nsCRT::strdup(extraInfo) : nsnull; } ProgressStatusProxyEvent::~ProgressStatusProxyEvent() { - PR_FREEIF(m_extraInfo); + if (m_extraInfo) + nsCRT::free(m_extraInfo); } NS_IMETHODIMP diff --git a/mailnews/imap/src/nsImapService.cpp b/mailnews/imap/src/nsImapService.cpp index 703867591d7..6b72f06944a 100644 --- a/mailnews/imap/src/nsImapService.cpp +++ b/mailnews/imap/src/nsImapService.cpp @@ -119,7 +119,8 @@ nsImapService::SelectFolder(nsIEventQueue * aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; nsresult rv; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, aUrlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv) && imapUrl) { @@ -137,7 +138,8 @@ nsImapService::SelectFolder(nsIEventQueue * aClientEventQueue, { nsXPIDLCString folderName; GetFolderName(aImapMailFolder, getter_Copies(folderName)); - urlSpec.Append("/select>/"); + urlSpec.Append("/select>"); + urlSpec.Append(hierarchySeparator); urlSpec.Append((const char *) folderName); rv = mailNewsUrl->SetSpec((char *) urlSpec.GetBuffer()); if (NS_SUCCEEDED(rv)) @@ -172,7 +174,8 @@ nsImapService::LiteSelectFolder(nsIEventQueue * aClientEventQueue, nsresult rv; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, aUrlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv)) { @@ -180,7 +183,6 @@ nsImapService::LiteSelectFolder(nsIEventQueue * aClientEventQueue, if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; nsCOMPtr uri = do_QueryInterface(imapUrl); urlSpec.Append("/liteselect>"); @@ -213,7 +215,8 @@ NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL { nsCOMPtr imapUrl; nsCAutoString urlSpec; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, nsnull, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, nsnull, urlSpec, hierarchySeparator); if (NS_FAILED(rv)) return rv; imapUrl->SetImapMessageSink(imapMessageSink); @@ -222,7 +225,6 @@ NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL url->GetSpec(getter_Copies(currentSpec)); urlSpec = currentSpec; - char hierarchySeparator = '/'; // ### fixme - should get from folder urlSpec.Append("fetch>"); urlSpec.Append(uidString); urlSpec.Append(">"); @@ -258,9 +260,11 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char* aMessageURI, { nsCOMPtr imapUrl; nsCAutoString urlSpec; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator); if (NS_FAILED(rv)) return rv; + imapUrl->AddChannelToLoadGroup(); rv = FetchMessage(imapUrl, nsIImapUrl::nsImapMsgFetch, folder, imapMessageSink, aURL, aDisplayConsumer, msgKey, PR_TRUE); } @@ -289,7 +293,8 @@ nsImapService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListener * { nsCOMPtr imapUrl; nsCAutoString urlSpec; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator); // now try to display the message rv = FetchMessage(imapUrl, nsIImapUrl::nsImapMsgFetch, folder, imapMessageSink, @@ -365,7 +370,8 @@ NS_IMETHODIMP nsImapService::SaveMessageToDisk(const char *aMessageURI, if (NS_FAILED(rv)) return rv; nsCAutoString urlSpec; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv)) { nsCOMPtr imapMessageSink(do_QueryInterface(folder, &rv)); @@ -408,25 +414,28 @@ nsImapService::FetchMessage(nsIImapUrl * aImapUrl, nsresult rv = aImapUrl->SetImapAction(aImapAction /* nsIImapUrl::nsImapMsgFetch */); rv = SetImapUrlSink(aImapMailFolder, aImapUrl); - rv = aImapUrl->SetImapMessageSink(aImapMessage); - if (NS_SUCCEEDED(rv)) - { + rv = aImapUrl->SetImapMessageSink(aImapMessage); + if (NS_SUCCEEDED(rv)) + { nsXPIDLCString currentSpec; nsCOMPtr url = do_QueryInterface(aImapUrl); url->GetSpec(getter_Copies(currentSpec)); urlSpec = currentSpec; - char hierarchySeparator = '/'; // ### fixme - should get from folder - urlSpec.Append("fetch>"); - urlSpec.Append(messageIdsAreUID ? uidString : sequenceString); - urlSpec.Append(">"); - urlSpec.Append(hierarchySeparator); + PRUnichar hierarchySeparator = '/'; + nsCOMPtr imapFolder = do_QueryInterface(aImapMailFolder); + if (imapFolder) + imapFolder->GetHierarchyDelimiter(&hierarchySeparator); + urlSpec.Append("fetch>"); + urlSpec.Append(messageIdsAreUID ? uidString : sequenceString); + urlSpec.Append(">"); + urlSpec.Append(hierarchySeparator); - nsXPIDLCString folderName; - GetFolderName(aImapMailFolder, getter_Copies(folderName)); - urlSpec.Append((const char *) folderName); - urlSpec.Append(">"); - urlSpec.Append(messageIdentifierList); + nsXPIDLCString folderName; + GetFolderName(aImapMailFolder, getter_Copies(folderName)); + urlSpec.Append((const char *) folderName); + urlSpec.Append(">"); + urlSpec.Append(messageIdentifierList); // mscott - this cast to a char * is okay...there's a bug in the XPIDL @@ -500,7 +509,8 @@ nsresult nsImapService::CreateStartOfImapUrl(nsIImapUrl ** imapUrl, nsIMsgFolder* aImapMailFolder, nsIUrlListener * aUrlListener, - nsCString & urlSpec) + nsCString & urlSpec, + PRUnichar &hierarchyDelimiter) { nsresult rv = NS_OK; char *hostname = nsnull; @@ -539,6 +549,10 @@ nsImapService::CreateStartOfImapUrl(nsIImapUrl ** imapUrl, // const char *. hopefully they will fix it soon. rv = mailnewsUrl->SetSpec((char *) urlSpec.GetBuffer()); + hierarchyDelimiter = kOnlineHierarchySeparatorUnknown; + nsCOMPtr imapFolder = do_QueryInterface(aImapMailFolder); + if (imapFolder) + imapFolder->GetHierarchyDelimiter(&hierarchyDelimiter); } PR_FREEIF(hostname); @@ -568,8 +582,9 @@ nsImapService::GetHeaders(nsIEventQueue * aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; // ### fixme - should get from folder - nsresult rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl),aImapMailFolder, aUrlListener, urlSpec); + nsresult rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl),aImapMailFolder, aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv) && imapUrl) { nsCOMPtr uri = do_QueryInterface(imapUrl); @@ -579,7 +594,6 @@ nsImapService::GetHeaders(nsIEventQueue * aClientEventQueue, if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; // ### fixme - should get from folder urlSpec.Append("/header>"); urlSpec.Append(messageIdsAreUID ? uidString : sequenceString); @@ -619,9 +633,10 @@ nsImapService::Noop(nsIEventQueue * aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; nsresult rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, - aUrlListener, urlSpec); + aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv) && imapUrl) { @@ -631,8 +646,6 @@ nsImapService::Noop(nsIEventQueue * aClientEventQueue, if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; // ### fixme - should get from folder - urlSpec.Append("/selectnoop>"); urlSpec.Append(hierarchySeparator); @@ -664,9 +677,10 @@ nsImapService::Expunge(nsIEventQueue * aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; // ### fixme - should get from folder nsresult rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, - aUrlListener, urlSpec); + aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv)) { @@ -677,7 +691,6 @@ nsImapService::Expunge(nsIEventQueue * aClientEventQueue, if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; // ### fixme - should get from folder urlSpec.Append("/Expunge>"); urlSpec.Append(hierarchySeparator); @@ -713,9 +726,10 @@ nsImapService::Biff(nsIEventQueue * aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; nsresult rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, - aUrlListener, urlSpec); + aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv) && imapUrl) { @@ -726,8 +740,6 @@ nsImapService::Biff(nsIEventQueue * aClientEventQueue, if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; // ### fixme - should get from folder - urlSpec.Append("/Biff>"); urlSpec.Append(hierarchySeparator); @@ -760,13 +772,13 @@ nsImapService::DeleteFolder(nsIEventQueue* eventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, urlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, urlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv)) { rv = SetImapUrlSink(folder, imapUrl); if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = kOnlineHierarchySeparatorUnknown; nsCOMPtr uri = do_QueryInterface(imapUrl); urlSpec.Append("/delete>"); @@ -811,9 +823,10 @@ nsImapService::DeleteMessages(nsIEventQueue * aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; nsresult rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, - aUrlListener, urlSpec); + aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv) && imapUrl) { @@ -822,7 +835,6 @@ nsImapService::DeleteMessages(nsIEventQueue * aClientEventQueue, if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; // ### fixme - should get from folder nsCOMPtr uri = do_QueryInterface(imapUrl); urlSpec.Append("/deletemsg>"); @@ -861,9 +873,10 @@ nsImapService::DeleteAllMessages(nsIEventQueue * aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; nsresult rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, - aUrlListener, urlSpec); + aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv)) { @@ -872,7 +885,6 @@ nsImapService::DeleteAllMessages(nsIEventQueue * aClientEventQueue, if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; // ### fixme - should get from folder nsCOMPtr uri = do_QueryInterface(imapUrl); urlSpec.Append("/deleteallmsgs>"); @@ -952,9 +964,10 @@ nsresult nsImapService::DiddleFlags(nsIEventQueue * aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; nsresult rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, - aUrlListener, urlSpec); + aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv) && imapUrl) { @@ -963,7 +976,6 @@ nsresult nsImapService::DiddleFlags(nsIEventQueue * aClientEventQueue, if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; // ### fixme - should get from folder nsCOMPtr uri = do_QueryInterface(imapUrl); urlSpec.Append('/'); @@ -1059,9 +1071,10 @@ nsImapService::DiscoverAllFolders(nsIEventQueue* aClientEventQueue, nsCOMPtr aImapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; nsresult rv = CreateStartOfImapUrl(getter_AddRefs(aImapUrl), aImapMailFolder, - aUrlListener, urlSpec); + aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED (rv)) { rv = SetImapUrlSink(aImapMailFolder, aImapUrl); @@ -1095,9 +1108,10 @@ nsImapService::DiscoverAllAndSubscribedFolders(nsIEventQueue* aClientEventQueue, nsCOMPtr aImapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; nsresult rv = CreateStartOfImapUrl(getter_AddRefs(aImapUrl), aImapMailFolder, - aUrlListener, urlSpec); + aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED (rv) && aImapUrl) { rv = SetImapUrlSink(aImapMailFolder, aImapUrl); @@ -1130,9 +1144,10 @@ nsImapService::DiscoverChildren(nsIEventQueue* aClientEventQueue, nsCOMPtr aImapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; nsresult rv = CreateStartOfImapUrl(getter_AddRefs(aImapUrl), aImapMailFolder, - aUrlListener, urlSpec); + aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED (rv)) { rv = SetImapUrlSink(aImapMailFolder, aImapUrl); @@ -1145,8 +1160,8 @@ nsImapService::DiscoverChildren(nsIEventQueue* aClientEventQueue, { nsCOMPtr uri = do_QueryInterface(aImapUrl); - // **** fix me with host specific hierarchySeparator please - urlSpec.Append("/discoverchildren>/"); + urlSpec.Append("/discoverchildren>"); + urlSpec.Append(hierarchySeparator); urlSpec.Append((const char *) folderName); // mscott - this cast to a char * is okay...there's a bug in the XPIDL // compiler that is preventing in string parameters from showing up as @@ -1181,8 +1196,9 @@ nsImapService::DiscoverLevelChildren(nsIEventQueue* aClientEventQueue, nsCOMPtr aImapUrl; nsCAutoString urlSpec; + PRUnichar hierarchySeparator = '/'; nsresult rv = CreateStartOfImapUrl(getter_AddRefs(aImapUrl), - aImapMailFolder,aUrlListener, urlSpec); + aImapMailFolder,aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED (rv) && aImapUrl) { rv = SetImapUrlSink(aImapMailFolder, aImapUrl); @@ -1196,8 +1212,7 @@ nsImapService::DiscoverLevelChildren(nsIEventQueue* aClientEventQueue, nsCOMPtr uri = do_QueryInterface(aImapUrl); urlSpec.Append("/discoverlevelchildren>"); urlSpec.Append(level); - // **** fix me with host specific hierarchySeparator please - urlSpec.Append("/"); // hierarchySeparator "/" + urlSpec.Append(hierarchySeparator); // hierarchySeparator "/" urlSpec.Append((const char *) folderName); rv = uri->SetSpec((char *) urlSpec.GetBuffer()); @@ -1270,11 +1285,10 @@ nsImapService::OnlineMessageCopy(nsIEventQueue* aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aSrcFolder, aUrlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aSrcFolder, aUrlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv)) { - // **** fix me with real host hierarchy separator - char hierarchySeparator = kOnlineHierarchySeparatorUnknown; SetImapUrlSink(aSrcFolder, imapUrl); imapUrl->SetCopyState(copyState); @@ -1335,11 +1349,10 @@ nsImapService::AppendMessageFromFile(nsIEventQueue* aClientEventQueue, nsCOMPtr imapUrl; nsCAutoString urlSpec; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aDstFolder, aListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aDstFolder, aListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv)) { - // **** fix me with real host hierarchy separator - char hierarchySeparator = kOnlineHierarchySeparatorUnknown; SetImapUrlSink(aDstFolder, imapUrl); imapUrl->SetMsgFileSpec(aFileSpec); imapUrl->SetCopyState(aCopyState); @@ -1439,7 +1452,8 @@ nsImapService::MoveFolder(nsIEventQueue* eventQueue, nsIMsgFolder* srcFolder, nsCAutoString urlSpec; nsresult rv; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), dstFolder, urlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), dstFolder, urlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv) && imapUrl) { rv = SetImapUrlSink(dstFolder, imapUrl); @@ -1486,13 +1500,13 @@ nsImapService::RenameLeaf(nsIEventQueue* eventQueue, nsIMsgFolder* srcFolder, nsCAutoString urlSpec; nsresult rv; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), srcFolder, urlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), srcFolder, urlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv)) { rv = SetImapUrlSink(srcFolder, imapUrl); if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; nsCOMPtr uri = do_QueryInterface(imapUrl); nsXPIDLCString folderName; @@ -1537,13 +1551,13 @@ nsImapService::CreateFolder(nsIEventQueue* eventQueue, nsIMsgFolder* parent, nsCAutoString urlSpec; nsresult rv; - rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), parent, urlListener, urlSpec); + PRUnichar hierarchySeparator = '/'; + rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), parent, urlListener, urlSpec, hierarchySeparator); if (NS_SUCCEEDED(rv) && imapUrl) { rv = SetImapUrlSink(parent, imapUrl); if (NS_SUCCEEDED(rv)) { - char hierarchySeparator = '/'; nsCOMPtr uri = do_QueryInterface(imapUrl); nsXPIDLCString folderName; diff --git a/mailnews/imap/src/nsImapService.h b/mailnews/imap/src/nsImapService.h index 86843a0f6ac..a73b556a9d6 100644 --- a/mailnews/imap/src/nsImapService.h +++ b/mailnews/imap/src/nsImapService.h @@ -201,7 +201,8 @@ protected: nsresult CreateStartOfImapUrl(nsIImapUrl **imapUrl, nsIMsgFolder* aImapFolder, nsIUrlListener * aUrlListener, - nsCString & urlSpec); + nsCString & urlSpec, + PRUnichar &hierarchyDelimiter); nsresult GetImapConnectionAndLoadUrl(nsIEventQueue* aClientEventQueue, nsIImapUrl* aImapUrl, nsISupports* aConsumer,