本文整理汇总了C++中Encoding::Mime2UTF8方法的典型用法代码示例。如果您正苦于以下问题:C++ Encoding::Mime2UTF8方法的具体用法?C++ Encoding::Mime2UTF8怎么用?C++ Encoding::Mime2UTF8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoding
的用法示例。
在下文中一共展示了Encoding::Mime2UTF8方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: header
/***********************************************************
* SaveMails
***********************************************************/
void
HDaemonApp::SaveMail(const char* all_content,
entry_ref* folder_ref,
entry_ref *file_ref,
bool *is_delete)
{
fGotMails = true;
if(!fHaveNewMails)
fHaveNewMails = true;
BString header(""),subject(""),to(""),date(""),cc(""),from("")
,priority(""),reply(""),mime("");
Encoding encode;
bool is_multipart = false;
int32 org_len = strlen(all_content);
// Probably deleted with Spam filter
if(org_len == 0)
{
*is_delete = false;
return;
}
//
int32 header_len = 0;
for(int32 i = 0;i < org_len;i++)
{
if(strncasecmp(&all_content[i],"Subject:",8) == 0 && all_content[i-1] == '\n')
i = GetHeaderParam(subject,all_content,i+8);
else if(strncasecmp(&all_content[i],"Date:",5) == 0 && all_content[i-1] == '\n')
i = GetHeaderParam(date,all_content,i+5);
else if(strncasecmp(&all_content[i],"Cc:",3) == 0 && all_content[i-1] == '\n')
i = GetHeaderParam(cc,all_content,i+3);
else if(strncasecmp(&all_content[i],"To:",3) == 0 && all_content[i-1] == '\n')
i = GetHeaderParam(to,all_content,i+3);
else if(strncasecmp(&all_content[i],"From:",5) == 0 && all_content[i-1] == '\n')
i = GetHeaderParam(from,all_content,i+5);
else if(strncasecmp(&all_content[i],"X-Priority:",11) == 0 && all_content[i-1] == '\n')
i = GetHeaderParam(priority,all_content,i+11);
else if(strncasecmp(&all_content[i],"Mime-Version:",13) == 0 && all_content[i-1] == '\n')
i = GetHeaderParam(mime,all_content,i+13);
else if(strncasecmp(&all_content[i],"Reply-To:",9) == 0 && all_content[i-1] == '\n')
i = GetHeaderParam(reply,all_content,i+9);
else if(all_content[i] == '\r'||all_content[i] == '\n')
{
if(all_content[i-2] == '\r'||all_content[i-1] == '\n')
{
header_len = i+2;
break;
}
}
}
header.Append(all_content,header_len);
if(subject.Length() == 0)
subject = "Untitled";
if(strstr(header.String(),"Content-Type: multipart"))
is_multipart = true;
//PRINT(("From:%s\n",from.String()));
encode.Mime2UTF8(from);
//PRINT(("Decoded From:%s\n",from.String()));
encode.Mime2UTF8(to);
encode.Mime2UTF8(cc);
encode.Mime2UTF8(reply);
// convert mime subject to UTF8
encode.Mime2UTF8(subject);
// Filter mails
BString folder_path;
FilterMail(subject.String(),
from.String(),
to.String(),
cc.String(),
reply.String(),
folder_path);
//PRINT(("path:%s\n",folder_path.String() ));
// Save to disk
BPath path = folder_path.String();
::create_directory(path.Path(),0777);
BDirectory destDir(path.Path());
path.Append(subject.String());
//PRINT(("path:%s\n",path.Path() ));
// create the e-mail file
BFile file;
TrackerUtils().SmartCreateFile(&file,&destDir,path.Leaf(),"_");
// write e-mail attributes
file.Write(all_content,strlen(all_content));
file.SetSize(strlen(all_content));
file.WriteAttr(B_MAIL_ATTR_STATUS,B_STRING_TYPE,0,"New",4);
file.WriteAttrString(B_MAIL_ATTR_PRIORITY,&priority);
file.WriteAttrString(B_MAIL_ATTR_TO,&to);
file.WriteAttrString(B_MAIL_ATTR_CC,&cc);
file.WriteAttrString(B_MAIL_ATTR_FROM,&from);
file.WriteAttrString(B_MAIL_ATTR_SUBJECT,&subject);
//.........这里部分代码省略.........