本文整理汇总了C++中nsCOMPtr::GetMsgHdrForKey方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCOMPtr::GetMsgHdrForKey方法的具体用法?C++ nsCOMPtr::GetMsgHdrForKey怎么用?C++ nsCOMPtr::GetMsgHdrForKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCOMPtr
的用法示例。
在下文中一共展示了nsCOMPtr::GetMsgHdrForKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMessage
lpnsMapiMessage MsgMapiListContext::GetMessage (nsMsgKey key, unsigned long flFlags)
{
lpnsMapiMessage message = (lpnsMapiMessage) CoTaskMemAlloc (sizeof(nsMapiMessage));
memset(message, 0, sizeof(nsMapiMessage));
if (message)
{
nsCString subject;
nsCString author;
nsCOMPtr <nsIMsgDBHdr> msgHdr;
nsresult rv = m_db->GetMsgHdrForKey (key, getter_AddRefs(msgHdr));
if (msgHdr)
{
msgHdr->GetSubject (getter_Copies(subject));
message->lpszSubject = (char *) CoTaskMemAlloc(subject.Length() + 1);
strcpy((char *) message->lpszSubject, subject.get());
PRUint32 date;
(void) msgHdr->GetDateInSeconds(&date);
message->lpszDateReceived = ConvertDateToMapiFormat (date);
// Pull out the flags info
// anything to do with MAPI_SENT? Since we're only reading the Inbox, I guess not
PRUint32 ourFlags;
(void) msgHdr->GetFlags(&ourFlags);
if (!(ourFlags & MSG_FLAG_READ))
message->flFlags |= MAPI_UNREAD;
if (ourFlags & (MSG_FLAG_MDN_REPORT_NEEDED | MSG_FLAG_MDN_REPORT_SENT))
message->flFlags |= MAPI_RECEIPT_REQUESTED;
nsCOMPtr<nsIMsgHeaderParser> parser = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID);
if (!parser)
return nsnull;
// Pull out the author/originator info
message->lpOriginator = (lpnsMapiRecipDesc) CoTaskMemAlloc (sizeof(nsMapiRecipDesc));
memset(message->lpOriginator, 0, sizeof(nsMapiRecipDesc));
if (message->lpOriginator)
{
msgHdr->GetAuthor (getter_Copies(author));
ConvertRecipientsToMapiFormat (parser, author.get(), message->lpOriginator, MAPI_ORIG);
}
// Pull out the To/CC info
nsCString recipients, ccList;
msgHdr->GetRecipients(getter_Copies(recipients));
msgHdr->GetCcList(getter_Copies(ccList));
PRUint32 numToRecips;
PRUint32 numCCRecips;
parser->ParseHeaderAddresses(nsnull, recipients.get(), nsnull, nsnull, &numToRecips);
parser->ParseHeaderAddresses(nsnull, ccList.get(), nsnull, nsnull, &numCCRecips);
message->lpRecips = (lpnsMapiRecipDesc) CoTaskMemAlloc ((numToRecips + numCCRecips) * sizeof(MapiRecipDesc));
memset(message->lpRecips, 0, (numToRecips + numCCRecips) * sizeof(MapiRecipDesc));
if (message->lpRecips)
{
ConvertRecipientsToMapiFormat (parser, recipients.get(), message->lpRecips, MAPI_TO);
ConvertRecipientsToMapiFormat (parser, ccList.get(), &message->lpRecips[numToRecips], MAPI_CC);
}
PR_LOG(MAPI, PR_LOG_DEBUG, ("MsgMapiListContext::GetMessage flags=%x subject %s date %s sender %s\n",
flFlags, (char *) message->lpszSubject,(char *) message->lpszDateReceived, author.get()) );
// Convert any body text that we have locally
if (!(flFlags & MAPI_ENVELOPE_ONLY))
message->lpszNoteText = (char *) ConvertBodyToMapiFormat (msgHdr);
}
if (! (flFlags & (MAPI_PEEK | MAPI_ENVELOPE_ONLY)))
m_db->MarkRead(key, PR_TRUE, nsnull);
}
return message;
}
示例2: GetMessage
lpnsMapiMessage MsgMapiListContext::GetMessage (nsMsgKey key, unsigned long flFlags)
{
lpnsMapiMessage message = (lpnsMapiMessage) CoTaskMemAlloc (sizeof(nsMapiMessage));
memset(message, 0, sizeof(nsMapiMessage));
if (message)
{
nsCString subject;
nsCString author;
nsCOMPtr <nsIMsgDBHdr> msgHdr;
nsresult rv = m_db->GetMsgHdrForKey (key, getter_AddRefs(msgHdr));
if (msgHdr)
{
msgHdr->GetSubject (getter_Copies(subject));
message->lpszSubject = (char *) CoTaskMemAlloc(subject.Length() + 1);
strcpy((char *) message->lpszSubject, subject.get());
uint32_t date;
(void) msgHdr->GetDateInSeconds(&date);
message->lpszDateReceived = ConvertDateToMapiFormat (date);
// Pull out the flags info
// anything to do with MAPI_SENT? Since we're only reading the Inbox, I guess not
uint32_t ourFlags;
(void) msgHdr->GetFlags(&ourFlags);
if (!(ourFlags & nsMsgMessageFlags::Read))
message->flFlags |= MAPI_UNREAD;
if (ourFlags & (nsMsgMessageFlags::MDNReportNeeded | nsMsgMessageFlags::MDNReportSent))
message->flFlags |= MAPI_RECEIPT_REQUESTED;
// Pull out the author/originator info
message->lpOriginator = (lpnsMapiRecipDesc) CoTaskMemAlloc (sizeof(nsMapiRecipDesc));
memset(message->lpOriginator, 0, sizeof(nsMapiRecipDesc));
if (message->lpOriginator)
{
msgHdr->GetAuthor (getter_Copies(author));
ConvertRecipientsToMapiFormat(EncodedHeader(author),
message->lpOriginator, MAPI_ORIG);
}
// Pull out the To/CC info
nsCString recipients, ccList;
msgHdr->GetRecipients(getter_Copies(recipients));
msgHdr->GetCcList(getter_Copies(ccList));
nsCOMArray<msgIAddressObject> parsedToRecips = EncodedHeader(recipients);
nsCOMArray<msgIAddressObject> parsedCCRecips = EncodedHeader(ccList);
uint32_t numToRecips = parsedToRecips.Length();
uint32_t numCCRecips = parsedCCRecips.Length();
message->lpRecips = (lpnsMapiRecipDesc) CoTaskMemAlloc ((numToRecips + numCCRecips) * sizeof(MapiRecipDesc));
memset(message->lpRecips, 0, (numToRecips + numCCRecips) * sizeof(MapiRecipDesc));
if (message->lpRecips)
{
ConvertRecipientsToMapiFormat(parsedToRecips, message->lpRecips,
MAPI_TO);
ConvertRecipientsToMapiFormat(parsedCCRecips,
&message->lpRecips[numToRecips], MAPI_CC);
}
MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("MsgMapiListContext::GetMessage flags=%x subject %s date %s sender %s\n",
flFlags, (char *) message->lpszSubject,(char *) message->lpszDateReceived, author.get()) );
// Convert any body text that we have locally
if (!(flFlags & MAPI_ENVELOPE_ONLY))
message->lpszNoteText = (char *) ConvertBodyToMapiFormat (msgHdr);
}
if (! (flFlags & (MAPI_PEEK | MAPI_ENVELOPE_ONLY)))
m_db->MarkRead(key, true, nullptr);
}
return message;
}