NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_pgp.c
Go to the documentation of this file.
1
70#include "config.h"
71#include <locale.h>
72#include <stdbool.h>
73#include <stdio.h>
74#include "private.h"
75#include "mutt/lib.h"
76#include "address/lib.h"
77#include "config/lib.h"
78#include "core/lib.h"
79#include "gui/lib.h"
80#include "lib.h"
81#include "expando/lib.h"
82#include "key/lib.h"
83#include "menu/lib.h"
84#include "mutt_logging.h"
85#include "pgp.h"
86#include "pgp_functions.h"
87#include "pgpkey.h"
88#include "pgplib.h"
89#include "sort.h"
90
92
94static const struct Mapping PgpHelp[] = {
95 // clang-format off
96 { N_("Exit"), OP_EXIT },
97 { N_("Select"), OP_GENERIC_SELECT_ENTRY },
98 { N_("Check key"), OP_VERIFY_KEY },
99 { N_("Help"), OP_HELP },
100 { NULL, 0 },
101 // clang-format on
102};
103
105static const char TrustFlags[] = "?- +";
106
110static int pgp_sort_address(const void *a, const void *b, void *sdata)
111{
112 struct PgpUid const *s = *(struct PgpUid const *const *) a;
113 struct PgpUid const *t = *(struct PgpUid const *const *) b;
114 const bool sort_reverse = *(bool *) sdata;
115
116 int rc = mutt_istr_cmp(s->addr, t->addr);
117 if (rc != 0)
118 goto done;
119
121
122done:
123 return sort_reverse ? -rc : rc;
124}
125
129static int pgp_sort_date(const void *a, const void *b, void *sdata)
130{
131 struct PgpUid const *s = *(struct PgpUid const *const *) a;
132 struct PgpUid const *t = *(struct PgpUid const *const *) b;
133 const bool sort_reverse = *(bool *) sdata;
134
136 if (rc != 0)
137 goto done;
138
139 rc = mutt_istr_cmp(s->addr, t->addr);
140
141done:
142 return sort_reverse ? -rc : rc;
143}
144
148static int pgp_sort_keyid(const void *a, const void *b, void *sdata)
149{
150 struct PgpUid const *s = *(struct PgpUid const *const *) a;
151 struct PgpUid const *t = *(struct PgpUid const *const *) b;
152 const bool sort_reverse = *(bool *) sdata;
153
155 if (rc != 0)
156 goto done;
157
158 rc = mutt_istr_cmp(s->addr, t->addr);
159
160done:
161 return sort_reverse ? -rc : rc;
162}
163
167static int pgp_sort_trust(const void *a, const void *b, void *sdata)
168{
169 struct PgpUid const *s = *(struct PgpUid const *const *) a;
170 struct PgpUid const *t = *(struct PgpUid const *const *) b;
171 const bool sort_reverse = *(bool *) sdata;
172
175 if (rc != 0)
176 goto done;
177
178 // Note: reversed
179 rc = mutt_numeric_cmp(t->trust, s->trust);
180 if (rc != 0)
181 goto done;
182
183 // Note: reversed
185 if (rc != 0)
186 goto done;
187
188 // Note: reversed
190 if (rc != 0)
191 goto done;
192
193 rc = mutt_istr_cmp(s->addr, t->addr);
194 if (rc != 0)
195 goto done;
196
198
199done:
200 return sort_reverse ? -rc : rc;
201}
202
211{
212 static char buf[3];
213
214 if (!(flags & KEYFLAG_CANENCRYPT))
215 buf[0] = '-';
216 else if (flags & KEYFLAG_PREFER_SIGNING)
217 buf[0] = '.';
218 else
219 buf[0] = 'e';
220
221 if (!(flags & KEYFLAG_CANSIGN))
222 buf[1] = '-';
224 buf[1] = '.';
225 else
226 buf[1] = 's';
227
228 buf[2] = '\0';
229
230 return buf;
231}
232
239{
241 return 'R';
243 return 'X';
245 return 'd';
247 return 'c';
248
249 return ' ';
250}
251
255long pgp_entry_pgp_date_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
256{
257#ifdef HAVE_PGP
258 const struct PgpEntry *entry = data;
259 const struct PgpUid *uid = entry->uid;
260 const struct PgpKeyInfo *key = uid->parent;
261
262 return key->gen_time;
263#endif
264 return 0;
265}
266
270void pgp_entry_pgp_date(const struct ExpandoNode *node, void *data,
271 MuttFormatFlags flags, struct Buffer *buf)
272{
273#ifdef HAVE_PGP
274 const struct PgpEntry *entry = data;
275 const struct PgpUid *uid = entry->uid;
276 const struct PgpKeyInfo *key = uid->parent;
277
278 bool use_c_locale = false;
279 const char *text = node->text;
280 if (*text == '!')
281 {
282 use_c_locale = true;
283 text++;
284 }
285
286 char tmp[128] = { 0 };
287 if (use_c_locale)
288 {
289 mutt_date_localtime_format_locale(tmp, sizeof(tmp), text, key->gen_time,
291 }
292 else
293 {
294 mutt_date_localtime_format(tmp, sizeof(tmp), text, key->gen_time);
295 }
296
297 buf_strcpy(buf, tmp);
298#endif
299}
300
304long pgp_entry_pgp_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
305{
306#ifdef HAVE_PGP
307 const struct PgpEntry *entry = data;
308 return entry->num;
309#else
310 return 0;
311#endif
312}
313
317void pgp_entry_pgp_t(const struct ExpandoNode *node, void *data,
318 MuttFormatFlags flags, struct Buffer *buf)
319{
320#ifdef HAVE_PGP
321 const struct PgpEntry *entry = data;
322 const struct PgpUid *uid = entry->uid;
323
324 buf_printf(buf, "%c", TrustFlags[uid->trust & 0x03]);
325#endif
326}
327
331void pgp_entry_pgp_u(const struct ExpandoNode *node, void *data,
332 MuttFormatFlags flags, struct Buffer *buf)
333{
334#ifdef HAVE_PGP
335 const struct PgpEntry *entry = data;
336 const struct PgpUid *uid = entry->uid;
337
338 const char *s = uid->addr;
339 buf_strcpy(buf, s);
340#endif
341}
342
346void pgp_entry_pgp_a(const struct ExpandoNode *node, void *data,
347 MuttFormatFlags flags, struct Buffer *buf)
348{
349#ifdef HAVE_PGP
350 const struct PgpEntry *entry = data;
351 const struct PgpUid *uid = entry->uid;
352 const struct PgpKeyInfo *key = uid->parent;
353
354 const char *s = key->algorithm;
355 buf_strcpy(buf, s);
356#endif
357}
358
362void pgp_entry_pgp_A(const struct ExpandoNode *node, void *data,
363 MuttFormatFlags flags, struct Buffer *buf)
364{
365#ifdef HAVE_PGP
366 const struct PgpEntry *entry = data;
367 const struct PgpUid *uid = entry->uid;
368 struct PgpKeyInfo *key = uid->parent;
369 struct PgpKeyInfo *pkey = pgp_principal_key(key);
370
371 const char *s = pkey->algorithm;
372 buf_strcpy(buf, s);
373#endif
374}
375
379void pgp_entry_pgp_c(const struct ExpandoNode *node, void *data,
380 MuttFormatFlags flags, struct Buffer *buf)
381{
382#ifdef HAVE_PGP
383 const struct PgpEntry *entry = data;
384 const struct PgpUid *uid = entry->uid;
385 const struct PgpKeyInfo *key = uid->parent;
386
387 const KeyFlags kflags = key->flags | uid->flags;
388
389 const char *s = pgp_key_abilities(kflags);
390 buf_strcpy(buf, s);
391#endif
392}
393
397void pgp_entry_pgp_C(const struct ExpandoNode *node, void *data,
398 MuttFormatFlags flags, struct Buffer *buf)
399{
400#ifdef HAVE_PGP
401 const struct PgpEntry *entry = data;
402 const struct PgpUid *uid = entry->uid;
403 struct PgpKeyInfo *key = uid->parent;
404 struct PgpKeyInfo *pkey = pgp_principal_key(key);
405
406 const KeyFlags kflags = (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags;
407
408 const char *s = pgp_key_abilities(kflags);
409 buf_strcpy(buf, s);
410#endif
411}
412
416void pgp_entry_pgp_f(const struct ExpandoNode *node, void *data,
417 MuttFormatFlags flags, struct Buffer *buf)
418{
419#ifdef HAVE_PGP
420 const struct PgpEntry *entry = data;
421 const struct PgpUid *uid = entry->uid;
422 const struct PgpKeyInfo *key = uid->parent;
423
424 const KeyFlags kflags = key->flags | uid->flags;
425
426 buf_printf(buf, "%c", pgp_flags(kflags));
427#endif
428}
429
433void pgp_entry_pgp_F(const struct ExpandoNode *node, void *data,
434 MuttFormatFlags flags, struct Buffer *buf)
435{
436#ifdef HAVE_PGP
437 const struct PgpEntry *entry = data;
438 const struct PgpUid *uid = entry->uid;
439 struct PgpKeyInfo *key = uid->parent;
440 struct PgpKeyInfo *pkey = pgp_principal_key(key);
441
442 const KeyFlags kflags = (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags;
443
444 buf_printf(buf, "%c", pgp_flags(kflags));
445#endif
446}
447
451void pgp_entry_pgp_k(const struct ExpandoNode *node, void *data,
452 MuttFormatFlags flags, struct Buffer *buf)
453{
454#ifdef HAVE_PGP
455 const struct PgpEntry *entry = data;
456 const struct PgpUid *uid = entry->uid;
457 struct PgpKeyInfo *key = uid->parent;
458
459 const char *s = pgp_this_keyid(key);
460 buf_strcpy(buf, s);
461#endif
462}
463
467void pgp_entry_pgp_K(const struct ExpandoNode *node, void *data,
468 MuttFormatFlags flags, struct Buffer *buf)
469{
470#ifdef HAVE_PGP
471 const struct PgpEntry *entry = data;
472 const struct PgpUid *uid = entry->uid;
473 struct PgpKeyInfo *key = uid->parent;
474 struct PgpKeyInfo *pkey = pgp_principal_key(key);
475
476 const char *s = pgp_this_keyid(pkey);
477 buf_strcpy(buf, s);
478#endif
479}
480
484long pgp_entry_pgp_l_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
485{
486#ifdef HAVE_PGP
487 const struct PgpEntry *entry = data;
488 const struct PgpUid *uid = entry->uid;
489 const struct PgpKeyInfo *key = uid->parent;
490
491 return key->keylen;
492#else
493 return 0;
494#endif
495}
496
500long pgp_entry_pgp_L_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
501{
502#ifdef HAVE_PGP
503 const struct PgpEntry *entry = data;
504 const struct PgpUid *uid = entry->uid;
505 struct PgpKeyInfo *key = uid->parent;
506 struct PgpKeyInfo *pkey = pgp_principal_key(key);
507
508 return pkey->keylen;
509#else
510 return 0;
511#endif
512}
513
517void pgp_entry_ignore(const struct ExpandoNode *node, void *data,
518 MuttFormatFlags flags, struct Buffer *buf)
519{
520}
521
527static int pgp_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
528{
529 struct PgpUid **key_table = menu->mdata;
530
531 struct PgpEntry entry = { 0 };
532 entry.uid = key_table[line];
533 entry.num = line + 1;
534
535 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
536 if (c_arrow_cursor)
537 {
538 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
539 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
540 }
541
542 const struct Expando *c_pgp_entry_format = cs_subset_expando(NeoMutt->sub, "pgp_entry_format");
543 return expando_filter(c_pgp_entry_format, PgpEntryRenderData, &entry,
544 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
545}
546
552static void pgp_key_table_free(struct Menu *menu, void **ptr)
553{
554 FREE(ptr);
555}
556
561{
562 if (nc->event_type != NT_CONFIG)
563 return 0;
564 if (!nc->global_data || !nc->event_data)
565 return -1;
566
567 struct EventConfig *ev_c = nc->event_data;
568
569 if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
570 !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
571 {
572 return 0;
573 }
574
575 struct Menu *menu = nc->global_data;
577 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
578
579 return 0;
580}
581
590{
591 if (nc->event_type != NT_WINDOW)
592 return 0;
593 if (!nc->global_data || !nc->event_data)
594 return -1;
596 return 0;
597
598 struct MuttWindow *win_menu = nc->global_data;
599 struct EventWindow *ev_w = nc->event_data;
600 if (ev_w->win != win_menu)
601 return 0;
602
603 struct Menu *menu = win_menu->wdata;
604
607
608 mutt_debug(LL_DEBUG5, "window delete done\n");
609 return 0;
610}
611
621struct PgpKeyInfo *dlg_pgp(struct PgpKeyInfo *keys, struct Address *p, const char *s)
622{
623 struct PgpUid **key_table = NULL;
624 struct Menu *menu = NULL;
625 char buf[1024] = { 0 };
626 struct PgpUid *a = NULL;
627 bool unusable = false;
628 int keymax = 0;
629
630 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
631 int i = 0;
632 for (struct PgpKeyInfo *kp = keys; kp; kp = kp->next)
633 {
634 if (!c_pgp_show_unusable && (kp->flags & KEYFLAG_CANTUSE))
635 {
636 unusable = true;
637 continue;
638 }
639
640 for (a = kp->address; a; a = a->next)
641 {
642 if (!c_pgp_show_unusable && (a->flags & KEYFLAG_CANTUSE))
643 {
644 unusable = true;
645 continue;
646 }
647
648 if (i == keymax)
649 {
650 keymax += 5;
651 mutt_mem_realloc(&key_table, sizeof(struct PgpUid *) * keymax);
652 }
653
654 key_table[i++] = a;
655 }
656 }
657
658 if ((i == 0) && unusable)
659 {
660 mutt_error(_("All matching keys are expired, revoked, or disabled"));
661 return NULL;
662 }
663
664 sort_t f = NULL;
665 short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
666 switch (c_pgp_sort_keys & SORT_MASK)
667 {
668 case SORT_ADDRESS:
670 break;
671 case SORT_DATE:
672 f = pgp_sort_date;
673 break;
674 case SORT_KEYID:
675 f = pgp_sort_keyid;
676 break;
677 case SORT_TRUST:
678 default:
679 f = pgp_sort_trust;
680 break;
681 }
682
683 if (key_table)
684 {
685 bool sort_reverse = c_pgp_sort_keys & SORT_REVERSE;
686 mutt_qsort_r(key_table, i, sizeof(struct PgpUid *), f, &sort_reverse);
687 }
688
690
691 menu = dlg->wdata;
692 menu->max = i;
694 menu->mdata = key_table;
696
697 struct PgpData pd = { false, menu, key_table, NULL };
698 dlg->wdata = &pd;
699
700 // NT_COLOR is handled by the SimpleDialog
703
704 if (p)
705 snprintf(buf, sizeof(buf), _("PGP keys matching <%s>"), buf_string(p->mailbox));
706 else
707 snprintf(buf, sizeof(buf), _("PGP keys matching \"%s\""), s);
708
709 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
710 sbar_set_title(sbar, buf);
711
713
714 struct MuttWindow *old_focus = window_set_focus(menu->win);
715 // ---------------------------------------------------------------------------
716 // Event Loop
717 int op = OP_NULL;
718 do
719 {
720 menu_tagging_dispatcher(menu->win, op);
721 window_redraw(NULL);
722
724 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
725 if (op < 0)
726 continue;
727 if (op == OP_NULL)
728 {
730 continue;
731 }
733
734 int rc = pgp_function_dispatcher(dlg, op);
735
736 if (rc == FR_UNKNOWN)
737 rc = menu_function_dispatcher(menu->win, op);
738 if (rc == FR_UNKNOWN)
739 rc = global_function_dispatcher(NULL, op);
740 } while (!pd.done);
741 // ---------------------------------------------------------------------------
742
743 window_set_focus(old_focus);
744 simple_dialog_free(&dlg);
745 return pd.key;
746}
747
753const struct ExpandoRenderData PgpEntryRenderData[] = {
754 // clang-format off
772 { -1, -1, NULL, NULL },
773 // clang-format on
774};
Email Address Handling.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:266
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
Definition: config_type.c:357
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition: curs_lib.c:443
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
static char pgp_flags(KeyFlags flags)
Turn PGP key flags into a string.
Definition: dlg_pgp.c:238
static const struct Mapping PgpHelp[]
Help Bar for the PGP key selection dialog.
Definition: dlg_pgp.c:94
static const char TrustFlags[]
Characters used to show the trust level for PGP keys.
Definition: dlg_pgp.c:105
const struct ExpandoRenderData PgpEntryRenderData[]
PgpEntryRenderData- Callbacks for PGP Key Expandos.
Definition: dlg_pgp.c:91
static char * pgp_key_abilities(KeyFlags flags)
Turn PGP key abilities into a string.
Definition: dlg_pgp.c:210
@ ED_PGP
Pgp ED_PGP_ ExpandoDataPgp.
Definition: domain.h:51
@ ED_PGP_KEY
Pgp_Key ED_PGK_ ExpandoDataPgpKey.
Definition: domain.h:53
int expando_filter(const struct Expando *exp, const struct ExpandoRenderData *rdata, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando and run the result through a filter.
Definition: filter.c:138
Parse Expando string.
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition: get.c:464
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: get.c:294
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:230
int pgp_function_dispatcher(struct MuttWindow *win, int op)
Perform a Pgp function - Implements function_dispatcher_t -.
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:172
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:318
long pgp_entry_pgp_l_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
PGP: Key length - Implements ExpandoRenderData::get_number() -.
Definition: dlg_pgp.c:484
long pgp_entry_pgp_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
PGP: Index number - Implements ExpandoRenderData::get_number() -.
Definition: dlg_pgp.c:304
long pgp_entry_pgp_date_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
PGP: Date of the key - Implements ExpandoRenderData::get_number() -.
Definition: dlg_pgp.c:255
long pgp_entry_pgp_L_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
PGP: Principal Key length - Implements ExpandoRenderData::get_number() -.
Definition: dlg_pgp.c:500
void pgp_entry_pgp_A(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Principal Key Algorithm - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:362
void pgp_entry_pgp_F(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Principal Key Flags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:433
void pgp_entry_pgp_K(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Principal Key id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:467
void pgp_entry_pgp_date(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Date of the key - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:270
void pgp_entry_pgp_k(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Key id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:451
void pgp_entry_pgp_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Trust/validity - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:317
void pgp_entry_pgp_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Key Capabilities - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:379
void pgp_entry_pgp_C(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Principal Key Capabilities - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:397
void pgp_entry_pgp_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Key Flags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:416
void pgp_entry_ignore(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Field not supported - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:517
void pgp_entry_pgp_u(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: User id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:331
void pgp_entry_pgp_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
PGP: Key Algorithm - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:346
struct PgpKeyInfo * dlg_pgp(struct PgpKeyInfo *keys, struct Address *p, const char *s)
Let the user select a key to use -.
Definition: dlg_pgp.c:621
#define mutt_error(...)
Definition: logging2.h:92
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int pgp_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format a PGP Key for the Menu - Implements Menu::make_entry() -.
Definition: dlg_pgp.c:527
static void pgp_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlg_pgp.c:552
static int pgp_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_pgp.c:589
static int pgp_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_pgp.c:560
static int pgp_sort_trust(const void *a, const void *b, void *sdata)
Compare two keys by their trust levels - Implements sort_t -.
Definition: dlg_pgp.c:167
static int pgp_sort_keyid(const void *a, const void *b, void *sdata)
Compare two keys by their IDs - Implements sort_t -.
Definition: dlg_pgp.c:148
static int pgp_sort_date(const void *a, const void *b, void *sdata)
Compare two keys by their dates - Implements sort_t -.
Definition: dlg_pgp.c:129
static int pgp_sort_address(const void *a, const void *b, void *sdata)
Compare two keys by their addresses - Implements sort_t -.
Definition: dlg_pgp.c:110
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:168
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:132
Manage keymappings.
#define GETCH_NO_FLAGS
No flags are set.
Definition: lib.h:51
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:115
#define FREE(x)
Definition: memory.h:45
GUI present the user with a selectable list.
#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
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:951
size_t mutt_date_localtime_format_locale(char *buf, size_t buflen, const char *format, time_t t, locale_t loc)
Format localtime using a given locale.
Definition: date.c:969
Convenience wrapper for the library headers.
#define N_(a)
Definition: message.h:32
#define _(a)
Definition: message.h:28
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:230
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:191
int mutt_istr_cmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:412
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
NeoMutt Logging.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:633
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:683
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:532
@ WT_DLG_PGP
Pgp Dialog, dlg_pgp()
Definition: mutt_window.h:88
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:101
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:228
#define KEYFLAG_EXPIRED
Key is expired.
Definition: lib.h:131
uint16_t KeyFlags
Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN.
Definition: lib.h:125
#define KEYFLAG_RESTRICTIONS
Definition: lib.h:140
#define KEYFLAG_CANENCRYPT
Key is suitable for encryption.
Definition: lib.h:128
#define KEYFLAG_CANTUSE
Definition: lib.h:139
#define KEYFLAG_PREFER_SIGNING
Key's owner prefers signing.
Definition: lib.h:137
#define KEYFLAG_CRITICAL
Key is marked critical.
Definition: lib.h:135
#define KEYFLAG_DISABLED
Key is marked disabled.
Definition: lib.h:133
#define KEYFLAG_REVOKED
Key is revoked.
Definition: lib.h:132
#define KEYFLAG_PREFER_ENCRYPTION
Key's owner prefers encryption.
Definition: lib.h:136
#define KEYFLAG_CANSIGN
Key is suitable for signing.
Definition: lib.h:127
@ ED_PGP_NUMBER
PgpEntry.num.
Definition: private.h:51
@ ED_PGP_USER_ID
PgpUid.addr.
Definition: private.h:53
@ ED_PGP_TRUST
PgpUid, TrustFlags.
Definition: private.h:52
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:48
char * pgp_this_keyid(struct PgpKeyInfo *k)
Get the ID of this key.
Definition: pgp.c:191
char * pgp_fpr_or_lkeyid(struct PgpKeyInfo *k)
Get the fingerprint or long keyid.
Definition: pgp.c:234
PGP sign, encrypt, check routines.
Pgp functions.
struct PgpKeyInfo * pgp_principal_key(struct PgpKeyInfo *key)
Get the main (parent) PGP key.
Definition: pgpkey.c:92
PGP key management routines.
Misc PGP helper routines.
@ ED_PGK_KEY_CAPABILITIES
PgpKeyInfo.flags, pgp_key_abilities()
Definition: pgplib.h:69
@ ED_PGK_KEY_FINGERPRINT
PgpKeyInfo.fingerprint.
Definition: pgplib.h:70
@ ED_PGK_PKEY_LENGTH
pgp_principal_key(), PgpKeyInfo.keylen
Definition: pgplib.h:79
@ ED_PGK_PKEY_ALGORITHM
pgp_principal_key(), PgpKeyInfo.algorithm
Definition: pgplib.h:74
@ ED_PGK_DATE
PgpKeyInfo.gen_time.
Definition: pgplib.h:67
@ ED_PGK_PKEY_FINGERPRINT
pgp_principal_key(), PgpKeyInfo.fingerprint
Definition: pgplib.h:76
@ ED_PGK_KEY_ID
PgpKeyInfo, pgp_this_keyid()
Definition: pgplib.h:72
@ ED_PGK_PROTOCOL
PgpKeyInfo.
Definition: pgplib.h:80
@ ED_PGK_PKEY_CAPABILITIES
pgp_principal_key(), PgpKeyInfo.flags, pgp_key_abilities()
Definition: pgplib.h:75
@ ED_PGK_KEY_FLAGS
PgpKeyInfo.kflags, pgp_flags()
Definition: pgplib.h:71
@ ED_PGK_PKEY_ID
pgp_principal_key(), PgpKeyInfo, pgp_this_keyid()
Definition: pgplib.h:78
@ ED_PGK_KEY_ALGORITHM
PgpKeyInfo.algorithm.
Definition: pgplib.h:68
@ ED_PGK_KEY_LENGTH
PgpKeyInfo.keylen.
Definition: pgplib.h:73
@ ED_PGK_PKEY_FLAGS
pgp_principal_key(), PgpKeyInfo.kflags, pgp_flags()
Definition: pgplib.h:77
void mutt_qsort_r(void *base, size_t nmemb, size_t size, sort_t compar, void *sdata)
Sort an array, where the comparator has access to opaque data rather than requiring global variables.
Definition: qsort_r.c:67
int(* sort_t)(const void *a, const void *b, void *sdata)
Definition: qsort_r.h:41
#define MUTT_FORMAT_ARROWCURSOR
Reserve space for arrow_cursor.
Definition: render.h:37
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: render.h:32
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:227
GUI display the mailboxes in a side panel.
#define SORT_MASK
Mask for the sort id.
Definition: sort2.h:70
@ SORT_TRUST
Sort by encryption key's trust level.
Definition: sort2.h:48
@ SORT_KEYID
Sort by the encryption key's ID.
Definition: sort2.h:47
@ SORT_DATE
Sort by the date the email was sent.
Definition: sort2.h:35
@ SORT_ADDRESS
Sort by email address.
Definition: sort2.h:46
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:71
Assorted sorting methods.
#define mutt_numeric_cmp(a, b)
Definition: sort.h:35
Key value store.
An email address.
Definition: address.h:36
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
String manipulation buffer.
Definition: buffer.h:36
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
A config-change event.
Definition: subset.h:71
const char * name
Name of config item that changed.
Definition: subset.h:73
An Event that happened to a Window.
Definition: mutt_window.h:238
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:239
Basic Expando Node.
Definition: node.h:67
const char * text
Node-specific text.
Definition: node.h:73
Parsed Expando trees.
Definition: expando.h:41
Mapping between user-readable string and a constant.
Definition: mapping.h:33
Definition: lib.h:79
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:86
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:161
int(* make_entry)(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Definition: lib.h:106
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:87
void * mdata
Private data.
Definition: lib.h:147
int max
Number of entries in the menu.
Definition: lib.h:81
void * wdata
Private data.
Definition: mutt_window.h:144
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:137
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
locale_t time_c_locale
Current locale but LC_TIME=C.
Definition: neomutt.h:48
Data passed to a notification function.
Definition: observer.h:34
void * event_data
Data from notify_send()
Definition: observer.h:38
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:36
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:37
void * global_data
Data from notify_observer_add()
Definition: observer.h:39
Data to pass to the Pgp Functions.
Definition: pgp_functions.h:34
struct PgpUid ** key_table
Array of Keys.
Definition: pgp_functions.h:37
struct Menu * menu
Pgp Menu.
Definition: pgp_functions.h:36
bool done
Should we close the Dialog?
Definition: pgp_functions.h:35
struct PgpKeyInfo * key
Selected Key.
Definition: pgp_functions.h:38
An entry in a PGP key menu.
Definition: private.h:39
struct PgpUid * uid
PGP Key info.
Definition: private.h:41
size_t num
Index number.
Definition: private.h:40
Information about a PGP key.
Definition: pgplib.h:47
KeyFlags flags
Definition: pgplib.h:51
struct PgpKeyInfo * next
Definition: pgplib.h:57
short keylen
Definition: pgplib.h:52
time_t gen_time
Definition: pgplib.h:53
const char * algorithm
Definition: pgplib.h:55
PGP User ID.
Definition: pgplib.h:35
short trust
Definition: pgplib.h:37
struct PgpKeyInfo * parent
Parent key.
Definition: pgplib.h:39
int flags
Definition: pgplib.h:38
char * addr
Definition: pgplib.h:36
struct PgpUid * next
Linked list.
Definition: pgplib.h:40
@ MENU_PGP
PGP encryption menu.
Definition: type.h:53