mu/mu4e: handle personal addresses as server cmdline params

So we don't need to pass them to index; they can't change anyway.
This commit is contained in:
Dirk-Jan C. Binnema 2020-02-04 01:03:18 +02:00
parent 38779cfade
commit 029a4c245e
3 changed files with 10 additions and 23 deletions

View File

@ -764,20 +764,6 @@ index_msg_cb (MuIndexStats *stats, void *user_data)
return MU_OK;
}
static void
set_my_addresses (MuStore *store, const std::vector<std::string>& addrs)
{
if (addrs.empty())
return;
const char **addresses = g_new0 (const char*, addrs.size() + 1);
for (auto i = 0U; i != addrs.size(); ++i)
addresses[i] = addrs[i].c_str();
mu_store_set_personal_addresses (store, (const char**)addresses);
g_free (addresses); // shallow
}
static MuError
index_and_maybe_cleanup (MuIndex *index, bool cleanup, bool lazy_check)
@ -808,13 +794,9 @@ index_and_maybe_cleanup (MuIndex *index, bool cleanup, bool lazy_check)
static void
index_handler (Context& context, const Parameters& params)
{
GError *gerr{};
const auto cleanup{get_bool_or(params, "cleanup")};
const auto lazy_check{get_bool_or(params, "lazy-check")};
const auto my_addresses{get_string_vec(params, "my-addresses")};
set_my_addresses(context.store, my_addresses);
GError *gerr{};
auto index{mu_index_new (context.store, &gerr)};
if (!index)
throw Error(Error::Code::Index, &gerr, "failed to create index object");
@ -1273,10 +1255,11 @@ mu_cmd_server (MuStore *store, MuConfig *opts/*unused*/, GError **err) try
return MU_OK;
}
install_sig_handler();
std::cout << ";; Welcome to the " << PACKAGE_STRING << " command-server\n"
<< ";; Use (help) to get a list of commands, (quit) to quit.\n";
while (!context.do_quit) {
while (!MuTerminate && !context.do_quit) {
try {
const auto line{read_line(context)};

View File

@ -439,8 +439,10 @@ config_options_group_server (void)
{
GOptionGroup *og;
GOptionEntry entries[] = {
{"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.maildir,
"top of the maildir", "<maildir>"},
{"my-address", 0, 0, G_OPTION_ARG_STRING_ARRAY,
&MU_CONFIG.my_addresses,
"my e-mail address; can be used multiple times",
"<address>"},
{"commands", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.commands,
"list the available command and their parameters, then exit", NULL},
{NULL, 0, 0, 0, NULL, NULL, NULL}

View File

@ -255,7 +255,9 @@ Start the process if needed."
(let* ((process-connection-type nil) ;; use a pipe
(args '("server"))
(args (append args (when mu4e-mu-home (list (concat "--muhome=" mu4e-mu-home)))))
(args (append args (list (concat "--maildir=" mu4e-maildir)))))
(args (append args (mapcar (lambda(addr)
(format "--my-address=%s" addr))
mu4e-user-mail-address-list))))
(setq mu4e~proc-buf "")
(setq mu4e~proc-process (apply 'start-process
mu4e~proc-name mu4e~proc-name