mirror of https://github.com/djcb/mu.git
message: support embed:text in attached mail
As before; scan attached messages as well.
This commit is contained in:
parent
8844ddac23
commit
2a5c1e239c
|
@ -29,6 +29,7 @@
|
||||||
#include <utils/mu-util.h>
|
#include <utils/mu-util.h>
|
||||||
#include <utils/mu-utils.hh>
|
#include <utils/mu-utils.hh>
|
||||||
#include <utils/mu-error.hh>
|
#include <utils/mu-error.hh>
|
||||||
|
#include <utils/mu-option.hh>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -39,7 +40,6 @@
|
||||||
|
|
||||||
#include "gmime/gmime-message.h"
|
#include "gmime/gmime-message.h"
|
||||||
#include "mu-mime-object.hh"
|
#include "mu-mime-object.hh"
|
||||||
#include "mu-option.hh"
|
|
||||||
|
|
||||||
using namespace Mu;
|
using namespace Mu;
|
||||||
|
|
||||||
|
@ -372,6 +372,15 @@ looks_like_attachment(const MimeObject& parent,
|
||||||
return it != att_types.cend(); /* if found, it's an attachment */
|
return it != att_types.cend(); /* if found, it's an attachment */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
append_text(Option<std::string>& str, Option<std::string> app)
|
||||||
|
{
|
||||||
|
if (!str)
|
||||||
|
str = app;
|
||||||
|
else if (app)
|
||||||
|
str.value() += app.value();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
accumulate_text(const MimePart& part, Message::Private& info,
|
accumulate_text(const MimePart& part, Message::Private& info,
|
||||||
const MimeContentType& ctype)
|
const MimeContentType& ctype)
|
||||||
|
@ -379,19 +388,12 @@ accumulate_text(const MimePart& part, Message::Private& info,
|
||||||
if (!ctype.is_type("text", "*"))
|
if (!ctype.is_type("text", "*"))
|
||||||
return; /* not a text type */
|
return; /* not a text type */
|
||||||
|
|
||||||
auto append = [](Option<std::string>& str, Option<std::string> app) {
|
|
||||||
if (!str)
|
|
||||||
str = app;
|
|
||||||
else if (app)
|
|
||||||
str.value() += app.value();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (part.is_attachment())
|
if (part.is_attachment())
|
||||||
append(info.embedded, part.to_string());
|
append_text(info.embedded, part.to_string());
|
||||||
else if (ctype.is_type("text", "plain"))
|
else if (ctype.is_type("text", "plain"))
|
||||||
append(info.body_txt, part.to_string());
|
append_text(info.body_txt, part.to_string());
|
||||||
else if (ctype.is_type("text", "html"))
|
else if (ctype.is_type("text", "html"))
|
||||||
append(info.body_html, part.to_string());
|
append_text(info.body_html, part.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -410,6 +412,26 @@ process_part(const MimeObject& parent, const MimePart& part,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
process_message_part(const MimeMessagePart& msg_part,
|
||||||
|
Message::Private& info)
|
||||||
|
{
|
||||||
|
auto submsg{msg_part.get_message()};
|
||||||
|
submsg.for_each([&](auto&& parent, auto&& child_obj) {
|
||||||
|
|
||||||
|
/* XXX: we only handle one level */
|
||||||
|
|
||||||
|
if (!child_obj.is_part())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto ctype{child_obj.content_type()};
|
||||||
|
if (!ctype || !ctype->is_type("text", "*"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
append_text(info.embedded, MimePart{child_obj}.to_string());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_object(const MimeObject& parent,
|
handle_object(const MimeObject& parent,
|
||||||
const MimeObject& obj, Message::Private& info);
|
const MimeObject& obj, Message::Private& info);
|
||||||
|
@ -464,8 +486,9 @@ handle_object(const MimeObject& parent,
|
||||||
|
|
||||||
if (obj.is_part())
|
if (obj.is_part())
|
||||||
process_part(parent, obj, info);
|
process_part(parent, obj, info);
|
||||||
|
else if (obj.is_message_part())
|
||||||
if (obj.is_multipart_signed())
|
process_message_part(obj, info);
|
||||||
|
else if (obj.is_multipart_signed())
|
||||||
info.flags |= Flags::Signed;
|
info.flags |= Flags::Signed;
|
||||||
else if (obj.is_multipart_encrypted()) {
|
else if (obj.is_multipart_encrypted()) {
|
||||||
/* FIXME: An encrypted part might be signed at the same time.
|
/* FIXME: An encrypted part might be signed at the same time.
|
||||||
|
|
Loading…
Reference in New Issue