it should work this way. MIME-13 is implemented completely. I hope so. Now... let's test it! :-D

MIME-13
Roker 3 years ago
parent b57fb0331a
commit 13d68fb7bf

@ -91,13 +91,13 @@ void Attachment::write_mime_headers(std::string& out) const
}
SAttachments parse_attachments(const bloblist_t* b)
SAttachments parse_attachments(const bloblist_t* b, bool has_pEp_msg_attachment)
{
unsigned nr_in_bloblist = 0;
SAttachments ret;
while(b)
{
ret.emplace_back(b, nr_in_bloblist);
ret.emplace_back(b, nr_in_bloblist, has_pEp_msg_attachment);
b = b->next;
++nr_in_bloblist;
}

@ -17,27 +17,30 @@ namespace pEpMIME
// refers to data in a bloblist_t. Does NOT any data!
struct Attachment
{
explicit Attachment(const bloblist_t* b, unsigned nr_in_bloblist)
explicit Attachment(const bloblist_t* b, unsigned nr_in_bloblist, bool has_pEp_msg_attachment)
: data{b->size ? sv{b->value, b->size} : sv{}}
, mime_type{b->mime_type}
, filename{exists(b->filename) ? b->filename : sv{}}
, dtype{b->disposition}
, need_te{need_transport_encoding(data)}
, nr{nr_in_bloblist}
{
if(::pEpMIME::is_inline(b))
{
dtype = PEP_CONTENT_DISP_INLINE;
}
if((mime_type=="message/rfc822") && (nr_in_bloblist==0) && has_pEp_msg_attachment)
{
mime_type += "; forwarded=\"no\"";
}
}
Attachment(sv _data, sv _mime_type, unsigned nr_in_bloblist)
Attachment(sv _data, sv _mime_type)
: data{_data}
, mime_type{_mime_type}
, filename{}
, dtype{ PEP_CONTENT_DISP_OTHER }
, need_te{ need_transport_encoding(data) }
, nr{ nr_in_bloblist }
{ }
@ -49,16 +52,15 @@ namespace pEpMIME
}
sv data;
sv mime_type;
std::string mime_type;
sv filename;
content_disposition_type dtype;
bool need_te; // need transport encoding
unsigned nr;
};
typedef std::vector<Attachment> SAttachments;
SAttachments parse_attachments(const bloblist_t* att);
SAttachments parse_attachments(const bloblist_t* att, bool has_pEp_msg_attachment);
inline
bool all(const Attachment&) { return true; }

@ -101,7 +101,7 @@ void generate_ma_body(std::string& smsg, sv plain_mimetype, sv plain, sv html)
void generate_mm_body(std::string& smsg, sv mime_type, sv body, const std::vector<Attachment>& a)
{
std::vector<Attachment> a2{a};
a2.emplace_back(body, mime_type, a2.size());
a2.emplace_back(body, mime_type);
const std::string delimiter = create_delimiter(a2);
@ -126,10 +126,10 @@ void generate_complex_body(std::string& smsg, unsigned det, const message* msg,
std::vector<Attachment> a2{a};
if(msg->longmsg)
a2.emplace_back(msg->longmsg, longmsg_mimetype, a2.size());
a2.emplace_back(msg->longmsg, longmsg_mimetype);
if(msg->longmsg_formatted)
a2.emplace_back(msg->longmsg_formatted, "text/html", a2.size());
a2.emplace_back(msg->longmsg_formatted, "text/html");
// basic delimiter:
const std::string delimiter = create_delimiter(a2) + "/" + std::to_string(det) + "/";

@ -220,7 +220,7 @@ char* generate_message(const message* msg_orig, bool omit_fields, bool has_pEp_m
msg.add_header(Pseudo_Header_Forwarded, "no");
}
const auto attachments = parse_attachments(msg->attachments);
const auto attachments = parse_attachments(msg->attachments, has_pEp_msg_attachment);
const unsigned inline_attachments = std::count_if(
attachments.cbegin(), attachments.cend(),
[](const Attachment& a) { return a.is_inline(); }

Loading…
Cancel
Save