NeoMutt  2024-11-14-34-g5aaf0d
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 "autocrypt_data.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() -.
 
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 223 of file dlg_autocrypt.c.

224{
225 struct AutocryptData *ad = menu->mdata;
226
227 // Clear out any existing data
229 menu->max = 0;
230
231 struct AutocryptAccountArray accounts = ARRAY_HEAD_INITIALIZER;
232
233 if (mutt_autocrypt_db_account_get_all(&accounts) < 0)
234 return false;
235
236 menu->max = ARRAY_SIZE(&accounts);
237
238 struct AutocryptAccount **pac = NULL;
239 ARRAY_FOREACH(pac, &accounts)
240 {
241 struct AccountEntry *entry = MUTT_MEM_CALLOC(1, struct AccountEntry);
242
243 entry->num = ARRAY_FOREACH_IDX + 1;
244 /* note: we are transferring the account pointer to the entries
245 * array, and freeing the accounts array below. the account
246 * will be freed in autocrypt_menu_free(). */
247 entry->account = *pac;
248
249 entry->addr = mutt_addr_new();
250 entry->addr->mailbox = buf_new((*pac)->email_addr);
251 mutt_addr_to_local(entry->addr);
252 ARRAY_ADD(&ad->entries, entry);
253 }
254 ARRAY_FREE(&accounts);
255
257 return true;
258}
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
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:156
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition: array.h:58
int mutt_autocrypt_db_account_get_all(struct AutocryptAccountArray *aaa)
Get all accounts from an Autocrypt database.
Definition: db.c:461
void account_entry_array_clear(struct AccountEntryArray *entries)
Clear an AccountEntry array.
struct Buffer * buf_new(const char *str)
Allocate a new Buffer.
Definition: buffer.c:304
#define MUTT_MEM_CALLOC(n, type)
Definition: memory.h:40
#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:47
struct Address * addr
Email address associated with the account.
Definition: private.h:50
struct AutocryptAccount * account
Account details.
Definition: private.h:49
int num
Number in the index.
Definition: private.h:48
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
Autocrypt account.
Definition: lib.h:108
Data to pass to the Autocrypt Functions.
struct Menu * menu
Autocrypt Menu.
struct AccountEntryArray entries
Account Entries.
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:63
@ ED_AUT_KEYID
AutocryptAccount.keyid.
Definition: private.h:62
@ ED_AUT_NUMBER
AccountEntry.num.
Definition: private.h:64
@ ED_AUT_ENABLED
AutocryptAccount.enabled.
Definition: private.h:61
@ ED_AUT_PREFER_ENCRYPT
AutocryptAccount.prefer_encrypt.
Definition: private.h:65
@ 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 86 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 89 of file dlg_autocrypt.c.