From 66ee2004fcb944c160b06371be9c18af059a8d86 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 18 Apr 2022 21:56:10 +0300 Subject: [PATCH] mu: extract Message::Options from command-line --- mu/mu-config.cc | 19 +++++++++++++------ mu/mu-config.hh | 14 ++++++++++---- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/mu/mu-config.cc b/mu/mu-config.cc index 023cf135..530cf5a6 100644 --- a/mu/mu-config.cc +++ b/mu/mu-config.cc @@ -337,8 +337,6 @@ crypto_option_entries() static GOptionEntry entries[] = { {"auto-retrieve", 'r', 0, G_OPTION_ARG_NONE, &MU_CONFIG.auto_retrieve, "attempt to retrieve keys online (false)", NULL}, - {"use-agent", 'a', 0, G_OPTION_ARG_NONE, &MU_CONFIG.use_agent, - "attempt to use the GPG agent (false)", NULL}, {"decrypt", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.decrypt, "attempt to decrypt the message", NULL}, {NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}}; @@ -722,10 +720,6 @@ Mu::mu_config_get_msg_options(const MuConfig* muopts) if (muopts->decrypt) opts |= MU_MSG_OPTION_DECRYPT; - if (muopts->verify) - opts |= MU_MSG_OPTION_VERIFY; - if (muopts->use_agent) - opts |= MU_MSG_OPTION_USE_AGENT; if (muopts->auto_retrieve) opts |= MU_MSG_OPTION_AUTO_RETRIEVE; if (muopts->overwrite) @@ -733,3 +727,16 @@ Mu::mu_config_get_msg_options(const MuConfig* muopts) return (MuMsgOptions)opts; } + +Message::Options +Mu::mu_config_message_options(const MuConfig *conf) +{ + Message::Options opts{}; + + if (conf->decrypt) + opts |= Message::Options::Decrypt; + if (conf->auto_retrieve) + opts |= Message::Options::RetrieveKeys; + + return opts; +} diff --git a/mu/mu-config.hh b/mu/mu-config.hh index d51fe825..b1162f39 100644 --- a/mu/mu-config.hh +++ b/mu/mu-config.hh @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2021 Dirk-Jan C. Binnema +** Copyright (C) 2008-2022 Dirk-Jan C. Binnema ** ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the @@ -145,11 +145,8 @@ struct _MuConfig { /* options for crypto * ie, 'view', 'extract' */ gboolean auto_retrieve; /* assume we're online */ - gboolean use_agent; /* attempt to use the gpg-agent */ gboolean decrypt; /* try to decrypt the * message body, if any */ - gboolean verify; /* try to crypto-verify the - * message */ /* options for view */ gboolean terminator; /* add separator \f between @@ -237,6 +234,15 @@ size_t mu_config_param_num(const MuConfig* conf); */ MuMsgOptions mu_config_get_msg_options(const MuConfig* opts); +/** + * determine Message::Options from command line args + * + * @param opts a MuConfig struct + * + * @return the corresponding Message::Options + */ +Message::Options mu_config_message_options(const MuConfig* opts); + /** * print help text for the current command *