fix 332626 transfer date of original message when appending message to imap folder, original patch by mhovis, with some reworking by me, sr=mscott

This commit is contained in:
bienvenu%nventure.com 2006-08-25 16:43:07 +00:00
Родитель a6cd2d536c
Коммит a4eef56122
4 изменённых файлов: 37 добавлений и 6 удалений

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

@ -42,7 +42,7 @@
interface nsIFileSpec;
interface nsIMsgMailNewsUrl;
[scriptable, uuid(5a53b814-68b1-11d3-a53e-0060b0fc04b7)]
[scriptable, uuid(71EDC407-FF4B-4D70-BE35-4001E992D8E7)]
interface nsIImapMessageSink : nsISupports {
// set up messge download output stream
@ -73,5 +73,5 @@ interface nsIImapMessageSink : nsISupports {
void SetContentModified(in nsIImapUrl aImapUrl, in nsImapContentModifiedType modified);
void SetImageCacheSessionForUrl(in nsIMsgMailNewsUrl aMailUrl);
unsigned long getCurMoveCopyMessageFlags(in nsIImapUrl runningUrl);
unsigned long getCurMoveCopyMessageInfo(in nsIImapUrl runningUrl, out PRTime date);
};

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

@ -115,6 +115,7 @@
#include "nsMsgCompCID.h"
#include "nsICacheEntryDescriptor.h"
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
static NS_DEFINE_CID(kCImapDB, NS_IMAPDB_CID);
@ -4722,7 +4723,7 @@ nsImapMailFolder::SetImageCacheSessionForUrl(nsIMsgMailNewsUrl *mailurl)
return rv;
}
NS_IMETHODIMP nsImapMailFolder::GetCurMoveCopyMessageFlags(nsIImapUrl *runningUrl, PRUint32 *aResult)
NS_IMETHODIMP nsImapMailFolder::GetCurMoveCopyMessageInfo(nsIImapUrl *runningUrl, PRTime *aDate, PRUint32 *aResult)
{
nsCOMPtr <nsISupports> copyState;
runningUrl->GetCopyState(getter_AddRefs(copyState));
@ -4736,6 +4737,8 @@ NS_IMETHODIMP nsImapMailFolder::GetCurMoveCopyMessageFlags(nsIImapUrl *runningUr
mailCopyState->m_message->GetLabel(&label);
if (label != 0)
*aResult |= label << 25;
if (aDate)
mailCopyState->m_message->GetDate(aDate);
}
// 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

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

@ -5360,8 +5360,9 @@ void nsImapProtocol::OnAppendMsgFromFile()
{
imapMessageFlagsType flagsToSet = 0;
PRUint32 msgFlags = 0;
PRTime date = 0;
if (m_imapMessageSink)
m_imapMessageSink->GetCurMoveCopyMessageFlags(m_runningUrl, &msgFlags);
m_imapMessageSink->GetCurMoveCopyMessageInfo(m_runningUrl, &date, &msgFlags);
if (msgFlags & MSG_FLAG_READ)
flagsToSet |= kImapMsgSeenFlag;
@ -5370,7 +5371,7 @@ void nsImapProtocol::OnAppendMsgFromFile()
// convert msg flag label (0xE000000) to imap flag label (0x0E00)
if (msgFlags & MSG_FLAG_LABELS)
flagsToSet |= (msgFlags & MSG_FLAG_LABELS) >> 16;
UploadMessageFromFile(fileSpec, mailboxName, flagsToSet);
UploadMessageFromFile(fileSpec, mailboxName, date, flagsToSet);
PR_Free( mailboxName );
}
else
@ -5382,6 +5383,7 @@ void nsImapProtocol::OnAppendMsgFromFile()
void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
const char* mailboxName,
PRTime date,
imapMessageFlagsType flags)
{
if (!fileSpec || !mailboxName) return;
@ -5415,6 +5417,32 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
command.Append(flagString);
command.Append(")");
}
// date should never be 0, but just in case...
if (date)
{
/* Use PR_FormatTimeUSEnglish() to format the date in US English format,
then figure out what our local GMT offset is, and append it (since
PR_FormatTimeUSEnglish() can't do that.) Generate four digit years as
per RFC 1123 (superceding RFC 822.)
*/
char szDateTime[64];
char dateStr[100];
PRExplodedTime exploded;
PR_ExplodeTime(date, PR_LocalTimeParameters, &exploded);
PR_FormatTimeUSEnglish(szDateTime, sizeof(szDateTime), "%d-%b-%Y %H:%M:%S", &exploded);
PRExplodedTime now;
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &now);
int gmtoffset = (now.tm_params.tp_gmt_offset + now.tm_params.tp_dst_offset) / 60;
PR_snprintf(dateStr, sizeof(dateStr),
" \"%s %c%02d%02d\"",
szDateTime,
(gmtoffset >= 0 ? '+' : '-'),
((gmtoffset >= 0 ? gmtoffset : -gmtoffset) / 60),
((gmtoffset >= 0 ? gmtoffset : -gmtoffset) % 60));
command.Append(dateStr);
}
command.Append(" {");
dataBuffer = (char*) PR_CALLOC(COPY_BUFFER_SIZE+1);

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

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