NeoMutt  2025-12-11-980-ge38c27
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_active (struct AccountEntry *entry)
 Toggle whether an Autocrypt account is active.
 
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_active (struct AutocryptData *ad, const struct KeyEvent *event)
 Toggle the current account active/inactive - 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 73 of file functions.c.

74{
76 ASSERT(mod_data);
77
78 struct MenuDefinition *md = NULL;
79 struct SubMenu *sm = NULL;
80
82 md = km_register_menu(MENU_AUTOCRYPT, "autocrypt");
83 km_menu_add_submenu(md, sm);
84 km_menu_add_submenu(md, sm_generic);
86
87 mod_data->menu_autocrypt = md;
88}
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:61
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_active()

static bool toggle_active ( struct AccountEntry * entry)
static

Toggle whether an Autocrypt account is active.

Parameters
entryMenu Entry for the account
Return values
trueSuccess
falseError

Definition at line 96 of file functions.c.

97{
98 entry->account->enabled = !entry->account->enabled;
100 {
101 entry->account->enabled = !entry->account->enabled;
102 /* L10N: This error message is displayed if a database update of an
103 account record fails for some odd reason. */
104 mutt_error(_("Error updating account record"));
105 return false;
106 }
107
108 return true;
109}
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()

static 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 117 of file functions.c.

118{
119 entry->account->prefer_encrypt = !entry->account->prefer_encrypt;
121 {
122 entry->account->prefer_encrypt = !entry->account->prefer_encrypt;
123 mutt_error(_("Error updating account record"));
124 return false;
125 }
126
127 return true;
128}
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-active", OP_AUTOCRYPT_TOGGLE_ACTIVE },
{ "toggle-prefer-encrypt", OP_AUTOCRYPT_TOGGLE_PREFER },
{ NULL, 0 }
}

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-active", OP_AUTOCRYPT_TOGGLE_ACTIVE },
54 { "toggle-prefer-encrypt", OP_AUTOCRYPT_TOGGLE_PREFER },
55 { NULL, 0 }
56};

◆ AutocryptDefaultBindings

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

Key bindings for the Autocrypt Account.

Definition at line 61 of file functions.c.

61 { /* map: autocrypt account */
62 { OP_AUTOCRYPT_CREATE_ACCT, "c" },
63 { OP_AUTOCRYPT_DELETE_ACCT, "D" },
64 { OP_AUTOCRYPT_TOGGLE_ACTIVE, "a" },
65 { OP_AUTOCRYPT_TOGGLE_PREFER, "p" },
66 { 0, NULL }
67};

◆ 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_ACTIVE, op_autocrypt_toggle_active },
{ 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_toggle_active(struct AutocryptData *ad, const struct KeyEvent *event)
Toggle the current account active/inactive - Implements autocrypt_function_t -.
Definition functions.c:172
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:135
static int op_autocrypt_delete_acct(struct AutocryptData *ad, const struct KeyEvent *event)
Delete the current account - Implements autocrypt_function_t -.
Definition functions.c:146
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:192

All the NeoMutt functions that the Autocrypt supports.

Definition at line 223 of file functions.c.

223 {
224 // clang-format off
225 { OP_AUTOCRYPT_CREATE_ACCT, op_autocrypt_create_acct },
226 { OP_AUTOCRYPT_DELETE_ACCT, op_autocrypt_delete_acct },
227 { OP_AUTOCRYPT_TOGGLE_ACTIVE, op_autocrypt_toggle_active },
228 { OP_AUTOCRYPT_TOGGLE_PREFER, op_autocrypt_toggle_prefer },
229 { OP_EXIT, op_quit },
230 { OP_QUIT, op_quit },
231 { 0, NULL },
232 // clang-format on
233};