NeoMutt  2025-12-11-911-gd8d604
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_exit (struct AutocryptData *ad, const struct KeyEvent *event)
 Exit this menu - 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 75 of file functions.c.

76{
78 ASSERT(mod_data);
79
80 struct MenuDefinition *md = NULL;
81 struct SubMenu *sm = NULL;
82
84 md = km_register_menu(MENU_AUTOCRYPT, "autocrypt");
85 km_menu_add_submenu(md, sm);
86 km_menu_add_submenu(md, sm_generic);
88
89 mod_data->menu_autocrypt = md;
90}
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:62
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:121
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:87
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:104
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:134
@ 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:663
#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 menu.h:77
Collection of related functions.
Definition menu.h:65
@ 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 98 of file functions.c.

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

120{
121 entry->account->prefer_encrypt = !entry->account->prefer_encrypt;
123 {
124 entry->account->prefer_encrypt = !entry->account->prefer_encrypt;
125 mutt_error(_("Error updating account record"));
126 return false;
127 }
128
129 return true;
130}
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 },
{ "exit", OP_EXIT },
{ "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 { "exit", OP_EXIT },
54 { "toggle-active", OP_AUTOCRYPT_TOGGLE_ACTIVE },
55 { "toggle-prefer-encrypt", OP_AUTOCRYPT_TOGGLE_PREFER },
56 { NULL, 0 }
57};

◆ 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" },
{ OP_EXIT, "q" },
{ 0, NULL }
}

Key bindings for the Autocrypt Account.

Definition at line 62 of file functions.c.

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

◆ 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_exit },
{ 0, NULL },
}
static int op_exit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
exit this menu - Implements alias_function_t -
Definition functions.c:312
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:174
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:137
static int op_autocrypt_delete_acct(struct AutocryptData *ad, const struct KeyEvent *event)
Delete the current account - Implements autocrypt_function_t -.
Definition functions.c:148
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:194

All the NeoMutt functions that the Autocrypt supports.

Definition at line 225 of file functions.c.

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