NeoMutt  2024-11-14-34-g5aaf0d
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, int op)
 Create a new autocrypt account - Implements autocrypt_function_t -.
 
static int op_autocrypt_delete_acct (struct AutocryptData *ad, int op)
 Delete the current account - Implements autocrypt_function_t -.
 
static int op_autocrypt_toggle_active (struct AutocryptData *ad, int op)
 Toggle the current account active/inactive - Implements autocrypt_function_t -.
 
static int op_autocrypt_toggle_prefer (struct AutocryptData *ad, int op)
 Toggle the current account prefer-encrypt flag - Implements autocrypt_function_t -.
 
static int op_exit (struct AutocryptData *ad, int op)
 Exit this menu - Implements autocrypt_function_t -.
 

Detailed Description

Prototype for a Autocrypt Function.

Parameters
menuMenu
opOperation to perform, e.g. OP_AUTOCRYPT_CREATE_ACCT
Return values
enumFunctionRetval

Function Documentation

◆ op_autocrypt_create_acct()

static int op_autocrypt_create_acct ( struct AutocryptData ad,
int  op 
)
static

Create a new autocrypt account - Implements autocrypt_function_t -.

Definition at line 113 of file functions.c.

114{
115 if (mutt_autocrypt_account_init(false) == 0)
116 populate_menu(ad->menu);
117
118 return FR_SUCCESS;
119}
int mutt_autocrypt_account_init(bool prompt)
Create a new Autocrypt account.
Definition: autocrypt.c:143
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
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()

static int op_autocrypt_delete_acct ( struct AutocryptData ad,
int  op 
)
static

Delete the current account - Implements autocrypt_function_t -.

Definition at line 124 of file functions.c.

125{
126 if (!ad->menu->mdata)
127 return FR_ERROR;
128
129 const int index = menu_get_index(ad->menu);
130 struct AccountEntry **pentry = ARRAY_GET(&ad->entries, index);
131 if (!pentry)
132 return 0;
133
134 char msg[128] = { 0 };
135 snprintf(msg, sizeof(msg),
136 // L10N: Confirmation message when deleting an autocrypt account
137 _("Really delete account \"%s\"?"), buf_string((*pentry)->addr->mailbox));
138 if (query_yesorno(msg, MUTT_NO) != MUTT_YES)
139 return FR_NO_ACTION;
140
141 if (mutt_autocrypt_db_account_delete((*pentry)->account) == 0)
142 populate_menu(ad->menu);
143
144 return FR_SUCCESS;
145}
#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:427
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:38
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:160
#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:327
An entry in the Autocrypt account Menu.
Definition: private.h:47
struct AccountEntryArray entries
Account Entries.
void * mdata
Private data.
Definition: lib.h:147
+ Here is the call graph for this function:

◆ op_autocrypt_toggle_active()

static int op_autocrypt_toggle_active ( struct AutocryptData ad,
int  op 
)
static

Toggle the current account active/inactive - Implements autocrypt_function_t -.

Definition at line 150 of file functions.c.

151{
152 if (!ad->menu->mdata)
153 return FR_ERROR;
154
155 const int index = menu_get_index(ad->menu);
156 struct AccountEntry **pentry = ARRAY_GET(&ad->entries, index);
157 if (!pentry)
158 return 0;
159
160 toggle_active((*pentry));
162
163 return FR_SUCCESS;
164}
static void toggle_active(struct AccountEntry *entry)
Toggle whether an Autocrypt account is active.
Definition: functions.c:82
#define MENU_REDRAW_FULL
Redraw everything.
Definition: lib.h:59
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:184
+ Here is the call graph for this function:

◆ op_autocrypt_toggle_prefer()

static int op_autocrypt_toggle_prefer ( struct AutocryptData ad,
int  op 
)
static

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

Definition at line 169 of file functions.c.

170{
171 if (!ad->menu->mdata)
172 return FR_ERROR;
173
174 const int index = menu_get_index(ad->menu);
175 struct AccountEntry **pentry = ARRAY_GET(&ad->entries, index);
176 if (!pentry)
177 return 0;
178
179 toggle_prefer_encrypt((*pentry));
181
182 return FR_SUCCESS;
183}
static void toggle_prefer_encrypt(struct AccountEntry *entry)
Toggle whether an Autocrypt account prefers encryption.
Definition: functions.c:98
+ Here is the call graph for this function:

◆ op_exit()

static int op_exit ( struct AutocryptData ad,
int  op 
)
static

Exit this menu - Implements autocrypt_function_t -.

Definition at line 188 of file functions.c.

189{
190 ad->done = true;
191 return FR_SUCCESS;
192}
bool done
Should we close the Dialog?