NeoMutt  2024-03-23-147-g885fbc
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 <assert.h>
72#include <locale.h>
73#include <stdbool.h>
74#include <stdio.h>
75#include "private.h"
76#include "mutt/lib.h"
77#include "address/lib.h"
78#include "config/lib.h"
79#include "core/lib.h"
80#include "gui/lib.h"
81#include "lib.h"
82#include "expando/lib.h"
83#include "key/lib.h"
84#include "menu/lib.h"
85#include "mutt_logging.h"
86#include "pgp.h"
87#include "pgp_functions.h"
88#include "pgpkey.h"
89#include "pgplib.h"
90#include "sort.h"
91
93
95static const struct Mapping PgpHelp[] = {
96 // clang-format off
97 { N_("Exit"), OP_EXIT },
98 { N_("Select"), OP_GENERIC_SELECT_ENTRY },
99 { N_("Check key"), OP_VERIFY_KEY },
100 { N_("Help"), OP_HELP },
101 { NULL, 0 },
102 // clang-format on
103};
104
106static const char TrustFlags[] = "?- +";
107
111static int pgp_sort_address(const void *a, const void *b, void *sdata)
112{
113 struct PgpUid const *s = *(struct PgpUid const *const *) a;
114 struct PgpUid const *t = *(struct PgpUid const *const *) b;
115 const bool sort_reverse = *(bool *) sdata;
116
117 int rc = mutt_istr_cmp(s->addr, t->addr);
118 if (rc != 0)
119 goto done;
120
122
123done:
124 return sort_reverse ? -rc : rc;
125}
126
130static int pgp_sort_date(const void *a, const void *b, void *sdata)
131{
132 struct PgpUid const *s = *(struct PgpUid const *const *) a;
133 struct PgpUid const *t = *(struct PgpUid const *const *) b;
134 const bool sort_reverse = *(bool *) sdata;
135
137 if (rc != 0)
138 goto done;
139
140 rc = mutt_istr_cmp(s->addr, t->addr);
141
142done:
143 return sort_reverse ? -rc : rc;
144}
145
149static int pgp_sort_keyid(const void *a, const void *b, void *sdata)
150{
151 struct PgpUid const *s = *(struct PgpUid const *const *) a;
152 struct PgpUid const *t = *(struct PgpUid const *const *) b;
153 const bool sort_reverse = *(bool *) sdata;
154
156 if (rc != 0)
157 goto done;
158
159 rc = mutt_istr_cmp(s->addr, t->addr);
160
161done:
162 return sort_reverse ? -rc : rc;
163}
164
168static int pgp_sort_trust(const void *a, const void *b, void *sdata)
169{
170 struct PgpUid const *s = *(struct PgpUid const *const *) a;
171 struct PgpUid const *t = *(struct PgpUid const *const *) b;
172 const bool sort_reverse = *(bool *) sdata;
173
176 if (rc != 0)
177 goto done;
178
179 // Note: reversed
180 rc = mutt_numeric_cmp(t->trust, s->trust);
181 if (rc != 0)
182 goto done;
183
184 // Note: reversed
186 if (rc != 0)
187 goto done;
188
189 // Note: reversed
191 if (rc != 0)
192 goto done;
193
194 rc = mutt_istr_cmp(s->addr, t->addr);
195 if (rc != 0)
196 goto done;
197
199
200done:
201 return sort_reverse ? -rc : rc;
202}
203
212{
213 static char buf[3];
214
215 if (!(flags & KEYFLAG_CANENCRYPT))
216 buf[0] = '-';
217 else if (flags & KEYFLAG_PREFER_SIGNING)
218 buf[0] = '.';
219 else
220 buf[0] = 'e';
221
222 if (!(flags & KEYFLAG_CANSIGN))
223 buf[1] = '-';
225 buf[1] = '.';
226 else
227 buf[1] = 's';
228
229 buf[2] = '\0';
230
231 return buf;
232}
233
240{
242 return 'R';
244 return 'X';
246 return 'd';
248 return 'c';
249
250 return ' ';
251}
252
256long pgp_entry_pgp_date_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
257{
258#ifdef HAVE_PGP
259 const struct PgpEntry *entry = data;
260 const struct PgpUid *uid = entry->uid;
261 const struct PgpKeyInfo *key = uid->parent;
262
263 return key->gen_time;
264#endif
265 return 0;
266}
267
271void pgp_entry_pgp_date(const struct ExpandoNode *node, void *data,
272 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
273{
274#ifdef HAVE_PGP
275 const struct PgpEntry *entry = data;
276 const struct PgpUid *uid = entry->uid;
277 const struct PgpKeyInfo *key = uid->parent;
278
279 char tmp[128] = { 0 };
280 char datestr[128] = { 0 };
281
282 int len = node->end - node->start;
283 const char *start = node->start;
284 bool use_c_locale = false;
285 if (*start == '!')
286 {
287 use_c_locale = true;
288 start++;
289 len--;
290 }
291
292 assert(len < sizeof(datestr));
293 mutt_strn_copy(datestr, start, len, sizeof(datestr));
294
295 if (use_c_locale)
296 {
297 mutt_date_localtime_format_locale(tmp, sizeof(tmp), datestr, key->gen_time,
299 }
300 else
301 {
302 mutt_date_localtime_format(tmp, sizeof(tmp), datestr, key->gen_time);
303 }
304
305 buf_strcpy(buf, tmp);
306#endif
307}
308
312long pgp_entry_pgp_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
313{
314#ifdef HAVE_PGP
315 const struct PgpEntry *entry = data;
316 return entry->num;
317#else
318 return 0;
319#endif
320}
321
325void pgp_entry_pgp_t(const struct ExpandoNode *node, void *data,
326 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
327{
328#ifdef HAVE_PGP
329 const struct PgpEntry *entry = data;
330 const struct PgpUid *uid = entry->uid;
331
332 buf_printf(buf, "%c", TrustFlags[uid->trust & 0x03]);
333#endif
334}
335
339void pgp_entry_pgp_u(const struct ExpandoNode *node, void *data,
340 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
341{
342#ifdef HAVE_PGP
343 const struct PgpEntry *entry = data;
344 const struct PgpUid *uid = entry->uid;
345
346 const char *s = uid->addr;
347 buf_strcpy(buf, s);
348#endif
349}
350
354void pgp_entry_pgp_a(const struct ExpandoNode *node, void *data,
355 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
356{
357#ifdef HAVE_PGP
358 const struct PgpEntry *entry = data;
359 const struct PgpUid *uid = entry->uid;
360 const struct PgpKeyInfo *key = uid->parent;
361
362 const char *s = key->algorithm;
363 buf_strcpy(buf, s);
364#endif
365}
366
370void pgp_entry_pgp_A(const struct ExpandoNode *node, void *data,
371 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
372{
373#ifdef HAVE_PGP
374 const struct PgpEntry *entry = data;
375 const struct PgpUid *uid = entry->uid;
376 struct PgpKeyInfo *key = uid->parent;
377 struct PgpKeyInfo *pkey = pgp_principal_key(key);
378
379 const char *s = pkey->algorithm;
380 buf_strcpy(buf, s);
381#endif
382}
383
387void pgp_entry_pgp_c(const struct ExpandoNode *node, void *data,
388 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
389{
390#ifdef HAVE_PGP
391 const struct PgpEntry *entry = data;
392 const struct PgpUid *uid = entry->uid;
393 const struct PgpKeyInfo *key = uid->parent;
394
395 const KeyFlags kflags = key->flags | uid->flags;
396
397 const char *s = pgp_key_abilities(kflags);
398 buf_strcpy(buf, s);
399#endif
400}
401
405void pgp_entry_pgp_C(const struct ExpandoNode *node, void *data,
406 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
407{
408#ifdef HAVE_PGP
409 const struct PgpEntry *entry = data;
410 const struct PgpUid *uid = entry->uid;
411 struct PgpKeyInfo *key = uid->parent;
412 struct PgpKeyInfo *pkey = pgp_principal_key(key);
413
414 const KeyFlags kflags = (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags;
415
416 const char *s = pgp_key_abilities(kflags);
417 buf_strcpy(buf, s);
418#endif
419}
420
424void pgp_entry_pgp_f(const struct ExpandoNode *node, void *data,
425 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
426{
427#ifdef HAVE_PGP
428 const struct PgpEntry *entry = data;
429 const struct PgpUid *uid = entry->uid;
430 const struct PgpKeyInfo *key = uid->parent;
431
432 const KeyFlags kflags = key->flags | uid->flags;
433
434 buf_printf(buf, "%c", pgp_flags(kflags));
435#endif
436}
437
441void pgp_entry_pgp_F(const struct ExpandoNode *node, void *data,
442 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
443{
444#ifdef HAVE_PGP
445 const struct PgpEntry *entry = data;
446 const struct PgpUid *uid = entry->uid;
447 struct PgpKeyInfo *key = uid->parent;
448 struct PgpKeyInfo *pkey = pgp_principal_key(key);
449
450 const KeyFlags kflags = (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags;
451
452 buf_printf(buf, "%c", pgp_flags(kflags));
453#endif
454}
455
459void pgp_entry_pgp_k(const struct ExpandoNode *node, void *data,
460 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
461{
462#ifdef HAVE_PGP
463 const struct PgpEntry *entry = data;
464 const struct PgpUid *uid = entry->uid;
465 struct PgpKeyInfo *key = uid->parent;
466
467 const char *s = pgp_this_keyid(key);
468 buf_strcpy(buf, s);
469#endif
470}
471
475void pgp_entry_pgp_K(const struct ExpandoNode *node, void *data,
476 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
477{
478#ifdef HAVE_PGP
479 const struct PgpEntry *entry = data;
480 const struct PgpUid *uid = entry->uid;
481 struct PgpKeyInfo *key = uid->parent;
482 struct PgpKeyInfo *pkey = pgp_principal_key(key);
483
484 const char *s = pgp_this_keyid(pkey);
485 buf_strcpy(buf, s);
486#endif
487}
488
492long pgp_entry_pgp_l_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
493{
494#ifdef HAVE_PGP
495 const struct PgpEntry *entry = data;
496 const struct PgpUid *uid = entry->uid;
497 const struct PgpKeyInfo *key = uid->parent;
498
499 return key->keylen;
500#else
501 return 0;
502#endif
503}
504
508long pgp_entry_pgp_L_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
509{
510#ifdef HAVE_PGP
511 const struct PgpEntry *entry = data;
512 const struct PgpUid *uid = entry->uid;
513 struct PgpKeyInfo *key = uid->parent;
514 struct PgpKeyInfo *pkey = pgp_principal_key(key);
515
516 return pkey->keylen;
517#else
518 return 0;
519#endif
520}
521
525void pgp_entry_ignore(const struct ExpandoNode *node, void *data,
526 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
527{
528}
529
535static int pgp_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
536{
537 struct PgpUid **key_table = menu->mdata;
538
539 struct PgpEntry entry = { 0 };
540 entry.uid = key_table[line];
541 entry.num = line + 1;
542
543 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
544 if (c_arrow_cursor)
545 {
546 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
547 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
548 }
549
550 const struct Expando *c_pgp_entry_format = cs_subset_expando(NeoMutt->sub, "pgp_entry_format");
551 return expando_render(c_pgp_entry_format, PgpEntryRenderData, &entry,
552 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
553}
554
560static void pgp_key_table_free(struct Menu *menu, void **ptr)
561{
562 FREE(ptr);
563}
564
569{
570 if (nc->event_type != NT_CONFIG)
571 return 0;
572 if (!nc->global_data || !nc->event_data)
573 return -1;
574
575 struct EventConfig *ev_c = nc->event_data;
576
577 if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
578 !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
579 {
580 return 0;
581 }
582
583 struct Menu *menu = nc->global_data;
585 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
586
587 return 0;
588}
589
598{
599 if (nc->event_type != NT_WINDOW)
600 return 0;
601 if (!nc->global_data || !nc->event_data)
602 return -1;
604 return 0;
605
606 struct MuttWindow *win_menu = nc->global_data;
607 struct EventWindow *ev_w = nc->event_data;
608 if (ev_w->win != win_menu)
609 return 0;
610
611 struct Menu *menu = win_menu->wdata;
612
615
616 mutt_debug(LL_DEBUG5, "window delete done\n");
617 return 0;
618}
619
629struct PgpKeyInfo *dlg_pgp(struct PgpKeyInfo *keys, struct Address *p, const char *s)
630{
631 struct PgpUid **key_table = NULL;
632 struct Menu *menu = NULL;
633 char buf[1024] = { 0 };
634 struct PgpUid *a = NULL;
635 bool unusable = false;
636 int keymax = 0;
637
638 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
639 int i = 0;
640 for (struct PgpKeyInfo *kp = keys; kp; kp = kp->next)
641 {
642 if (!c_pgp_show_unusable && (kp->flags & KEYFLAG_CANTUSE))
643 {
644 unusable = true;
645 continue;
646 }
647
648 for (a = kp->address; a; a = a->next)
649 {
650 if (!c_pgp_show_unusable && (a->flags & KEYFLAG_CANTUSE))
651 {
652 unusable = true;
653 continue;
654 }
655
656 if (i == keymax)
657 {
658 keymax += 5;
659 mutt_mem_realloc(&key_table, sizeof(struct PgpUid *) * keymax);
660 }
661
662 key_table[i++] = a;
663 }
664 }
665
666 if ((i == 0) && unusable)
667 {
668 mutt_error(_("All matching keys are expired, revoked, or disabled"));
669 return NULL;
670 }
671
672 sort_t f = NULL;
673 short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
674 switch (c_pgp_sort_keys & SORT_MASK)
675 {
676 case SORT_ADDRESS:
678 break;
679 case SORT_DATE:
680 f = pgp_sort_date;
681 break;
682 case SORT_KEYID:
683 f = pgp_sort_keyid;
684 break;
685 case SORT_TRUST:
686 default:
687 f = pgp_sort_trust;
688 break;
689 }
690
691 if (key_table)
692 {
693 bool sort_reverse = c_pgp_sort_keys & SORT_REVERSE;
694 mutt_qsort_r(key_table, i, sizeof(struct PgpUid *), f, &sort_reverse);
695 }
696
698
699 menu = dlg->wdata;
700 menu->max = i;
702 menu->mdata = key_table;
704
705 struct PgpData pd = { false, menu, key_table, NULL };
706 dlg->wdata = &pd;
707
708 // NT_COLOR is handled by the SimpleDialog
711
712 if (p)
713 snprintf(buf, sizeof(buf), _("PGP keys matching <%s>"), buf_string(p->mailbox));
714 else
715 snprintf(buf, sizeof(buf), _("PGP keys matching \"%s\""), s);
716
717 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
718 sbar_set_title(sbar, buf);
719
721
722 struct MuttWindow *old_focus = window_set_focus(menu->win);
723 // ---------------------------------------------------------------------------
724 // Event Loop
725 int op = OP_NULL;
726 do
727 {
728 menu_tagging_dispatcher(menu->win, op);
729 window_redraw(NULL);
730
732 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
733 if (op < 0)
734 continue;
735 if (op == OP_NULL)
736 {
738 continue;
739 }
741
742 int rc = pgp_function_dispatcher(dlg, op);
743
744 if (rc == FR_UNKNOWN)
745 rc = menu_function_dispatcher(menu->win, op);
746 if (rc == FR_UNKNOWN)
747 rc = global_function_dispatcher(NULL, op);
748 } while (!pd.done);
749 // ---------------------------------------------------------------------------
750
751 window_set_focus(old_focus);
752 simple_dialog_free(&dlg);
753 return pd.key;
754}
755
761const struct ExpandoRenderData PgpEntryRenderData[] = {
762 // clang-format off
780 { -1, -1, NULL, NULL },
781 // clang-format on
782};
Email Address Handling.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:394
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:292
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:267
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
Definition: config_type.c:358
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:239
static const struct Mapping PgpHelp[]
Help Bar for the PGP key selection dialog.
Definition: dlg_pgp.c:95
static const char TrustFlags[]
Characters used to show the trust level for PGP keys.
Definition: dlg_pgp.c:106
const struct ExpandoRenderData PgpEntryRenderData[]
PgpEntryRenderData- Callbacks for PGP Key Expandos.
Definition: dlg_pgp.c:92
static char * pgp_key_abilities(KeyFlags flags)
Turn PGP key abilities into a string.
Definition: dlg_pgp.c:211
@ ED_PGP
Pgp ED_PGP_ ExpandoDataPgp.
Definition: domain.h:52
@ ED_PGP_KEY
Pgp_Key ED_PGK_ ExpandoDataPgpKey.
Definition: domain.h:54
Parse Expando string.
int expando_render(const struct Expando *exp, const struct ExpandoRenderData *rdata, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando + data into a string.
Definition: expando.c:110
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition: get.c:463
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: get.c:293
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:492
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:312
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:256
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:508
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:424
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:459
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:271
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:405
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:339
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:325
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:441
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:354
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:370
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:387
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:475
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:525
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:629
#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:535
static void pgp_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlg_pgp.c:560
static int pgp_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_pgp.c:597
static int pgp_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_pgp.c:568
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:168
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:149
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:130
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:111
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:114
#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:950
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:968
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:461
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:709
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:409
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:91
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:239
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:240
Basic Expando Node.
Definition: node.h:67
const char * end
End of string data.
Definition: node.h:78
const char * start
Start of string data.
Definition: node.h:77
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:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
locale_t time_c_locale
Current locale but LC_TIME=C.
Definition: neomutt.h:47
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