maintain keywords when copying local messages to imap servers, sr=mscott, part of 360463

This commit is contained in:
bienvenu%nventure.com 2006-11-21 22:08:08 +00:00
Родитель f99e53ef19
Коммит a8e5974b0f
4 изменённых файлов: 34 добавлений и 12 удалений

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

@ -42,7 +42,7 @@
interface nsIFileSpec;
interface nsIMsgMailNewsUrl;
[scriptable, uuid(71EDC407-FF4B-4D70-BE35-4001E992D8E7)]
[scriptable, uuid(b92c9161-2345-4adb-af90-5a42cd898209)]
interface nsIImapMessageSink : nsISupports {
// set up messge download output stream
@ -73,5 +73,6 @@ interface nsIImapMessageSink : nsISupports {
void SetContentModified(in nsIImapUrl aImapUrl, in nsImapContentModifiedType modified);
void SetImageCacheSessionForUrl(in nsIMsgMailNewsUrl aMailUrl);
unsigned long getCurMoveCopyMessageInfo(in nsIImapUrl runningUrl, out PRTime date);
unsigned long getCurMoveCopyMessageInfo(in nsIImapUrl runningUrl,
out PRTime date, out string keywords);
};

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

@ -4730,7 +4730,7 @@ nsImapMailFolder::SetImageCacheSessionForUrl(nsIMsgMailNewsUrl *mailurl)
return rv;
}
NS_IMETHODIMP nsImapMailFolder::GetCurMoveCopyMessageInfo(nsIImapUrl *runningUrl, PRTime *aDate, PRUint32 *aResult)
NS_IMETHODIMP nsImapMailFolder::GetCurMoveCopyMessageInfo(nsIImapUrl *runningUrl, PRTime *aDate, char **aKeywords, PRUint32 *aResult)
{
nsCOMPtr <nsISupports> copyState;
runningUrl->GetCopyState(getter_AddRefs(copyState));
@ -4740,12 +4740,19 @@ NS_IMETHODIMP nsImapMailFolder::GetCurMoveCopyMessageInfo(nsIImapUrl *runningUrl
if (mailCopyState && mailCopyState->m_message)
{
nsMsgLabelValue label;
PRUint32 supportedFlags = 0;
mailCopyState->m_message->GetFlags(aResult);
GetSupportedUserFlags(&supportedFlags);
if (supportedFlags & (kImapMsgSupportUserFlag | kImapMsgLabelFlags))
{
mailCopyState->m_message->GetLabel(&label);
if (label != 0)
*aResult |= label << 25;
}
if (aDate)
mailCopyState->m_message->GetDate(aDate);
if (aKeywords && (supportedFlags & (kImapMsgSupportUserFlag)))
mailCopyState->m_message->GetStringProperty("keywords", aKeywords);
}
// if we don't have a source header, and it's not the drafts folder,
// then mark the message read, since it must be an append to the
@ -4893,7 +4900,10 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
nsCOMPtr<nsITransactionManager> txnMgr;
m_copyState->m_msgWindow->GetTransactionManager(getter_AddRefs(txnMgr));
if (txnMgr)
txnMgr->DoTransaction(m_copyState->m_undoMsgTxn);
{
nsresult rv2 = txnMgr->DoTransaction(m_copyState->m_undoMsgTxn);
NS_ASSERTION(NS_SUCCEEDED(rv2), "doing transaction failed");
}
}
(void) OnCopyCompleted(m_copyState->m_srcSupport, aExitCode);
}
@ -6878,7 +6888,7 @@ nsImapMailFolder::CopyMessages(nsIMsgFolder* srcFolder,
if (!junkScore.IsEmpty()) // ignore already scored messages.
mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "junkscore", junkScore.get(), 0);
if (!junkScoreOrigin.IsEmpty())
mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "junkscoreorigin", junkScore.get(), 0);
mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "junkscoreorigin", junkScoreOrigin.get(), 0);
msgDBHdr->GetLabel(&label);
if (label != 0)
{

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

@ -5379,8 +5379,10 @@ void nsImapProtocol::OnAppendMsgFromFile()
imapMessageFlagsType flagsToSet = 0;
PRUint32 msgFlags = 0;
PRTime date = 0;
nsXPIDLCString keywords;
if (m_imapMessageSink)
m_imapMessageSink->GetCurMoveCopyMessageInfo(m_runningUrl, &date, &msgFlags);
m_imapMessageSink->GetCurMoveCopyMessageInfo(m_runningUrl, &date,
getter_Copies(keywords), &msgFlags);
if (msgFlags & MSG_FLAG_READ)
flagsToSet |= kImapMsgSeenFlag;
@ -5394,7 +5396,7 @@ void nsImapProtocol::OnAppendMsgFromFile()
rv = m_runningUrl->GetImapAction(&imapAction);
if (NS_SUCCEEDED(rv) && (imapAction == nsIImapUrl::nsImapAppendDraftFromFile))
flagsToSet |= kImapMsgDraftFlag;
UploadMessageFromFile(fileSpec, mailboxName, date, flagsToSet);
UploadMessageFromFile(fileSpec, mailboxName, date, flagsToSet, keywords);
PR_Free( mailboxName );
}
else
@ -5407,7 +5409,8 @@ void nsImapProtocol::OnAppendMsgFromFile()
void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
const char* mailboxName,
PRTime date,
imapMessageFlagsType flags)
imapMessageFlagsType flags,
nsCString &keywords)
{
if (!fileSpec || !mailboxName) return;
IncrementCommandTagNumber();
@ -5431,13 +5434,22 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
command.Append(" append \"");
command.Append(escapedName);
command.Append("\"");
if (flags)
if (flags || keywords.Length())
{
command.Append(" (");
if (flags)
{
SetupMessageFlagsString(flagString, flags,
GetServerStateParser().SupportsUserFlags());
command.Append(flagString);
}
if (keywords.Length())
{
if (flags)
command.Append(' ');
command.Append(keywords);
}
command.Append(")");
}
@ -7465,8 +7477,7 @@ void nsImapProtocol::SetupMessageFlagsString(nsCString& flagString,
userFlags & kImapMsgSupportMDNSentFlag))
flagString.Append("$MDNSent "); // Not always available
if ((flags & kImapMsgLabelFlags) && (userFlags & (kImapMsgSupportUserFlag |
kImapMsgLabelFlags)))
if (flags & kImapMsgLabelFlags)
{
// turn into a number from 1-5
PRUint32 labelValue = (flags & kImapMsgLabelFlags) >> 9;

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

@ -408,7 +408,7 @@ private:
void WaitForPotentialListOfBodysToFetch(PRUint32 **msgIdList, PRUint32 &msgCount);
void HeaderFetchCompleted();
void UploadMessageFromFile(nsIFileSpec* fileSpec, const char* mailboxName, PRTime date,
imapMessageFlagsType flags);
imapMessageFlagsType flags, nsCString &keywords);
// mailbox name utilities.
char *CreateEscapedMailboxName(const char *rawName);