NeoMutt
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_autocrypt.c File Reference

Autocrypt account menu. More...

#include "config.h"
#include <stdbool.h>
#include <stdint.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 "lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "format_flags.h"
#include "functions.h"
#include "mutt_logging.h"
#include "muttlib.h"
+ Include dependency graph for dlg_autocrypt.c:

Go to the source code of this file.

Functions

static const char * autocrypt_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
 Format a string for the Autocrypt account list - Implements format_t -.
 
static void autocrypt_make_entry (struct Menu *menu, char *buf, size_t buflen, int num)
 Create a line for the Autocrypt account menu - Implements Menu::make_entry() -.
 
static void autocrypt_menu_free (struct Menu *menu, void **ptr)
 Free the Autocrypt account Menu - Implements Menu::mdata_free() -.
 
bool populate_menu (struct Menu *menu)
 Add the Autocrypt data to a Menu.
 
static int autocrypt_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static int autocrypt_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
void dlg_autocrypt (void)
 Display the Autocrypt account Menu -.
 

Variables

static const struct Mapping AutocryptHelp []
 Help Bar for the Autocrypt Account selection dialog.
 

Detailed Description

Autocrypt account menu.

Authors
  • Kevin J. McCarthy

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

Function Documentation

◆ populate_menu()

bool populate_menu ( struct Menu menu)

Add the Autocrypt data to a Menu.

Parameters
menuMenu to populate
Return values
trueSuccess

Definition at line 213 of file dlg_autocrypt.c.

214{
215 // Clear out any existing data
216 autocrypt_menu_free(menu, &menu->mdata);
217 menu->max = 0;
218
219 struct AutocryptAccount **accounts = NULL;
220 int num_accounts = 0;
221
222 if (mutt_autocrypt_db_account_get_all(&accounts, &num_accounts) < 0)
223 return false;
224
225 struct AccountEntry *entries = mutt_mem_calloc(num_accounts, sizeof(struct AccountEntry));
226 menu->mdata = entries;
228 menu->max = num_accounts;
229
230 for (int i = 0; i < num_accounts; i++)
231 {
232 entries[i].num = i + 1;
233 /* note: we are transferring the account pointer to the entries
234 * array, and freeing the accounts array below. the account
235 * will be freed in autocrypt_menu_free(). */
236 entries[i].account = accounts[i];
237
238 entries[i].addr = mutt_addr_new();
239 entries[i].addr->mailbox = buf_new(accounts[i]->email_addr);
240 mutt_addr_to_local(entries[i].addr);
241 }
242 FREE(&accounts);
243
245 return true;
246}
struct Address * mutt_addr_new(void)
Create a new Address.
Definition: address.c:399
bool mutt_addr_to_local(struct Address *a)
Convert an Address from Punycode.
Definition: address.c:1341
int mutt_autocrypt_db_account_get_all(struct AutocryptAccount ***accounts, int *num_accounts)
Get all accounts from an Autocrypt database.
Definition: db.c:460
struct Buffer * buf_new(const char *str)
Allocate a new Buffer.
Definition: buffer.c:316
static void autocrypt_menu_free(struct Menu *menu, void **ptr)
Free the Autocrypt account Menu - Implements Menu::mdata_free() -.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
#define FREE(x)
Definition: memory.h:45
#define MENU_REDRAW_FULL
Redraw everything.
Definition: lib.h:60
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:180
An entry in the Autocrypt account Menu.
Definition: private.h:44
struct Address * addr
Email address associated with the account.
Definition: private.h:47
struct AutocryptAccount * account
Account details.
Definition: private.h:46
int num
Number in the index.
Definition: private.h:45
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
Autocrypt account.
Definition: lib.h:106
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:151
void * mdata
Private data.
Definition: lib.h:137
int max
Number of entries in the menu.
Definition: lib.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ AutocryptHelp

const struct Mapping AutocryptHelp[]
static
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("Create"), OP_AUTOCRYPT_CREATE_ACCT },
{ N_("Delete"), OP_AUTOCRYPT_DELETE_ACCT },
{ N_("Tgl Active"), OP_AUTOCRYPT_TOGGLE_ACTIVE },
{ N_("Prf Encr"), OP_AUTOCRYPT_TOGGLE_PREFER },
{ N_("Help"), OP_HELP },
{ NULL, 0 }
}
#define N_(a)
Definition: message.h:32

Help Bar for the Autocrypt Account selection dialog.

Definition at line 86 of file dlg_autocrypt.c.