NeoMutt  2024-12-12-14-g7b49f7
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 "expando.h"
#include "functions.h"
#include "mutt_logging.h"
+ Include dependency graph for dlg_autocrypt.c:

Go to the source code of this file.

Functions

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

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

145{
146 struct AutocryptData *ad = menu->mdata;
147
148 // Clear out any existing data
150 menu->max = 0;
151
152 struct AutocryptAccountArray accounts = ARRAY_HEAD_INITIALIZER;
153
154 if (mutt_autocrypt_db_account_get_all(&accounts) < 0)
155 return false;
156
157 menu->max = ARRAY_SIZE(&accounts);
158
159 struct AutocryptAccount **pac = NULL;
160 ARRAY_FOREACH(pac, &accounts)
161 {
162 struct AccountEntry *entry = MUTT_MEM_CALLOC(1, struct AccountEntry);
163
164 entry->num = ARRAY_FOREACH_IDX + 1;
165 /* note: we are transferring the account pointer to the entries
166 * array, and freeing the accounts array below. the account
167 * will be freed in autocrypt_menu_free(). */
168 entry->account = *pac;
169
170 entry->addr = mutt_addr_new();
171 entry->addr->mailbox = buf_new((*pac)->email_addr);
172 mutt_addr_to_local(entry->addr);
173 ARRAY_ADD(&ad->entries, entry);
174 }
175 ARRAY_FREE(&accounts);
176
178 return true;
179}
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:46
struct Address * addr
Email address associated with the account.
Definition: private.h:49
struct AutocryptAccount * account
Account details.
Definition: private.h:48
int num
Number in the index.
Definition: private.h:47
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
Autocrypt account.
Definition: lib.h:110
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

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