NeoMutt  2024-10-02-37-gfa9146
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 <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 "expando/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "functions.h"
#include "mutt_logging.h"
+ Include dependency graph for dlg_autocrypt.c:

Go to the source code of this file.

Functions

void autocrypt_a (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Autocrypt: Address - Implements ExpandoRenderData::get_string() -.
 
void autocrypt_k (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Autocrypt: GPG Key - Implements ExpandoRenderData::get_string() -.
 
long autocrypt_n_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Autocrypt: Index number - Implements ExpandoRenderData::get_number() -.
 
void autocrypt_p (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Autocrypt: Prefer-encrypt flag - Implements ExpandoRenderData::get_string() -.
 
void autocrypt_s (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Autocrypt: Status flag - Implements ExpandoRenderData::get_string() -.
 
static int autocrypt_make_entry (struct Menu *menu, int line, int max_cols, struct Buffer *buf)
 Format an Autocrypt Account for the 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

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

Detailed Description

Autocrypt account menu.

Authors
  • Kevin J. McCarthy
  • Richard Russon
  • Tóth János

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 234 of file dlg_autocrypt.c.

235{
236 // Clear out any existing data
237 autocrypt_menu_free(menu, &menu->mdata);
238 menu->max = 0;
239
240 struct AutocryptAccount **accounts = NULL;
241 int num_accounts = 0;
242
243 if (mutt_autocrypt_db_account_get_all(&accounts, &num_accounts) < 0)
244 return false;
245
246 struct AccountEntry *entries = mutt_mem_calloc(num_accounts, sizeof(struct AccountEntry));
247 menu->mdata = entries;
249 menu->max = num_accounts;
250
251 for (int i = 0; i < num_accounts; i++)
252 {
253 entries[i].num = i + 1;
254 /* note: we are transferring the account pointer to the entries
255 * array, and freeing the accounts array below. the account
256 * will be freed in autocrypt_menu_free(). */
257 entries[i].account = accounts[i];
258
259 entries[i].addr = mutt_addr_new();
260 entries[i].addr->mailbox = buf_new(accounts[i]->email_addr);
261 mutt_addr_to_local(entries[i].addr);
262 }
263 FREE(&accounts);
264
266 return true;
267}
struct Address * mutt_addr_new(void)
Create a new Address.
Definition: address.c:401
bool mutt_addr_to_local(struct Address *a)
Convert an Address from Punycode.
Definition: address.c:1340
int mutt_autocrypt_db_account_get_all(struct AutocryptAccount ***accounts, int *num_accounts)
Get all accounts from an Autocrypt database.
Definition: db.c:463
struct Buffer * buf_new(const char *str)
Allocate a new Buffer.
Definition: buffer.c:304
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:51
#define FREE(x)
Definition: memory.h:45
#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
An entry in the Autocrypt account Menu.
Definition: private.h:45
struct Address * addr
Email address associated with the account.
Definition: private.h:48
struct AutocryptAccount * account
Account details.
Definition: private.h:47
int num
Number in the index.
Definition: private.h:46
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
Autocrypt account.
Definition: lib.h:107
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:161
void * mdata
Private data.
Definition: lib.h:147
int max
Number of entries in the menu.
Definition: lib.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ AutocryptRenderData

const struct ExpandoRenderData AutocryptRenderData
Initial value:
= {
{ -1, -1, NULL, NULL },
}
@ ED_AUT_ADDRESS
AccountEntry.addr.
Definition: private.h:60
@ ED_AUT_KEYID
AutocryptAccount.keyid.
Definition: private.h:59
@ ED_AUT_NUMBER
AccountEntry.num.
Definition: private.h:61
@ ED_AUT_ENABLED
AutocryptAccount.enabled.
Definition: private.h:58
@ ED_AUT_PREFER_ENCRYPT
AutocryptAccount.prefer_encrypt.
Definition: private.h:62
@ ED_AUTOCRYPT
Autocrypt ED_AUT_ ExpandoDataAutocrypt.
Definition: domain.h:37
long autocrypt_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Autocrypt: Index number - Implements ExpandoRenderData::get_number() -.
void autocrypt_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Autocrypt: Address - Implements ExpandoRenderData::get_string() -.
void autocrypt_p(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Autocrypt: Prefer-encrypt flag - Implements ExpandoRenderData::get_string() -.
void autocrypt_s(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Autocrypt: Status flag - Implements ExpandoRenderData::get_string() -.
void autocrypt_k(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Autocrypt: GPG Key - Implements ExpandoRenderData::get_string() -.

Callbacks for Autocrypt Expandos.

See also
AutocryptFormatDef, ExpandoDataAutocrypt, ExpandoDataGlobal

Definition at line 85 of file dlg_autocrypt.c.

◆ 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 88 of file dlg_autocrypt.c.