many: update for lib/message updates

Adapt to the new names / directory. Big commit, but mostly just very boring renaming.
This commit is contained in:
Dirk-Jan C. Binnema 2022-03-20 14:12:41 +02:00
parent 4c4fb1759f
commit f7c84006d7
32 changed files with 528 additions and 580 deletions

View File

@ -18,7 +18,7 @@
*/ */
#include "mu-guile-message.hh" #include "mu-guile-message.hh"
#include "libguile/scm.h" #include "libguile/scm.h"
#include "mu-message.hh" #include "message/mu-message.hh"
#include <config.h> #include <config.h>
#include <glib-object.h> #include <glib-object.h>
@ -36,10 +36,9 @@
#include <mu-msg-part.hh> #include <mu-msg-part.hh>
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
/* pseudo field, not in Xapian */ /* pseudo field, not in Xapian */
constexpr auto MU_GUILE_MSG_FIELD_ID_TIMESTAMP = MessageField::id_size() + 1; constexpr auto MU_GUILE_MSG_FIELD_ID_TIMESTAMP = Field::id_size() + 1;
/* some symbols */ /* some symbols */
static SCM SYMB_PRIO_LOW, SYMB_PRIO_NORMAL, SYMB_PRIO_HIGH; static SCM SYMB_PRIO_LOW, SYMB_PRIO_NORMAL, SYMB_PRIO_HIGH;
@ -74,8 +73,8 @@ mu_guile_msg_to_scm(MuMsg* msg)
} }
typedef struct { typedef struct {
MessageFlags flags; Flags flags;
SCM lst; SCM lst;
} FlagData; } FlagData;
#define MU_GUILE_INITIALIZED_OR_ERROR \ #define MU_GUILE_INITIALIZED_OR_ERROR \
@ -109,9 +108,9 @@ static SCM
get_prio_scm(MuMsg* msg) get_prio_scm(MuMsg* msg)
{ {
switch (mu_msg_get_prio(msg)) { switch (mu_msg_get_prio(msg)) {
case MessagePriority::Low: return SYMB_PRIO_LOW; case Priority::Low: return SYMB_PRIO_LOW;
case MessagePriority::Normal: return SYMB_PRIO_NORMAL; case Priority::Normal: return SYMB_PRIO_NORMAL;
case MessagePriority::High: return SYMB_PRIO_HIGH; case Priority::High: return SYMB_PRIO_HIGH;
default: g_return_val_if_reached(SCM_UNDEFINED); default: g_return_val_if_reached(SCM_UNDEFINED);
} }
@ -181,10 +180,10 @@ SCM_DEFINE(get_field,
if (field_id == MU_GUILE_MSG_FIELD_ID_TIMESTAMP) if (field_id == MU_GUILE_MSG_FIELD_ID_TIMESTAMP)
return scm_from_uint((unsigned)mu_msg_get_timestamp(msgwrap->_msg)); return scm_from_uint((unsigned)mu_msg_get_timestamp(msgwrap->_msg));
const auto opt_id{message_field_id(static_cast<size_t>(field_id))}; const auto field_opt{field_from_number(static_cast<size_t>(field_id))};
SCM_ASSERT(!!opt_id, FIELD, SCM_ARG2, FUNC_NAME); SCM_ASSERT(!!field_opt, FIELD, SCM_ARG2, FUNC_NAME);
switch (*opt_id) { switch (field_opt->id) {
case Field::Id::Priority: case Field::Id::Priority:
return get_prio_scm(msgwrap->_msg); return get_prio_scm(msgwrap->_msg);
case Field::Id::Flags: case Field::Id::Flags:
@ -197,16 +196,17 @@ SCM_DEFINE(get_field,
default: break; default: break;
} }
switch (message_field(*opt_id).type) { switch (field_opt->type) {
case Field::Type::String: case Field::Type::String:
return mu_guile_scm_from_str(mu_msg_get_field_string(msgwrap->_msg, *opt_id)); return mu_guile_scm_from_str(mu_msg_get_field_string(msgwrap->_msg,
field_opt->id));
case Field::Type::ByteSize: case Field::Type::ByteSize:
case Field::Type::TimeT: case Field::Type::TimeT:
return scm_from_uint(mu_msg_get_field_numeric(msgwrap->_msg, *opt_id)); return scm_from_uint(mu_msg_get_field_numeric(msgwrap->_msg, field_opt->id));
case Field::Type::Integer: case Field::Type::Integer:
return scm_from_int(mu_msg_get_field_numeric(msgwrap->_msg, *opt_id)); return scm_from_int(mu_msg_get_field_numeric(msgwrap->_msg, field_opt->id));
case Field::Type::StringList: case Field::Type::StringList:
return msg_string_list_field(msgwrap->_msg, *opt_id); return msg_string_list_field(msgwrap->_msg, field_opt->id);
default: SCM_ASSERT(0, FIELD, SCM_ARG2, FUNC_NAME); default: SCM_ASSERT(0, FIELD, SCM_ARG2, FUNC_NAME);
} }
} }
@ -472,7 +472,7 @@ define_symbols(void)
static void static void
define_vars(void) define_vars(void)
{ {
message_field_for_each([](auto&& field){ field_for_each([](auto&& field){
const auto name{"mu:field:" + std::string{field.name}}; const auto name{"mu:field:" + std::string{field.name}};
scm_c_define(name.c_str(), scm_from_uint(field.value_no())); scm_c_define(name.c_str(), scm_from_uint(field.value_no()));
scm_c_export(name.c_str(), NULL); scm_c_export(name.c_str(), NULL);

View File

@ -44,7 +44,7 @@ struct EmailEqual {
} }
}; };
using ContactUMap = std::unordered_map<const std::string, MessageContact, EmailHash, EmailEqual>; using ContactUMap = std::unordered_map<const std::string, Contact, EmailHash, EmailEqual>;
struct ContactsCache::Private { struct ContactsCache::Private {
Private(const std::string& serialized, const StringVec& personal) Private(const std::string& serialized, const StringVec& personal)
: contacts_{deserialize(serialized)}, : contacts_{deserialize(serialized)},
@ -126,7 +126,7 @@ ContactsCache::Private::deserialize(const std::string& serialized) const
g_warning("error: '%s'", line.c_str()); g_warning("error: '%s'", line.c_str());
continue; continue;
} }
MessageContact ci(parts[1], // email Contact ci(parts[1], // email
std::move(parts[2]), // name std::move(parts[2]), // name
(time_t)g_ascii_strtoll(parts[4].c_str(), NULL, 10), // message_date (time_t)g_ascii_strtoll(parts[4].c_str(), NULL, 10), // message_date
parts[3][0] == '1' ? true : false, // personal parts[3][0] == '1' ? true : false, // personal
@ -182,9 +182,9 @@ ContactsCache::dirty() const
return priv_->dirty_; return priv_->dirty_;
} }
//const MessageContact //const Contact
void void
ContactsCache::add(MessageContact&& contact) ContactsCache::add(Contact&& contact)
{ {
std::lock_guard<std::mutex> l_{priv_->mtx_}; std::lock_guard<std::mutex> l_{priv_->mtx_};
@ -219,7 +219,7 @@ ContactsCache::add(MessageContact&& contact)
} }
} }
const MessageContact* const Contact*
ContactsCache::_find(const std::string& email) const ContactsCache::_find(const std::string& email) const
{ {
std::lock_guard<std::mutex> l_{priv_->mtx_}; std::lock_guard<std::mutex> l_{priv_->mtx_};
@ -251,19 +251,19 @@ ContactsCache::size() const
/** /**
* This is used for sorting the MessageContacts in order of relevance. A highly * This is used for sorting the Contacts in order of relevance. A highly
* specific algorithm, but the details don't matter _too_ much. * specific algorithm, but the details don't matter _too_ much.
* *
* This is currently used for the ordering in mu-cfind and auto-completion in * This is currently used for the ordering in mu-cfind and auto-completion in
* mu4e, if the various completion methods don't override it... * mu4e, if the various completion methods don't override it...
*/ */
constexpr auto RecentOffset{15 * 24 * 3600}; constexpr auto RecentOffset{15 * 24 * 3600};
struct MessageContactLessThan { struct ContactLessThan {
MessageContactLessThan() ContactLessThan()
: recently_{::time({}) - RecentOffset} {} : recently_{::time({}) - RecentOffset} {}
bool operator()(const Mu::MessageContact& ci1, const Mu::MessageContact& ci2) const bool operator()(const Mu::Contact& ci1, const Mu::Contact& ci2) const
{ {
// non-personal is less relevant. // non-personal is less relevant.
if (ci1.personal != ci2.personal) if (ci1.personal != ci2.personal)
@ -286,8 +286,8 @@ struct MessageContactLessThan {
const time_t recently_; const time_t recently_;
}; };
using ContactSet = std::set<std::reference_wrapper<const MessageContact>, using ContactSet = std::set<std::reference_wrapper<const Contact>,
MessageContactLessThan>; ContactLessThan>;
void void
ContactsCache::for_each(const EachContactFunc& each_contact) const ContactsCache::for_each(const EachContactFunc& each_contact) const
@ -338,22 +338,22 @@ test_mu_contacts_cache_base()
g_assert_true(contacts.empty()); g_assert_true(contacts.empty());
g_assert_cmpuint(contacts.size(), ==, 0); g_assert_cmpuint(contacts.size(), ==, 0);
contacts.add(Mu::MessageContact("foo.bar@example.com", contacts.add(Mu::Contact("foo.bar@example.com",
"Foo", {}, 12345)); "Foo", {}, 12345));
g_assert_false(contacts.empty()); g_assert_false(contacts.empty());
g_assert_cmpuint(contacts.size(), ==, 1); g_assert_cmpuint(contacts.size(), ==, 1);
contacts.add(Mu::MessageContact("cuux@example.com", "Cuux", {}, contacts.add(Mu::Contact("cuux@example.com", "Cuux", {},
54321)); 54321));
g_assert_cmpuint(contacts.size(), ==, 2); g_assert_cmpuint(contacts.size(), ==, 2);
contacts.add( contacts.add(
Mu::MessageContact("foo.bar@example.com", "Foo", {}, 77777)); Mu::Contact("foo.bar@example.com", "Foo", {}, 77777));
g_assert_cmpuint(contacts.size(), ==, 2); g_assert_cmpuint(contacts.size(), ==, 2);
contacts.add( contacts.add(
Mu::MessageContact("Foo.Bar@Example.Com", "Foo", {}, 88888)); Mu::Contact("Foo.Bar@Example.Com", "Foo", {}, 88888));
g_assert_cmpuint(contacts.size(), ==, 2); g_assert_cmpuint(contacts.size(), ==, 2);
// note: replaces first. // note: replaces first.
@ -417,31 +417,31 @@ test_mu_contacts_cache_sort()
{ /* recent messages, older comes first */ { /* recent messages, older comes first */
Mu::ContactsCache ccache(""); Mu::ContactsCache ccache("");
ccache.add(Mu::MessageContact{"a@example.com", "a", now, true, 1000, 0}); ccache.add(Mu::Contact{"a@example.com", "a", now, true, 1000, 0});
ccache.add(Mu::MessageContact{"b@example.com", "b", now-1, true, 1000, 0}); ccache.add(Mu::Contact{"b@example.com", "b", now-1, true, 1000, 0});
assert_equal(result_chars(ccache), "ba"); assert_equal(result_chars(ccache), "ba");
} }
{ /* non-recent messages, less frequent comes first */ { /* non-recent messages, less frequent comes first */
Mu::ContactsCache ccache(""); Mu::ContactsCache ccache("");
ccache.add(Mu::MessageContact{"a@example.com", "a", now-2*RecentOffset, true, 1000, 0}); ccache.add(Mu::Contact{"a@example.com", "a", now-2*RecentOffset, true, 1000, 0});
ccache.add(Mu::MessageContact{"b@example.com", "b", now-3*RecentOffset, true, 2000, 0}); ccache.add(Mu::Contact{"b@example.com", "b", now-3*RecentOffset, true, 2000, 0});
assert_equal(result_chars(ccache), "ab"); assert_equal(result_chars(ccache), "ab");
} }
{ /* non-personal comes first */ { /* non-personal comes first */
Mu::ContactsCache ccache(""); Mu::ContactsCache ccache("");
ccache.add(Mu::MessageContact{"a@example.com", "a", now-5*RecentOffset, true, 1000, 0}); ccache.add(Mu::Contact{"a@example.com", "a", now-5*RecentOffset, true, 1000, 0});
ccache.add(Mu::MessageContact{"b@example.com", "b", now, false, 8000, 0}); ccache.add(Mu::Contact{"b@example.com", "b", now, false, 8000, 0});
assert_equal(result_chars(ccache), "ba"); assert_equal(result_chars(ccache), "ba");
} }
{ /* if all else fails, alphabetically */ { /* if all else fails, alphabetically */
Mu::ContactsCache ccache(""); Mu::ContactsCache ccache("");
ccache.add(Mu::MessageContact{"a@example.com", "a", now, false, 1000, 0}); ccache.add(Mu::Contact{"a@example.com", "a", now, false, 1000, 0});
ccache.add(Mu::MessageContact{"b@example.com", "b", now, false, 1000, 0}); ccache.add(Mu::Contact{"b@example.com", "b", now, false, 1000, 0});
g_assert_cmpuint(ccache.size(),==,2); g_assert_cmpuint(ccache.size(),==,2);
assert_equal(result_chars(ccache), "ab"); assert_equal(result_chars(ccache), "ab");
} }

View File

@ -30,7 +30,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <utils/mu-utils.hh> #include <utils/mu-utils.hh>
#include "mu-message-contact.hh" #include <message/mu-message.hh>
namespace Mu { namespace Mu {
@ -53,19 +53,19 @@ public:
/** /**
* Add a contact * Add a contact
* *
* @param contact a MessageContact object * @param contact a Contact object
* *
*/ */
void add(MessageContact&& contact); void add(Contact&& contact);
/** /**
* Add a contacts sequemce * Add a contacts sequemce
* *
* @param contacts a MessageContact object sequence * @param contacts a Contact object sequence
* *
*/ */
void add(MessageContacts&& contacts) { void add(Contacts&& contacts) {
for (auto&& contact: contacts) for (auto&& contact: contacts)
add(std::move(contact)); add(std::move(contact));
} }
@ -124,14 +124,14 @@ public:
* *
* @return contact info, or {} if not found * @return contact info, or {} if not found
*/ */
const MessageContact* _find(const std::string& email) const; const Contact* _find(const std::string& email) const;
/** /**
* Prototype for a callable that receives a contact * Prototype for a callable that receives a contact
* *
* @param contact some contact * @param contact some contact
*/ */
using EachContactFunc = std::function<void(const MessageContact& contact_info)>; using EachContactFunc = std::function<void(const Contact& contact_info)>;
/** /**
* Invoke some callable for each contact, in order of rank. * Invoke some callable for each contact, in order of rank.

View File

@ -24,7 +24,7 @@
#include <iostream> #include <iostream>
#include <regex> #include <regex>
#include <mu-message.hh> #include <message/mu-message.hh>
#include <utils/mu-utils.hh> #include <utils/mu-utils.hh>
namespace Mu { namespace Mu {
@ -38,11 +38,11 @@ struct Data {
Type type; /**< type of data */ Type type; /**< type of data */
std::string field; /**< full name of the field */ std::string field; /**< full name of the field */
std::string prefix; /**< Xapian prefix for thef field */ std::string prefix; /**< Xapian prefix for thef field */
Message::Field::Id id; /**< Xapian value no for the field */ Field::Id id; /**< The field */
protected: protected:
Data(Type _type, const std::string& _field, const std::string& _prefix, Data(Type _type, const std::string& _field, const std::string& _prefix,
Message::Field::Id _id) Field::Id _id)
: type(_type), field(_field), prefix(_prefix), id(_id) : type(_type), field(_field), prefix(_prefix), id(_id)
{ {
} }
@ -82,7 +82,7 @@ struct Range : public Data {
*/ */
Range(const std::string& _field, Range(const std::string& _field,
const std::string& _prefix, const std::string& _prefix,
Message::Field::Id _id, Field::Id _id,
const std::string& _lower, const std::string& _lower,
const std::string& _upper) const std::string& _upper)
: :
@ -110,7 +110,7 @@ struct Value : public Data {
*/ */
Value(const std::string& _field, Value(const std::string& _field,
const std::string& _prefix, const std::string& _prefix,
Message::Field::Id _id, Field::Id _id,
const std::string& _value, const std::string& _value,
bool _phrase = false) bool _phrase = false)
: Data(Value::Type::Value, _field, _prefix, _id), value(_value), phrase(_phrase) : Data(Value::Type::Value, _field, _prefix, _id), value(_value), phrase(_phrase)

View File

@ -34,7 +34,6 @@
#include "glibconfig.h" #include "glibconfig.h"
#include "mu-maildir.hh" #include "mu-maildir.hh"
#include "mu-message-flags.hh"
#include "utils/mu-utils.hh" #include "utils/mu-utils.hh"
#include "utils/mu-util.h" #include "utils/mu-util.h"
@ -93,7 +92,7 @@ create_maildir(const std::string& path, mode_t mode)
return Ok(); return Ok();
} }
static Mu::Result<void> /* create a noindex file if requested */ static Mu::Result<void> /* create a noindex file if requested */
create_noindex(const std::string& path) create_noindex(const std::string& path)
{ {
const auto noindexpath{path + G_DIR_SEPARATOR_S MU_MAILDIR_NOINDEX_FILE}; const auto noindexpath{path + G_DIR_SEPARATOR_S MU_MAILDIR_NOINDEX_FILE};
@ -309,7 +308,7 @@ base_message_dir_file(const std::string& path)
Mu::Result<Mu::MessageFlags> Mu::Result<Mu::Flags>
Mu::mu_maildir_flags_from_path(const std::string& path) Mu::mu_maildir_flags_from_path(const std::string& path)
{ /* { /*
* this gets us the source maildir filesystem path, the directory * this gets us the source maildir filesystem path, the directory
@ -321,11 +320,11 @@ Mu::mu_maildir_flags_from_path(const std::string& path)
/* a message under new/ is just.. New. Filename is not considered */ /* a message under new/ is just.. New. Filename is not considered */
if (dirfile->is_new) if (dirfile->is_new)
return Ok(MessageFlags::New); return Ok(Flags::New);
/* it's cur/ message, so parse the file name */ /* it's cur/ message, so parse the file name */
const auto parts{message_file_parts(dirfile->file)}; const auto parts{message_file_parts(dirfile->file)};
auto flags{message_flags_from_absolute_expr(parts.flags_suffix, auto flags{flags_from_absolute_expr(parts.flags_suffix,
true/*ignore invalid*/)}; true/*ignore invalid*/)};
if (!flags) if (!flags)
return Err(Error{Error::Code::InvalidArgument, return Err(Error{Error::Code::InvalidArgument,
@ -433,8 +432,8 @@ msg_move(const std::string& src, const std::string& dst)
Mu::Result<void> Mu::Result<void>
Mu::mu_maildir_move_message(const std::string& oldpath, Mu::mu_maildir_move_message(const std::string& oldpath,
const std::string& newpath, const std::string& newpath,
bool ignore_dups) bool ignore_dups)
{ {
if (oldpath == newpath) { if (oldpath == newpath) {
if (ignore_dups) if (ignore_dups)
@ -468,7 +467,7 @@ reinvent_filename_base()
* @return the destion filename. * @return the destion filename.
*/ */
static std::string static std::string
determine_dst_filename(const std::string& file, MessageFlags flags, determine_dst_filename(const std::string& file, Flags flags,
bool new_name) bool new_name)
{ {
/* Recalculate a unique new base file name */ /* Recalculate a unique new base file name */
@ -478,12 +477,12 @@ determine_dst_filename(const std::string& file, MessageFlags flags,
/* for a New message, there are no flags etc.; so we only return the /* for a New message, there are no flags etc.; so we only return the
* name sans suffix */ * name sans suffix */
if (any_of(flags & MessageFlags::New)) if (any_of(flags & Flags::New))
return std::move(parts.base); return std::move(parts.base);
const auto flagstr{ const auto flagstr{
message_flags_to_string( flags_to_string(
message_flags_filter( flags_filter(
flags, MessageFlagCategory::Mailfile))}; flags, MessageFlagCategory::Mailfile))};
return parts.base + parts.separator + "2," + flagstr; return parts.base + parts.separator + "2," + flagstr;
@ -497,7 +496,7 @@ static Mu::Result<void>
check_determine_target_params (const std::string& old_path, check_determine_target_params (const std::string& old_path,
const std::string& root_maildir_path, const std::string& root_maildir_path,
const std::string& target_maildir, const std::string& target_maildir,
MessageFlags newflags) Flags newflags)
{ {
if (!g_path_is_absolute(old_path.c_str())) if (!g_path_is_absolute(old_path.c_str()))
return Err(Error{Error::Code::File, return Err(Error{Error::Code::File,
@ -518,7 +517,7 @@ check_determine_target_params (const std::string& old_path,
"old-path must be below root-maildir (%s) (%s)", "old-path must be below root-maildir (%s) (%s)",
old_path.c_str(), root_maildir_path.c_str()}); old_path.c_str(), root_maildir_path.c_str()});
if (any_of(newflags & MessageFlags::New) && newflags != MessageFlags::New) if (any_of(newflags & Flags::New) && newflags != Flags::New)
return Err(Error{Error::Code::File, return Err(Error{Error::Code::File,
"if ::New is specified, " "if ::New is specified, "
"it must be the only flag"}); "it must be the only flag"});
@ -530,7 +529,7 @@ Mu::Result<std::string>
Mu::mu_maildir_determine_target(const std::string& old_path, Mu::mu_maildir_determine_target(const std::string& old_path,
const std::string& root_maildir_path, const std::string& root_maildir_path,
const std::string& target_maildir, const std::string& target_maildir,
MessageFlags newflags, Flags newflags,
bool new_name) bool new_name)
{ {
/* sanity checks */ /* sanity checks */
@ -557,7 +556,7 @@ Mu::mu_maildir_determine_target(const std::string& old_path,
/* and the complete path name. */ /* and the complete path name. */
const auto subdir = std::invoke([&]()->std::string { const auto subdir = std::invoke([&]()->std::string {
if (none_of(newflags & MessageFlags::New)) if (none_of(newflags & Flags::New))
return "cur"; return "cur";
else else
return "new"; return "new";

View File

@ -27,7 +27,7 @@
#include <glib.h> #include <glib.h>
#include <time.h> #include <time.h>
#include <sys/types.h> /* for mode_t */ #include <sys/types.h> /* for mode_t */
#include <mu-message-flags.hh> #include <message/mu-message.hh>
namespace Mu { namespace Mu {
@ -81,7 +81,7 @@ Result<void> mu_maildir_clear_links(const std::string& dir);
* *
* @return the message flags or an error * @return the message flags or an error
*/ */
Result<MessageFlags> mu_maildir_flags_from_path(const std::string& pathname); Result<Flags> mu_maildir_flags_from_path(const std::string& pathname);
/** /**
* get the maildir for a certain message path, ie, the path *before* * get the maildir for a certain message path, ie, the path *before*
@ -135,7 +135,7 @@ Result<std::string>
mu_maildir_determine_target(const std::string& old_path, mu_maildir_determine_target(const std::string& old_path,
const std::string& root_maildir_path, const std::string& root_maildir_path,
const std::string& target_maildir, const std::string& target_maildir,
MessageFlags newflags, Flags newflags,
bool new_name); bool new_name);
} // namespace Mu } // namespace Mu

View File

@ -32,7 +32,6 @@
#include "utils/mu-xapian-utils.hh" #include "utils/mu-xapian-utils.hh"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
struct Mu::MuMsgDoc { struct Mu::MuMsgDoc {
MuMsgDoc(Xapian::Document* doc) : _doc(doc) {} MuMsgDoc(Xapian::Document* doc) : _doc(doc) {}
@ -75,7 +74,7 @@ Mu::mu_msg_doc_get_str_field(MuMsgDoc* self, Field::Id field_id)
return xapian_try( return xapian_try(
[&] { [&] {
const auto value_no{message_field(field_id).value_no()}; const auto value_no{field_from_id(field_id).value_no()};
const std::string s(self->doc().get_value(value_no)); const std::string s(self->doc().get_value(value_no));
return s.empty() ? NULL : g_strdup(s.c_str()); return s.empty() ? NULL : g_strdup(s.c_str());
}, },
@ -86,12 +85,12 @@ GSList*
Mu::mu_msg_doc_get_str_list_field(MuMsgDoc* self, Field::Id field_id) Mu::mu_msg_doc_get_str_list_field(MuMsgDoc* self, Field::Id field_id)
{ {
g_return_val_if_fail(self, NULL); g_return_val_if_fail(self, NULL);
g_return_val_if_fail(message_field(field_id).type == Field::Type::StringList, NULL); g_return_val_if_fail(field_from_id(field_id).type == Field::Type::StringList, NULL);
return xapian_try( return xapian_try(
[&] { [&] {
/* return a comma-separated string as a GSList */ /* return a comma-separated string as a GSList */
const auto value_no{message_field(field_id).value_no()}; const auto value_no{field_from_id(field_id).value_no()};
const std::string s(self->doc().get_value(value_no)); const std::string s(self->doc().get_value(value_no));
return s.empty() ? NULL : mu_str_to_list(s.c_str(), ',', TRUE); return s.empty() ? NULL : mu_str_to_list(s.c_str(), ',', TRUE);
}, },
@ -102,11 +101,11 @@ gint64
Mu::mu_msg_doc_get_num_field(MuMsgDoc* self, Field::Id field_id) Mu::mu_msg_doc_get_num_field(MuMsgDoc* self, Field::Id field_id)
{ {
g_return_val_if_fail(self, -1); g_return_val_if_fail(self, -1);
g_return_val_if_fail(message_field(field_id).is_numerical(), -1); g_return_val_if_fail(field_from_id(field_id).is_numerical(), -1);
return xapian_try( return xapian_try(
[&] { [&] {
const auto value_no{message_field(field_id).value_no()}; const auto value_no{field_from_id(field_id).value_no()};
const std::string s(self->doc().get_value(value_no)); const std::string s(self->doc().get_value(value_no));
if (s.empty()) if (s.empty())
return (gint64)0; return (gint64)0;

View File

@ -55,35 +55,35 @@ void mu_msg_doc_destroy(MuMsgDoc* self);
* get a string parameter from the msgdoc * get a string parameter from the msgdoc
* *
* @param self a MuMsgDoc instance * @param self a MuMsgDoc instance
* @param mfid a Message::Field::Id for a string field * @param mfid a Field::Id for a string field
* *
* @return a string for the given field (see do_free), or NULL in case of error. * @return a string for the given field (see do_free), or NULL in case of error.
* free with g_free * free with g_free
*/ */
gchar* mu_msg_doc_get_str_field(MuMsgDoc* self, Message::Field::Id mfid) G_GNUC_WARN_UNUSED_RESULT; gchar* mu_msg_doc_get_str_field(MuMsgDoc* self, Field::Id mfid) G_GNUC_WARN_UNUSED_RESULT;
/** /**
* get a string-list parameter from the msgdoc * get a string-list parameter from the msgdoc
* *
* @param self a MuMsgDoc instance * @param self a MuMsgDoc instance
* @param mfid a Message::Field::Id for a string-list field * @param mfid a Field::Id for a string-list field
* *
* @return a list for the given field (see do_free), or NULL in case * @return a list for the given field (see do_free), or NULL in case
* of error. free with mu_str_free_list * of error. free with mu_str_free_list
*/ */
GSList* mu_msg_doc_get_str_list_field(MuMsgDoc* self, Message::Field::Id mfid) G_GNUC_WARN_UNUSED_RESULT; GSList* mu_msg_doc_get_str_list_field(MuMsgDoc* self, Field::Id mfid) G_GNUC_WARN_UNUSED_RESULT;
/** /**
* *
* get a numeric parameter from the msgdoc * get a numeric parameter from the msgdoc
* *
* @param self a MuMsgDoc instance * @param self a MuMsgDoc instance
* @param mfid a Message::Field::Id for a numeric field * @param mfid a Field::Id for a numeric field
* *
* @return the numerical value, or -1 in case of error. You'll need to * @return the numerical value, or -1 in case of error. You'll need to
* cast this value to the actual type (e.g. time_t for Field::Id::Date) * cast this value to the actual type (e.g. time_t for Field::Id::Date)
*/ */
gint64 mu_msg_doc_get_num_field(MuMsgDoc* self, Message::Field::Id mfid); gint64 mu_msg_doc_get_num_field(MuMsgDoc* self, Field::Id mfid);
} // namespace Mu } // namespace Mu

View File

@ -37,7 +37,6 @@
#include "utils/mu-str.h" #include "utils/mu-str.h"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
static gboolean static gboolean
init_file_metadata(MuMsgFile* self, const char* path, const char* mdir, GError** err); init_file_metadata(MuMsgFile* self, const char* path, const char* mdir, GError** err);
@ -346,15 +345,15 @@ looks_like_attachment(GMimeObject* part)
} }
static void static void
msg_cflags_cb(GMimeObject* parent, GMimeObject* part, MessageFlags* flags) msg_cflags_cb(GMimeObject* parent, GMimeObject* part, Flags* flags)
{ {
if (GMIME_IS_MULTIPART_SIGNED(part)) if (GMIME_IS_MULTIPART_SIGNED(part))
*flags |= MessageFlags::Signed; *flags |= Flags::Signed;
/* FIXME: An encrypted part might be signed at the same time. /* FIXME: An encrypted part might be signed at the same time.
* In that case the signed flag is lost. */ * In that case the signed flag is lost. */
if (GMIME_IS_MULTIPART_ENCRYPTED(part)) if (GMIME_IS_MULTIPART_ENCRYPTED(part))
*flags |= MessageFlags::Encrypted; *flags |= Flags::Encrypted;
/* smime */ /* smime */
if (GMIME_IS_APPLICATION_PKCS7_MIME(part)) { if (GMIME_IS_APPLICATION_PKCS7_MIME(part)) {
@ -363,10 +362,10 @@ msg_cflags_cb(GMimeObject* parent, GMimeObject* part, MessageFlags* flags)
if (pkcs7) { if (pkcs7) {
switch(pkcs7->smime_type) { switch(pkcs7->smime_type) {
case GMIME_SECURE_MIME_TYPE_ENVELOPED_DATA: case GMIME_SECURE_MIME_TYPE_ENVELOPED_DATA:
*flags |= MessageFlags::Encrypted; *flags |= Flags::Encrypted;
break; break;
case GMIME_SECURE_MIME_TYPE_SIGNED_DATA: case GMIME_SECURE_MIME_TYPE_SIGNED_DATA:
*flags |= MessageFlags::Signed; *flags |= Flags::Signed;
break; break;
default: default:
break; break;
@ -374,20 +373,20 @@ msg_cflags_cb(GMimeObject* parent, GMimeObject* part, MessageFlags* flags)
} }
} }
if (any_of(*flags & MessageFlags::HasAttachment)) if (any_of(*flags & Flags::HasAttachment))
return; return;
if (!GMIME_IS_PART(part)) if (!GMIME_IS_PART(part))
return; return;
if (looks_like_attachment(part)) if (looks_like_attachment(part))
*flags |= MessageFlags::HasAttachment; *flags |= Flags::HasAttachment;
} }
static MessageFlags static Flags
get_content_flags(MuMsgFile* self) get_content_flags(MuMsgFile* self)
{ {
MessageFlags flags{MessageFlags::None}; Flags flags{Flags::None};
if (GMIME_IS_MESSAGE(self->_mime_msg)) { if (GMIME_IS_MESSAGE(self->_mime_msg)) {
/* toplevel */ /* toplevel */
@ -401,27 +400,27 @@ get_content_flags(MuMsgFile* self)
char *ml{get_mailing_list(self)}; char *ml{get_mailing_list(self)};
if (ml) { if (ml) {
flags |= MessageFlags::MailingList; flags |= Flags::MailingList;
g_free(ml); g_free(ml);
} }
return flags; return flags;
} }
static MessageFlags static Flags
get_flags(MuMsgFile* self) get_flags(MuMsgFile* self)
{ {
g_return_val_if_fail(self, MessageFlags::None); g_return_val_if_fail(self, Flags::None);
auto flags{mu_maildir_flags_from_path(self->_path) auto flags{mu_maildir_flags_from_path(self->_path)
.value_or(MessageFlags::None)}; .value_or(Flags::None)};
flags |= get_content_flags(self); flags |= get_content_flags(self);
/* pseudo-flag --> unread means either NEW or NOT SEEN, just /* pseudo-flag --> unread means either NEW or NOT SEEN, just
* for searching convenience */ * for searching convenience */
if (any_of(flags & MessageFlags::New) || if (any_of(flags & Flags::New) ||
none_of(flags & MessageFlags::Seen)) none_of(flags & Flags::Seen))
flags |= MessageFlags::Unread; flags |= Flags::Unread;
return flags; return flags;
} }
@ -433,41 +432,41 @@ get_size(MuMsgFile* self)
return self->_size; return self->_size;
} }
static MessagePriority static Priority
parse_prio_str(const char* priostr) parse_prio_str(const char* priostr)
{ {
int i; int i;
struct { struct {
const char* _str; const char* _str;
MessagePriority _prio; Priority _prio;
} str_prio[] = {{"high", MessagePriority::High}, } str_prio[] = {{"high", Priority::High},
{"1", MessagePriority::High}, {"1", Priority::High},
{"2", MessagePriority::High}, {"2", Priority::High},
{"normal", MessagePriority::Normal}, {"normal", Priority::Normal},
{"3", MessagePriority::Normal}, {"3", Priority::Normal},
{"low", MessagePriority::Low}, {"low", Priority::Low},
{"list", MessagePriority::Low}, {"list", Priority::Low},
{"bulk", MessagePriority::Low}, {"bulk", Priority::Low},
{"4", MessagePriority::Low}, {"4", Priority::Low},
{"5", MessagePriority::Low}}; {"5", Priority::Low}};
for (i = 0; i != G_N_ELEMENTS(str_prio); ++i) for (i = 0; i != G_N_ELEMENTS(str_prio); ++i)
if (g_ascii_strcasecmp(priostr, str_prio[i]._str) == 0) if (g_ascii_strcasecmp(priostr, str_prio[i]._str) == 0)
return str_prio[i]._prio; return str_prio[i]._prio;
/* e.g., last-fm uses 'fm-user'... as precedence */ /* e.g., last-fm uses 'fm-user'... as precedence */
return MessagePriority::Normal; return Priority::Normal;
} }
static MessagePriority static Priority
get_prio(MuMsgFile* self) get_prio(MuMsgFile* self)
{ {
GMimeObject* obj; GMimeObject* obj;
const char* priostr; const char* priostr;
g_return_val_if_fail(self, MessagePriority::Normal); g_return_val_if_fail(self, Priority::Normal);
obj = GMIME_OBJECT(self->_mime_msg); obj = GMIME_OBJECT(self->_mime_msg);
@ -477,7 +476,7 @@ get_prio(MuMsgFile* self)
if (!priostr) if (!priostr)
priostr = g_mime_object_get_header(obj, "Importance"); priostr = g_mime_object_get_header(obj, "Importance");
if (!priostr) if (!priostr)
return MessagePriority::Normal; return Priority::Normal;
else else
return parse_prio_str(priostr); return parse_prio_str(priostr);
} }
@ -713,7 +712,7 @@ char*
Mu::mu_msg_file_get_str_field(MuMsgFile* self, Field::Id field_id, gboolean* do_free) Mu::mu_msg_file_get_str_field(MuMsgFile* self, Field::Id field_id, gboolean* do_free)
{ {
g_return_val_if_fail(self, NULL); g_return_val_if_fail(self, NULL);
g_return_val_if_fail(message_field(field_id).is_string(), NULL); g_return_val_if_fail(field_from_id(field_id).is_string(), NULL);
*do_free = FALSE; /* default */ *do_free = FALSE; /* default */
@ -738,7 +737,7 @@ Mu::mu_msg_file_get_str_field(MuMsgFile* self, Field::Id field_id, gboolean* do_
case Field::Id::BodyHtml: /* use mu_msg_get_body_html */ case Field::Id::BodyHtml: /* use mu_msg_get_body_html */
case Field::Id::EmbeddedText: case Field::Id::EmbeddedText:
g_warning("%*s is not retrievable through: %s", g_warning("%*s is not retrievable through: %s",
STR_V(message_field(field_id).name), __func__); STR_V(field_from_id(field_id).name), __func__);
return NULL; return NULL;
default: g_return_val_if_reached(NULL); default: g_return_val_if_reached(NULL);
@ -749,7 +748,7 @@ GSList*
Mu::mu_msg_file_get_str_list_field(MuMsgFile* self, Field::Id field_id) Mu::mu_msg_file_get_str_list_field(MuMsgFile* self, Field::Id field_id)
{ {
g_return_val_if_fail(self, NULL); g_return_val_if_fail(self, NULL);
g_return_val_if_fail(message_field(field_id).is_string_list(), NULL); g_return_val_if_fail(field_from_id(field_id).is_string_list(), NULL);
switch (field_id) { switch (field_id) {
case Field::Id::References: return get_references(self); case Field::Id::References: return get_references(self);
@ -762,7 +761,7 @@ gint64
Mu::mu_msg_file_get_num_field(MuMsgFile* self, const Field::Id field_id) Mu::mu_msg_file_get_num_field(MuMsgFile* self, const Field::Id field_id)
{ {
g_return_val_if_fail(self, -1); g_return_val_if_fail(self, -1);
g_return_val_if_fail(message_field(field_id).is_numerical(), -1); g_return_val_if_fail(field_from_id(field_id).is_numerical(), -1);
switch (field_id) { switch (field_id) {
case Field::Id::Date: { case Field::Id::Date: {

View File

@ -70,7 +70,7 @@ char* mu_msg_file_get_header(MuMsgFile* self, const char* header);
* @return a string, or NULL * @return a string, or NULL
*/ */
char* mu_msg_file_get_str_field(MuMsgFile* self, char* mu_msg_file_get_str_field(MuMsgFile* self,
Message::Field::Id msfid, Field::Id msfid,
gboolean* do_free) G_GNUC_WARN_UNUSED_RESULT; gboolean* do_free) G_GNUC_WARN_UNUSED_RESULT;
/** /**
@ -82,7 +82,7 @@ char* mu_msg_file_get_str_field(MuMsgFile* self,
* @return a GSList*, or NULL; free with mu_str_free_list * @return a GSList*, or NULL; free with mu_str_free_list
*/ */
GSList* mu_msg_file_get_str_list_field(MuMsgFile* self, GSList* mu_msg_file_get_str_list_field(MuMsgFile* self,
Message::Field::Id msfid) G_GNUC_WARN_UNUSED_RESULT; Field::Id msfid) G_GNUC_WARN_UNUSED_RESULT;
/** /**
* get a numeric value for this message -- the return value should be * get a numeric value for this message -- the return value should be
@ -93,7 +93,7 @@ GSList* mu_msg_file_get_str_list_field(MuMsgFile* self,
* *
* @return the numeric value, or -1 in case of error * @return the numeric value, or -1 in case of error
*/ */
gint64 mu_msg_file_get_num_field(MuMsgFile* self, Message::Field::Id mfid); gint64 mu_msg_file_get_num_field(MuMsgFile* self, Field::Id mfid);
} // namespace Mu } // namespace Mu

View File

@ -19,7 +19,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "mu-message.hh" #include "message/mu-message.hh"
#include "mu-query-results.hh" #include "mu-query-results.hh"
#include "utils/mu-str.h" #include "utils/mu-str.h"
#include "mu-msg.hh" #include "mu-msg.hh"
@ -27,7 +27,6 @@
#include "mu-maildir.hh" #include "mu-maildir.hh"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
static void static void
add_prop_nonempty(Sexp::List& list, const char* elm, const GSList* str_lst) add_prop_nonempty(Sexp::List& list, const char* elm, const GSList* str_lst)
@ -51,7 +50,7 @@ add_prop_nonempty(Sexp::List& list, const char* name, const char* str)
static Mu::Sexp static Mu::Sexp
make_contact_sexp(const MessageContact& contact) make_contact_sexp(const Contact& contact)
{ {
return Sexp::make_list( return Sexp::make_list(
/* name */ /* name */
@ -84,7 +83,7 @@ add_list_post(Sexp::List& list, MuMsg* msg)
if (g_regex_match(rx, list_post, (GRegexMatchFlags)0, &minfo)) { if (g_regex_match(rx, list_post, (GRegexMatchFlags)0, &minfo)) {
auto address = (char*)g_match_info_fetch(minfo, 1); auto address = (char*)g_match_info_fetch(minfo, 1);
list.add_prop(":list-post", make_contact_sexp(MessageContact{address})); list.add_prop(":list-post", make_contact_sexp(Contact{address}));
g_free(address); g_free(address);
} }
@ -359,7 +358,7 @@ Mu::msg_to_sexp_list(MuMsg* msg, unsigned docid, MuMsgOptions opts)
add_prop_nonempty(items, ":maildir", mu_msg_get_maildir(msg)); add_prop_nonempty(items, ":maildir", mu_msg_get_maildir(msg));
items.add_prop(":priority", items.add_prop(":priority",
Sexp::make_symbol_sv(message_priority_name(mu_msg_get_prio(msg)))); Sexp::make_symbol_sv(priority_name(mu_msg_get_prio(msg))));
/* in the no-headers-only case (see below) we get a more complete list of contacts, so no /* in the no-headers-only case (see below) we get a more complete list of contacts, so no
* need to get them here if that's the case */ * need to get them here if that's the case */

View File

@ -32,7 +32,6 @@
#include "gmime/gmime-message.h" #include "gmime/gmime-message.h"
#include "mu-message-contact.hh"
#include "mu-msg-priv.hh" /* include before mu-msg.h */ #include "mu-msg-priv.hh" /* include before mu-msg.h */
#include "mu-msg.hh" #include "mu-msg.hh"
#include "utils/mu-str.h" #include "utils/mu-str.h"
@ -40,7 +39,6 @@
#include "mu-maildir.hh" #include "mu-maildir.hh"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
/* note, we do the gmime initialization here rather than in /* note, we do the gmime initialization here rather than in
* mu-runtime, because this way we don't need mu-runtime for simple * mu-runtime, because this way we don't need mu-runtime for simple
@ -250,9 +248,9 @@ get_str_list_field(MuMsg* self, Field::Id field_id)
val = NULL; val = NULL;
if (self->_doc && if (self->_doc &&
any_of(message_field(field_id).flags & Field::Flag::Value)) any_of(field_from_id(field_id).flags & Field::Flag::Value))
val = mu_msg_doc_get_str_list_field(self->_doc, field_id); val = mu_msg_doc_get_str_list_field(self->_doc, field_id);
else if (any_of(message_field(field_id).flags & Field::Flag::GMime)) { else if (any_of(field_from_id(field_id).flags & Field::Flag::GMime)) {
/* if we don't have a file object yet, we need to /* if we don't have a file object yet, we need to
* create it from the file on disk */ * create it from the file on disk */
if (!mu_msg_load_msg_file(self, NULL)) if (!mu_msg_load_msg_file(self, NULL))
@ -273,10 +271,10 @@ get_str_field(MuMsg* self, Field::Id field_id)
val = NULL; val = NULL;
if (self->_doc && if (self->_doc &&
any_of(message_field(field_id).flags & Field::Flag::Value)) any_of(field_from_id(field_id).flags & Field::Flag::Value))
val = mu_msg_doc_get_str_field(self->_doc, field_id); val = mu_msg_doc_get_str_field(self->_doc, field_id);
else if (any_of(message_field(field_id).flags & Field::Flag::GMime)) { else if (any_of(field_from_id(field_id).flags & Field::Flag::GMime)) {
/* if we don't have a file object yet, we need to /* if we don't have a file object yet, we need to
* create it from the file on disk */ * create it from the file on disk */
if (!mu_msg_load_msg_file(self, NULL)) if (!mu_msg_load_msg_file(self, NULL))
@ -292,7 +290,7 @@ static gint64
get_num_field(MuMsg* self, Field::Id field_id) get_num_field(MuMsg* self, Field::Id field_id)
{ {
if (self->_doc && if (self->_doc &&
any_of(message_field(field_id).flags & Field::Flag::Value)) any_of(field_from_id(field_id).flags & Field::Flag::Value))
return mu_msg_doc_get_num_field(self->_doc, field_id); return mu_msg_doc_get_num_field(self->_doc, field_id);
/* if we don't have a file object yet, we need to /* if we don't have a file object yet, we need to
@ -423,11 +421,11 @@ Mu::mu_msg_get_date(MuMsg* self)
return (time_t)get_num_field(self, Field::Id::Date); return (time_t)get_num_field(self, Field::Id::Date);
} }
MessageFlags Flags
Mu::mu_msg_get_flags(MuMsg* self) Mu::mu_msg_get_flags(MuMsg* self)
{ {
g_return_val_if_fail(self, MessageFlags::None); g_return_val_if_fail(self, Flags::None);
return static_cast<MessageFlags>(get_num_field(self, Field::Id::Flags)); return static_cast<Flags>(get_num_field(self, Field::Id::Flags));
} }
size_t size_t
@ -437,12 +435,12 @@ Mu::mu_msg_get_size(MuMsg* self)
return (size_t)get_num_field(self, Field::Id::Size); return (size_t)get_num_field(self, Field::Id::Size);
} }
Mu::MessagePriority Mu::Priority
Mu::mu_msg_get_prio(MuMsg* self) Mu::mu_msg_get_prio(MuMsg* self)
{ {
g_return_val_if_fail(self, MessagePriority{}); g_return_val_if_fail(self, Priority{});
return message_priority_from_char( return priority_from_char(
static_cast<char>(get_num_field(self, Field::Id::Priority))); static_cast<char>(get_num_field(self, Field::Id::Priority)));
} }
@ -619,12 +617,12 @@ Mu::mu_msg_get_field_numeric(MuMsg* self, Field::Id field_id)
} }
static Mu::MessageContacts static Mu::Contacts
get_all_contacts(MuMsg *self) get_all_contacts(MuMsg *self)
{ {
MessageContacts contacts; Contacts contacts;
message_field_for_each([&](const auto& field){ field_for_each([&](const auto& field){
if (!field.is_contact()) if (!field.is_contact())
return; return;
auto type_contacts{mu_msg_get_contacts(self, field.id)}; auto type_contacts{mu_msg_get_contacts(self, field.id)};
@ -637,27 +635,27 @@ get_all_contacts(MuMsg *self)
return contacts; return contacts;
} }
Mu::MessageContacts Mu::Contacts
Mu::mu_msg_get_contacts(MuMsg *self, std::optional<MessageField::Id> field_id) Mu::mu_msg_get_contacts(MuMsg *self, std::optional<Field::Id> field_id)
{ {
typedef const char*(*AddressFunc)(MuMsg*); typedef const char*(*AddressFunc)(MuMsg*);
using AddressInfo = std::pair<GMimeAddressType, AddressFunc>; using AddressInfo = std::pair<GMimeAddressType, AddressFunc>;
g_return_val_if_fail(self, MessageContacts{}); g_return_val_if_fail(self, Contacts{});
g_return_val_if_fail(!field_id || message_field(*field_id).is_contact(), g_return_val_if_fail(!field_id || field_from_id(*field_id).is_contact(),
MessageContacts{}); Contacts{});
if (!field_id) if (!field_id)
return get_all_contacts(self); return get_all_contacts(self);
const auto info = std::invoke([&]()->AddressInfo { const auto info = std::invoke([&]()->AddressInfo {
switch (*field_id) { switch (*field_id) {
case MessageField::Id::From: case Field::Id::From:
return { GMIME_ADDRESS_TYPE_FROM, mu_msg_get_from }; return { GMIME_ADDRESS_TYPE_FROM, mu_msg_get_from };
case MessageField::Id::To: case Field::Id::To:
return { GMIME_ADDRESS_TYPE_TO, mu_msg_get_to }; return { GMIME_ADDRESS_TYPE_TO, mu_msg_get_to };
case MessageField::Id::Cc: case Field::Id::Cc:
return { GMIME_ADDRESS_TYPE_CC, mu_msg_get_cc }; return { GMIME_ADDRESS_TYPE_CC, mu_msg_get_cc };
case MessageField::Id::Bcc: case Field::Id::Bcc:
return { GMIME_ADDRESS_TYPE_BCC, mu_msg_get_bcc }; return { GMIME_ADDRESS_TYPE_BCC, mu_msg_get_bcc };
default: default:
throw std::logic_error("bug"); throw std::logic_error("bug");
@ -668,14 +666,13 @@ Mu::mu_msg_get_contacts(MuMsg *self, std::optional<MessageField::Id> field_id)
if (self->_file) { if (self->_file) {
if (auto&& lst{g_mime_message_get_addresses( if (auto&& lst{g_mime_message_get_addresses(
self->_file->_mime_msg, info.first)}; lst) self->_file->_mime_msg, info.first)}; lst)
return make_message_contacts(lst, *field_id, mdate); return make_contacts(lst, *field_id, mdate);
} else if (info.second) { } else if (info.second) {
if (auto&& lst_str{info.second(self)}; lst_str) if (auto&& lst_str{info.second(self)}; lst_str)
return make_message_contacts(lst_str, *field_id, mdate); return make_contacts(lst_str, *field_id, mdate);
} }
return {}; return {};
} }
@ -697,7 +694,7 @@ bool
Mu::mu_msg_move_to_maildir(MuMsg* self, Mu::mu_msg_move_to_maildir(MuMsg* self,
const std::string& root_maildir_path, const std::string& root_maildir_path,
const std::string& target_maildir, const std::string& target_maildir,
MessageFlags flags, Flags flags,
bool ignore_dups, bool ignore_dups,
bool new_name, bool new_name,
GError** err) GError** err)

View File

@ -22,7 +22,7 @@
#include <utils/mu-result.hh> #include <utils/mu-result.hh>
#include <mu-message.hh> #include <message/mu-message.hh>
#include <utils/mu-util.h> #include <utils/mu-util.h>
#include <utils/mu-utils.hh> #include <utils/mu-utils.hh>
@ -295,10 +295,10 @@ time_t mu_msg_get_date(MuMsg* msg);
* *
* @param msg valid MuMsg* instance * @param msg valid MuMsg* instance
* *
* @return the file/content flags as logically OR'd #Mu::MessageFlags. * @return the file/content flags as logically OR'd #Mu::Flags.
* Non-standard flags are ignored. * Non-standard flags are ignored.
*/ */
MessageFlags mu_msg_get_flags(MuMsg* msg); Flags mu_msg_get_flags(MuMsg* msg);
/** /**
* get the file size in bytes of this message * get the file size in bytes of this message
@ -317,7 +317,7 @@ size_t mu_msg_get_size(MuMsg* msg);
* *
* @return a string that should not be freed * @return a string that should not be freed
*/ */
const char* mu_msg_get_field_string(MuMsg* msg, Message::Field::Id mfid); const char* mu_msg_get_field_string(MuMsg* msg, Field::Id mfid);
/** /**
* get some field value as string-list * get some field value as string-list
@ -327,7 +327,7 @@ const char* mu_msg_get_field_string(MuMsg* msg, Message::Field::Id mfid);
* *
* @return a list that should not be freed * @return a list that should not be freed
*/ */
const GSList* mu_msg_get_field_string_list(MuMsg* self, Message::Field::Id mfid); const GSList* mu_msg_get_field_string_list(MuMsg* self, Field::Id mfid);
/** /**
* get some field value as string * get some field value as string
@ -337,7 +337,7 @@ const GSList* mu_msg_get_field_string_list(MuMsg* self, Message::Field::Id mfid)
* *
* @return a string that should not be freed * @return a string that should not be freed
*/ */
gint64 mu_msg_get_field_numeric(MuMsg* msg, Message::Field::Id mfid); gint64 mu_msg_get_field_numeric(MuMsg* msg, Field::Id mfid);
/** /**
* get the message priority for this message. The X-Priority, X-MSMailPriority, * get the message priority for this message. The X-Priority, X-MSMailPriority,
@ -348,7 +348,7 @@ gint64 mu_msg_get_field_numeric(MuMsg* msg, Message::Field::Id mfid);
* *
* @return the message priority * @return the message priority
*/ */
MessagePriority mu_msg_get_prio(MuMsg* msg); Priority mu_msg_get_prio(MuMsg* msg);
/** /**
* get the timestamp (mtime) for the file containing this message * get the timestamp (mtime) for the file containing this message
@ -401,7 +401,7 @@ const GSList* mu_msg_get_tags(MuMsg* self);
* @return negative if m1 is smaller, positive if m1 is smaller, 0 if * @return negative if m1 is smaller, positive if m1 is smaller, 0 if
* they are equal * they are equal
*/ */
int mu_msg_cmp(MuMsg* m1, MuMsg* m2, Message::Field::Id mfid); int mu_msg_cmp(MuMsg* m1, MuMsg* m2, Field::Id mfid);
/** /**
* check whether there there's a readable file behind this message * check whether there there's a readable file behind this message
@ -433,7 +433,7 @@ gboolean mu_msg_is_readable(MuMsg* self);
bool mu_msg_move_to_maildir(MuMsg* msg, bool mu_msg_move_to_maildir(MuMsg* msg,
const std::string& root_maildir_path, const std::string& root_maildir_path,
const std::string& target_maildir, const std::string& target_maildir,
MessageFlags flags, Flags flags,
bool ignore_dups, bool ignore_dups,
bool new_name, bool new_name,
GError** err); GError** err);
@ -445,8 +445,8 @@ bool mu_msg_move_to_maildir(MuMsg* msg,
* *
* @return a sequence * @return a sequence
*/ */
Mu::MessageContacts mu_msg_get_contacts (MuMsg *self, Mu::Contacts mu_msg_get_contacts (MuMsg *self,
std::optional<MessageField::Id> field_id={}); std::optional<Field::Id> field_id={});
/** /**
* create a 'display contact' from an email header To/Cc/Bcc/From-type address * create a 'display contact' from an email header To/Cc/Bcc/From-type address
* ie., turn * ie., turn

View File

@ -28,7 +28,6 @@
#include "mu-message.hh" #include "mu-message.hh"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
// 3 precedence levels: units (NOT,()) > factors (OR) > terms (AND) // 3 precedence levels: units (NOT,()) > factors (OR) > terms (AND)
@ -95,15 +94,15 @@ struct Parser::Private {
static std::string static std::string
process_value(const std::string& field, const std::string& value) process_value(const std::string& field, const std::string& value)
{ {
const auto id_opt{message_field_id(field)}; const auto id_opt{field_from_name(field)};
if (id_opt) { if (id_opt) {
switch (*id_opt) { switch (id_opt->id) {
case Field::Id::Priority: { case Field::Id::Priority: {
if (!value.empty()) if (!value.empty())
return std::string(1, value[0]); return std::string(1, value[0]);
} break; } break;
case Field::Id::Flags: case Field::Id::Flags:
if (const auto info{message_flag_info(value)}; info) if (const auto info{flag_info(value)}; info)
return std::string(1, info->shortcut_lower()); return std::string(1, info->shortcut_lower());
break; break;
default: default:
@ -117,7 +116,7 @@ process_value(const std::string& field, const std::string& value)
static void static void
add_field(std::vector<FieldInfo>& fields, Field::Id field_id) add_field(std::vector<FieldInfo>& fields, Field::Id field_id)
{ {
const auto field{message_field(field_id)}; const auto field{field_from_id(field_id)};
if (!field.shortcut) if (!field.shortcut)
return; // can't be searched return; // can't be searched
@ -147,8 +146,8 @@ process_field(const std::string& field_str, Parser::Flags flags)
add_field(fields, Field::Id::From); add_field(fields, Field::Id::From);
add_field(fields, Field::Id::Subject); add_field(fields, Field::Id::Subject);
add_field(fields, Field::Id::BodyText); add_field(fields, Field::Id::BodyText);
} else if (const auto id_opt{message_field_id(field_str)}; id_opt) } else if (const auto field_opt{field_from_name(field_str)}; field_opt)
add_field(fields, *id_opt); add_field(fields, field_opt->id);
return fields; return fields;
} }
@ -156,10 +155,10 @@ process_field(const std::string& field_str, Parser::Flags flags)
static bool static bool
is_range_field(const std::string& field_str) is_range_field(const std::string& field_str)
{ {
if (const auto field_id_opt{message_field_id(field_str)}; !field_id_opt) if (const auto field_opt{field_from_name(field_str)}; !field_opt)
return false; return false;
else else
return message_field(*field_id_opt).is_range(); return field_opt->is_range();
} }
struct MyRange { struct MyRange {
@ -171,17 +170,17 @@ static MyRange
process_range(const std::string& field_str, process_range(const std::string& field_str,
const std::string& lower, const std::string& upper) const std::string& lower, const std::string& upper)
{ {
const auto id_opt{message_field_id(field_str)}; const auto field_opt{field_from_name(field_str)};
if (!id_opt) if (!field_opt)
return {lower, upper}; return {lower, upper};
std::string l2 = lower; std::string l2 = lower;
std::string u2 = upper; std::string u2 = upper;
if (*id_opt == Field::Id::Date) { if (field_opt->id == Field::Id::Date) {
l2 = Mu::date_to_time_t_string(lower, true); l2 = Mu::date_to_time_t_string(lower, true);
u2 = Mu::date_to_time_t_string(upper, false); u2 = Mu::date_to_time_t_string(upper, false);
} else if (*id_opt == Field::Id::Size) { } else if (field_opt->id == Field::Id::Size) {
l2 = Mu::size_to_string(lower, true); l2 = Mu::size_to_string(lower, true);
u2 = Mu::size_to_string(upper, false); u2 = Mu::size_to_string(upper, false);
} }
@ -193,14 +192,13 @@ std::vector<std::string>
Parser::Private::process_regex(const std::string& field_str, Parser::Private::process_regex(const std::string& field_str,
const std::regex& rx) const const std::regex& rx) const
{ {
const auto id_opt{message_field_id(field_str)}; const auto field_opt{field_from_name(field_str)};
if (!id_opt) if (!field_opt)
return {}; return {};
const auto field{message_field(*id_opt)}; const auto prefix{field_opt->xapian_term()};
const auto prefix{field.xapian_term()};
std::vector<std::string> terms; std::vector<std::string> terms;
store_.for_each_term(field.id, [&](auto&& str) { store_.for_each_term(field_opt->id, [&](auto&& str) {
if (std::regex_search(str.c_str() + 1, rx)) // avoid copy if (std::regex_search(str.c_str() + 1, rx)) // avoid copy
terms.emplace_back(str); terms.emplace_back(str);
return true; return true;

View File

@ -23,7 +23,7 @@
#include "utils/mu-option.hh" #include "utils/mu-option.hh"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
// We use a MatchDecider to gather information about the matches, and decide // We use a MatchDecider to gather information about the matches, and decide
// whether to include them in the results. // whether to include them in the results.
@ -98,7 +98,7 @@ struct MatchDecider : public Xapian::MatchDecider {
private: private:
Option<std::string> opt_string(const Xapian::Document& doc, Field::Id id) const noexcept { Option<std::string> opt_string(const Xapian::Document& doc, Field::Id id) const noexcept {
const auto value_no{message_field(id).value_no()}; const auto value_no{field_from_id(id).value_no()};
std::string val = xapian_try([&] { return doc.get_value(value_no); }, std::string{""}); std::string val = xapian_try([&] { return doc.get_value(value_no); }, std::string{""});
if (val.empty()) if (val.empty())
return Nothing; return Nothing;

View File

@ -219,7 +219,7 @@ public:
*/ */
Option<std::string> message_id() const noexcept Option<std::string> message_id() const noexcept
{ {
return opt_string(Message::Field::Id::MessageId); return opt_string(Field::Id::MessageId);
} }
/** /**
@ -230,7 +230,7 @@ public:
*/ */
Option<std::string> thread_id() const noexcept Option<std::string> thread_id() const noexcept
{ {
return opt_string(Message::Field::Id::ThreadId); return opt_string(Field::Id::ThreadId);
} }
/** /**
@ -239,7 +239,7 @@ public:
* *
* @return a filesystem path * @return a filesystem path
*/ */
Option<std::string> path() const noexcept { return opt_string(Message::Field::Id::Path); } Option<std::string> path() const noexcept { return opt_string(Field::Id::Path); }
/** /**
* Get the date for the document (message) the iterator is pointing at. * Get the date for the document (message) the iterator is pointing at.
@ -247,7 +247,7 @@ public:
* *
* @return a filesystem path * @return a filesystem path
*/ */
Option<std::string> date() const noexcept { return opt_string(Message::Field::Id::Date); } Option<std::string> date() const noexcept { return opt_string(Field::Id::Date); }
/** /**
* Get the file-system path for the document (message) this iterator is * Get the file-system path for the document (message) this iterator is
@ -255,7 +255,7 @@ public:
* *
* @return the subject * @return the subject
*/ */
Option<std::string> subject() const noexcept { return opt_string(Message::Field::Id::Subject); } Option<std::string> subject() const noexcept { return opt_string(Field::Id::Subject); }
/** /**
* Get the references for the document (messages) this is iterator is * Get the references for the document (messages) this is iterator is
@ -266,7 +266,7 @@ public:
*/ */
std::vector<std::string> references() const noexcept std::vector<std::string> references() const noexcept
{ {
return split(opt_string(Message::Field::Id::References).value_or(""), ","); return split(opt_string(Field::Id::References).value_or(""), ",");
} }
/** /**
@ -276,10 +276,10 @@ public:
* *
* @return the value * @return the value
*/ */
Option<std::string> opt_string(Message::Field::Id id) const noexcept Option<std::string> opt_string(Field::Id id) const noexcept
{ {
std::string empty; std::string empty;
const auto value_no{message_field(id).value_no()}; const auto value_no{field_from_id(id).value_no()};
std::string val = xapian_try([&] {return document().get_value(value_no);}, empty); std::string val = xapian_try([&] {return document().get_value(value_no);}, empty);
if (val.empty()) if (val.empty())
return Nothing; return Nothing;

View File

@ -18,7 +18,7 @@
*/ */
#include "mu-query-threads.hh" #include "mu-query-threads.hh"
#include "mu-message-fields.hh" #include <message/mu-message.hh>
#include <set> #include <set>
#include <unordered_set> #include <unordered_set>
@ -385,10 +385,10 @@ subject_matches(const std::string& sub1, const std::string& sub2)
static bool static bool
update_container(Container& container, update_container(Container& container,
bool descending, bool descending,
ThreadPath& tpath, ThreadPath& tpath,
size_t seg_size, size_t seg_size,
const std::string& prev_subject = "") const std::string& prev_subject = "")
{ {
if (!container.children.empty()) { if (!container.children.empty()) {
Container* first = container.children.front(); Container* first = container.children.front();
@ -433,10 +433,10 @@ update_container(Container& container,
static void static void
update_containers(Containers& children, update_containers(Containers& children,
bool descending, bool descending,
ThreadPath& tpath, ThreadPath& tpath,
size_t seg_size, size_t seg_size,
std::string& prev_subject) std::string& prev_subject)
{ {
size_t idx{0}; size_t idx{0};
@ -606,13 +606,13 @@ Mu::calculate_threads(Mu::QueryResults& qres, bool descending)
struct MockQueryResult { struct MockQueryResult {
MockQueryResult(const std::string& message_id_arg, MockQueryResult(const std::string& message_id_arg,
const std::string& date_arg, const std::string& date_arg,
const std::vector<std::string>& refs_arg = {}) const std::vector<std::string>& refs_arg = {})
: message_id_{message_id_arg}, date_{date_arg}, refs_{refs_arg} : message_id_{message_id_arg}, date_{date_arg}, refs_{refs_arg}
{ {
} }
MockQueryResult(const std::string& message_id_arg, MockQueryResult(const std::string& message_id_arg,
const std::vector<std::string>& refs_arg = {}) const std::vector<std::string>& refs_arg = {})
: MockQueryResult(message_id_arg, "", refs_arg) : MockQueryResult(message_id_arg, "", refs_arg)
{ {
} }
@ -669,9 +669,9 @@ static void
test_sort_ascending() test_sort_ascending()
{ {
auto results = MockQueryResults{MockQueryResult{"m1", "1", {"m2"}}, auto results = MockQueryResults{MockQueryResult{"m1", "1", {"m2"}},
MockQueryResult{"m2", "2", {"m3"}}, MockQueryResult{"m2", "2", {"m3"}},
MockQueryResult{"m3", "3", {}}, MockQueryResult{"m3", "3", {}},
MockQueryResult{"m4", "4", {}}}; MockQueryResult{"m4", "4", {}}};
calculate_threads(results, false); calculate_threads(results, false);
@ -682,14 +682,14 @@ static void
test_sort_descending() test_sort_descending()
{ {
auto results = MockQueryResults{MockQueryResult{"m1", "1", {"m2"}}, auto results = MockQueryResults{MockQueryResult{"m1", "1", {"m2"}},
MockQueryResult{"m2", "2", {"m3"}}, MockQueryResult{"m2", "2", {"m3"}},
MockQueryResult{"m3", "3", {}}, MockQueryResult{"m3", "3", {}},
MockQueryResult{"m4", "4", {}}}; MockQueryResult{"m4", "4", {}}};
calculate_threads(results, true); calculate_threads(results, true);
assert_thread_paths(results, assert_thread_paths(results,
{{"m1", "1:f:f:z"}, {"m2", "1:f:z"}, {"m3", "1:z"}, {"m4", "0:z"}}); {{"m1", "1:f:f:z"}, {"m2", "1:f:z"}, {"m3", "1:z"}, {"m4", "0:z"}});
} }
static void static void
@ -705,7 +705,7 @@ test_id_table_inconsistent()
calculate_threads(results, false); calculate_threads(results, false);
assert_thread_paths(results, assert_thread_paths(results,
{ {
{"m2", "0"}, {"m2", "0"},
{"m1", "0:0"}, {"m1", "0:0"},
{"m3", "1"}, {"m3", "1"},
@ -730,7 +730,7 @@ test_dups_dup_last()
calculate_threads(results, false); calculate_threads(results, false);
assert_thread_paths(results, assert_thread_paths(results,
{ {
{"/path1", "0"}, {"/path1", "0"},
{"/path2", "0:0"}, {"/path2", "0:0"},
}); });
@ -755,7 +755,7 @@ test_dups_dup_first()
calculate_threads(results, false); calculate_threads(results, false);
assert_thread_paths(results, assert_thread_paths(results,
{ {
{"/path2", "0"}, {"/path2", "0"},
{"/path1", "0:0"}, {"/path1", "0:0"},
}); });
@ -773,7 +773,7 @@ test_do_not_prune_root_empty_with_children()
calculate_threads(results, false); calculate_threads(results, false);
assert_thread_paths(results, assert_thread_paths(results,
{ {
{"x1", "0:0"}, {"x1", "0:0"},
{"x2", "0:1"}, {"x2", "0:1"},
}); });
@ -790,7 +790,7 @@ test_prune_root_empty_with_child()
calculate_threads(results, false); calculate_threads(results, false);
assert_thread_paths(results, assert_thread_paths(results,
{ {
{"m1", "0"}, {"m1", "0"},
}); });
} }
@ -807,7 +807,7 @@ test_prune_empty_with_children()
calculate_threads(results, false); calculate_threads(results, false);
assert_thread_paths(results, assert_thread_paths(results,
{ {
{"m1", "0:0"}, {"m1", "0:0"},
{"m2", "0:1"}, {"m2", "0:1"},
}); });
@ -828,7 +828,7 @@ test_thread_info_ascending()
calculate_threads(results, false); calculate_threads(results, false);
assert_thread_paths(results, assert_thread_paths(results,
{ {
{"m2", "0"}, // 2 {"m2", "0"}, // 2
{"m4", "0:0"}, // 2 {"m4", "0:0"}, // 2
{"m3", "0:1"}, // 3 {"m3", "0:1"}, // 3
@ -840,11 +840,11 @@ test_thread_info_ascending()
g_assert_true(results[0].query_match().has_flag(QueryMatch::Flags::Root)); g_assert_true(results[0].query_match().has_flag(QueryMatch::Flags::Root));
g_assert_true(results[1].query_match().has_flag(QueryMatch::Flags::Root | g_assert_true(results[1].query_match().has_flag(QueryMatch::Flags::Root |
QueryMatch::Flags::HasChild)); QueryMatch::Flags::HasChild));
g_assert_true(results[2].query_match().has_flag(QueryMatch::Flags::Last)); g_assert_true(results[2].query_match().has_flag(QueryMatch::Flags::Last));
g_assert_true(results[3].query_match().has_flag(QueryMatch::Flags::First)); g_assert_true(results[3].query_match().has_flag(QueryMatch::Flags::First));
g_assert_true(results[4].query_match().has_flag(QueryMatch::Flags::Orphan | g_assert_true(results[4].query_match().has_flag(QueryMatch::Flags::Orphan |
QueryMatch::Flags::First)); QueryMatch::Flags::First));
g_assert_true( g_assert_true(
results[5].query_match().has_flag(QueryMatch::Flags::Orphan | QueryMatch::Flags::Last)); results[5].query_match().has_flag(QueryMatch::Flags::Orphan | QueryMatch::Flags::Last));
} }
@ -864,7 +864,7 @@ test_thread_info_descending()
calculate_threads(results, true /*descending*/); calculate_threads(results, true /*descending*/);
assert_thread_paths(results, assert_thread_paths(results,
{ {
{"m1", "1:z"}, // 5 {"m1", "1:z"}, // 5
{"m2", "2:z"}, // 2 {"m2", "2:z"}, // 2
{"m4", "2:f:z"}, // 2 {"m4", "2:f:z"}, // 2
@ -875,14 +875,14 @@ test_thread_info_descending()
}); });
g_assert_true(results[0].query_match().has_flag(QueryMatch::Flags::Root)); g_assert_true(results[0].query_match().has_flag(QueryMatch::Flags::Root));
g_assert_true(results[1].query_match().has_flag(QueryMatch::Flags::Root | g_assert_true(results[1].query_match().has_flag(QueryMatch::Flags::Root |
QueryMatch::Flags::HasChild)); QueryMatch::Flags::HasChild));
g_assert_true(results[2].query_match().has_flag(QueryMatch::Flags::Last)); g_assert_true(results[2].query_match().has_flag(QueryMatch::Flags::Last));
g_assert_true(results[3].query_match().has_flag(QueryMatch::Flags::First)); g_assert_true(results[3].query_match().has_flag(QueryMatch::Flags::First));
g_assert_true( g_assert_true(
results[4].query_match().has_flag(QueryMatch::Flags::Orphan | QueryMatch::Flags::Last)); results[4].query_match().has_flag(QueryMatch::Flags::Orphan | QueryMatch::Flags::Last));
g_assert_true(results[5].query_match().has_flag(QueryMatch::Flags::Orphan | g_assert_true(results[5].query_match().has_flag(QueryMatch::Flags::Orphan |
QueryMatch::Flags::First)); QueryMatch::Flags::First));
} }
int int
@ -898,11 +898,11 @@ try {
g_test_add_func("/threader/dups/dup-first", test_dups_dup_first); g_test_add_func("/threader/dups/dup-first", test_dups_dup_first);
g_test_add_func("/threader/prune/do-not-prune-root-empty-with-children", g_test_add_func("/threader/prune/do-not-prune-root-empty-with-children",
test_do_not_prune_root_empty_with_children); test_do_not_prune_root_empty_with_children);
g_test_add_func("/threader/prune/prune-root-empty-with-child", g_test_add_func("/threader/prune/prune-root-empty-with-child",
test_prune_root_empty_with_child); test_prune_root_empty_with_child);
g_test_add_func("/threader/prune/prune-empty-with-children", g_test_add_func("/threader/prune/prune-empty-with-children",
test_prune_empty_with_children); test_prune_empty_with_children);
g_test_add_func("/threader/thread-info/ascending", test_thread_info_ascending); g_test_add_func("/threader/thread-info/ascending", test_thread_info_ascending);
g_test_add_func("/threader/thread-info/descending", test_thread_info_descending); g_test_add_func("/threader/thread-info/descending", test_thread_info_descending);

View File

@ -35,7 +35,6 @@
#include <mu-xapian.hh> #include <mu-xapian.hh>
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
struct Query::Private { struct Query::Private {
Private(const Store& store) : store_{store}, parser_{store_} {} Private(const Store& store) : store_{store}, parser_{store_} {}
@ -77,7 +76,7 @@ Query::~Query() = default;
static Xapian::Enquire& static Xapian::Enquire&
sort_enquire(Xapian::Enquire& enq, Field::Id sortfield_id, QueryFlags qflags) sort_enquire(Xapian::Enquire& enq, Field::Id sortfield_id, QueryFlags qflags)
{ {
const auto value_no{message_field(sortfield_id).value_no()}; const auto value_no{field_from_id(sortfield_id).value_no()};
enq.set_sort_by_value(value_no, any_of(qflags & QueryFlags::Descending)); enq.set_sort_by_value(value_no, any_of(qflags & QueryFlags::Descending));
return enq; return enq;
@ -115,7 +114,7 @@ Query::Private::make_related_enquire(const StringSet& thread_ids,
Xapian::Enquire enq{store_.database()}; Xapian::Enquire enq{store_.database()};
std::vector<Xapian::Query> qvec; std::vector<Xapian::Query> qvec;
for (auto&& t : thread_ids) for (auto&& t : thread_ids)
qvec.emplace_back(message_field(Field::Id::ThreadId).xapian_term(t)); qvec.emplace_back(field_from_id(Field::Id::ThreadId).xapian_term(t));
Xapian::Query qr{Xapian::Query::OP_OR, qvec.begin(), qvec.end()}; Xapian::Query qr{Xapian::Query::OP_OR, qvec.begin(), qvec.end()};
enq.set_query(qr); enq.set_query(qr);
@ -187,7 +186,7 @@ Query::Private::run_singular(const std::string& expr,
static Option<std::string> static Option<std::string>
opt_string(const Xapian::Document& doc, Field::Id id) noexcept opt_string(const Xapian::Document& doc, Field::Id id) noexcept
{ {
const auto value_no{message_field(id).value_no()}; const auto value_no{field_from_id(id).value_no()};
std::string val = std::string val =
xapian_try([&] { return doc.get_value(value_no); }, std::string{""}); xapian_try([&] { return doc.get_value(value_no); }, std::string{""});
if (val.empty()) if (val.empty())
@ -245,7 +244,7 @@ Query::Private::run_related(const std::string& expr,
Option<QueryResults> Option<QueryResults>
Query::Private::run(const std::string& expr, Query::Private::run(const std::string& expr,
std::optional<Message::Field::Id> sortfield_id, QueryFlags qflags, std::optional<Field::Id> sortfield_id, QueryFlags qflags,
size_t maxnum) const size_t maxnum) const
{ {
const auto eff_maxnum{maxnum == 0 ? store_size() : maxnum}; const auto eff_maxnum{maxnum == 0 ? store_size() : maxnum};
@ -260,7 +259,7 @@ Query::Private::run(const std::string& expr,
} }
Option<QueryResults> Option<QueryResults>
Query::run(const std::string& expr, std::optional<Message::Field::Id> sortfield_id, Query::run(const std::string& expr, std::optional<Field::Id> sortfield_id,
QueryFlags qflags, size_t maxnum) const QueryFlags qflags, size_t maxnum) const
try { try {
// some flags are for internal use only. // some flags are for internal use only.

View File

@ -27,7 +27,7 @@
#include <mu-store.hh> #include <mu-store.hh>
#include <mu-query-results.hh> #include <mu-query-results.hh>
#include <utils/mu-utils.hh> #include <utils/mu-utils.hh>
#include <mu-message.hh> #include <message/mu-message.hh>
namespace Mu { namespace Mu {
@ -44,10 +44,10 @@ public:
* @return the query-results, or Nothing in case of error. * @return the query-results, or Nothing in case of error.
*/ */
Option<QueryResults> run(const std::string& expr = "", Option<QueryResults> run(const std::string& expr = "",
std::optional<Message::Field::Id> sortfield_id = {}, std::optional<Field::Id> sortfield_id = {},
QueryFlags flags = QueryFlags::None, QueryFlags flags = QueryFlags::None,
size_t maxnum = 0) const; size_t maxnum = 0) const;
/** /**
* run a Xapian query to count the number of matches; for the syntax, please * run a Xapian query to count the number of matches; for the syntax, please

View File

@ -19,8 +19,7 @@
#include "config.h" #include "config.h"
#include "mu-message-flags.hh" #include "mu-message.hh"
#include "mu-message-fields.hh"
#include "mu-msg.hh" #include "mu-msg.hh"
#include "mu-server.hh" #include "mu-server.hh"
@ -49,7 +48,6 @@
#include "utils/mu-readline.hh" #include "utils/mu-readline.hh"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
using namespace Command; using namespace Command;
/// @brief object to manage the server-context for all commands. /// @brief object to manage the server-context for all commands.
@ -127,7 +125,7 @@ private:
Sexp::List perform_move(Store::Id docid, Sexp::List perform_move(Store::Id docid,
MuMsg* msg, MuMsg* msg,
const std::string& maildirarg, const std::string& maildirarg,
MessageFlags flags, Flags flags,
bool new_name, bool new_name,
bool no_view); bool no_view);
@ -523,7 +521,7 @@ Server::Private::contacts_handler(const Parameters& params)
auto rank{0}; auto rank{0};
Sexp::List contacts; Sexp::List contacts;
store().contacts_cache().for_each([&](const MessageContact& ci) { store().contacts_cache().for_each([&](const Contact& ci) {
rank++; rank++;
/* since the last time we got some contacts */ /* since the last time we got some contacts */
@ -560,7 +558,7 @@ docids_for_msgid(const Store& store, const std::string& msgid, size_t max = 100)
throw Error(Error::Code::InvalidArgument, "invalid message-id '%s'", msgid.c_str()); throw Error(Error::Code::InvalidArgument, "invalid message-id '%s'", msgid.c_str());
} }
const auto xprefix{message_field(Field::Id::MessageId).shortcut}; const auto xprefix{field_from_id(Field::Id::MessageId).shortcut};
/*XXX this is a bit dodgy */ /*XXX this is a bit dodgy */
auto tmp{g_ascii_strdown(msgid.c_str(), -1)}; auto tmp{g_ascii_strdown(msgid.c_str(), -1)};
auto expr{g_strdup_printf("%c:%s", xprefix, tmp)}; auto expr{g_strdup_printf("%c:%s", xprefix, tmp)};
@ -674,7 +672,7 @@ Server::Private::find_handler(const Parameters& params)
const auto include_related{get_bool_or(params, ":include-related", false)}; const auto include_related{get_bool_or(params, ":include-related", false)};
auto sort_field = message_field_id(sortfieldstr); auto sort_field = field_from_name(sortfieldstr);
if (!sort_field && sortfieldstr.empty()) if (!sort_field && sortfieldstr.empty())
throw Error{Error::Code::InvalidArgument, "invalid sort field %s", throw Error{Error::Code::InvalidArgument, "invalid sort field %s",
sortfieldstr.c_str()}; sortfieldstr.c_str()};
@ -692,7 +690,7 @@ Server::Private::find_handler(const Parameters& params)
qflags |= QueryFlags::Threading; qflags |= QueryFlags::Threading;
std::lock_guard l{store_.lock()}; std::lock_guard l{store_.lock()};
auto qres{store_.run_query(q, sort_field, qflags, maxnum)}; auto qres{store_.run_query(q, sort_field->id, qflags, maxnum)};
if (!qres) if (!qres)
throw Error(Error::Code::Query, "failed to run query"); throw Error(Error::Code::Query, "failed to run query");
@ -816,7 +814,7 @@ Sexp::List
Server::Private::perform_move(Store::Id docid, Server::Private::perform_move(Store::Id docid,
MuMsg* msg, MuMsg* msg,
const std::string& maildirarg, const std::string& maildirarg,
MessageFlags flags, Flags flags,
bool new_name, bool new_name,
bool no_view) bool no_view)
{ {
@ -853,15 +851,15 @@ Server::Private::perform_move(Store::Id docid,
} }
static MessageFlags static Flags
calculate_message_flags(MuMsg* msg, std::optional<std::string> flagopt) calculate_message_flags(MuMsg* msg, std::optional<std::string> flagopt)
{ {
const auto flags = std::invoke([&]()->std::optional<MessageFlags>{ const auto flags = std::invoke([&]()->std::optional<Flags>{
auto msgflags{mu_msg_get_flags(msg)}; auto msgflags{mu_msg_get_flags(msg)};
if (!flagopt) if (!flagopt)
return mu_msg_get_flags(msg); return mu_msg_get_flags(msg);
else else
return message_flags_from_expr(*flagopt, msgflags); return flags_from_expr(*flagopt, msgflags);
}); });
if (!flags) if (!flags)
@ -1043,7 +1041,7 @@ Server::Private::maybe_mark_as_read(MuMsg* msg, Store::Id docid, bool rename)
throw Error{Error::Code::Store, "missing message"}; throw Error{Error::Code::Store, "missing message"};
const auto oldflags{mu_msg_get_flags(msg)}; const auto oldflags{mu_msg_get_flags(msg)};
const auto newflags{message_flags_from_delta_expr("+S-u-N", oldflags)}; const auto newflags{flags_from_delta_expr("+S-u-N", oldflags)};
if (!newflags || oldflags == *newflags) if (!newflags || oldflags == *newflags)
return false; // nothing to do. return false; // nothing to do.

View File

@ -35,8 +35,6 @@
#include <vector> #include <vector>
#include <xapian.h> #include <xapian.h>
#include "mu-message-flags.hh"
#include "mu-message.hh"
#include "mu-msg.hh" #include "mu-msg.hh"
#include "mu-store.hh" #include "mu-store.hh"
#include "mu-query.hh" #include "mu-query.hh"
@ -48,7 +46,6 @@
#include "utils/mu-xapian-utils.hh" #include "utils/mu-xapian-utils.hh"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
static_assert(std::is_same<Store::Id, Xapian::docid>::value, "wrong type for Store::Id"); static_assert(std::is_same<Store::Id, Xapian::docid>::value, "wrong type for Store::Id");
@ -213,7 +210,7 @@ struct Store::Private {
void add_synonyms() void add_synonyms()
{ {
for (auto&& info: AllMessageFlagInfos) { for (auto&& info: AllMessageFlagInfos) {
constexpr auto field{message_field(Field::Id::Flags)}; constexpr auto field{field_from_id(Field::Id::Flags)};
const auto s1{field.xapian_term(info.name)}; const auto s1{field.xapian_term(info.name)};
const auto s2{field.xapian_term(info.shortcut)}; const auto s2{field.xapian_term(info.shortcut)};
writable_db().clear_synonyms(s1); writable_db().clear_synonyms(s1);
@ -222,7 +219,7 @@ struct Store::Private {
} }
for (auto&& prio : AllMessagePriorities) { for (auto&& prio : AllMessagePriorities) {
constexpr auto field{message_field(Field::Id::Priority)}; constexpr auto field{field_from_id(Field::Id::Priority)};
const auto s1{field.xapian_term(to_string(prio))}; const auto s1{field.xapian_term(to_string(prio))};
const auto s2{field.xapian_term(to_char(prio))}; const auto s2{field.xapian_term(to_char(prio))};
writable_db().clear_synonyms(s1); writable_db().clear_synonyms(s1);
@ -310,7 +307,7 @@ hash_str(char* buf, size_t buf_size, const char* data)
static std::string static std::string
get_uid_term(const char* path) get_uid_term(const char* path)
{ {
return message_field(Field::Id::Uid).xapian_term( return field_from_id(Field::Id::Uid).xapian_term(
format("016%" PRIx64, get_hash64(path))); format("016%" PRIx64, get_hash64(path)));
} }
@ -588,7 +585,7 @@ Store::for_each_message_path(Store::ForEachMessageFunc msg_func) const
enq.set_cutoff(0, 0); enq.set_cutoff(0, 0);
Xapian::MSet matches(enq.get_mset(0, priv_->db().get_doccount())); Xapian::MSet matches(enq.get_mset(0, priv_->db().get_doccount()));
constexpr auto path_no{message_field(Field::Id::Path).value_no()}; constexpr auto path_no{field_from_id(Field::Id::Path).value_no()};
for (auto&& it = matches.begin(); it != matches.end(); ++it, ++n) for (auto&& it = matches.begin(); it != matches.end(); ++it, ++n)
if (!msg_func(*it, it.get_document().get_value(path_no))) if (!msg_func(*it, it.get_document().get_value(path_no)))
break; break;
@ -605,7 +602,7 @@ Store::commit()
} }
std::size_t std::size_t
Store::for_each_term(Message::Field::Id field_id, Store::ForEachTermFunc func) const Store::for_each_term(Field::Id field_id, Store::ForEachTermFunc func) const
{ {
size_t n{}; size_t n{};
@ -615,7 +612,7 @@ Store::for_each_term(Message::Field::Id field_id, Store::ForEachTermFunc func) c
* the message parser which already has the lock * the message parser which already has the lock
*/ */
std::vector<std::string> terms; std::vector<std::string> terms;
const auto prefix{message_field(field_id).xapian_term()}; const auto prefix{field_from_id(field_id).xapian_term()};
for (auto it = priv_->db().allterms_begin(prefix); for (auto it = priv_->db().allterms_begin(prefix);
it != priv_->db().allterms_end(prefix); ++it) { it != priv_->db().allterms_end(prefix); ++it) {
if (!func(*it)) if (!func(*it))
@ -666,7 +663,7 @@ Store::parse_query(const std::string& expr, bool xapian) const
static void static void
add_terms_values_date(Xapian::Document& doc, MuMsg* msg) add_terms_values_date(Xapian::Document& doc, MuMsg* msg)
{ {
constexpr auto value_no{message_field(Field::Id::Date).value_no()}; constexpr auto value_no{field_from_id(Field::Id::Date).value_no()};
const auto dstr = Mu::date_to_time_t_string( const auto dstr = Mu::date_to_time_t_string(
static_cast<time_t>(mu_msg_get_field_numeric(msg, Field::Id::Date))); static_cast<time_t>(mu_msg_get_field_numeric(msg, Field::Id::Date)));
@ -676,7 +673,7 @@ add_terms_values_date(Xapian::Document& doc, MuMsg* msg)
static void static void
add_terms_values_size(Xapian::Document& doc, MuMsg* msg) add_terms_values_size(Xapian::Document& doc, MuMsg* msg)
{ {
constexpr auto value_no{message_field(Field::Id::Size).value_no()}; constexpr auto value_no{field_from_id(Field::Id::Size).value_no()};
const auto szstr = Mu::size_to_string(mu_msg_get_field_numeric( const auto szstr = Mu::size_to_string(mu_msg_get_field_numeric(
msg, Field::Id::Size)); msg, Field::Id::Size));
doc.add_value(value_no, szstr); doc.add_value(value_no, szstr);
@ -701,15 +698,15 @@ add_terms_values_number(Xapian::Document& doc, MuMsg* msg, const Field& field)
} }
if (field.id == Field::Id::Flags) { if (field.id == Field::Id::Flags) {
g_return_if_fail(num < static_cast<int64_t>(MessageFlags::_final_)); g_return_if_fail(num < static_cast<int64_t>(Flags::_final_));
const auto msgflag{static_cast<MessageFlags>(num)}; const auto msgflag{static_cast<Flags>(num)};
message_flag_infos_for_each([&](auto&& info) { flag_infos_for_each([&](auto&& info) {
if (any_of(info.flag & msgflag)) if (any_of(info.flag & msgflag))
add_term(doc, field.xapian_term(info.shortcut_lower())); add_term(doc, field.xapian_term(info.shortcut_lower()));
}); });
} else if (field.id == Field::Id::Priority) } else if (field.id == Field::Id::Priority)
add_term(doc, add_term(doc,
field.xapian_term(to_char(static_cast<MessagePriority>(num)))); field.xapian_term(to_char(static_cast<Priority>(num))));
} }
/* for string and string-list */ /* for string and string-list */
@ -787,7 +784,7 @@ maybe_index_text_part(Xapian::Document& doc, MuMsg* msg, MuMsgPart* part)
const auto str = Mu::utf8_flatten(txt); const auto str = Mu::utf8_flatten(txt);
g_free(txt); g_free(txt);
static const auto pfx{message_field(Field::Id::EmbeddedText).xapian_term()}; static const auto pfx{field_from_id(Field::Id::EmbeddedText).xapian_term()};
termgen.index_text(str, 1, pfx); termgen.index_text(str, 1, pfx);
} }
@ -802,13 +799,13 @@ each_part(MuMsg* msg, MuMsgPart* part, DocHolder* doc_holder)
/* save the mime type of any part */ /* save the mime type of any part */
if (part->type) if (part->type)
add_term(doc, message_field(Field::Id::Mime) add_term(doc, field_from_id(Field::Id::Mime)
.xapian_term(format("%s/%s", part->type, part->subtype))); .xapian_term(format("%s/%s", part->type, part->subtype)));
if (char *fname = mu_msg_part_get_filename(part, FALSE); fname) { if (char *fname = mu_msg_part_get_filename(part, FALSE); fname) {
const auto flat{Mu::utf8_flatten(fname)}; const auto flat{Mu::utf8_flatten(fname)};
g_free(fname); g_free(fname);
add_term(doc, message_field(Field::Id::File).xapian_term(flat)); add_term(doc, field_from_id(Field::Id::File).xapian_term(flat));
} }
maybe_index_text_part(doc, msg, part); maybe_index_text_part(doc, msg, part);
@ -828,7 +825,7 @@ add_terms_values_attach(Xapian::Document& doc, MuMsg* msg)
static void static void
add_terms_values_body(Xapian::Document& doc, MuMsg* msg, const Field& field) add_terms_values_body(Xapian::Document& doc, MuMsg* msg, const Field& field)
{ {
if (any_of(mu_msg_get_flags(msg) & MessageFlags::Encrypted)) if (any_of(mu_msg_get_flags(msg) & Flags::Encrypted))
return; /* ignore encrypted bodies */ return; /* ignore encrypted bodies */
Xapian::TermGenerator termgen; Xapian::TermGenerator termgen;
@ -866,29 +863,34 @@ add_contacts_terms_values(Xapian::Document& doc, MuMsg *msg,
Xapian::TermGenerator termgen; Xapian::TermGenerator termgen;
termgen.set_document(doc); termgen.set_document(doc);
for (auto&& contact: mu_msg_get_contacts(msg)) { auto contacts{mu_msg_get_contacts(msg)};
for (auto&& contact: contacts) {
// e.g. Reply-To doesn't have a field connected. // e.g. Reply-To doesn't have a field connected.
const auto field_opt{contact.field()}; const auto field_opt{contact.field_id};
if (!field_opt) if (!field_opt)
goto next; continue;
doc.add_value(field_opt->value_no(), contact.display_name()); const auto field{field_from_id(*field_opt)};
add_term(doc, field_opt->xapian_term(contact.email)); doc.add_value(field.value_no(), contact.display_name());
add_term(doc, field.xapian_term(contact.email));
if (!contact.name.empty()) if (!contact.name.empty())
termgen.index_text(utf8_flatten(contact.name), termgen.index_text(utf8_flatten(contact.name),
1, field_opt->xapian_term()); 1, field.xapian_term());
// index name / domain separately, too. // index name / domain separately, too.
if (const auto at = contact.email.find('@'); at != std::string::npos) { if (const auto at = contact.email.find('@'); at != std::string::npos) {
add_term(doc, field_opt->xapian_term(contact.email.substr(0, at))); add_term(doc, field.xapian_term(contact.email.substr(0, at)));
add_term(doc, field_opt->xapian_term(contact.email.substr(at))); add_term(doc, field.xapian_term(contact.email.substr(at)));
} }
next:
contacts_cache.add(std::move(contact));
} }
contacts_cache.add(std::move(contacts));
} }
Xapian::Document Xapian::Document
@ -897,9 +899,9 @@ Store::Private::new_doc_from_message(MuMsg* msg)
Xapian::Document doc; Xapian::Document doc;
add_contacts_terms_values(doc, msg, this->contacts_cache_); add_contacts_terms_values(doc, msg, this->contacts_cache_);
message_field_for_each([&](auto&& field) { field_for_each([&](auto&& field) {
if (!field.is_full_text() && !field.is_searchable() && !field.is_value()) if (!field.is_searchable() && !field.is_value())
return; return;
if (field.is_contact()) if (field.is_contact())
@ -939,7 +941,7 @@ static void
update_threading_info(MuMsg* msg, Xapian::Document& doc) update_threading_info(MuMsg* msg, Xapian::Document& doc)
{ {
const GSList* refs; const GSList* refs;
const auto field{message_field(Field::Id::ThreadId)}; const auto field{field_from_id(Field::Id::ThreadId)};
// refs contains a list of parent messages, with the oldest // refs contains a list of parent messages, with the oldest
// one first until the last one, which is the direct parent of // one first until the last one, which is the direct parent of

View File

@ -34,7 +34,7 @@
#include <index/mu-indexer.hh> #include <index/mu-indexer.hh>
#include <mu-query-results.hh> #include <mu-query-results.hh>
#include <utils/mu-utils.hh> #include <utils/mu-utils.hh>
#include <mu-message.hh> #include <message/mu-message.hh>
namespace Mu { namespace Mu {
@ -156,7 +156,7 @@ public:
*/ */
std::mutex& lock() const; std::mutex& lock() const;
Option<QueryResults> run_query(const std::string& expr = "", Option<QueryResults> run_query(const std::string& expr = "",
std::optional<Message::Field::Id> sortfield_id = {}, std::optional<Field::Id> sortfield_id = {},
QueryFlags flags = QueryFlags::None, QueryFlags flags = QueryFlags::None,
size_t maxnum = 0) const; size_t maxnum = 0) const;
@ -287,7 +287,7 @@ public:
* *
* @return the number of times func was invoked * @return the number of times func was invoked
*/ */
size_t for_each_term(Message::Field::Id id, ForEachTermFunc func) const; size_t for_each_term(Field::Id id, ForEachTermFunc func) const;
/** /**

View File

@ -17,47 +17,6 @@
# #
# tests # tests
# #
test('test-message-contact',
executable('test-message-contact',
'../mu-message-contact.cc',
install: false,
cpp_args: ['-DBUILD_TESTS'],
dependencies: [glib_dep, gmime_dep, lib_mu_dep,
lib_test_mu_common_dep]))
test('test-message-document',
executable('test-message-document',
'../mu-message-document.cc',
install: false,
cpp_args: ['-DBUILD_TESTS'],
dependencies: [glib_dep, gmime_dep, lib_mu_dep,
lib_test_mu_common_dep]))
test('test-message-fields',
executable('test-message-fields',
'../mu-message-fields.cc',
install: false,
cpp_args: ['-DBUILD_TESTS'],
dependencies: [glib_dep, gmime_dep, lib_mu_dep,
lib_test_mu_common_dep]))
test('test-message-flags',
executable('test-message-flags',
'../mu-message-flags.cc',
install: false,
cpp_args: ['-DBUILD_TESTS'],
dependencies: [glib_dep, gmime_dep, lib_mu_dep,
lib_test_mu_common_dep]))
test('test-message-priority',
executable('test-message-priority',
'../mu-message-priority.cc',
install: false,
cpp_args: ['-DBUILD_TESTS'],
dependencies: [glib_dep, gmime_dep, lib_mu_dep,
lib_test_mu_common_dep]))
test('test-maildir', test('test-maildir',
executable('test-maildir', executable('test-maildir',
'test-mu-maildir.cc', 'test-mu-maildir.cc',
@ -77,7 +36,7 @@ test('test-query',
executable('test-query', executable('test-query',
'test-query.cc', 'test-query.cc',
install: false, install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep])) dependencies: [glib_dep, gmime_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test-tokenizer', test('test-tokenizer',
executable('test-tokenizer', executable('test-tokenizer',
@ -101,4 +60,4 @@ test('test-parser',
executable('test-parser', executable('test-parser',
'test-parser.cc', 'test-parser.cc',
install: false, install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep])) dependencies: [glib_dep, gmime_dep, lib_mu_dep, lib_test_mu_common_dep]))

View File

@ -174,24 +174,24 @@ test_mu_maildir_flags_from_path(void)
int i; int i;
struct { struct {
const char* path; const char* path;
MessageFlags flags; Flags flags;
} paths[] = { } paths[] = {
{"/home/foo/Maildir/test/cur/123456:2,FSR", {"/home/foo/Maildir/test/cur/123456:2,FSR",
(MessageFlags::Replied | MessageFlags::Seen | MessageFlags::Flagged)}, (Flags::Replied | Flags::Seen | Flags::Flagged)},
{"/home/foo/Maildir/test/new/123456", MessageFlags::New}, {"/home/foo/Maildir/test/new/123456", Flags::New},
{/* NOTE: when in new/, the :2,.. stuff is ignored */ {/* NOTE: when in new/, the :2,.. stuff is ignored */
"/home/foo/Maildir/test/new/123456:2,FR", "/home/foo/Maildir/test/new/123456:2,FR",
MessageFlags::New}, Flags::New},
{"/home/foo/Maildir/test/cur/123456:2,DTP", {"/home/foo/Maildir/test/cur/123456:2,DTP",
(MessageFlags::Draft | MessageFlags::Trashed | MessageFlags::Passed)}, (Flags::Draft | Flags::Trashed | Flags::Passed)},
{"/home/foo/Maildir/test/cur/123456:2,S", MessageFlags::Seen}}; {"/home/foo/Maildir/test/cur/123456:2,S", Flags::Seen}};
for (i = 0; i != G_N_ELEMENTS(paths); ++i) { for (i = 0; i != G_N_ELEMENTS(paths); ++i) {
auto res{mu_maildir_flags_from_path(paths[i].path)}; auto res{mu_maildir_flags_from_path(paths[i].path)};
g_assert_true(!!res); g_assert_true(!!res);
if (g_test_verbose()) if (g_test_verbose())
g_print("%s -> <%s>\n", paths[i].path, g_print("%s -> <%s>\n", paths[i].path,
message_flags_to_string(res.value()).c_str()); flags_to_string(res.value()).c_str());
g_assert_true(res.value() == paths[i].flags); g_assert_true(res.value() == paths[i].flags);
} }
} }
@ -214,7 +214,7 @@ test_determine_target_ok(void)
std::string old_path; std::string old_path;
std::string root_maildir; std::string root_maildir;
std::string target_maildir; std::string target_maildir;
MessageFlags new_flags; Flags new_flags;
bool new_name; bool new_name;
std::string expected; std::string expected;
}; };
@ -223,7 +223,7 @@ test_determine_target_ok(void)
"/home/foo/Maildir/test/cur/123456:2,FR", "/home/foo/Maildir/test/cur/123456:2,FR",
"/home/foo/Maildir", "/home/foo/Maildir",
{}, {},
MessageFlags::Seen | MessageFlags::Passed, Flags::Seen | Flags::Passed,
false, false,
"/home/foo/Maildir/test/cur/123456:2,PS" "/home/foo/Maildir/test/cur/123456:2,PS"
}, },
@ -232,7 +232,7 @@ test_determine_target_ok(void)
"/home/foo/Maildir/test/cur/123456:2,FR", "/home/foo/Maildir/test/cur/123456:2,FR",
"/home/foo/Maildir", "/home/foo/Maildir",
{}, {},
MessageFlags::New, Flags::New,
false, false,
"/home/foo/Maildir/test/new/123456" "/home/foo/Maildir/test/new/123456"
}, },
@ -241,7 +241,7 @@ test_determine_target_ok(void)
"/home/foo/Maildir/test/cur/123456", "/home/foo/Maildir/test/cur/123456",
"/home/foo/Maildir", "/home/foo/Maildir",
{}, {},
MessageFlags::Seen | MessageFlags::Flagged, Flags::Seen | Flags::Flagged,
false, false,
"/home/foo/Maildir/test/cur/123456:2,FS" "/home/foo/Maildir/test/cur/123456:2,FS"
}, },
@ -250,7 +250,7 @@ test_determine_target_ok(void)
"/home/foo/Maildir/test/cur/123456:2,FR", "/home/foo/Maildir/test/cur/123456:2,FR",
"/home/foo/Maildir", "/home/foo/Maildir",
"/test2", "/test2",
MessageFlags::Flagged | MessageFlags::Replied, Flags::Flagged | Flags::Replied,
false, false,
"/home/foo/Maildir/test2/cur/123456:2,FR" "/home/foo/Maildir/test2/cur/123456:2,FR"
}, },
@ -258,7 +258,7 @@ test_determine_target_ok(void)
"/home/foo/Maildir/test/new/123456", "/home/foo/Maildir/test/new/123456",
"/home/foo/Maildir", "/home/foo/Maildir",
{}, {},
MessageFlags::None, Flags::None,
false, false,
"/home/foo/Maildir/test/cur/123456:2," "/home/foo/Maildir/test/cur/123456:2,"
}, },
@ -290,157 +290,157 @@ test_determine_target_ok(void)
// static void // static void
// test_mu_maildir_determine_target(void) // test_mu_maildir_determine_target(void)
// { // {
// int i; // int i;
// struct { // struct {
// std::string oldpath; // std::string oldpath;
// MessageFlags flags; // Flags flags;
// std::string newpath; // std::string newpath;
// } paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR", // } paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR",
// MessageFlags::Replied, // Flags::Replied,
// "/home/foo/Maildir/test/cur/123456:2,R"}, // "/home/foo/Maildir/test/cur/123456:2,R"},
// {"/home/foo/Maildir/test/cur/123456:2,FR", // {"/home/foo/Maildir/test/cur/123456:2,FR",
// MessageFlags::New, // Flags::New,
// "/home/foo/Maildir/test/new/123456"}, // "/home/foo/Maildir/test/new/123456"},
// {"/home/foo/Maildir/test/new/123456:2,FR", // {"/home/foo/Maildir/test/new/123456:2,FR",
// (MessageFlags::Seen | MessageFlags::Replied), // (Flags::Seen | Flags::Replied),
// "/home/foo/Maildir/test/cur/123456:2,RS"}, // "/home/foo/Maildir/test/cur/123456:2,RS"},
// {"/home/foo/Maildir/test/new/1313038887_0.697:2,", // {"/home/foo/Maildir/test/new/1313038887_0.697:2,",
// (MessageFlags::Seen | MessageFlags::Flagged | MessageFlags::Passed), // (Flags::Seen | Flags::Flagged | Flags::Passed),
// "/home/foo/Maildir/test/cur/1313038887_0.697:2,FPS"}, // "/home/foo/Maildir/test/cur/1313038887_0.697:2,FPS"},
// {"/home/djcb/Maildir/trash/new/1312920597.2206_16.cthulhu", // {"/home/djcb/Maildir/trash/new/1312920597.2206_16.cthulhu",
// MessageFlags::Seen, // Flags::Seen,
// "/home/djcb/Maildir/trash/cur/1312920597.2206_16.cthulhu:2,S"}}; // "/home/djcb/Maildir/trash/cur/1312920597.2206_16.cthulhu:2,S"}};
// for (i = 0; i != G_N_ELEMENTS(paths); ++i) { // for (i = 0; i != G_N_ELEMENTS(paths); ++i) {
// const auto res{mu_maildir_determine_target(paths[i].oldpath, // const auto res{mu_maildir_determine_target(paths[i].oldpath,
// "/home/foo/Maildir", // "/home/foo/Maildir",
// {}, // {},
// paths[i].flags, false)}; // paths[i].flags, false)};
// g_assert_true(res && res.value() == paths[i].newpath); // g_assert_true(res && res.value() == paths[i].newpath);
// char *newbase = g_path_get_basename(newpath->c_str()); // char *newbase = g_path_get_basename(newpath->c_str());
// assert_matches_regexp(newbase, // assert_matches_regexp(newbase,
// "\\d+\\." // "\\d+\\."
// "[[:xdigit:]]{16}\\." // "[[:xdigit:]]{16}\\."
// "[[:alnum:]][[:alnum:]-]+(:2,.*)?"); // "[[:alnum:]][[:alnum:]-]+(:2,.*)?");
// g_free(newbase); // g_free(newbase);
// } // }
// } // }
// static void // static void
// test_mu_maildir_get_new_path_01(void) // test_mu_maildir_get_new_path_01(void)
// { // {
// struct { // struct {
// std::string oldpath; // std::string oldpath;
// MessageFlags flags; // Flags flags;
// std::string newpath; // std::string newpath;
// } paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR", // } paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR",
// MessageFlags::Replied, // Flags::Replied,
// "/home/foo/Maildir/test/cur/123456:2,R"}, // "/home/foo/Maildir/test/cur/123456:2,R"},
// {"/home/foo/Maildir/test/cur/123456:2,FR", // {"/home/foo/Maildir/test/cur/123456:2,FR",
// MessageFlags::New, // Flags::New,
// "/home/foo/Maildir/test/new/123456"}, // "/home/foo/Maildir/test/new/123456"},
// {"/home/foo/Maildir/test/new/123456:2,FR", // {"/home/foo/Maildir/test/new/123456:2,FR",
// (MessageFlags::Seen | MessageFlags::Replied), // (Flags::Seen | Flags::Replied),
// "/home/foo/Maildir/test/cur/123456:2,RS"}, // "/home/foo/Maildir/test/cur/123456:2,RS"},
// {"/home/foo/Maildir/test/new/1313038887_0.697:2,", // {"/home/foo/Maildir/test/new/1313038887_0.697:2,",
// (MessageFlags::Seen | MessageFlags::Flagged | MessageFlags::Passed), // (Flags::Seen | Flags::Flagged | Flags::Passed),
// "/home/foo/Maildir/test/cur/1313038887_0.697:2,FPS"}, // "/home/foo/Maildir/test/cur/1313038887_0.697:2,FPS"},
// {"/home/djcb/Maildir/trash/new/1312920597.2206_16.cthulhu", // {"/home/djcb/Maildir/trash/new/1312920597.2206_16.cthulhu",
// MessageFlags::Seen, // Flags::Seen,
// "/home/djcb/Maildir/trash/cur/1312920597.2206_16.cthulhu:2,S"}}; // "/home/djcb/Maildir/trash/cur/1312920597.2206_16.cthulhu:2,S"}};
// for (int i = 0; i != G_N_ELEMENTS(paths); ++i) { // for (int i = 0; i != G_N_ELEMENTS(paths); ++i) {
// const auto newpath{mu_maildir_determine_target( // const auto newpath{mu_maildir_determine_target(
// paths[i].oldpath, // paths[i].oldpath,
// "/home/foo/maildir", // "/home/foo/maildir",
// {}, paths[i].flags, false)}; // {}, paths[i].flags, false)};
// g_assert_true(newpath.has_value()); // g_assert_true(newpath.has_value());
// g_assert_true(*newpath == paths[i].newpath); // g_assert_true(*newpath == paths[i].newpath);
// } // }
// } // }
// static void // static void
// test_mu_maildir_get_new_path_02(void) // test_mu_maildir_get_new_path_02(void)
// { // {
// struct { // struct {
// std::string oldpath; // std::string oldpath;
// MessageFlags flags; // Flags flags;
// std::string targetdir; // std::string targetdir;
// std::string newpath; // std::string newpath;
// } paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR", // } paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR",
// MessageFlags::Replied, // Flags::Replied,
// "/home/foo/Maildir/blabla", // "/home/foo/Maildir/blabla",
// "/home/foo/Maildir/blabla/cur/123456:2,R"}, // "/home/foo/Maildir/blabla/cur/123456:2,R"},
// {"/home/foo/Maildir/test/cur/123456:2,FR", // {"/home/foo/Maildir/test/cur/123456:2,FR",
// MessageFlags::New, // Flags::New,
// "/home/bar/Maildir/coffee", // "/home/bar/Maildir/coffee",
// "/home/bar/Maildir/coffee/new/123456"}, // "/home/bar/Maildir/coffee/new/123456"},
// {"/home/foo/Maildir/test/new/123456", // {"/home/foo/Maildir/test/new/123456",
// (MessageFlags::Seen | MessageFlags::Replied), // (Flags::Seen | Flags::Replied),
// "/home/cuux/Maildir/tea", // "/home/cuux/Maildir/tea",
// "/home/cuux/Maildir/tea/cur/123456:2,RS"}, // "/home/cuux/Maildir/tea/cur/123456:2,RS"},
// {"/home/foo/Maildir/test/new/1313038887_0.697:2,", // {"/home/foo/Maildir/test/new/1313038887_0.697:2,",
// (MessageFlags::Seen | MessageFlags::Flagged | MessageFlags::Passed), // (Flags::Seen | Flags::Flagged | Flags::Passed),
// "/home/boy/Maildir/stuff", // "/home/boy/Maildir/stuff",
// "/home/boy/Maildir/stuff/cur/1313038887_0.697:2,FPS"}}; // "/home/boy/Maildir/stuff/cur/1313038887_0.697:2,FPS"}};
// for (int i = 0; i != G_N_ELEMENTS(paths); ++i) { // for (int i = 0; i != G_N_ELEMENTS(paths); ++i) {
// auto newpath{mu_maildir_determine_target(paths[i].oldpath, // auto newpath{mu_maildir_determine_target(paths[i].oldpath,
// paths[i].targetdir, // paths[i].targetdir,
// paths[i].flags, // paths[i].flags,
// false)}; // false)};
// g_assert_true(newpath.has_value()); // g_assert_true(newpath.has_value());
// g_assert_true(*newpath == paths[i].newpath); // g_assert_true(*newpath == paths[i].newpath);
// } // }
// } // }
// static void // static void
// test_mu_maildir_get_new_path_custom(void) // test_mu_maildir_get_new_path_custom(void)
// { // {
// struct { // struct {
// std::string oldpath; // std::string oldpath;
// MessageFlags flags; // Flags flags;
// std::string targetdir; // std::string targetdir;
// std::string newpath; // std::string newpath;
// } paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR", // } paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR",
// MessageFlags::Replied, // Flags::Replied,
// "/home/foo/Maildir/blabla", // "/home/foo/Maildir/blabla",
// "/home/foo/Maildir/blabla/cur/123456:2,R"}, // "/home/foo/Maildir/blabla/cur/123456:2,R"},
// {"/home/foo/Maildir/test/cur/123456:2,hFeRllo123", // {"/home/foo/Maildir/test/cur/123456:2,hFeRllo123",
// MessageFlags::Flagged, // Flags::Flagged,
// "/home/foo/Maildir/blabla", // "/home/foo/Maildir/blabla",
// "/home/foo/Maildir/blabla/cur/123456:2,Fhello123"}, // "/home/foo/Maildir/blabla/cur/123456:2,Fhello123"},
// {"/home/foo/Maildir/test/cur/123456:2,abc", // {"/home/foo/Maildir/test/cur/123456:2,abc",
// MessageFlags::Passed, // Flags::Passed,
// "/home/foo/Maildir/blabla", // "/home/foo/Maildir/blabla",
// "/home/foo/Maildir/blabla/cur/123456:2,Pabc"}}; // "/home/foo/Maildir/blabla/cur/123456:2,Pabc"}};
// for (int i = 0; i != G_N_ELEMENTS(paths); ++i) { // for (int i = 0; i != G_N_ELEMENTS(paths); ++i) {
// auto newpath{mu_maildir_get_new_path(paths[i].oldpath, // auto newpath{mu_maildir_get_new_path(paths[i].oldpath,
// paths[i].targetdir, // paths[i].targetdir,
// paths[i].flags, // paths[i].flags,
// FALSE)}; // FALSE)};
// g_assert_true(newpath); // g_assert_true(newpath);
// g_assert_true(*newpath == paths[i].newpath); // g_assert_true(*newpath == paths[i].newpath);
// } // }
// } // }
// static void // static void
// test_mu_maildir_from_path(void) // test_mu_maildir_from_path(void)
// { // {
// unsigned u; // unsigned u;
// struct { // struct {
// std::string path, exp; // std::string path, exp;
// } cases[] = {{"/home/foo/Maildir/test/cur/123456:2,FR", "/home/foo/Maildir/test"}, // } cases[] = {{"/home/foo/Maildir/test/cur/123456:2,FR", "/home/foo/Maildir/test"},
// {"/home/foo/Maildir/lala/new/1313038887_0.697:2,", "/home/foo/Maildir/lala"}}; // {"/home/foo/Maildir/lala/new/1313038887_0.697:2,", "/home/foo/Maildir/lala"}};
// for (u = 0; u != G_N_ELEMENTS(cases); ++u) { // for (u = 0; u != G_N_ELEMENTS(cases); ++u) {
// auto mdir{mu_maildir_from_path(cases[u].path)}; // auto mdir{mu_maildir_from_path(cases[u].path)};
// g_assert_true(mdir.has_value()); // g_assert_true(mdir.has_value());
// g_assert_true(*mdir == cases[u].exp); // g_assert_true(*mdir == cases[u].exp);
// } // }
// } // }
int int

View File

@ -49,8 +49,8 @@ get_msg(const char* path)
if (!msg) { if (!msg) {
g_printerr("failed to load %s: %s\n", g_printerr("failed to load %s: %s\n",
path, path,
err ? err->message : "something went wrong"); err ? err->message : "something went wrong");
g_clear_error(&err); g_clear_error(&err);
g_assert(0); g_assert(0);
} }
@ -70,22 +70,22 @@ test_mu_msg_01(void)
g_assert_cmpstr(mu_msg_get_subject(msg), ==, "gcc include search order"); g_assert_cmpstr(mu_msg_get_subject(msg), ==, "gcc include search order");
g_assert_cmpstr(mu_msg_get_from(msg), ==, "Mickey Mouse <anon@example.com>"); g_assert_cmpstr(mu_msg_get_from(msg), ==, "Mickey Mouse <anon@example.com>");
g_assert_cmpstr(mu_msg_get_msgid(msg), g_assert_cmpstr(mu_msg_get_msgid(msg),
==, ==,
"3BE9E6535E3029448670913581E7A1A20D852173@" "3BE9E6535E3029448670913581E7A1A20D852173@"
"emss35m06.us.lmco.com"); "emss35m06.us.lmco.com");
g_assert_cmpstr(mu_msg_get_header(msg, "Mailing-List"), g_assert_cmpstr(mu_msg_get_header(msg, "Mailing-List"),
==, ==,
"contact gcc-help-help@gcc.gnu.org; run by ezmlm"); "contact gcc-help-help@gcc.gnu.org; run by ezmlm");
g_assert_true(mu_msg_get_prio(msg) == Mu::MessagePriority::Normal); g_assert_true(mu_msg_get_prio(msg) == Priority::Normal);
g_assert_cmpuint(mu_msg_get_date(msg), ==, 1217530645); g_assert_cmpuint(mu_msg_get_date(msg), ==, 1217530645);
const auto contacts{mu_msg_get_contacts(msg)}; const auto contacts{mu_msg_get_contacts(msg)};
g_assert_cmpuint(contacts.size(), == , 2); g_assert_cmpuint(contacts.size(), == , 2);
g_assert_true(contacts[0].name == "Mickey Mouse"); g_assert_true(contacts[0].name == "Mickey Mouse");
g_assert_true(contacts[0].email == "anon@example.com"); g_assert_true(contacts[0].email == "anon@example.com");
g_assert_true(contacts[1].name == "Donald Duck"); g_assert_true(contacts[1].name == "Donald Duck");
g_assert_true(contacts[1].email == "gcc-help@gcc.gnu.org"); g_assert_true(contacts[1].email == "gcc-help@gcc.gnu.org");
mu_msg_unref(msg); mu_msg_unref(msg);
} }
@ -101,10 +101,10 @@ test_mu_msg_02(void)
g_assert_cmpstr(mu_msg_get_from(msg), ==, "anon@example.com"); g_assert_cmpstr(mu_msg_get_from(msg), ==, "anon@example.com");
g_assert_cmpstr(mu_msg_get_msgid(msg), ==, "r6bpm5-6n6.ln1@news.ducksburg.com"); g_assert_cmpstr(mu_msg_get_msgid(msg), ==, "r6bpm5-6n6.ln1@news.ducksburg.com");
g_assert_cmpstr(mu_msg_get_header(msg, "Errors-To"), g_assert_cmpstr(mu_msg_get_header(msg, "Errors-To"),
==, ==,
"help-gnu-emacs-bounces+xxxx.klub=gmail.com@gnu.org"); "help-gnu-emacs-bounces+xxxx.klub=gmail.com@gnu.org");
g_assert_true(mu_msg_get_prio(msg) /* 'low' */ g_assert_true(mu_msg_get_prio(msg) /* 'low' */
== Mu::MessagePriority::Low); == Priority::Low);
g_assert_cmpuint(mu_msg_get_date(msg), ==, 1218051515); g_assert_cmpuint(mu_msg_get_date(msg), ==, 1218051515);
const auto contacts{mu_msg_get_contacts(msg)}; const auto contacts{mu_msg_get_contacts(msg)};
@ -114,8 +114,8 @@ test_mu_msg_02(void)
g_assert_true(contacts[1].name.empty()); g_assert_true(contacts[1].name.empty());
g_assert_true(contacts[1].email == "help-gnu-emacs@gnu.org"); g_assert_true(contacts[1].email == "help-gnu-emacs@gnu.org");
g_print("flags: %s\n", Mu::message_flags_to_string(mu_msg_get_flags(msg)).c_str()); g_print("flags: %s\n", Mu::flags_to_string(mu_msg_get_flags(msg)).c_str());
g_assert_true(mu_msg_get_flags(msg) == (MessageFlags::Seen|MessageFlags::MailingList)); g_assert_true(mu_msg_get_flags(msg) == (Flags::Seen|Flags::MailingList));
mu_msg_unref(msg); mu_msg_unref(msg);
} }
@ -131,11 +131,11 @@ test_mu_msg_03(void)
g_assert_cmpstr(mu_msg_get_subject(msg), ==, "Greetings from Lothlórien"); g_assert_cmpstr(mu_msg_get_subject(msg), ==, "Greetings from Lothlórien");
g_assert_cmpstr(mu_msg_get_from(msg), ==, "Frodo Baggins <frodo@example.com>"); g_assert_cmpstr(mu_msg_get_from(msg), ==, "Frodo Baggins <frodo@example.com>");
g_assert_true(mu_msg_get_prio(msg) /* 'low' */ g_assert_true(mu_msg_get_prio(msg) /* 'low' */
== Mu::MessagePriority::Normal); == Priority::Normal);
g_assert_cmpuint(mu_msg_get_date(msg), ==, 0); g_assert_cmpuint(mu_msg_get_date(msg), ==, 0);
g_assert_cmpstr(mu_msg_get_body_text(msg, MU_MSG_OPTION_NONE), g_assert_cmpstr(mu_msg_get_body_text(msg, MU_MSG_OPTION_NONE),
==, ==,
"\nLet's write some fünkÿ text\nusing umlauts.\n\nFoo.\n"); "\nLet's write some fünkÿ text\nusing umlauts.\n\nFoo.\n");
params = mu_msg_get_body_text_content_type_parameters(msg, MU_MSG_OPTION_NONE); params = mu_msg_get_body_text_content_type_parameters(msg, MU_MSG_OPTION_NONE);
g_assert_cmpuint(g_slist_length((GSList*)params), ==, 2); g_assert_cmpuint(g_slist_length((GSList*)params), ==, 2);
@ -143,7 +143,7 @@ test_mu_msg_03(void)
g_assert_cmpstr((char*)params->data, ==, "charset"); g_assert_cmpstr((char*)params->data, ==, "charset");
params = g_slist_next(params); params = g_slist_next(params);
g_assert_cmpstr((char*)params->data, ==, "UTF-8"); g_assert_cmpstr((char*)params->data, ==, "UTF-8");
g_assert_true(mu_msg_get_flags(msg) == (MessageFlags::Unread)); g_assert_true(mu_msg_get_flags(msg) == (Flags::Unread));
mu_msg_unref(msg); mu_msg_unref(msg);
} }
@ -157,13 +157,13 @@ test_mu_msg_04(void)
g_assert_cmpstr(mu_msg_get_subject(msg), ==, "pics for you"); g_assert_cmpstr(mu_msg_get_subject(msg), ==, "pics for you");
g_assert_cmpstr(mu_msg_get_from(msg), ==, "Sitting Bull <sb@example.com>"); g_assert_cmpstr(mu_msg_get_from(msg), ==, "Sitting Bull <sb@example.com>");
g_assert_true(mu_msg_get_prio(msg) /* 'low' */ g_assert_true(mu_msg_get_prio(msg) /* 'low' */
== Mu::MessagePriority::Normal); == Priority::Normal);
g_assert_cmpuint(mu_msg_get_date(msg), ==, 0); g_assert_cmpuint(mu_msg_get_date(msg), ==, 0);
g_assert_true(mu_msg_get_flags(msg) == g_assert_true(mu_msg_get_flags(msg) ==
(MessageFlags::HasAttachment|MessageFlags::Unread)); (Flags::HasAttachment|Flags::Unread));
g_assert_true(mu_msg_get_flags(msg) == g_assert_true(mu_msg_get_flags(msg) ==
(MessageFlags::HasAttachment|MessageFlags::Unread)); (Flags::HasAttachment|Flags::Unread));
mu_msg_unref(msg); mu_msg_unref(msg);
} }
@ -177,7 +177,7 @@ test_mu_msg_multimime(void)
g_assert_cmpstr(mu_msg_get_subject(msg), ==, "multimime"); g_assert_cmpstr(mu_msg_get_subject(msg), ==, "multimime");
g_assert_cmpstr(mu_msg_get_body_text(msg, MU_MSG_OPTION_NONE), ==, "abcdef"); g_assert_cmpstr(mu_msg_get_body_text(msg, MU_MSG_OPTION_NONE), ==, "abcdef");
g_assert_true(mu_msg_get_flags(msg) == g_assert_true(mu_msg_get_flags(msg) ==
(MessageFlags::HasAttachment|MessageFlags::Flagged|MessageFlags::Seen)); (Flags::HasAttachment|Flags::Flagged|Flags::Seen));
mu_msg_unref(msg); mu_msg_unref(msg);
} }
@ -189,19 +189,19 @@ test_mu_msg_flags(void)
struct { struct {
const char* path; const char* path;
MessageFlags flags; Flags flags;
} msgflags[] = {{MU_TESTMAILDIR4 "/multimime!2,FS", } msgflags[] = {{MU_TESTMAILDIR4 "/multimime!2,FS",
(MessageFlags::Flagged | MessageFlags::Seen | (Flags::Flagged | Flags::Seen |
MessageFlags::HasAttachment)}, Flags::HasAttachment)},
{MU_TESTMAILDIR4 "/special!2,Sabc", {MU_TESTMAILDIR4 "/special!2,Sabc",
(MessageFlags::Seen|MessageFlags::HasAttachment)} (Flags::Seen|Flags::HasAttachment)}
}; };
for (u = 0; u != G_N_ELEMENTS(msgflags); ++u) { for (u = 0; u != G_N_ELEMENTS(msgflags); ++u) {
MuMsg* msg; MuMsg* msg;
g_assert((msg = get_msg(msgflags[u].path))); g_assert((msg = get_msg(msgflags[u].path)));
const auto flags{mu_msg_get_flags(msg)}; const auto flags{mu_msg_get_flags(msg)};
//g_print("flags: %s\n", Mu::message_flags_to_string(flags).c_str()); //g_print("flags: %s\n", Mu::flags_to_string(flags).c_str());
g_assert_true(flags == msgflags[u].flags); g_assert_true(flags == msgflags[u].flags);
mu_msg_unref(msg); mu_msg_unref(msg);
} }
@ -217,7 +217,7 @@ test_mu_msg_umlaut(void)
g_assert_cmpstr(mu_msg_get_subject(msg), ==, "Motörhead"); g_assert_cmpstr(mu_msg_get_subject(msg), ==, "Motörhead");
g_assert_cmpstr(mu_msg_get_from(msg), ==, "Mü <testmu@testmu.xx>"); g_assert_cmpstr(mu_msg_get_from(msg), ==, "Mü <testmu@testmu.xx>");
g_assert_true(mu_msg_get_prio(msg) /* 'low' */ g_assert_true(mu_msg_get_prio(msg) /* 'low' */
== Mu::MessagePriority::Normal); == Priority::Normal);
g_assert_cmpuint(mu_msg_get_date(msg), ==, 0); g_assert_cmpuint(mu_msg_get_date(msg), ==, 0);
mu_msg_unref(msg); mu_msg_unref(msg);
@ -284,17 +284,17 @@ test_mu_msg_references_many(void)
unsigned u; unsigned u;
const GSList *refs, *cur; const GSList *refs, *cur;
const char* expt_refs[] = { const char* expt_refs[] = {
"e9065dac-13c1-4103-9e31-6974ca232a89@t15g2000prt.googlegroups.com", "e9065dac-13c1-4103-9e31-6974ca232a89@t15g2000prt.googlegroups.com",
"87hbblwelr.fsf@sapphire.mobileactivedefense.com", "87hbblwelr.fsf@sapphire.mobileactivedefense.com",
"pql248-4va.ln1@wilbur.25thandClement.com", "pql248-4va.ln1@wilbur.25thandClement.com",
"ikns6r$li3$1@Iltempo.Update.UU.SE", "ikns6r$li3$1@Iltempo.Update.UU.SE",
"8762s0jreh.fsf@sapphire.mobileactivedefense.com", "8762s0jreh.fsf@sapphire.mobileactivedefense.com",
"ikqqp1$jv0$1@Iltempo.Update.UU.SE", "ikqqp1$jv0$1@Iltempo.Update.UU.SE",
"87hbbjc5jt.fsf@sapphire.mobileactivedefense.com", "87hbbjc5jt.fsf@sapphire.mobileactivedefense.com",
"ikr0na$lru$1@Iltempo.Update.UU.SE", "ikr0na$lru$1@Iltempo.Update.UU.SE",
"tO8cp.1228$GE6.370@news.usenetserver.com", "tO8cp.1228$GE6.370@news.usenetserver.com",
"ikr6ks$nlf$1@Iltempo.Update.UU.SE", "ikr6ks$nlf$1@Iltempo.Update.UU.SE",
"8ioh48-8mu.ln1@leafnode-msgid.gclare.org.uk"}; "8ioh48-8mu.ln1@leafnode-msgid.gclare.org.uk"};
msg = get_msg(MU_TESTMAILDIR2 "/bar/cur/181736.eml"); msg = get_msg(MU_TESTMAILDIR2 "/bar/cur/181736.eml");
refs = mu_msg_get_references(msg); refs = mu_msg_get_references(msg);
@ -321,11 +321,11 @@ test_mu_msg_tags(void)
g_assert_cmpstr(mu_msg_get_to(msg), ==, "Julius Caesar <jc@example.com>"); g_assert_cmpstr(mu_msg_get_to(msg), ==, "Julius Caesar <jc@example.com>");
g_assert_cmpstr(mu_msg_get_subject(msg), g_assert_cmpstr(mu_msg_get_subject(msg),
==, ==,
"Fere libenter homines id quod volunt credunt"); "Fere libenter homines id quod volunt credunt");
g_assert_cmpstr(mu_msg_get_from(msg), ==, "John Milton <jm@example.com>"); g_assert_cmpstr(mu_msg_get_from(msg), ==, "John Milton <jm@example.com>");
g_assert_true(mu_msg_get_prio(msg) /* 'low' */ g_assert_true(mu_msg_get_prio(msg) /* 'low' */
== Mu::MessagePriority::High); == Priority::High);
g_assert_cmpuint(mu_msg_get_date(msg), ==, 1217530645); g_assert_cmpuint(mu_msg_get_date(msg), ==, 1217530645);
tags = mu_msg_get_tags(msg); tags = mu_msg_get_tags(msg);
@ -348,31 +348,31 @@ test_mu_msg_comp_unix_programmer(void)
msg = get_msg(MU_TESTMAILDIR4 "/181736.eml"); msg = get_msg(MU_TESTMAILDIR4 "/181736.eml");
g_assert_cmpstr(mu_msg_get_to(msg), ==, NULL); g_assert_cmpstr(mu_msg_get_to(msg), ==, NULL);
g_assert_cmpstr(mu_msg_get_subject(msg), g_assert_cmpstr(mu_msg_get_subject(msg),
==, ==,
"Re: Are writes \"atomic\" to readers of the file?"); "Re: Are writes \"atomic\" to readers of the file?");
g_assert_cmpstr(mu_msg_get_from(msg), ==, "Jimbo Foobarcuux <jimbo@slp53.sl.home>"); g_assert_cmpstr(mu_msg_get_from(msg), ==, "Jimbo Foobarcuux <jimbo@slp53.sl.home>");
g_assert_cmpstr(mu_msg_get_msgid(msg), ==, "oktdp.42997$Te.22361@news.usenetserver.com"); g_assert_cmpstr(mu_msg_get_msgid(msg), ==, "oktdp.42997$Te.22361@news.usenetserver.com");
refs = mu_str_from_list(mu_msg_get_references(msg), ','); refs = mu_str_from_list(mu_msg_get_references(msg), ',');
g_assert_cmpstr(refs, g_assert_cmpstr(refs,
==, ==,
"e9065dac-13c1-4103-9e31-6974ca232a89@t15g2000prt" "e9065dac-13c1-4103-9e31-6974ca232a89@t15g2000prt"
".googlegroups.com," ".googlegroups.com,"
"87hbblwelr.fsf@sapphire.mobileactivedefense.com," "87hbblwelr.fsf@sapphire.mobileactivedefense.com,"
"pql248-4va.ln1@wilbur.25thandClement.com," "pql248-4va.ln1@wilbur.25thandClement.com,"
"ikns6r$li3$1@Iltempo.Update.UU.SE," "ikns6r$li3$1@Iltempo.Update.UU.SE,"
"8762s0jreh.fsf@sapphire.mobileactivedefense.com," "8762s0jreh.fsf@sapphire.mobileactivedefense.com,"
"ikqqp1$jv0$1@Iltempo.Update.UU.SE," "ikqqp1$jv0$1@Iltempo.Update.UU.SE,"
"87hbbjc5jt.fsf@sapphire.mobileactivedefense.com," "87hbbjc5jt.fsf@sapphire.mobileactivedefense.com,"
"ikr0na$lru$1@Iltempo.Update.UU.SE," "ikr0na$lru$1@Iltempo.Update.UU.SE,"
"tO8cp.1228$GE6.370@news.usenetserver.com," "tO8cp.1228$GE6.370@news.usenetserver.com,"
"ikr6ks$nlf$1@Iltempo.Update.UU.SE," "ikr6ks$nlf$1@Iltempo.Update.UU.SE,"
"8ioh48-8mu.ln1@leafnode-msgid.gclare.org.uk"); "8ioh48-8mu.ln1@leafnode-msgid.gclare.org.uk");
g_free(refs); g_free(refs);
//"jimbo@slp53.sl.home (Jimbo Foobarcuux)"; //"jimbo@slp53.sl.home (Jimbo Foobarcuux)";
g_assert_true(mu_msg_get_prio(msg) /* 'low' */ g_assert_true(mu_msg_get_prio(msg) /* 'low' */
== Mu::MessagePriority::Normal); == Priority::Normal);
g_assert_cmpuint(mu_msg_get_date(msg), ==, 1299603860); g_assert_cmpuint(mu_msg_get_date(msg), ==, 1299603860);
mu_msg_unref(msg); mu_msg_unref(msg);
@ -381,9 +381,9 @@ test_mu_msg_comp_unix_programmer(void)
static void static void
test_mu_str_prio_01(void) test_mu_str_prio_01(void)
{ {
g_assert_true(message_priority_name(Mu::MessagePriority::Low) == "low"); g_assert_true(priority_name(Priority::Low) == "low");
g_assert_true(message_priority_name(Mu::MessagePriority::Normal) == "normal"); g_assert_true(priority_name(Priority::Normal) == "normal");
g_assert_true(message_priority_name(Mu::MessagePriority::High) == "high"); g_assert_true(priority_name(Priority::High) == "high");
} }
G_GNUC_UNUSED static gboolean G_GNUC_UNUSED static gboolean
@ -400,9 +400,9 @@ test_mu_str_display_contact(void)
const char* word; const char* word;
const char* disp; const char* disp;
} words[] = {{"\"Foo Bar\" <aap@noot.mies>", "Foo Bar"}, } words[] = {{"\"Foo Bar\" <aap@noot.mies>", "Foo Bar"},
{"Foo Bar <aap@noot.mies>", "Foo Bar"}, {"Foo Bar <aap@noot.mies>", "Foo Bar"},
{"<aap@noot.mies>", "aap@noot.mies"}, {"<aap@noot.mies>", "aap@noot.mies"},
{"foo@bar.nl", "foo@bar.nl"}}; {"foo@bar.nl", "foo@bar.nl"}};
for (i = 0; i != G_N_ELEMENTS(words); ++i) for (i = 0; i != G_N_ELEMENTS(words); ++i)
g_assert_cmpstr(mu_str_display_contact_s(words[i].word), ==, words[i].disp); g_assert_cmpstr(mu_str_display_contact_s(words[i].word), ==, words[i].disp);

View File

@ -32,7 +32,6 @@
#include "test-mu-common.hh" #include "test-mu-common.hh"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
static void static void
test_query() test_query()

View File

@ -21,6 +21,7 @@
#define MU_XAPIAN_UTILS_HH__ #define MU_XAPIAN_UTILS_HH__
#include <xapian.h> #include <xapian.h>
#include <glib.h>
namespace Mu { namespace Mu {

View File

@ -35,7 +35,7 @@ mu = executable(
'mu-config.hh', 'mu-config.hh',
mu_help_strings_h mu_help_strings_h
], ],
dependencies: [ glib_dep, lib_mu_dep, thread_dep, config_h_dep ], dependencies: [ glib_dep, gmime_dep, lib_mu_dep, thread_dep, config_h_dep ],
cpp_args: ['-DMU_SCRIPTS_DIR="'+ join_paths(datadir, 'mu', 'scripts') + '"'], cpp_args: ['-DMU_SCRIPTS_DIR="'+ join_paths(datadir, 'mu', 'scripts') + '"'],
install: true) install: true)

View File

@ -274,7 +274,7 @@ struct ECData {
}; };
static void static void
each_contact(const Mu::MessageContact& ci, ECData& ecdata) each_contact(const Mu::Contact& ci, ECData& ecdata)
{ {
if (ecdata.personal && ci.personal) if (ecdata.personal && ci.personal)
return; return;

View File

@ -28,13 +28,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
#include "message/mu-fields.hh"
#include "mu-msg.hh" #include "mu-msg.hh"
#include "mu-maildir.hh" #include "mu-maildir.hh"
#include "mu-query-match-deciders.hh" #include "mu-query-match-deciders.hh"
#include "mu-query.hh" #include "mu-query.hh"
#include "mu-bookmarks.hh" #include "mu-bookmarks.hh"
#include "mu-runtime.hh" #include "mu-runtime.hh"
#include "mu-message.hh" #include "message/mu-message.hh"
#include "utils/mu-util.h" #include "utils/mu-util.h"
#include "utils/mu-str.h" #include "utils/mu-str.h"
@ -43,7 +44,6 @@
#include "utils/mu-utils.hh" #include "utils/mu-utils.hh"
using namespace Mu; using namespace Mu;
using namespace Mu::Message;
struct OutputInfo { struct OutputInfo {
Xapian::docid docid{}; Xapian::docid docid{};
@ -74,8 +74,8 @@ static Option<QueryResults>
run_query(const Store& store, const std::string& expr, const MuConfig* opts, run_query(const Store& store, const std::string& expr, const MuConfig* opts,
GError** err) GError** err)
{ {
const auto sortfield_id{message_field_id(opts->sortfield ? opts->sortfield : "")}; const auto sortfield{field_from_name(opts->sortfield ? opts->sortfield : "")};
if (!sortfield_id && opts->sortfield) { if (!sortfield && opts->sortfield) {
g_set_error(err, MU_ERROR_DOMAIN, MU_ERROR_IN_PARAMETERS, g_set_error(err, MU_ERROR_DOMAIN, MU_ERROR_IN_PARAMETERS,
"invvalid sort field: '%s'\n", opts->sortfield); "invvalid sort field: '%s'\n", opts->sortfield);
return Nothing; return Nothing;
@ -91,7 +91,7 @@ run_query(const Store& store, const std::string& expr, const MuConfig* opts,
if (opts->threads) if (opts->threads)
qflags |= QueryFlags::Threading; qflags |= QueryFlags::Threading;
return store.run_query(expr, sortfield_id, qflags, opts->maxnum); return store.run_query(expr, sortfield->id, qflags, opts->maxnum);
} }
static gboolean static gboolean
@ -233,7 +233,7 @@ ansi_color_maybe(Field::Id field_id, gboolean color)
case Field::Id::Date: ansi = MU_COLOR_MAGENTA; break; case Field::Id::Date: ansi = MU_COLOR_MAGENTA; break;
default: default:
if (message_field(field_id).type != Field::Type::String) if (field_from_id(field_id).type != Field::Type::String)
ansi = MU_COLOR_YELLOW; ansi = MU_COLOR_YELLOW;
else else
ansi = MU_COLOR_RED; ansi = MU_COLOR_RED;
@ -275,10 +275,10 @@ field_string_list(MuMsg* msg, Field::Id field_id)
/* ugly... for backward compat */ /* ugly... for backward compat */
static const char* static const char*
flags_s(MessageFlags flags) flags_s(Flags flags)
{ {
static char buf[64]; static char buf[64];
const auto flagstr{message_flags_to_string(flags)}; const auto flagstr{flags_to_string(flags)};
::strncpy(buf, flagstr.c_str(), sizeof(buf) - 1); ::strncpy(buf, flagstr.c_str(), sizeof(buf) - 1);
@ -290,7 +290,7 @@ display_field(MuMsg* msg, Field::Id field_id)
{ {
gint64 val; gint64 val;
switch (message_field(field_id).type) { switch (field_from_id(field_id).type) {
case Field::Type::String: { case Field::Type::String: {
const gchar* str; const gchar* str;
str = mu_msg_get_field_string(msg, field_id); str = mu_msg_get_field_string(msg, field_id);
@ -299,11 +299,11 @@ display_field(MuMsg* msg, Field::Id field_id)
case Field::Type::Integer: case Field::Type::Integer:
if (field_id == Field::Id::Priority) { if (field_id == Field::Id::Priority) {
const auto val = static_cast<char>(mu_msg_get_field_numeric(msg, field_id)); const auto val = static_cast<char>(mu_msg_get_field_numeric(msg, field_id));
const auto prio = message_priority_from_char(val); const auto prio = priority_from_char(val);
return message_priority_name_c_str(prio); return priority_name_c_str(prio);
} else if (field_id == Field::Id::Flags) { } else if (field_id == Field::Id::Flags) {
val = mu_msg_get_field_numeric(msg, field_id); val = mu_msg_get_field_numeric(msg, field_id);
return flags_s(static_cast<MessageFlags>(val)); return flags_s(static_cast<Flags>(val));
} else /* as string */ } else /* as string */
return mu_msg_get_field_string(msg, field_id); return mu_msg_get_field_string(msg, field_id);
@ -384,16 +384,15 @@ output_plain_fields(MuMsg* msg, const char* fields, gboolean color, gboolean thr
g_return_if_fail(fields); g_return_if_fail(fields);
for (myfields = fields, nonempty = 0; *myfields; ++myfields) { for (myfields = fields, nonempty = 0; *myfields; ++myfields) {
const auto id_opt{message_field_id(*myfields)}; const auto field_opt{field_from_shortcut(*myfields)};
if (!id_opt || (!message_field(*id_opt).is_value() && if (!field_opt || (!field_opt->is_value() && !field_opt->is_contact()))
!message_field(*id_opt).is_contact()))
nonempty += printf("%c", *myfields); nonempty += printf("%c", *myfields);
else { else {
ansi_color_maybe(*id_opt, color); ansi_color_maybe(field_opt->id, color);
nonempty += mu_util_fputs_encoded(display_field(msg, *id_opt).c_str(), nonempty += mu_util_fputs_encoded(
stdout); display_field(msg, field_opt->id).c_str(), stdout);
ansi_reset_maybe(*id_opt, color); ansi_reset_maybe(field_opt->id, color);
} }
} }

View File

@ -34,7 +34,7 @@
#include "mu-maildir.hh" #include "mu-maildir.hh"
#include "mu-contacts-cache.hh" #include "mu-contacts-cache.hh"
#include "mu-runtime.hh" #include "mu-runtime.hh"
#include "mu-message-flags.hh" #include "message/mu-message.hh"
#include "utils/mu-util.h" #include "utils/mu-util.h"
#include "utils/mu-str.h" #include "utils/mu-str.h"
@ -49,7 +49,7 @@ static gboolean
view_msg_sexp(MuMsg* msg, const MuConfig* opts) view_msg_sexp(MuMsg* msg, const MuConfig* opts)
{ {
::fputs(msg_to_sexp(msg, 0, mu_config_get_msg_options(opts)).to_sexp_string().c_str(), ::fputs(msg_to_sexp(msg, 0, mu_config_get_msg_options(opts)).to_sexp_string().c_str(),
stdout); stdout);
return TRUE; return TRUE;
} }
@ -121,10 +121,10 @@ body_or_summary(MuMsg* msg, const MuConfig* opts)
color = !opts->nocolor; color = !opts->nocolor;
body = mu_msg_get_body_text(msg, (MuMsgOptions)my_opts); body = mu_msg_get_body_text(msg, (MuMsgOptions)my_opts);
if (!body) { if (!body) {
if (any_of(mu_msg_get_flags(msg) & MessageFlags::Encrypted)) { if (any_of(mu_msg_get_flags(msg) & Flags::Encrypted)) {
color_maybe(MU_COLOR_CYAN); color_maybe(MU_COLOR_CYAN);
g_print("[No body found; " g_print("[No body found; "
"message has encrypted parts]\n"); "message has encrypted parts]\n");
} else { } else {
color_maybe(MU_COLOR_MAGENTA); color_maybe(MU_COLOR_MAGENTA);
g_print("[No body found]\n"); g_print("[No body found]\n");
@ -308,7 +308,7 @@ foreach_msg_file(Mu::Store& store, const MuConfig* opts, ForeachMsgFunc foreach_
/* note: params[0] will be 'add' */ /* note: params[0] will be 'add' */
if (!opts->params[0] || !opts->params[1]) { if (!opts->params[0] || !opts->params[1]) {
g_print("usage: mu %s <file> [<files>]\n", g_print("usage: mu %s <file> [<files>]\n",
opts->params[0] ? opts->params[0] : "<cmd>"); opts->params[0] ? opts->params[0] : "<cmd>");
mu_util_g_set_error(err, MU_ERROR_IN_PARAMETERS, "missing parameters"); mu_util_g_set_error(err, MU_ERROR_IN_PARAMETERS, "missing parameters");
return MU_ERROR_IN_PARAMETERS; return MU_ERROR_IN_PARAMETERS;
} }
@ -327,8 +327,8 @@ foreach_msg_file(Mu::Store& store, const MuConfig* opts, ForeachMsgFunc foreach_
if (!foreach_func(store, path, err)) { if (!foreach_func(store, path, err)) {
all_ok = FALSE; all_ok = FALSE;
g_printerr("error with %s: %s\n", g_printerr("error with %s: %s\n",
path, path,
(err && *err) ? (*err)->message : "something went wrong"); (err && *err) ? (*err)->message : "something went wrong");
g_clear_error(err); g_clear_error(err);
continue; continue;
} }
@ -336,9 +336,9 @@ foreach_msg_file(Mu::Store& store, const MuConfig* opts, ForeachMsgFunc foreach_
if (!all_ok) { if (!all_ok) {
mu_util_g_set_error(err, mu_util_g_set_error(err,
MU_ERROR_XAPIAN_STORE_FAILED, MU_ERROR_XAPIAN_STORE_FAILED,
"%s failed for some message(s)", "%s failed for some message(s)",
opts->params[0]); opts->params[0]);
return MU_ERROR_XAPIAN_STORE_FAILED; return MU_ERROR_XAPIAN_STORE_FAILED;
} }
@ -399,14 +399,14 @@ each_sig(MuMsg* msg, MuMsgPart* part, VData* vdata)
if (vdata->oneline) if (vdata->oneline)
vdata->report = g_strdup_printf("%s%s%s", vdata->report = g_strdup_printf("%s%s%s",
vdata->report ? vdata->report : "", vdata->report ? vdata->report : "",
vdata->report ? "; " : "", vdata->report ? "; " : "",
report->report); report->report);
else else
vdata->report = g_strdup_printf("%s%s\t%s", vdata->report = g_strdup_printf("%s%s\t%s",
vdata->report ? vdata->report : "", vdata->report ? vdata->report : "",
vdata->report ? "\n" : "", vdata->report ? "\n" : "",
report->report); report->report);
if (vdata->combined_status == MU_MSG_PART_SIG_STATUS_BAD || if (vdata->combined_status == MU_MSG_PART_SIG_STATUS_BAD ||
vdata->combined_status == MU_MSG_PART_SIG_STATUS_ERROR) vdata->combined_status == MU_MSG_PART_SIG_STATUS_ERROR)
@ -536,16 +536,16 @@ cmd_init(const MuConfig* opts, GError** err)
/* not provided, nor could we find a good default */ /* not provided, nor could we find a good default */
if (!opts->maildir) { if (!opts->maildir) {
mu_util_g_set_error(err, mu_util_g_set_error(err,
MU_ERROR_IN_PARAMETERS, MU_ERROR_IN_PARAMETERS,
"missing --maildir parameter and could " "missing --maildir parameter and could "
"not determine default"); "not determine default");
return MU_ERROR_IN_PARAMETERS; return MU_ERROR_IN_PARAMETERS;
} }
if (opts->max_msg_size < 0) { if (opts->max_msg_size < 0) {
mu_util_g_set_error(err, mu_util_g_set_error(err,
MU_ERROR_IN_PARAMETERS, MU_ERROR_IN_PARAMETERS,
"invalid value for max-message-size"); "invalid value for max-message-size");
return MU_ERROR_IN_PARAMETERS; return MU_ERROR_IN_PARAMETERS;
} else if (opts->batch_size < 0) { } else if (opts->batch_size < 0) {
mu_util_g_set_error(err, MU_ERROR_IN_PARAMETERS, "invalid value for batch-size"); mu_util_g_set_error(err, MU_ERROR_IN_PARAMETERS, "invalid value for batch-size");
@ -585,9 +585,9 @@ show_usage(void)
{ {
g_print("usage: mu command [options] [parameters]\n"); g_print("usage: mu command [options] [parameters]\n");
g_print("where command is one of index, find, cfind, view, mkdir, " g_print("where command is one of index, find, cfind, view, mkdir, "
"extract, add, remove, script, verify or server\n"); "extract, add, remove, script, verify or server\n");
g_print("see the mu, mu-<command> or mu-easy manpages for " g_print("see the mu, mu-<command> or mu-easy manpages for "
"more information\n"); "more information\n");
} }
typedef MuError (*readonly_store_func)(const Mu::Store&, const MuConfig*, GError** err); typedef MuError (*readonly_store_func)(const Mu::Store&, const MuConfig*, GError** err);

View File

@ -22,7 +22,7 @@
#include <glib.h> #include <glib.h>
#include <sys/types.h> /* for mode_t */ #include <sys/types.h> /* for mode_t */
#include <mu-message.hh> #include <message/mu-message.hh>
#include <mu-msg.hh> #include <mu-msg.hh>
#include <utils/mu-util.h> #include <utils/mu-util.h>