接收时间和发送时间
nsParseMailbox.cpp中int nsParseMailMessageState::ParseHeaders ()这个函数对返回的日期串的解析,对于126邮件从一个文件夹移动到另一个文件夹中的操作,不知为什么传过来的时间总是当前的时间
造成每次移动后,原来的日期都不能正常显示,目前只是判断了如果 received 中的时间比 date中的时间新的话,则使用date的时间,具体为什么会传当前时间还要分析(实际过程:要移动的邮件copy完成后,会重新获取一下新位置的邮件信息,而126返回的串的日期是不正确的)
抓包先进行下面两个操作
146 uid copy 2166 "&V4NXPpCuTvY-"
146 OK COPY completed
147 uid store 2166 +FLAGS (\Deleted \Seen)
* 5 FETCH (FLAGS (\Deleted \Seen) UID 2166)
147 OK STORE completed
后面再获取:
7 UID fetch 1383299324 (UID RFC822.SIZE FLAGS BODY.PEEK)
* 16 FETCH (UID 1383299324 FLAGS (\Seen) RFC822.SIZE 1738 BODY {393}
Content-Type: multipart/alternative;
boundary="------------080906050404020303020606"
Date: 2014-04-28 16:22:18
From: he <hechengjin@richinfo.cn>
Message-ID: <535E0FBA.5010404@richinfo.cn>
Received: from hechengjin88 (unknown )
.by IMAP (Coremail) with SMTP id Oj3h3QDHMhkEgWdT;
.Mon, 05 May 2014 20:16:21 +0800 (CST)
Subject: xxxx
To: he <hechengjin88@126.com>
)
7 OK Fetch completed
即在移动邮件后,新邮件夹中每次重新从服务端获取新到的邮件的头信息,而不是读取本地的邮件信息,而从服务端返回的信息中日期是不正确的。
如何触发获取新邮件消息头的,本地又是如何存储的,移动的过程中除了在服务端执行命令外,本地双进行了哪些操作/ 这个过程能不能不请求服务端的消息头。
nsParseMailbox.cpp
读信页显示窗口时间的修改msghdrviewOverlay.js
增加通过 x-richinfo-localizeddate-received 获取时间值
nsMimeHtmlEmitter.cpp
中增加 x-richinfo-localizeddate-received获取对 received中日期解析及获取
关联字段的修改
nsMsgDBView.cpp
nsMsgDBView::CellTextForColumn
case 'd':// date
{
rv = FetchDate(msgHdr, aValue,true);
协议解析的修改
nsParseMailbox.cpp
nsParseMailMessageState:: ParseHeaders
case 'R': case 'r':
nsParseMailMessageState:: ParseFolderLine
nsParseMailMessageState:: ParseAFolderLine
nsImapMailFolder.cpp
nsImapMailFolder:: ParseAdoptedHeaderLine
nsImapMailFolder:: ParseMsgHdrs
IMAP请求的修改nsImapProtocol.cpp
#define IMAP_ENV_HEADERS "From To Cc Bcc Subject Date Message-ID Received " 最后加上一个空格,要不和后面的连接在一起了
#define IMAP_DB_HEADERS "Priority X-Priority References Newsgroups In-Reply-To Content-Type"
#define IMAP_ENV_AND_DB_HEADERS IMAP_ENV_HEADERS IMAP_DB_HEADERS
发送的请求
7 UID fetch 1382926263 (UID RFC822.SIZE FLAGS BODY.PEEK)
http://forums.mozillazine.org/viewtopic.php?f=39&t=729645http://forums.mozillazine.org/viewtopic.php?f=39&t=640808
Set the variable:
mailnews.use_received_date = true (boolean)
If you are using a POP3 account, that should suffice.
For a IMAP account, you should set also:
mailnews.customDBHeaders = Received (string)
In this way, the "Received" column will not be identical to the "Date" column anymore; now it shows the reception date on your mail server, that is generally considered to be a better choice.
扩展通过mailnews.customDBHeaders开关
https://addons.mozilla.org/zh-cn/thunderbird/addon/imap-received-date/
关于时区的设置
http://kb.mozillazine.org/Time_and_time_zone_settings
关于日期显示格式的设置
http://kb.mozillazine.org/Date_display_format
在线代码查找
http://mxr.mozilla.org/comm-esr17/
其它功能参考
http://apveening.a61.nl/software/
本帖最后由 hechengjin 于 2016-4-20 23:34 编辑
mailnews.display.date_senders_timezone; 为true 读信页会显示时区mailnews/local/src/nsParseMailbox.cpp
int nsParseMailMessageState::ParseHeaders () 目前的方案:收件箱里显示的是smtp服务器的时间,即received里的时间,而已发送里显示的是当前系统的时间即 data 里的时间,当两者不一致时会有出入.
另外收件箱里,只有data里的时间比smtp里的时间还早时,会显示data时间,这个是为了防止在移动邮件时,老是出现时间为执行当前操作的时间,原来的时间都找不到了,具体细节还要研究 D:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimedrft.cpp
#include "nsIDateTimeFormat.h"
#include "nsDateTimeFormatCID.h"
char *date = MimeHeaders_get(headers, HEADER_DATE, false, true); // "Tue, 27 May 2014 09:38:27 +0800"
nsresult rv = NS_OK;
nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
if (!mDateFormatter)
{
mDateFormatter = do_CreateInstance(NS_DATETIMEFORMAT_CONTRACTID, &rv);
}
nsCAutoString convertedDateString;
PRExplodedTime explodedMsgTime;
rv = static_cast<nsresult>(PR_ParseTimeStringToExplodedTime(date, false, &explodedMsgTime));
PRExplodedTime explodedCompTime;
PR_ExplodeTime(PR_ImplodeTime(&explodedMsgTime), PR_LocalTimeParameters, &explodedCompTime);
nsAutoString formattedDateString;
if (NS_SUCCEEDED(rv))
{
rv = mDateFormatter->FormatPRExplodedTime(nullptr /* nsILocale* locale */,
kDateFormatShort,
kTimeFormatNoSeconds,
&explodedCompTime,
formattedDateString);//formattedDateString = 2014-5-27 9:38
if (NS_SUCCEEDED(rv))
{
CopyUTF16toUTF8(formattedDateString, convertedDateString);
char *result = 0;
result = (char *) PR_MALLOC(100);
memcpy(result, convertedDateString.get(), convertedDateString.Length());
result = 0;
mime_intl_insert_message_header_1(&newBody, &result, HEADER_DATE,
MimeGetNamedString(MIME_MHTML_DATE),
mailcharset, htmlEdit);
}
else
{
mime_intl_insert_message_header_1(&newBody, &date, HEADER_DATE,
MimeGetNamedString(MIME_MHTML_DATE),
mailcharset, htmlEdit);
}
}
D:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\extensions\mdn\src\nsMsgMdnGenerator.cpp
char opertorTime = {0};// "Tue, 27 May 2014 09:38:27 +0800"
PR_FormatTimeUSEnglish(opertorTime, 50,
"Date: %a, %d %b %Y %H:%M:%S ",
&now);
PR_snprintf(opertorTime + strlen(opertorTime), 50,
"%c%02d%02d" CRLF,
(gmtoffset >= 0 ? '+' : '-'),
((gmtoffset >= 0 ? gmtoffset : -gmtoffset) / 60),
((gmtoffset >= 0 ? gmtoffset : -gmtoffset) % 60));
nsresult rv2 = NS_OK;
nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
if (!mDateFormatter)
{
mDateFormatter = do_CreateInstance(NS_DATETIMEFORMAT_CONTRACTID, &rv);
}
nsCAutoString convertedDateString;
PRExplodedTime explodedMsgTime;
rv2 = static_cast<nsresult>(PR_ParseTimeStringToExplodedTime(opertorTime, false, &explodedMsgTime));
PRExplodedTime explodedCompTime;
PR_ExplodeTime(PR_ImplodeTime(&explodedMsgTime), PR_LocalTimeParameters, &explodedCompTime);
nsAutoString formattedDateString;
if (NS_SUCCEEDED(rv2))
{
rv = mDateFormatter->FormatPRExplodedTime(nullptr /* nsILocale* locale */,
kDateFormatShort,
kTimeFormatSeconds,
&explodedCompTime,
formattedDateString);//formattedDateString = 2014-5-27 9:38:27
}
firstPart1.AppendLiteral(CRLF);
firstPart1.Append(formattedDateString);
///////////////
页:
[1]