NeoMutt  2023-03-22-27-g3cb248
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
94static const struct Mapping GpgmeHelp[] = {
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
108{
109 size_t num;
111};
112
121static int crypt_compare_key_address(const void *a, const void *b)
122{
123 struct CryptKeyInfo **s = (struct CryptKeyInfo **) a;
124 struct CryptKeyInfo **t = (struct CryptKeyInfo **) b;
125
126 int r = mutt_istr_cmp((*s)->uid, (*t)->uid);
127 if (r != 0)
128 return r > 0;
130}
131
140static int crypt_compare_address_qsort(const void *a, const void *b)
141{
142 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
143 return (c_pgp_sort_keys & SORT_REVERSE) ? !crypt_compare_key_address(a, b) :
145}
146
155static int crypt_compare_keyid(const void *a, const void *b)
156{
157 struct CryptKeyInfo **s = (struct CryptKeyInfo **) a;
158 struct CryptKeyInfo **t = (struct CryptKeyInfo **) b;
159
161 if (r != 0)
162 return r > 0;
163 return mutt_istr_cmp((*s)->uid, (*t)->uid) > 0;
164}
165
174static int crypt_compare_keyid_qsort(const void *a, const void *b)
175{
176 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
177 return (c_pgp_sort_keys & SORT_REVERSE) ? !crypt_compare_keyid(a, b) :
179}
180
189static int crypt_compare_key_date(const void *a, const void *b)
190{
191 struct CryptKeyInfo **s = (struct CryptKeyInfo **) a;
192 struct CryptKeyInfo **t = (struct CryptKeyInfo **) b;
193 unsigned long ts = 0, tt = 0;
194
195 if ((*s)->kobj->subkeys && ((*s)->kobj->subkeys->timestamp > 0))
196 ts = (*s)->kobj->subkeys->timestamp;
197 if ((*t)->kobj->subkeys && ((*t)->kobj->subkeys->timestamp > 0))
198 tt = (*t)->kobj->subkeys->timestamp;
199
200 if (ts > tt)
201 return 1;
202 if (ts < tt)
203 return 0;
204
205 return mutt_istr_cmp((*s)->uid, (*t)->uid) > 0;
206}
207
216static int crypt_compare_date_qsort(const void *a, const void *b)
217{
218 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
219 return (c_pgp_sort_keys & SORT_REVERSE) ? !crypt_compare_key_date(a, b) :
221}
222
234static int crypt_compare_key_trust(const void *a, const void *b)
235{
236 struct CryptKeyInfo **s = (struct CryptKeyInfo **) a;
237 struct CryptKeyInfo **t = (struct CryptKeyInfo **) b;
238 unsigned long ts = 0, tt = 0;
239
240 int r = (((*s)->flags & KEYFLAG_RESTRICTIONS) - ((*t)->flags & KEYFLAG_RESTRICTIONS));
241 if (r != 0)
242 return r > 0;
243
244 ts = (*s)->validity;
245 tt = (*t)->validity;
246 r = (tt - ts);
247 if (r != 0)
248 return r < 0;
249
250 if ((*s)->kobj->subkeys)
251 ts = (*s)->kobj->subkeys->length;
252 if ((*t)->kobj->subkeys)
253 tt = (*t)->kobj->subkeys->length;
254 if (ts != tt)
255 return ts > tt;
256
257 if ((*s)->kobj->subkeys && ((*s)->kobj->subkeys->timestamp > 0))
258 ts = (*s)->kobj->subkeys->timestamp;
259 if ((*t)->kobj->subkeys && ((*t)->kobj->subkeys->timestamp > 0))
260 tt = (*t)->kobj->subkeys->timestamp;
261 if (ts > tt)
262 return 1;
263 if (ts < tt)
264 return 0;
265
266 r = mutt_istr_cmp((*s)->uid, (*t)->uid);
267 if (r != 0)
268 return r > 0;
270}
271
280static int crypt_compare_trust_qsort(const void *a, const void *b)
281{
282 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
283 return (c_pgp_sort_keys & SORT_REVERSE) ? !crypt_compare_key_trust(a, b) :
285}
286
295{
296 static char buf[3];
297
298 if (!(flags & KEYFLAG_CANENCRYPT))
299 buf[0] = '-';
300 else if (flags & KEYFLAG_PREFER_SIGNING)
301 buf[0] = '.';
302 else
303 buf[0] = 'e';
304
305 if (!(flags & KEYFLAG_CANSIGN))
306 buf[1] = '-';
308 buf[1] = '.';
309 else
310 buf[1] = 's';
311
312 buf[2] = '\0';
313
314 return buf;
315}
316
325{
327 return 'R';
329 return 'X';
331 return 'd';
333 return 'c';
334
335 return ' ';
336}
337
363static const char *crypt_format_str(char *buf, size_t buflen, size_t col, int cols,
364 char op, const char *src, const char *prec,
365 const char *if_str, const char *else_str,
366 intptr_t data, MuttFormatFlags flags)
367{
368 char fmt[128] = { 0 };
369 bool optional = (flags & MUTT_FORMAT_OPTIONAL);
370
371 struct CryptEntry *entry = (struct CryptEntry *) data;
372 struct CryptKeyInfo *key = entry->key;
373
374 /* if (isupper ((unsigned char) op)) */
375 /* key = pkey; */
376
377 KeyFlags kflags = (key->flags /* | (pkey->flags & KEYFLAG_RESTRICTIONS)
378 | uid->flags */);
379
380 switch (tolower(op))
381 {
382 case 'a':
383 if (!optional)
384 {
385 const char *s = NULL;
386 snprintf(fmt, sizeof(fmt), "%%%s.3s", prec);
387 if (key->kobj->subkeys)
388 s = gpgme_pubkey_algo_name(key->kobj->subkeys->pubkey_algo);
389 else
390 s = "?";
391 snprintf(buf, buflen, fmt, s);
392 }
393 break;
394
395 case 'c':
396 if (!optional)
397 {
398 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
399 snprintf(buf, buflen, fmt, crypt_key_abilities(kflags));
400 }
401 else if (!(kflags & KEYFLAG_ABILITIES))
402 optional = false;
403 break;
404
405 case 'f':
406 if (!optional)
407 {
408 snprintf(fmt, sizeof(fmt), "%%%sc", prec);
409 snprintf(buf, buflen, fmt, crypt_flags(kflags));
410 }
411 else if (!(kflags & KEYFLAG_RESTRICTIONS))
412 optional = false;
413 break;
414
415 case 'i':
416 if (!optional)
417 {
418 /* fixme: we need a way to distinguish between main and subkeys.
419 * Store the idx in entry? */
420 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
421 snprintf(buf, buflen, fmt, crypt_fpr_or_lkeyid(key));
422 }
423 break;
424
425 case 'k':
426 if (!optional)
427 {
428 /* fixme: we need a way to distinguish between main and subkeys.
429 * Store the idx in entry? */
430 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
431 snprintf(buf, buflen, fmt, crypt_keyid(key));
432 }
433 break;
434
435 case 'l':
436 if (!optional)
437 {
438 snprintf(fmt, sizeof(fmt), "%%%slu", prec);
439 unsigned long val;
440 if (key->kobj->subkeys)
441 val = key->kobj->subkeys->length;
442 else
443 val = 0;
444 snprintf(buf, buflen, fmt, val);
445 }
446 break;
447
448 case 'n':
449 if (!optional)
450 {
451 snprintf(fmt, sizeof(fmt), "%%%sd", prec);
452 snprintf(buf, buflen, fmt, entry->num);
453 }
454 break;
455
456 case 'p':
457 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
458 snprintf(buf, buflen, fmt, gpgme_get_protocol_name(key->kobj->protocol));
459 break;
460
461 case 't':
462 {
463 char *s = NULL;
464 if ((kflags & KEYFLAG_ISX509))
465 {
466 s = "x";
467 }
468 else
469 {
470 switch (key->validity)
471 {
472 case GPGME_VALIDITY_FULL:
473 s = "f";
474 break;
475 case GPGME_VALIDITY_MARGINAL:
476 s = "m";
477 break;
478 case GPGME_VALIDITY_NEVER:
479 s = "n";
480 break;
481 case GPGME_VALIDITY_ULTIMATE:
482 s = "u";
483 break;
484 case GPGME_VALIDITY_UNDEFINED:
485 s = "q";
486 break;
487 case GPGME_VALIDITY_UNKNOWN:
488 default:
489 s = "?";
490 break;
491 }
492 }
493 snprintf(fmt, sizeof(fmt), "%%%sc", prec);
494 snprintf(buf, buflen, fmt, *s);
495 break;
496 }
497
498 case 'u':
499 if (!optional)
500 {
501 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
502 snprintf(buf, buflen, fmt, key->uid);
503 }
504 break;
505
506 case '[':
507 {
508 char buf2[128];
509 bool do_locales = true;
510 struct tm tm = { 0 };
511
512 char *p = buf;
513
514 const char *cp = src;
515 if (*cp == '!')
516 {
517 do_locales = false;
518 cp++;
519 }
520
521 size_t len = buflen - 1;
522 while ((len > 0) && (*cp != ']'))
523 {
524 if (*cp == '%')
525 {
526 cp++;
527 if (len >= 2)
528 {
529 *p++ = '%';
530 *p++ = *cp;
531 len -= 2;
532 }
533 else
534 {
535 break; /* not enough space */
536 }
537 cp++;
538 }
539 else
540 {
541 *p++ = *cp++;
542 len--;
543 }
544 }
545 *p = '\0';
546
547 if (key->kobj->subkeys && (key->kobj->subkeys->timestamp > 0))
548 tm = mutt_date_localtime(key->kobj->subkeys->timestamp);
549 else
550 tm = mutt_date_localtime(0); // Default to 1970-01-01
551
552 if (!do_locales)
553 setlocale(LC_TIME, "C");
554 strftime(buf2, sizeof(buf2), buf, &tm);
555 if (!do_locales)
556 setlocale(LC_TIME, "");
557
558 snprintf(fmt, sizeof(fmt), "%%%ss", prec);
559 snprintf(buf, buflen, fmt, buf2);
560 if (len > 0)
561 src = cp + 1;
562 break;
563 }
564
565 default:
566 *buf = '\0';
567 }
568
569 if (optional)
570 {
571 mutt_expando_format(buf, buflen, col, cols, if_str, crypt_format_str, data,
573 }
574 else if (flags & MUTT_FORMAT_OPTIONAL)
575 {
576 mutt_expando_format(buf, buflen, col, cols, else_str, crypt_format_str,
578 }
579
580 /* We return the format string, unchanged */
581 return src;
582}
583
589static void crypt_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
590{
591 struct CryptKeyInfo **key_table = menu->mdata;
592 struct CryptEntry entry;
593
594 entry.key = key_table[line];
595 entry.num = line + 1;
596
597 const char *const c_pgp_entry_format = cs_subset_string(NeoMutt->sub, "pgp_entry_format");
598 mutt_expando_format(buf, buflen, 0, menu->win->state.cols, NONULL(c_pgp_entry_format),
599 crypt_format_str, (intptr_t) &entry, MUTT_FORMAT_ARROWCURSOR);
600}
601
607static void gpgme_key_table_free(struct Menu *menu, void **ptr)
608{
609 FREE(ptr);
610}
611
616{
617 if (nc->event_type != NT_CONFIG)
618 return 0;
619 if (!nc->global_data || !nc->event_data)
620 return -1;
621
622 struct EventConfig *ev_c = nc->event_data;
623
624 if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
625 !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
626 {
627 return 0;
628 }
629
630 struct Menu *menu = nc->global_data;
632 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
633
634 return 0;
635}
636
645{
646 if (nc->event_type != NT_WINDOW)
647 return 0;
648 if (!nc->global_data || !nc->event_data)
649 return -1;
651 return 0;
652
653 struct MuttWindow *win_menu = nc->global_data;
654 struct EventWindow *ev_w = nc->event_data;
655 if (ev_w->win != win_menu)
656 return 0;
657
658 struct Menu *menu = win_menu->wdata;
659
662
663 mutt_debug(LL_DEBUG5, "window delete done\n");
664 return 0;
665}
666
679 struct Address *p, const char *s,
680 unsigned int app, bool *forced_valid)
681{
682 int keymax;
683 int i;
684 int (*f)(const void *, const void *);
685 enum MenuType menu_to_use = MENU_GENERIC;
686 bool unusable = false;
687
688 /* build the key table */
689 keymax = 0;
690 i = 0;
691 struct CryptKeyInfo **key_table = NULL;
692 for (struct CryptKeyInfo *k = keys; k; k = k->next)
693 {
694 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
695 if (!c_pgp_show_unusable && (k->flags & KEYFLAG_CANTUSE))
696 {
697 unusable = true;
698 continue;
699 }
700
701 if (i == keymax)
702 {
703 keymax += 20;
704 mutt_mem_realloc(&key_table, sizeof(struct CryptKeyInfo *) * keymax);
705 }
706
707 key_table[i++] = k;
708 }
709
710 if (!i && unusable)
711 {
712 mutt_error(_("All matching keys are marked expired/revoked"));
713 return NULL;
714 }
715
716 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
717 switch (c_pgp_sort_keys & SORT_MASK)
718 {
719 case SORT_ADDRESS:
721 break;
722 case SORT_DATE:
724 break;
725 case SORT_KEYID:
727 break;
728 case SORT_TRUST:
729 default:
731 break;
732 }
733 qsort(key_table, i, sizeof(struct CryptKeyInfo *), f);
734
735 if (app & APPLICATION_PGP)
736 menu_to_use = MENU_KEY_SELECT_PGP;
737 else if (app & APPLICATION_SMIME)
738 menu_to_use = MENU_KEY_SELECT_SMIME;
739
740 struct MuttWindow *dlg = simple_dialog_new(menu_to_use, WT_DLG_CRYPT_GPGME, GpgmeHelp);
741
742 struct Menu *menu = dlg->wdata;
743 menu->max = i;
745 menu->mdata = key_table;
747
748 struct GpgmeData gd = { false, menu, key_table, NULL, forced_valid };
749 dlg->wdata = &gd;
750
751 // NT_COLOR is handled by the SimpleDialog
754
755 {
756 const char *ts = NULL;
757
758 if ((app & APPLICATION_PGP) && (app & APPLICATION_SMIME))
759 ts = _("PGP and S/MIME keys matching");
760 else if ((app & APPLICATION_PGP))
761 ts = _("PGP keys matching");
762 else if ((app & APPLICATION_SMIME))
763 ts = _("S/MIME keys matching");
764 else
765 ts = _("keys matching");
766
767 char buf[1024] = { 0 };
768 if (p)
769 {
770 /* L10N: 1$s is one of the previous four entries.
771 %2$s is an address.
772 e.g. "S/MIME keys matching <me@mutt.org>" */
773 snprintf(buf, sizeof(buf), _("%s <%s>"), ts, p->mailbox);
774 }
775 else
776 {
777 /* L10N: e.g. 'S/MIME keys matching "Michael Elkins".' */
778 snprintf(buf, sizeof(buf), _("%s \"%s\""), ts, s);
779 }
780
781 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
782 sbar_set_title(sbar, buf);
783 }
784
786
787 // ---------------------------------------------------------------------------
788 // Event Loop
789 int op = OP_NULL;
790 do
791 {
792 menu_tagging_dispatcher(menu->win, op);
793 window_redraw(NULL);
794
795 op = km_dokey(menu_to_use);
796 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
797 if (op < 0)
798 continue;
799 if (op == OP_NULL)
800 {
801 km_error_key(menu_to_use);
802 continue;
803 }
805
806 int rc = gpgme_function_dispatcher(dlg, op);
807
808 if (rc == FR_UNKNOWN)
809 rc = menu_function_dispatcher(menu->win, op);
810 if (rc == FR_UNKNOWN)
811 rc = global_function_dispatcher(NULL, op);
812 } while (!gd.done);
813 // ---------------------------------------------------------------------------
814
815 simple_dialog_free(&dlg);
816 return gd.key;
817}
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:209
const char * crypt_keyid(struct CryptKeyInfo *k)
Find the ID for the key.
Definition: crypt_gpgme.c:133
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:657
@ 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:216
static char crypt_flags(KeyFlags flags)
Parse the key flags into a single character.
Definition: dlg_gpgme.c:324
static char * crypt_key_abilities(KeyFlags flags)
Parse key flags into a string.
Definition: dlg_gpgme.c:294
static int crypt_compare_key_trust(const void *a, const void *b)
Compare the trust of keys for sorting.
Definition: dlg_gpgme.c:234
static int crypt_compare_key_date(const void *a, const void *b)
Compare Key creation dates and addresses for sorting.
Definition: dlg_gpgme.c:189
static int crypt_compare_key_address(const void *a, const void *b)
Compare Key addresses and IDs for sorting.
Definition: dlg_gpgme.c:121
static int crypt_compare_keyid(const void *a, const void *b)
Compare Key IDs and addresses for sorting.
Definition: dlg_gpgme.c:155
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:678
static int crypt_compare_keyid_qsort(const void *a, const void *b)
Compare the IDs of two keys.
Definition: dlg_gpgme.c:174
static int crypt_compare_address_qsort(const void *a, const void *b)
Compare the addresses of two keys.
Definition: dlg_gpgme.c:140
static int crypt_compare_trust_qsort(const void *a, const void *b)
Compare the trust levels of two keys.
Definition: dlg_gpgme.c:280
static const struct Mapping GpgmeHelp[]
Help Bar for the GPGME key selection dialog.
Definition: dlg_gpgme.c:94
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:363
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:726
#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:589
static void gpgme_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlg_gpgme.c:607
static int gpgme_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_gpgme.c:615
static int gpgme_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_gpgme.c:644
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:797
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1065
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:60
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:73
NeoMutt Logging.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:605
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:523
@ 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:205
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:74
@ SORT_TRUST
Sort by encryption key's trust level.
Definition: sort2.h:52
@ SORT_KEYID
Sort by the encryption key's ID.
Definition: sort2.h:51
@ SORT_DATE
Sort by the date the email was sent.
Definition: sort2.h:39
@ SORT_ADDRESS
Sort by email address.
Definition: sort2.h:50
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:75
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:108
struct CryptKeyInfo * key
Key.
Definition: dlg_gpgme.c:110
size_t num
Index number.
Definition: dlg_gpgme.c:109
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:215
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:216
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:70
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:77
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:97
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
void * mdata
Private data.
Definition: lib.h:138
int max
Number of entries in the menu.
Definition: lib.h:72
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