NeoMutt  2024-04-25-89-g194907
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, int max_cols, 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 char tmp[128] = { 0 };
279 char datestr[128] = { 0 };
280
281 int len = node->end - node->start;
282 const char *start = node->start;
283 bool use_c_locale = false;
284 if (*start == '!')
285 {
286 use_c_locale = true;
287 start++;
288 len--;
289 }
290
291 ASSERT(len < sizeof(datestr));
292 mutt_strn_copy(datestr, start, len, sizeof(datestr));
293
294 if (use_c_locale)
295 {
296 mutt_date_localtime_format_locale(tmp, sizeof(tmp), datestr, key->gen_time,
298 }
299 else
300 {
301 mutt_date_localtime_format(tmp, sizeof(tmp), datestr, key->gen_time);
302 }
303
304 buf_strcpy(buf, tmp);
305#endif
306}
307
311long pgp_entry_pgp_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
312{
313#ifdef HAVE_PGP
314 const struct PgpEntry *entry = data;
315 return entry->num;
316#else
317 return 0;
318#endif
319}
320
324void pgp_entry_pgp_t(const struct ExpandoNode *node, void *data,
325 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
326{
327#ifdef HAVE_PGP
328 const struct PgpEntry *entry = data;
329 const struct PgpUid *uid = entry->uid;
330
331 buf_printf(buf, "%c", TrustFlags[uid->trust & 0x03]);
332#endif
333}
334
338void pgp_entry_pgp_u(const struct ExpandoNode *node, void *data,
339 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
340{
341#ifdef HAVE_PGP
342 const struct PgpEntry *entry = data;
343 const struct PgpUid *uid = entry->uid;
344
345 const char *s = uid->addr;
346 buf_strcpy(buf, s);
347#endif
348}
349
353void pgp_entry_pgp_a(const struct ExpandoNode *node, void *data,
354 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
355{
356#ifdef HAVE_PGP
357 const struct PgpEntry *entry = data;
358 const struct PgpUid *uid = entry->uid;
359 const struct PgpKeyInfo *key = uid->parent;
360
361 const char *s = key->algorithm;
362 buf_strcpy(buf, s);
363#endif
364}
365
369void pgp_entry_pgp_A(const struct ExpandoNode *node, void *data,
370 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
371{
372#ifdef HAVE_PGP
373 const struct PgpEntry *entry = data;
374 const struct PgpUid *uid = entry->uid;
375 struct PgpKeyInfo *key = uid->parent;
376 struct PgpKeyInfo *pkey = pgp_principal_key(key);
377
378 const char *s = pkey->algorithm;
379 buf_strcpy(buf, s);
380#endif
381}
382
386void pgp_entry_pgp_c(const struct ExpandoNode *node, void *data,
387 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
388{
389#ifdef HAVE_PGP
390 const struct PgpEntry *entry = data;
391 const struct PgpUid *uid = entry->uid;
392 const struct PgpKeyInfo *key = uid->parent;
393
394 const KeyFlags kflags = key->flags | uid->flags;
395
396 const char *s = pgp_key_abilities(kflags);
397 buf_strcpy(buf, s);
398#endif
399}
400
404void pgp_entry_pgp_C(const struct ExpandoNode *node, void *data,
405 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
406{
407#ifdef HAVE_PGP
408 const struct PgpEntry *entry = data;
409 const struct PgpUid *uid = entry->uid;
410 struct PgpKeyInfo *key = uid->parent;
411 struct PgpKeyInfo *pkey = pgp_principal_key(key);
412
413 const KeyFlags kflags = (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags;
414
415 const char *s = pgp_key_abilities(kflags);
416 buf_strcpy(buf, s);
417#endif
418}
419
423void pgp_entry_pgp_f(const struct ExpandoNode *node, void *data,
424 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
425{
426#ifdef HAVE_PGP
427 const struct PgpEntry *entry = data;
428 const struct PgpUid *uid = entry->uid;
429 const struct PgpKeyInfo *key = uid->parent;
430
431 const KeyFlags kflags = key->flags | uid->flags;
432
433 buf_printf(buf, "%c", pgp_flags(kflags));
434#endif
435}
436
440void pgp_entry_pgp_F(const struct ExpandoNode *node, void *data,
441 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
442{
443#ifdef HAVE_PGP
444 const struct PgpEntry *entry = data;
445 const struct PgpUid *uid = entry->uid;
446 struct PgpKeyInfo *key = uid->parent;
447 struct PgpKeyInfo *pkey = pgp_principal_key(key);
448
449 const KeyFlags kflags = (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags;
450
451 buf_printf(buf, "%c", pgp_flags(kflags));
452#endif
453}
454
458void pgp_entry_pgp_k(const struct ExpandoNode *node, void *data,
459 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
460{
461#ifdef HAVE_PGP
462 const struct PgpEntry *entry = data;
463 const struct PgpUid *uid = entry->uid;
464 struct PgpKeyInfo *key = uid->parent;
465
466 const char *s = pgp_this_keyid(key);
467 buf_strcpy(buf, s);
468#endif
469}
470
474void pgp_entry_pgp_K(const struct ExpandoNode *node, void *data,
475 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
476{
477#ifdef HAVE_PGP
478 const struct PgpEntry *entry = data;
479 const struct PgpUid *uid = entry->uid;
480 struct PgpKeyInfo *key = uid->parent;
481 struct PgpKeyInfo *pkey = pgp_principal_key(key);
482
483 const char *s = pgp_this_keyid(pkey);
484 buf_strcpy(buf, s);
485#endif
486}
487
491long pgp_entry_pgp_l_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
492{
493#ifdef HAVE_PGP
494 const struct PgpEntry *entry = data;
495 const struct PgpUid *uid = entry->uid;
496 const struct PgpKeyInfo *key = uid->parent;
497
498 return key->keylen;
499#else
500 return 0;
501#endif
502}
503
507long pgp_entry_pgp_L_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
508{
509#ifdef HAVE_PGP
510 const struct PgpEntry *entry = data;
511 const struct PgpUid *uid = entry->uid;
512 struct PgpKeyInfo *key = uid->parent;
513 struct PgpKeyInfo *pkey = pgp_principal_key(key);
514
515 return pkey->keylen;
516#else
517 return 0;
518#endif
519}
520
524void pgp_entry_ignore(const struct ExpandoNode *node, void *data,
525 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
526{
527}
528
534static int pgp_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
535{
536 struct PgpUid **key_table = menu->mdata;
537
538 struct PgpEntry entry = { 0 };
539 entry.uid = key_table[line];
540 entry.num = line + 1;
541
542 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
543 if (c_arrow_cursor)
544 {
545 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
546 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
547 }
548
549 const struct Expando *c_pgp_entry_format = cs_subset_expando(NeoMutt->sub, "pgp_entry_format");
550 return expando_filter(c_pgp_entry_format, PgpEntryRenderData, &entry,
551 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
552}
553
559static void pgp_key_table_free(struct Menu *menu, void **ptr)
560{
561 FREE(ptr);
562}
563
568{
569 if (nc->event_type != NT_CONFIG)
570 return 0;
571 if (!nc->global_data || !nc->event_data)
572 return -1;
573
574 struct EventConfig *ev_c = nc->event_data;
575
576 if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
577 !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
578 {
579 return 0;
580 }
581
582 struct Menu *menu = nc->global_data;
584 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
585
586 return 0;
587}
588
597{
598 if (nc->event_type != NT_WINDOW)
599 return 0;
600 if (!nc->global_data || !nc->event_data)
601 return -1;
603 return 0;
604
605 struct MuttWindow *win_menu = nc->global_data;
606 struct EventWindow *ev_w = nc->event_data;
607 if (ev_w->win != win_menu)
608 return 0;
609
610 struct Menu *menu = win_menu->wdata;
611
614
615 mutt_debug(LL_DEBUG5, "window delete done\n");
616 return 0;
617}
618
628struct PgpKeyInfo *dlg_pgp(struct PgpKeyInfo *keys, struct Address *p, const char *s)
629{
630 struct PgpUid **key_table = NULL;
631 struct Menu *menu = NULL;
632 char buf[1024] = { 0 };
633 struct PgpUid *a = NULL;
634 bool unusable = false;
635 int keymax = 0;
636
637 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
638 int i = 0;
639 for (struct PgpKeyInfo *kp = keys; kp; kp = kp->next)
640 {
641 if (!c_pgp_show_unusable && (kp->flags & KEYFLAG_CANTUSE))
642 {
643 unusable = true;
644 continue;
645 }
646
647 for (a = kp->address; a; a = a->next)
648 {
649 if (!c_pgp_show_unusable && (a->flags & KEYFLAG_CANTUSE))
650 {
651 unusable = true;
652 continue;
653 }
654
655 if (i == keymax)
656 {
657 keymax += 5;
658 mutt_mem_realloc(&key_table, sizeof(struct PgpUid *) * keymax);
659 }
660
661 key_table[i++] = a;
662 }
663 }
664
665 if ((i == 0) && unusable)
666 {
667 mutt_error(_("All matching keys are expired, revoked, or disabled"));
668 return NULL;
669 }
670
671 sort_t f = NULL;
672 short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
673 switch (c_pgp_sort_keys & SORT_MASK)
674 {
675 case SORT_ADDRESS:
677 break;
678 case SORT_DATE:
679 f = pgp_sort_date;
680 break;
681 case SORT_KEYID:
682 f = pgp_sort_keyid;
683 break;
684 case SORT_TRUST:
685 default:
686 f = pgp_sort_trust;
687 break;
688 }
689
690 if (key_table)
691 {
692 bool sort_reverse = c_pgp_sort_keys & SORT_REVERSE;
693 mutt_qsort_r(key_table, i, sizeof(struct PgpUid *), f, &sort_reverse);
694 }
695
697
698 menu = dlg->wdata;
699 menu->max = i;
701 menu->mdata = key_table;
703
704 struct PgpData pd = { false, menu, key_table, NULL };
705 dlg->wdata = &pd;
706
707 // NT_COLOR is handled by the SimpleDialog
710
711 if (p)
712 snprintf(buf, sizeof(buf), _("PGP keys matching <%s>"), buf_string(p->mailbox));
713 else
714 snprintf(buf, sizeof(buf), _("PGP keys matching \"%s\""), s);
715
716 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
717 sbar_set_title(sbar, buf);
718
720
721 struct MuttWindow *old_focus = window_set_focus(menu->win);
722 // ---------------------------------------------------------------------------
723 // Event Loop
724 int op = OP_NULL;
725 do
726 {
727 menu_tagging_dispatcher(menu->win, op);
728 window_redraw(NULL);
729
731 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
732 if (op < 0)
733 continue;
734 if (op == OP_NULL)
735 {
737 continue;
738 }
740
741 int rc = pgp_function_dispatcher(dlg, op);
742
743 if (rc == FR_UNKNOWN)
744 rc = menu_function_dispatcher(menu->win, op);
745 if (rc == FR_UNKNOWN)
746 rc = global_function_dispatcher(NULL, op);
747 } while (!pd.done);
748 // ---------------------------------------------------------------------------
749
750 window_set_focus(old_focus);
751 simple_dialog_free(&dlg);
752 return pd.key;
753}
754
760const struct ExpandoRenderData PgpEntryRenderData[] = {
761 // clang-format off
779 { -1, -1, NULL, NULL },
780 // clang-format on
781};
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:52
@ ED_PGP_KEY
Pgp_Key ED_PGK_ ExpandoDataPgpKey.
Definition: domain.h:54
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:141
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:491
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:311
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:507
void pgp_entry_pgp_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Key Flags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:423
void pgp_entry_pgp_k(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Key id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:458
void pgp_entry_pgp_date(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Date of the key - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:270
void pgp_entry_pgp_C(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Principal Key Capabilities - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:404
void pgp_entry_pgp_u(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: User id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:338
void pgp_entry_pgp_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Trust/validity - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:324
void pgp_entry_pgp_F(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Principal Key Flags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:440
void pgp_entry_pgp_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Key Algorithm - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:353
void pgp_entry_pgp_A(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Principal Key Algorithm - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:369
void pgp_entry_pgp_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Key Capabilities - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:386
void pgp_entry_pgp_K(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Principal Key id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:474
void pgp_entry_ignore(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Field not supported - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:524
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:628
#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:534
static void pgp_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlg_pgp.c:559
static int pgp_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_pgp.c:596
static int pgp_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_pgp.c:567
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
char * mutt_strn_copy(char *dest, const char *src, size_t len, size_t dsize)
Copy a sub-string into a buffer.
Definition: string.c:360
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:634
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:684
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:533
@ 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:102
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:229
#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 ASSERT(COND)
Definition: signal2.h:58
#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:239
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:240
Basic Expando Node.
Definition: node.h:69
const char * end
End of string data.
Definition: node.h:80
const char * start
Start of string data.
Definition: node.h:79
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:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
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:56