NeoMutt  2022-04-29-247-gc6aae8
Teaching an old dog new tricks
DOXYGEN
dlg_gpgme.c
Go to the documentation of this file.
1
68#include "config.h"
69#include <ctype.h>
70#include <gpgme.h>
71#include <locale.h>
72#include <stdbool.h>
73#include <stdint.h>
74#include <stdio.h>
75#include <stdlib.h>
76#include <time.h>
77#include "private.h"
78#include "mutt/lib.h"
79#include "address/lib.h"
80#include "config/lib.h"
81#include "core/lib.h"
82#include "gui/lib.h"
83#include "lib.h"
84#include "menu/lib.h"
85#include "crypt_gpgme.h"
86#include "format_flags.h"
87#include "gpgme_functions.h"
88#include "keymap.h"
89#include "mutt_logging.h"
90#include "muttlib.h"
91#include "opcodes.h"
92#ifdef ENABLE_NLS
93#include <libintl.h>
94#endif
95
97static const struct Mapping GpgmeHelp[] = {
98 // clang-format off
99 { N_("Exit"), OP_EXIT },
100 { N_("Select"), OP_GENERIC_SELECT_ENTRY },
101 { N_("Check key"), OP_VERIFY_KEY },
102 { N_("Help"), OP_HELP },
103 { NULL, 0 },
104 // clang-format on
105};
106
111{
112 size_t num;
114};
115
124static int crypt_compare_key_address(const void *a, const void *b)
125{
126 struct CryptKeyInfo **s = (struct CryptKeyInfo **) a;
127 struct CryptKeyInfo **t = (struct CryptKeyInfo **) b;
128
129 int r = mutt_istr_cmp((*s)->uid, (*t)->uid);
130 if (r != 0)
131 return r > 0;
133}
134
143static int crypt_compare_address_qsort(const void *a, const void *b)
144{
145 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
146 return (c_pgp_sort_keys & SORT_REVERSE) ? !crypt_compare_key_address(a, b) :
148}
149
158static int crypt_compare_keyid(const void *a, const void *b)
159{
160 struct CryptKeyInfo **s = (struct CryptKeyInfo **) a;
161 struct CryptKeyInfo **t = (struct CryptKeyInfo **) b;
162
164 if (r != 0)
165 return r > 0;
166 return mutt_istr_cmp((*s)->uid, (*t)->uid) > 0;
167}
168
177static int crypt_compare_keyid_qsort(const void *a, const void *b)
178{
179 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
180 return (c_pgp_sort_keys & SORT_REVERSE) ? !crypt_compare_keyid(a, b) :
182}
183
192static int crypt_compare_key_date(const void *a, const void *b)
193{
194 struct CryptKeyInfo **s = (struct CryptKeyInfo **) a;
195 struct CryptKeyInfo **t = (struct CryptKeyInfo **) b;
196 unsigned long ts = 0, tt = 0;
197
198 if ((*s)->kobj->subkeys && ((*s)->kobj->subkeys->timestamp > 0))
199 ts = (*s)->kobj->subkeys->timestamp;
200 if ((*t)->kobj->subkeys && ((*t)->kobj->subkeys->timestamp > 0))
201 tt = (*t)->kobj->subkeys->timestamp;
202
203 if (ts > tt)
204 return 1;
205 if (ts < tt)
206 return 0;
207
208 return mutt_istr_cmp((*s)->uid, (*t)->uid) > 0;
209}
210
219static int crypt_compare_date_qsort(const void *a, const void *b)
220{
221 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
222 return (c_pgp_sort_keys & SORT_REVERSE) ? !crypt_compare_key_date(a, b) :
224}
225
237static int crypt_compare_key_trust(const void *a, const void *b)
238{
239 struct CryptKeyInfo **s = (struct CryptKeyInfo **) a;
240 struct CryptKeyInfo **t = (struct CryptKeyInfo **) b;
241 unsigned long ts = 0, tt = 0;
242
243 int r = (((*s)->flags & KEYFLAG_RESTRICTIONS) - ((*t)->flags & KEYFLAG_RESTRICTIONS));
244 if (r != 0)
245 return r > 0;
246
247 ts = (*s)->validity;
248 tt = (*t)->validity;
249 r = (tt - ts);
250 if (r != 0)
251 return r < 0;
252
253 if ((*s)->kobj->subkeys)
254 ts = (*s)->kobj->subkeys->length;
255 if ((*t)->kobj->subkeys)
256 tt = (*t)->kobj->subkeys->length;
257 if (ts != tt)
258 return ts > tt;
259
260 if ((*s)->kobj->subkeys && ((*s)->kobj->subkeys->timestamp > 0))
261 ts = (*s)->kobj->subkeys->timestamp;
262 if ((*t)->kobj->subkeys && ((*t)->kobj->subkeys->timestamp > 0))
263 tt = (*t)->kobj->subkeys->timestamp;
264 if (ts > tt)
265 return 1;
266 if (ts < tt)
267 return 0;
268
269 r = mutt_istr_cmp((*s)->uid, (*t)->uid);
270 if (r != 0)
271 return r > 0;
273}
274
283static int crypt_compare_trust_qsort(const void *a, const void *b)
284{
285 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
286 return (c_pgp_sort_keys & SORT_REVERSE) ? !crypt_compare_key_trust(a, b) :
288}
289
298{
299 static char buf[3];
300
301 if (!(flags & KEYFLAG_CANENCRYPT))
302 buf[0] = '-';
303 else if (flags & KEYFLAG_PREFER_SIGNING)
304 buf[0] = '.';
305 else
306 buf[0] = 'e';
307
308 if (!(flags & KEYFLAG_CANSIGN))
309 buf[1] = '-';
311 buf[1] = '.';
312 else
313 buf[1] = 's';
314
315 buf[2] = '\0';
316
317 return buf;
318}
319
328{
330 return 'R';
332 return 'X';
334 return 'd';
336 return 'c';
337
338 return ' ';
339}
340
364static const char *crypt_format_str(char *buf, size_t buflen, size_t col, int cols,
365 char op, const char *src, const char *prec,
366 const char *if_str, const char *else_str,
367 intptr_t data, MuttFormatFlags flags)
368{
369 char fmt[128] = { 0 };
370 bool optional = (flags & MUTT_FORMAT_OPTIONAL);
371
372 struct CryptEntry *entry = (struct CryptEntry *) data;
373 struct CryptKeyInfo *key = entry->key;
374
375 /* if (isupper ((unsigned char) op)) */
376 /* key = pkey; */
377
378 KeyFlags kflags = (key->flags /* | (pkey->flags & KEYFLAG_RESTRICTIONS)
379 | uid->flags */);
380
381 switch (tolower(op))
382 {
383 case 'a':
384 if (!optional)
385 {
386 const char *s = NULL;
387 snprintf(fmt, sizeof(fmt), "%%%s.3s", prec);
388 if (key->kobj->subkeys)
389 s = gpgme_pubkey_algo_name(key->kobj->subkeys->pubkey_algo);
390 else
391 s = "?";
392 snprintf(buf, buflen, fmt, s);
393 }
394 break;
395
396 case 'c':
397 if (!optional)
398 {
399 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
400 snprintf(buf, buflen, fmt, crypt_key_abilities(kflags));
401 }
402 else if (!(kflags & KEYFLAG_ABILITIES))
403 optional = false;
404 break;
405
406 case 'f':
407 if (!optional)
408 {
409 snprintf(fmt, sizeof(fmt), "%%%sc", prec);
410 snprintf(buf, buflen, fmt, crypt_flags(kflags));
411 }
412 else if (!(kflags & KEYFLAG_RESTRICTIONS))
413 optional = false;
414 break;
415
416 case 'k':
417 if (!optional)
418 {
419 /* fixme: we need a way to distinguish between main and subkeys.
420 * Store the idx in entry? */
421 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
422 snprintf(buf, buflen, fmt, crypt_keyid(key));
423 }
424 break;
425
426 case 'l':
427 if (!optional)
428 {
429 snprintf(fmt, sizeof(fmt), "%%%slu", prec);
430 unsigned long val;
431 if (key->kobj->subkeys)
432 val = key->kobj->subkeys->length;
433 else
434 val = 0;
435 snprintf(buf, buflen, fmt, val);
436 }
437 break;
438
439 case 'n':
440 if (!optional)
441 {
442 snprintf(fmt, sizeof(fmt), "%%%sd", prec);
443 snprintf(buf, buflen, fmt, entry->num);
444 }
445 break;
446
447 case 'p':
448 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
449 snprintf(buf, buflen, fmt, gpgme_get_protocol_name(key->kobj->protocol));
450 break;
451
452 case 't':
453 {
454 char *s = NULL;
455 if ((kflags & KEYFLAG_ISX509))
456 s = "x";
457 else
458 {
459 switch (key->validity)
460 {
461 case GPGME_VALIDITY_FULL:
462 s = "f";
463 break;
464 case GPGME_VALIDITY_MARGINAL:
465 s = "m";
466 break;
467 case GPGME_VALIDITY_NEVER:
468 s = "n";
469 break;
470 case GPGME_VALIDITY_ULTIMATE:
471 s = "u";
472 break;
473 case GPGME_VALIDITY_UNDEFINED:
474 s = "q";
475 break;
476 case GPGME_VALIDITY_UNKNOWN:
477 default:
478 s = "?";
479 break;
480 }
481 }
482 snprintf(fmt, sizeof(fmt), "%%%sc", prec);
483 snprintf(buf, buflen, fmt, *s);
484 break;
485 }
486
487 case 'u':
488 if (!optional)
489 {
490 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
491 snprintf(buf, buflen, fmt, key->uid);
492 }
493 break;
494
495 case '[':
496 {
497 char buf2[128];
498 bool do_locales = true;
499 struct tm tm = { 0 };
500
501 char *p = buf;
502
503 const char *cp = src;
504 if (*cp == '!')
505 {
506 do_locales = false;
507 cp++;
508 }
509
510 size_t len = buflen - 1;
511 while ((len > 0) && (*cp != ']'))
512 {
513 if (*cp == '%')
514 {
515 cp++;
516 if (len >= 2)
517 {
518 *p++ = '%';
519 *p++ = *cp;
520 len -= 2;
521 }
522 else
523 break; /* not enough space */
524 cp++;
525 }
526 else
527 {
528 *p++ = *cp++;
529 len--;
530 }
531 }
532 *p = '\0';
533
534 if (key->kobj->subkeys && (key->kobj->subkeys->timestamp > 0))
535 tm = mutt_date_localtime(key->kobj->subkeys->timestamp);
536 else
537 tm = mutt_date_localtime(0); // Default to 1970-01-01
538
539 if (!do_locales)
540 setlocale(LC_TIME, "C");
541 strftime(buf2, sizeof(buf2), buf, &tm);
542 if (!do_locales)
543 setlocale(LC_TIME, "");
544
545 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
546 snprintf(buf, buflen, fmt, buf2);
547 if (len > 0)
548 src = cp + 1;
549 break;
550 }
551
552 default:
553 *buf = '\0';
554 }
555
556 if (optional)
557 {
558 mutt_expando_format(buf, buflen, col, cols, if_str, crypt_format_str, data,
560 }
561 else if (flags & MUTT_FORMAT_OPTIONAL)
562 {
563 mutt_expando_format(buf, buflen, col, cols, else_str, crypt_format_str,
565 }
566
567 /* We return the format string, unchanged */
568 return src;
569}
570
576static void crypt_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
577{
578 struct CryptKeyInfo **key_table = menu->mdata;
579 struct CryptEntry entry;
580
581 entry.key = key_table[line];
582 entry.num = line + 1;
583
584 const char *const c_pgp_entry_format = cs_subset_string(NeoMutt->sub, "pgp_entry_format");
585 mutt_expando_format(buf, buflen, 0, menu->win->state.cols, NONULL(c_pgp_entry_format),
586 crypt_format_str, (intptr_t) &entry, MUTT_FORMAT_ARROWCURSOR);
587}
588
594static void gpgme_key_table_free(struct Menu *menu, void **ptr)
595{
596 FREE(ptr);
597}
598
603{
604 if (nc->event_type != NT_CONFIG)
605 return 0;
606 if (!nc->global_data || !nc->event_data)
607 return -1;
608
609 struct EventConfig *ev_c = nc->event_data;
610
611 if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
612 !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
613 {
614 return 0;
615 }
616
617 struct Menu *menu = nc->global_data;
619 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
620
621 return 0;
622}
623
632{
633 if (nc->event_type != NT_WINDOW)
634 return 0;
635 if (!nc->global_data || !nc->event_data)
636 return -1;
638 return 0;
639
640 struct MuttWindow *win_menu = nc->global_data;
641 struct EventWindow *ev_w = nc->event_data;
642 if (ev_w->win != win_menu)
643 return 0;
644
645 struct Menu *menu = win_menu->wdata;
646
649
650 mutt_debug(LL_DEBUG5, "window delete done\n");
651 return 0;
652}
653
666 struct Address *p, const char *s,
667 unsigned int app, bool *forced_valid)
668{
669 int keymax;
670 int i;
671 int (*f)(const void *, const void *);
672 enum MenuType menu_to_use = MENU_GENERIC;
673 bool unusable = false;
674
675 /* build the key table */
676 keymax = 0;
677 i = 0;
678 struct CryptKeyInfo **key_table = NULL;
679 for (struct CryptKeyInfo *k = keys; k; k = k->next)
680 {
681 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
682 if (!c_pgp_show_unusable && (k->flags & KEYFLAG_CANTUSE))
683 {
684 unusable = true;
685 continue;
686 }
687
688 if (i == keymax)
689 {
690 keymax += 20;
691 mutt_mem_realloc(&key_table, sizeof(struct CryptKeyInfo *) * keymax);
692 }
693
694 key_table[i++] = k;
695 }
696
697 if (!i && unusable)
698 {
699 mutt_error(_("All matching keys are marked expired/revoked"));
700 return NULL;
701 }
702
703 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
704 switch (c_pgp_sort_keys & SORT_MASK)
705 {
706 case SORT_ADDRESS:
708 break;
709 case SORT_DATE:
711 break;
712 case SORT_KEYID:
714 break;
715 case SORT_TRUST:
716 default:
718 break;
719 }
720 qsort(key_table, i, sizeof(struct CryptKeyInfo *), f);
721
722 if (app & APPLICATION_PGP)
723 menu_to_use = MENU_KEY_SELECT_PGP;
724 else if (app & APPLICATION_SMIME)
725 menu_to_use = MENU_KEY_SELECT_SMIME;
726
727 struct MuttWindow *dlg = simple_dialog_new(menu_to_use, WT_DLG_CRYPT_GPGME, GpgmeHelp);
728
729 struct Menu *menu = dlg->wdata;
730 menu->max = i;
732 menu->mdata = key_table;
734
735 struct GpgmeData gd = { false, menu, key_table, NULL, forced_valid };
736 dlg->wdata = &gd;
737
738 // NT_COLOR is handled by the SimpleDialog
741
742 {
743 const char *ts = NULL;
744
745 if ((app & APPLICATION_PGP) && (app & APPLICATION_SMIME))
746 ts = _("PGP and S/MIME keys matching");
747 else if ((app & APPLICATION_PGP))
748 ts = _("PGP keys matching");
749 else if ((app & APPLICATION_SMIME))
750 ts = _("S/MIME keys matching");
751 else
752 ts = _("keys matching");
753
754 char buf[1024] = { 0 };
755 if (p)
756 {
757 /* L10N: 1$s is one of the previous four entries.
758 %2$s is an address.
759 e.g. "S/MIME keys matching <me@mutt.org>" */
760 snprintf(buf, sizeof(buf), _("%s <%s>"), ts, p->mailbox);
761 }
762 else
763 {
764 /* L10N: e.g. 'S/MIME keys matching "Michael Elkins".' */
765 snprintf(buf, sizeof(buf), _("%s \"%s\""), ts, s);
766 }
767
768 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
769 sbar_set_title(sbar, buf);
770 }
771
773
774 // ---------------------------------------------------------------------------
775 // Event Loop
776 int op = OP_NULL;
777 do
778 {
779 menu_tagging_dispatcher(menu->win, op);
780 window_redraw(NULL);
781
782 op = km_dokey(menu_to_use);
783 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
784 if (op < 0)
785 continue;
786 if (op == OP_NULL)
787 {
788 km_error_key(menu_to_use);
789 continue;
790 }
792
793 int rc = gpgme_function_dispatcher(dlg, op);
794
795 if (rc == FR_UNKNOWN)
796 rc = menu_function_dispatcher(menu->win, op);
797 if (rc == FR_UNKNOWN)
798 rc = global_function_dispatcher(NULL, op);
799 } while (!gd.done);
800 // ---------------------------------------------------------------------------
801
802 simple_dialog_free(&dlg);
803 return gd.key;
804}
Email Address Handling.
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:292
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
const char * crypt_fpr_or_lkeyid(struct CryptKeyInfo *k)
Find the fingerprint of a key.
Definition: crypt_gpgme.c:214
const char * crypt_keyid(struct CryptKeyInfo *k)
Find the ID for the key.
Definition: crypt_gpgme.c:138
Wrapper for PGP/SMIME calls to GPGME.
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition: date.c:655
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
static int crypt_compare_date_qsort(const void *a, const void *b)
Compare the dates of two keys.
Definition: dlg_gpgme.c:219
static char crypt_flags(KeyFlags flags)
Parse the key flags into a single character.
Definition: dlg_gpgme.c:327
static char * crypt_key_abilities(KeyFlags flags)
Parse key flags into a string.
Definition: dlg_gpgme.c:297
static int crypt_compare_key_trust(const void *a, const void *b)
Compare the trust of keys for sorting.
Definition: dlg_gpgme.c:237
static int crypt_compare_key_date(const void *a, const void *b)
Compare Key creation dates and addresses for sorting.
Definition: dlg_gpgme.c:192
static int crypt_compare_key_address(const void *a, const void *b)
Compare Key addresses and IDs for sorting.
Definition: dlg_gpgme.c:124
static int crypt_compare_keyid(const void *a, const void *b)
Compare Key IDs and addresses for sorting.
Definition: dlg_gpgme.c:158
struct CryptKeyInfo * dlg_select_gpgme_key(struct CryptKeyInfo *keys, struct Address *p, const char *s, unsigned int app, bool *forced_valid)
Get the user to select a key.
Definition: dlg_gpgme.c:665
static int crypt_compare_keyid_qsort(const void *a, const void *b)
Compare the IDs of two keys.
Definition: dlg_gpgme.c:177
static int crypt_compare_address_qsort(const void *a, const void *b)
Compare the addresses of two keys.
Definition: dlg_gpgme.c:143
static int crypt_compare_trust_qsort(const void *a, const void *b)
Compare the trust levels of two keys.
Definition: dlg_gpgme.c:283
static const struct Mapping GpgmeHelp[]
Help Bar for the GPGME key selection dialog.
Definition: dlg_gpgme.c:97
Flags to control mutt_expando_format()
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
#define MUTT_FORMAT_OPTIONAL
Allow optional field processing.
Definition: format_flags.h:33
#define MUTT_FORMAT_ARROWCURSOR
Reserve space for arrow_cursor.
Definition: format_flags.h:35
uint8_t MuttFormatFlags
Flags for mutt_expando_format(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: format_flags.h:29
Gpgme functions.
int gpgme_function_dispatcher(struct MuttWindow *win, int op)
Perform a Gpgme function - Implements function_dispatcher_t -.
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:320
static const char * crypt_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
Format a string for the key selection menu - Implements format_t -.
Definition: dlg_gpgme.c:364
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags)
Expand expandos (x) in a string -.
Definition: muttlib.c:777
#define mutt_error(...)
Definition: logging.h:87
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
static void crypt_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the key selection list - Implements Menu::make_entry() -.
Definition: dlg_gpgme.c:576
static void gpgme_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlg_gpgme.c:594
static int gpgme_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_gpgme.c:602
static int gpgme_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_gpgme.c:631
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:166
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:129
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:795
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
Manage keymappings.
@ LL_DEBUG5
Log at debug level 5.
Definition: logging.h:44
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
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:43
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:178
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:228
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:189
int mutt_istr_cmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:483
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:807
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:604
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:522
@ WT_DLG_CRYPT_GPGME
Crypt-GPGME Dialog, dlg_select_gpgme_key()
Definition: mutt_window.h:83
@ 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:206
Some miscellaneous functions.
#define KEYFLAG_EXPIRED
Key is expired.
Definition: lib.h:131
#define KEYFLAG_ISX509
Key is an X.509 key.
Definition: lib.h:129
uint16_t KeyFlags
Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN.
Definition: lib.h:125
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:90
#define KEYFLAG_RESTRICTIONS
Definition: lib.h:140
#define KEYFLAG_ABILITIES
Definition: lib.h:142
#define KEYFLAG_CANENCRYPT
Key is suitable for encryption.
Definition: lib.h:128
#define KEYFLAG_CANTUSE
Definition: lib.h:139
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:91
#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
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
@ 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:46
All user-callable functions.
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
GUI display the mailboxes in a side panel.
#define SORT_MASK
Mask for the sort id.
Definition: sort2.h:78
@ SORT_TRUST
Sort by encryption key's trust level.
Definition: sort2.h:56
@ SORT_KEYID
Sort by the encryption key's ID.
Definition: sort2.h:55
@ SORT_DATE
Sort by the date the email was sent.
Definition: sort2.h:43
@ SORT_ADDRESS
Sort by email address.
Definition: sort2.h:54
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:79
Key value store.
#define NONULL(x)
Definition: string2.h:37
An email address.
Definition: address.h:36
char * mailbox
Mailbox and host address.
Definition: address.h:38
An entry in the Select-Key menu.
Definition: dlg_gpgme.c:111
struct CryptKeyInfo * key
Key.
Definition: dlg_gpgme.c:113
size_t num
Index number.
Definition: dlg_gpgme.c:112
A stored PGP key.
Definition: crypt_gpgme.h:44
gpgme_validity_t validity
uid validity (cached for convenience)
Definition: crypt_gpgme.h:50
KeyFlags flags
global and per uid flags (for convenience)
Definition: crypt_gpgme.h:49
struct CryptKeyInfo * next
Linked list.
Definition: crypt_gpgme.h:45
const char * uid
and for convenience point to this user ID
Definition: crypt_gpgme.h:48
gpgme_key_t kobj
Definition: crypt_gpgme.h:46
A config-change event.
Definition: subset.h:70
const char * name
Name of config item that changed.
Definition: subset.h:72
An Event that happened to a Window.
Definition: mutt_window.h:216
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
Data to pass to the Gpgme Functions.
bool * forced_valid
User insists on out-of-date key.
struct CryptKeyInfo * key
Selected Key.
struct CryptKeyInfo ** key_table
Array of Keys.
bool done
Should we close the Dialog?
struct Menu * menu
Gpgme Menu.
Mapping between user-readable string and a constant.
Definition: mapping.h:32
Definition: lib.h:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:96
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
void * mdata
Private data.
Definition: lib.h:137
int max
Number of entries in the menu.
Definition: lib.h:71
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
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:37
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
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
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
MenuType
Types of GUI selections.
Definition: type.h:36
@ MENU_KEY_SELECT_PGP
Select a PGP key.
Definition: type.h:47
@ MENU_KEY_SELECT_SMIME
Select a SMIME key.
Definition: type.h:48
@ MENU_GENERIC
Generic selection list.
Definition: type.h:45