NeoMutt  2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Autocrypt Function API

Prototype for a Autocrypt Function. More...

Collaboration diagram for Autocrypt Function API:

Functions

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 -.

Detailed Description

Prototype for a Autocrypt Function.

Parameters
menuMenu
eventEvent to process
Return values
enumFunctionRetval
Precondition
menu is not NULL
event is not NULL

Function Documentation

◆ op_autocrypt_create_acct()

int op_autocrypt_create_acct ( struct AutocryptData * ad,
const struct KeyEvent * event )
static

Create a new autocrypt account - Implements autocrypt_function_t -.

Definition at line 138 of file functions.c.

139{
140 if (mutt_autocrypt_account_init(false) == 0)
141 populate_menu(ad->menu);
142
143 return FR_SUCCESS;
144}
int mutt_autocrypt_account_init(bool prompt)
Create a new Autocrypt account.
Definition autocrypt.c:150
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
bool populate_menu(struct Menu *menu)
Add the Autocrypt data to a Menu.
struct Menu * menu
Autocrypt Menu.
Here is the call graph for this function:

◆ op_autocrypt_delete_acct()

int op_autocrypt_delete_acct ( struct AutocryptData * ad,
const struct KeyEvent * event )
static

Delete the current account - Implements autocrypt_function_t -.

Definition at line 149 of file functions.c.

150{
151 if (!ad->menu->mdata)
152 return FR_ERROR;
153
154 const int index = menu_get_index(ad->menu);
155 struct AccountEntry **pentry = ARRAY_GET(&ad->entries, index);
156 if (!pentry)
157 return 0;
158
159 char msg[128] = { 0 };
160 snprintf(msg, sizeof(msg),
161 // L10N: Confirmation message when deleting an autocrypt account
162 _("Really delete account \"%s\"?"), buf_string((*pentry)->addr->mailbox));
163 if (query_yesorno(msg, MUTT_NO) != MUTT_YES)
164 return FR_NO_ACTION;
165
166 if (mutt_autocrypt_db_account_delete((*pentry)->account) == 0)
167 populate_menu(ad->menu);
168
169 return FR_SUCCESS;
170}
#define ARRAY_GET(head, idx)
Return the element at index.
Definition array.h:109
int mutt_autocrypt_db_account_delete(struct AutocryptAccount *acct)
Delete an Account from the Autocrypt database.
Definition db.c:434
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:153
#define _(a)
Definition message.h:28
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition quad.h:38
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition quad.h:39
enum QuadOption query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
Definition question.c:329
An entry in the Autocrypt account Menu.
Definition private.h:45
struct AccountEntryArray entries
Account Entries.
void * mdata
Private data.
Definition lib.h:155
Here is the call graph for this function:

◆ op_autocrypt_toggle_enabled()

int op_autocrypt_toggle_enabled ( struct AutocryptData * ad,
const struct KeyEvent * event )
static

Toggle the current account enabled/disabled - Implements autocrypt_function_t -.

Definition at line 175 of file functions.c.

176{
177 if (!ad->menu->mdata)
178 return FR_ERROR;
179
180 const int index = menu_get_index(ad->menu);
181 struct AccountEntry **pentry = ARRAY_GET(&ad->entries, index);
182 if (!pentry)
183 return 0;
184
185 if (!toggle_enabled((*pentry)))
186 return FR_ERROR;
187
189 return FR_SUCCESS;
190}
static bool toggle_enabled(struct AccountEntry *entry)
Toggle whether an Autocrypt account is enabled.
Definition functions.c:99
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:177
@ MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:64
Here is the call graph for this function:

◆ op_autocrypt_toggle_prefer()

int op_autocrypt_toggle_prefer ( struct AutocryptData * ad,
const struct KeyEvent * event )
static

Toggle the current account prefer-encrypt flag - Implements autocrypt_function_t -.

Definition at line 195 of file functions.c.

196{
197 if (!ad->menu->mdata)
198 return FR_ERROR;
199
200 const int index = menu_get_index(ad->menu);
201 struct AccountEntry **pentry = ARRAY_GET(&ad->entries, index);
202 if (!pentry)
203 return 0;
204
205 if (!toggle_prefer_encrypt((*pentry)))
206 return FR_ERROR;
207
209 return FR_SUCCESS;
210}
static bool toggle_prefer_encrypt(struct AccountEntry *entry)
Toggle whether an Autocrypt account prefers encryption.
Definition functions.c:120
Here is the call graph for this function:

◆ op_quit()

int op_quit ( struct AutocryptData * ad,
const struct KeyEvent * event )
static

Save changes and exit this dialog - Implements autocrypt_function_t -.

Definition at line 215 of file functions.c.

216{
217 ad->done = true;
218 return FR_SUCCESS;
219}
bool done
Should we close the Dialog?