本文整理汇总了C++中Attachment::setContentID方法的典型用法代码示例。如果您正苦于以下问题:C++ Attachment::setContentID方法的具体用法?C++ Attachment::setContentID怎么用?C++ Attachment::setContentID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attachment
的用法示例。
在下文中一共展示了Attachment::setContentID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Attachment * Attachment::attachmentWithSingleMIME(struct mailmime * mime)
{
struct mailmime_data * data;
const char * bytes;
size_t length;
Attachment * result;
struct mailmime_single_fields single_fields;
char * str;
char * name;
char * filename;
char * content_id;
char * description;
char * loc;
Encoding encoding;
clist * ct_parameters;
MCAssert(mime->mm_type == MAILMIME_SINGLE);
result = new Attachment();
result->setUniqueID(mailcore::String::uuidString());
data = mime->mm_data.mm_single;
bytes = data->dt_data.dt_text.dt_data;
length = data->dt_data.dt_text.dt_length;
mailmime_single_fields_init(&single_fields, mime->mm_mime_fields, mime->mm_content_type);
encoding = encodingForMIMEEncoding(single_fields.fld_encoding, data->dt_encoding);
Data * mimeData;
mimeData = Data::dataWithBytes(bytes, (unsigned int) length);
mimeData = mimeData->decodedDataUsingEncoding(encoding);
result->setData(mimeData);
str = get_content_type_str(mime->mm_content_type);
result->setMimeType(String::stringWithUTF8Characters(str));
free(str);
name = single_fields.fld_content_name;
filename = single_fields.fld_disposition_filename;
content_id = single_fields.fld_id;
description = single_fields.fld_description;
loc = single_fields.fld_location;
ct_parameters = single_fields.fld_content->ct_parameters;
if (filename != NULL) {
result->setFilename(String::stringByDecodingMIMEHeaderValue(filename));
}
else if (name != NULL) {
result->setFilename(String::stringByDecodingMIMEHeaderValue(name));
}
if (content_id != NULL) {
result->setContentID(String::stringWithUTF8Characters(content_id));
}
if (description != NULL) {
result->setContentDescription(String::stringWithUTF8Characters(description));
}
if (single_fields.fld_content_charset != NULL) {
result->setCharset(String::stringByDecodingMIMEHeaderValue(single_fields.fld_content_charset));
}
if (loc != NULL) {
result->setContentLocation(String::stringWithUTF8Characters(loc));
}
if (ct_parameters != NULL) {
clistiter * iter = clist_begin(ct_parameters);
struct mailmime_parameter * param;
while (iter != NULL) {
param = (struct mailmime_parameter *) clist_content(iter);
if (param != NULL) {
if ((strcasecmp("name", param->pa_name) != 0) && (strcasecmp("charset", param->pa_name) != 0)) {
result->setContentTypeParameter(String::stringWithUTF8Characters(param->pa_name), String::stringWithUTF8Characters(param->pa_value));
}
}
iter = clist_next(iter);
}
}
if (single_fields.fld_disposition != NULL) {
if (single_fields.fld_disposition->dsp_type != NULL) {
if (single_fields.fld_disposition->dsp_type->dsp_type == MAILMIME_DISPOSITION_TYPE_INLINE) {
result->setInlineAttachment(true);
}
else if (single_fields.fld_disposition->dsp_type->dsp_type == MAILMIME_DISPOSITION_TYPE_ATTACHMENT) {
result->setAttachment(true);
}
}
}
return (Attachment *) result->autorelease();
}