fix copying multiple imap messages on servers with non-canonical hierarchy delimiter (e.g., cyrus servers), also whitespace cleanup, r=cavin, sr=sspitzer

This commit is contained in:
bienvenu%netscape.com 2002-11-12 01:00:17 +00:00
Родитель bc1d071781
Коммит 0f49f4a5ec
2 изменённых файлов: 71 добавлений и 71 удалений

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

@ -737,84 +737,84 @@ NS_IMETHODIMP nsImapService::DisplayMessageForPrinting(const char* aMessageURI,
NS_IMETHODIMP
nsImapService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListener *
aMailboxCopy, PRBool moveMessage,
nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **aURL)
nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **aURL)
{
nsresult rv = NS_ERROR_NULL_POINTER;
nsCOMPtr<nsISupports> streamSupport;
if (!aSrcMailboxURI || !aMailboxCopy) return rv;
streamSupport = do_QueryInterface(aMailboxCopy, &rv);
if (NS_FAILED(rv)) return rv;
nsresult rv = NS_ERROR_NULL_POINTER;
nsCOMPtr<nsISupports> streamSupport;
if (!aSrcMailboxURI || !aMailboxCopy) return rv;
streamSupport = do_QueryInterface(aMailboxCopy, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> folder;
nsXPIDLCString msgKey;
rv = DecomposeImapURI(aSrcMailboxURI, getter_AddRefs(folder), getter_Copies(msgKey));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIImapMessageSink> imapMessageSink(do_QueryInterface(folder, &rv));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIImapUrl> imapUrl;
nsCAutoString urlSpec;
PRUnichar hierarchySeparator = GetHierarchyDelimiter(folder);
PRBool hasMsgOffline = PR_FALSE;
nsMsgKey key = atoi(msgKey);
nsCOMPtr<nsIMsgFolder> folder;
nsXPIDLCString msgKey;
rv = DecomposeImapURI(aSrcMailboxURI, getter_AddRefs(folder), getter_Copies(msgKey));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIImapMessageSink> imapMessageSink(do_QueryInterface(folder, &rv));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIImapUrl> imapUrl;
nsCAutoString urlSpec;
PRUnichar hierarchySeparator = GetHierarchyDelimiter(folder);
PRBool hasMsgOffline = PR_FALSE;
nsMsgKey key = atoi(msgKey);
rv = CreateStartOfImapUrl(aSrcMailboxURI, getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
rv = CreateStartOfImapUrl(aSrcMailboxURI, getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
if (folder)
{
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(imapUrl));
folder->HasMsgOffline(key, &hasMsgOffline);
if (msgurl)
msgurl->SetMsgIsInLocalCache(hasMsgOffline);
}
// now try to download the message
nsImapAction imapAction = nsIImapUrl::nsImapOnlineToOfflineCopy;
if (moveMessage)
imapAction = nsIImapUrl::nsImapOnlineToOfflineMove;
rv = FetchMessage(imapUrl,imapAction, folder, imapMessageSink,aMsgWindow, aURL, streamSupport, msgKey, PR_TRUE);
} // if we got an imap message sink
} // if we decomposed the imap message
return rv;
if (folder)
{
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(imapUrl));
folder->HasMsgOffline(key, &hasMsgOffline);
if (msgurl)
msgurl->SetMsgIsInLocalCache(hasMsgOffline);
}
// now try to download the message
nsImapAction imapAction = nsIImapUrl::nsImapOnlineToOfflineCopy;
if (moveMessage)
imapAction = nsIImapUrl::nsImapOnlineToOfflineMove;
rv = FetchMessage(imapUrl,imapAction, folder, imapMessageSink,aMsgWindow, aURL, streamSupport, msgKey, PR_TRUE);
} // if we got an imap message sink
} // if we decomposed the imap message
return rv;
}
NS_IMETHODIMP
nsImapService::CopyMessages(nsMsgKeyArray *keys, nsIMsgFolder *srcFolder, nsIStreamListener *aMailboxCopy, PRBool moveMessage,
nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **aURL)
nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **aURL)
{
nsresult rv = NS_OK;
nsCOMPtr<nsISupports> streamSupport;
if (!keys || !aMailboxCopy)
return NS_ERROR_NULL_POINTER;
streamSupport = do_QueryInterface(aMailboxCopy, &rv);
if (!streamSupport || NS_FAILED(rv)) return rv;
nsresult rv = NS_OK;
nsCOMPtr<nsISupports> streamSupport;
if (!keys || !aMailboxCopy)
return NS_ERROR_NULL_POINTER;
streamSupport = do_QueryInterface(aMailboxCopy, &rv);
if (!streamSupport || NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> folder = srcFolder;
nsXPIDLCString msgKey;
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgFolder> folder = srcFolder;
nsXPIDLCString msgKey;
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIImapMessageSink> imapMessageSink(do_QueryInterface(folder, &rv));
if (NS_SUCCEEDED(rv))
{
nsCString messageIds;
if (NS_SUCCEEDED(rv))
{
nsCString messageIds;
AllocateImapUidString(keys->GetArray(), keys->GetSize(), messageIds);
AllocateImapUidString(keys->GetArray(), keys->GetSize(), messageIds);
nsCOMPtr<nsIImapUrl> imapUrl;
nsCAutoString urlSpec;
PRUnichar hierarchySeparator = GetHierarchyDelimiter(folder);
PRUnichar hierarchySeparator = GetHierarchyDelimiter(folder);
rv = CreateStartOfImapUrl(nsnull, getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
nsImapAction action;
if (moveMessage)
action = nsIImapUrl::nsImapOnlineToOfflineMove;
else
action = nsIImapUrl::nsImapOnlineToOfflineCopy;
imapUrl->SetCopyState(aMailboxCopy);
// now try to display the message
rv = FetchMessage(imapUrl, action, folder, imapMessageSink,
aMsgWindow, aURL, streamSupport, messageIds.get(), PR_TRUE);
// ### end of copy operation should know how to do the delete.if this is a move
nsImapAction action;
if (moveMessage)
action = nsIImapUrl::nsImapOnlineToOfflineMove;
else
action = nsIImapUrl::nsImapOnlineToOfflineCopy;
imapUrl->SetCopyState(aMailboxCopy);
// now try to display the message
rv = FetchMessage(imapUrl, action, folder, imapMessageSink,
aMsgWindow, aURL, streamSupport, messageIds.get(), PR_TRUE);
// ### end of copy operation should know how to do the delete.if this is a move
} // if we got an imap message sink
} // if we got an imap message sink
} // if we decomposed the imap message
return rv;
}

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

@ -1274,8 +1274,8 @@ NS_IMETHODIMP nsImapUrl::GetUri(char** aURI)
{
*aURI = nsnull;
PRUint32 key = m_listOfMessageIds ? atoi(m_listOfMessageIds) : 0;
nsXPIDLCString theFile;
CreateCanonicalSourceFolderPathString(getter_Copies(theFile));
nsXPIDLCString canonicalPath;
AllocateCanonicalPath(m_sourceCanonicalFolderPathSubString, m_onlineSubDirSeparator, (getter_Copies(canonicalPath)));
nsCString fullFolderPath("/");
fullFolderPath += (const char *) m_userName;
nsCAutoString hostName;
@ -1283,7 +1283,7 @@ NS_IMETHODIMP nsImapUrl::GetUri(char** aURI)
fullFolderPath += '@';
fullFolderPath += hostName;
fullFolderPath += '/';
fullFolderPath.Append(theFile);
fullFolderPath.Append(canonicalPath);
char * baseMessageURI;
nsCreateImapBaseMessageURI(fullFolderPath.get(), &baseMessageURI);