NeoMutt  2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c File Reference

Autocrypt functions. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "private.h"
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "functions.h"
#include "lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "question/lib.h"
#include "autocrypt_data.h"
#include "module_data.h"
Include dependency graph for functions.c:

Go to the source code of this file.

Functions

void autocrypt_init_keys (struct NeoMutt *n, struct SubMenu *sm_generic)
 Initialise the Autocrypt Keybindings - Implements ::init_keys_api.
static bool toggle_enabled (struct AccountEntry *entry)
 Toggle whether an Autocrypt account is enabled.
static bool toggle_prefer_encrypt (struct AccountEntry *entry)
 Toggle whether an Autocrypt account prefers encryption.
static int op_autocrypt_create_acct (struct AutocryptData *ad, const struct KeyEvent *event)
 Create a new autocrypt account - Implements autocrypt_function_t -.
static int op_autocrypt_delete_acct (struct AutocryptData *ad, const struct KeyEvent *event)
 Delete the current account - Implements autocrypt_function_t -.
static int op_autocrypt_toggle_enabled (struct AutocryptData *ad, const struct KeyEvent *event)
 Toggle the current account enabled/disabled - Implements autocrypt_function_t -.
static int op_autocrypt_toggle_prefer (struct AutocryptData *ad, const struct KeyEvent *event)
 Toggle the current account prefer-encrypt flag - Implements autocrypt_function_t -.
static int op_quit (struct AutocryptData *ad, const struct KeyEvent *event)
 Save changes and exit this dialog - Implements autocrypt_function_t -.
int autocrypt_function_dispatcher (struct MuttWindow *win, const struct KeyEvent *event)
 Perform a Autocrypt function - Implements function_dispatcher_t -.

Variables

static const struct MenuFuncOp OpAutocrypt []
 Functions for the Autocrypt Account.
static const struct MenuOpSeq AutocryptDefaultBindings []
 Key bindings for the Autocrypt Account.
static const struct AutocryptFunction AutocryptFunctions []
 All the NeoMutt functions that the Autocrypt supports.

Detailed Description

Autocrypt functions.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file functions.c.

Function Documentation

◆ autocrypt_init_keys()

void autocrypt_init_keys ( struct NeoMutt * n,
struct SubMenu * sm_generic )

Initialise the Autocrypt Keybindings - Implements ::init_keys_api.

Definition at line 76 of file functions.c.

77{
79 ASSERT(mod_data);
80
81 struct MenuDefinition *md = NULL;
82 struct SubMenu *sm = NULL;
83
85 md = km_register_menu(MENU_AUTOCRYPT, "autocrypt");
86 km_menu_add_submenu(md, sm);
87 km_menu_add_submenu(md, sm_generic);
89
90 mod_data->menu_autocrypt = md;
91}
static const struct MenuFuncOp OpAutocrypt[]
Functions for the Autocrypt Account.
Definition functions.c:50
static const struct MenuOpSeq AutocryptDefaultBindings[]
Key bindings for the Autocrypt Account.
Definition functions.c:64
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:123
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:88
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:105
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:136
@ MODULE_ID_AUTOCRYPT
ModuleAutocrypt, Autocrypt
Definition module_api.h:50
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:666
#define ASSERT(COND)
Definition signal2.h:59
Autocrypt private Module data.
Definition module_data.h:32
struct MenuDefinition * menu_autocrypt
Autocrypt menu definition.
Definition module_data.h:34
Functions for a Dialog or Window.
Definition menudef.h:44
Collection of related functions.
Definition menudef.h:33
@ MENU_AUTOCRYPT
Autocrypt Account menu.
Definition type.h:37
Here is the call graph for this function:
Here is the caller graph for this function:

◆ toggle_enabled()

bool toggle_enabled ( struct AccountEntry * entry)
static

Toggle whether an Autocrypt account is enabled.

Parameters
entryMenu Entry for the account
Return values
trueSuccess
falseError

Definition at line 99 of file functions.c.

100{
101 entry->account->enabled = !entry->account->enabled;
103 {
104 entry->account->enabled = !entry->account->enabled;
105 /* L10N: This error message is displayed if a database update of an
106 account record fails for some odd reason. */
107 mutt_error(_("Error updating account record"));
108 return false;
109 }
110
111 return true;
112}
int mutt_autocrypt_db_account_update(struct AutocryptAccount *acct)
Update Account info in the Autocrypt database.
Definition db.c:383
#define mutt_error(...)
Definition logging2.h:94
#define _(a)
Definition message.h:28
struct AutocryptAccount * account
Account details.
Definition private.h:47
bool enabled
Is this account enabled.
Definition lib.h:119
Here is the call graph for this function:
Here is the caller graph for this function:

◆ toggle_prefer_encrypt()

bool toggle_prefer_encrypt ( struct AccountEntry * entry)
static

Toggle whether an Autocrypt account prefers encryption.

Parameters
entryMenu Entry for the account
Return values
trueSuccess
falseError

Definition at line 120 of file functions.c.

121{
122 entry->account->prefer_encrypt = !entry->account->prefer_encrypt;
124 {
125 entry->account->prefer_encrypt = !entry->account->prefer_encrypt;
126 mutt_error(_("Error updating account record"));
127 return false;
128 }
129
130 return true;
131}
bool prefer_encrypt
false = nopref, true = mutual
Definition lib.h:118
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ OpAutocrypt

const struct MenuFuncOp OpAutocrypt[]
static
Initial value:
= {
{ "create-account", OP_AUTOCRYPT_CREATE_ACCT },
{ "delete-account", OP_AUTOCRYPT_DELETE_ACCT },
{ "toggle-enabled", OP_AUTOCRYPT_TOGGLE_ENABLED },
{ "toggle-prefer-encrypt", OP_AUTOCRYPT_TOGGLE_PREFER },
{ "toggle-active", OP_AUTOCRYPT_TOGGLE_ENABLED, MFF_DEPRECATED },
{ NULL, 0 }
}
@ MFF_DEPRECATED
Function is deprecated.
Definition get.h:67

Functions for the Autocrypt Account.

Definition at line 50 of file functions.c.

50 { /* map: autocrypt account */
51 { "create-account", OP_AUTOCRYPT_CREATE_ACCT },
52 { "delete-account", OP_AUTOCRYPT_DELETE_ACCT },
53 { "toggle-enabled", OP_AUTOCRYPT_TOGGLE_ENABLED },
54 { "toggle-prefer-encrypt", OP_AUTOCRYPT_TOGGLE_PREFER },
55
56 // Deprecated
57 { "toggle-active", OP_AUTOCRYPT_TOGGLE_ENABLED, MFF_DEPRECATED },
58 { NULL, 0 }
59};

◆ AutocryptDefaultBindings

const struct MenuOpSeq AutocryptDefaultBindings[]
static
Initial value:
= {
{ OP_AUTOCRYPT_CREATE_ACCT, "c" },
{ OP_AUTOCRYPT_DELETE_ACCT, "D" },
{ OP_AUTOCRYPT_TOGGLE_ENABLED, "a" },
{ OP_AUTOCRYPT_TOGGLE_PREFER, "p" },
{ 0, NULL }
}

Key bindings for the Autocrypt Account.

Definition at line 64 of file functions.c.

64 { /* map: autocrypt account */
65 { OP_AUTOCRYPT_CREATE_ACCT, "c" },
66 { OP_AUTOCRYPT_DELETE_ACCT, "D" },
67 { OP_AUTOCRYPT_TOGGLE_ENABLED, "a" },
68 { OP_AUTOCRYPT_TOGGLE_PREFER, "p" },
69 { 0, NULL }
70};

◆ AutocryptFunctions

const struct AutocryptFunction AutocryptFunctions[]
static
Initial value:
= {
{ OP_AUTOCRYPT_CREATE_ACCT, op_autocrypt_create_acct },
{ OP_AUTOCRYPT_DELETE_ACCT, op_autocrypt_delete_acct },
{ OP_AUTOCRYPT_TOGGLE_ENABLED, op_autocrypt_toggle_enabled },
{ OP_AUTOCRYPT_TOGGLE_PREFER, op_autocrypt_toggle_prefer },
{ OP_EXIT, op_quit },
{ OP_QUIT, op_quit },
{ 0, NULL },
}
static int op_quit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
Save changes and exit this dialog - Implements alias_function_t -.
Definition functions.c:308
static int op_autocrypt_create_acct(struct AutocryptData *ad, const struct KeyEvent *event)
Create a new autocrypt account - Implements autocrypt_function_t -.
Definition functions.c:138
static int op_autocrypt_delete_acct(struct AutocryptData *ad, const struct KeyEvent *event)
Delete the current account - Implements autocrypt_function_t -.
Definition functions.c:149
static int op_autocrypt_toggle_prefer(struct AutocryptData *ad, const struct KeyEvent *event)
Toggle the current account prefer-encrypt flag - Implements autocrypt_function_t -.
Definition functions.c:195
static int op_autocrypt_toggle_enabled(struct AutocryptData *ad, const struct KeyEvent *event)
Toggle the current account enabled/disabled - Implements autocrypt_function_t -.
Definition functions.c:175

All the NeoMutt functions that the Autocrypt supports.

Definition at line 226 of file functions.c.

226 {
227 // clang-format off
228 { OP_AUTOCRYPT_CREATE_ACCT, op_autocrypt_create_acct },
229 { OP_AUTOCRYPT_DELETE_ACCT, op_autocrypt_delete_acct },
230 { OP_AUTOCRYPT_TOGGLE_ENABLED, op_autocrypt_toggle_enabled },
231 { OP_AUTOCRYPT_TOGGLE_PREFER, op_autocrypt_toggle_prefer },
232 { OP_EXIT, op_quit },
233 { OP_QUIT, op_quit },
234 { 0, NULL },
235 // clang-format on
236};