NeoMutt  2024-03-23-23-gec7045
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_gpgme.c
Go to the documentation of this file.
1
71#include "config.h"
72#include <assert.h>
73#include <gpgme.h>
74#include <locale.h>
75#include <stdbool.h>
76#include <stdio.h>
77#include <time.h>
78#include "private.h"
79#include "mutt/lib.h"
80#include "address/lib.h"
81#include "config/lib.h"
82#include "core/lib.h"
83#include "gui/lib.h"
84#include "lib.h"
85#include "expando/lib.h"
86#include "key/lib.h"
87#include "menu/lib.h"
88#include "crypt_gpgme.h"
89#include "gpgme_functions.h"
90#include "mutt_logging.h"
91#include "pgplib.h"
92#include "sort.h"
93
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
110static int crypt_sort_address(const void *a, const void *b, void *sdata)
111{
112 struct CryptKeyInfo *s = *(struct CryptKeyInfo **) a;
113 struct CryptKeyInfo *t = *(struct CryptKeyInfo **) b;
114 const bool sort_reverse = *(bool *) sdata;
115
116 int rc = mutt_istr_cmp(s->uid, t->uid);
117 if (rc != 0)
118 goto done;
119
121
122done:
123 return sort_reverse ? -rc : rc;
124}
125
129static int crypt_sort_keyid(const void *a, const void *b, void *sdata)
130{
131 struct CryptKeyInfo *s = *(struct CryptKeyInfo **) a;
132 struct CryptKeyInfo *t = *(struct CryptKeyInfo **) b;
133 const bool sort_reverse = *(bool *) sdata;
134
136 if (rc != 0)
137 goto done;
138
139 rc = mutt_istr_cmp(s->uid, t->uid);
140
141done:
142 return sort_reverse ? -rc : rc;
143}
144
148static int crypt_sort_date(const void *a, const void *b, void *sdata)
149{
150 struct CryptKeyInfo *s = *(struct CryptKeyInfo **) a;
151 struct CryptKeyInfo *t = *(struct CryptKeyInfo **) b;
152 const bool sort_reverse = *(bool *) sdata;
153
154 unsigned long ts = 0;
155 unsigned long tt = 0;
156 int rc = 0;
157
158 if (s->kobj->subkeys && (s->kobj->subkeys->timestamp > 0))
159 ts = s->kobj->subkeys->timestamp;
160 if (t->kobj->subkeys && (t->kobj->subkeys->timestamp > 0))
161 tt = t->kobj->subkeys->timestamp;
162
163 if (ts > tt)
164 {
165 rc = 1;
166 goto done;
167 }
168
169 if (ts < tt)
170 {
171 rc = -1;
172 goto done;
173 }
174
175 rc = mutt_istr_cmp(s->uid, t->uid);
176
177done:
178 return sort_reverse ? -rc : rc;
179}
180
184static int crypt_sort_trust(const void *a, const void *b, void *sdata)
185{
186 struct CryptKeyInfo *s = *(struct CryptKeyInfo **) a;
187 struct CryptKeyInfo *t = *(struct CryptKeyInfo **) b;
188 const bool sort_reverse = *(bool *) sdata;
189
190 unsigned long ts = 0;
191 unsigned long tt = 0;
192
194 if (rc != 0)
195 goto done;
196
197 // Note: reversed
199 if (rc != 0)
200 return rc;
201
202 ts = 0;
203 tt = 0;
204 if (s->kobj->subkeys)
205 ts = s->kobj->subkeys->length;
206 if (t->kobj->subkeys)
207 tt = t->kobj->subkeys->length;
208
209 // Note: reversed
210 rc = mutt_numeric_cmp(tt, ts);
211 if (rc != 0)
212 goto done;
213
214 ts = 0;
215 tt = 0;
216 if (s->kobj->subkeys && (s->kobj->subkeys->timestamp > 0))
217 ts = s->kobj->subkeys->timestamp;
218 if (t->kobj->subkeys && (t->kobj->subkeys->timestamp > 0))
219 tt = t->kobj->subkeys->timestamp;
220
221 // Note: reversed
222 rc = mutt_numeric_cmp(tt, ts);
223 if (rc != 0)
224 goto done;
225
226 rc = mutt_istr_cmp(s->uid, t->uid);
227 if (rc != 0)
228 goto done;
229
231
232done:
233 return sort_reverse ? -rc : rc;
234}
235
244{
245 static char buf[3];
246
247 if (!(flags & KEYFLAG_CANENCRYPT))
248 buf[0] = '-';
249 else if (flags & KEYFLAG_PREFER_SIGNING)
250 buf[0] = '.';
251 else
252 buf[0] = 'e';
253
254 if (!(flags & KEYFLAG_CANSIGN))
255 buf[1] = '-';
257 buf[1] = '.';
258 else
259 buf[1] = 's';
260
261 buf[2] = '\0';
262
263 return buf;
264}
265
274{
276 return "R";
278 return "X";
280 return "d";
282 return "c";
283
284 return " ";
285}
286
290long pgp_entry_gpgme_date_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
291{
292#ifdef HAVE_PKG_GPGME
293 const struct CryptEntry *entry = data;
294 const struct CryptKeyInfo *key = entry->key;
295 return key->kobj->subkeys->timestamp;
296#endif
297 return 0;
298}
299
303void pgp_entry_gpgme_date(const struct ExpandoNode *node, void *data,
304 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
305{
306#ifdef HAVE_PKG_GPGME
307 const struct CryptEntry *entry = data;
308 const struct CryptKeyInfo *key = entry->key;
309
310 char tmp[128] = { 0 };
311 char datestr[128] = { 0 };
312
313 int len = node->end - node->start;
314 const char *start = node->start;
315 bool use_c_locale = false;
316 if (*start == '!')
317 {
318 use_c_locale = true;
319 start++;
320 len--;
321 }
322
323 assert(len < sizeof(datestr));
324 mutt_strn_copy(datestr, start, len, sizeof(datestr));
325
326 struct tm tm = { 0 };
327 if (key->kobj->subkeys && (key->kobj->subkeys->timestamp > 0))
328 {
329 tm = mutt_date_localtime(key->kobj->subkeys->timestamp);
330 }
331 else
332 {
333 tm = mutt_date_localtime(0); // Default to 1970-01-01
334 }
335
336 if (use_c_locale)
337 {
338 strftime_l(tmp, sizeof(tmp), datestr, &tm, NeoMutt->time_c_locale);
339 }
340 else
341 {
342 strftime(tmp, sizeof(tmp), datestr, &tm);
343 }
344
345 buf_strcpy(buf, tmp);
346#endif
347}
348
352long pgp_entry_gpgme_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
353{
354#ifdef HAVE_PKG_GPGME
355 const struct CryptEntry *entry = data;
356 return entry->num;
357#else
358 return 0;
359#endif
360}
361
365void pgp_entry_gpgme_p(const struct ExpandoNode *node, void *data,
366 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
367{
368#ifdef HAVE_PKG_GPGME
369 const struct CryptEntry *entry = data;
370 const struct CryptKeyInfo *key = entry->key;
371
372 const char *s = gpgme_get_protocol_name(key->kobj->protocol);
373 buf_strcpy(buf, s);
374#endif
375}
376
380void pgp_entry_gpgme_t(const struct ExpandoNode *node, void *data,
381 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
382{
383#ifdef HAVE_PKG_GPGME
384 const struct CryptEntry *entry = data;
385 const struct CryptKeyInfo *key = entry->key;
386
387 const char *s = "";
388 if ((key->flags & KEYFLAG_ISX509))
389 {
390 s = "x";
391 }
392 else
393 {
394 switch (key->validity)
395 {
396 case GPGME_VALIDITY_FULL:
397 s = "f";
398 break;
399 case GPGME_VALIDITY_MARGINAL:
400 s = "m";
401 break;
402 case GPGME_VALIDITY_NEVER:
403 s = "n";
404 break;
405 case GPGME_VALIDITY_ULTIMATE:
406 s = "u";
407 break;
408 case GPGME_VALIDITY_UNDEFINED:
409 s = "q";
410 break;
411 case GPGME_VALIDITY_UNKNOWN:
412 default:
413 s = "?";
414 break;
415 }
416 }
417
418 buf_strcpy(buf, s);
419#endif
420}
421
425void pgp_entry_gpgme_u(const struct ExpandoNode *node, void *data,
426 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
427{
428#ifdef HAVE_PKG_GPGME
429 const struct CryptEntry *entry = data;
430 const struct CryptKeyInfo *key = entry->key;
431
432 const char *s = key->uid;
433 buf_strcpy(buf, s);
434#endif
435}
436
440void pgp_entry_gpgme_a(const struct ExpandoNode *node, void *data,
441 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
442{
443#ifdef HAVE_PKG_GPGME
444 const struct CryptEntry *entry = data;
445 const struct CryptKeyInfo *key = entry->key;
446
447 const char *s = NULL;
448 if (key->kobj->subkeys)
449 s = gpgme_pubkey_algo_name(key->kobj->subkeys->pubkey_algo);
450 else
451 s = "?";
452
453 buf_strcpy(buf, s);
454#endif
455}
456
460void pgp_entry_gpgme_c(const struct ExpandoNode *node, void *data,
461 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
462{
463#ifdef HAVE_PKG_GPGME
464 const struct CryptEntry *entry = data;
465 const struct CryptKeyInfo *key = entry->key;
466
467 const char *s = crypt_key_abilities(key->flags);
468 buf_strcpy(buf, s);
469#endif
470}
471
475void pgp_entry_gpgme_f(const struct ExpandoNode *node, void *data,
476 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
477{
478#ifdef HAVE_PKG_GPGME
479 const struct CryptEntry *entry = data;
480 const struct CryptKeyInfo *key = entry->key;
481
482 const char *s = crypt_flags(key->flags);
483 buf_strcpy(buf, s);
484#endif
485}
486
490void pgp_entry_gpgme_i(const struct ExpandoNode *node, void *data,
491 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
492{
493#ifdef HAVE_PKG_GPGME
494 const struct CryptEntry *entry = data;
495 struct CryptKeyInfo *key = entry->key;
496
497 /* fixme: we need a way to distinguish between main and subkeys.
498 * Store the idx in entry? */
499 const char *s = crypt_fpr_or_lkeyid(key);
500 buf_strcpy(buf, s);
501#endif
502}
503
507void pgp_entry_gpgme_k(const struct ExpandoNode *node, void *data,
508 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
509{
510#ifdef HAVE_PKG_GPGME
511 const struct CryptEntry *entry = data;
512 struct CryptKeyInfo *key = entry->key;
513
514 /* fixme: we need a way to distinguish between main and subkeys.
515 * Store the idx in entry? */
516 const char *s = crypt_keyid(key);
517 buf_strcpy(buf, s);
518#endif
519}
520
524long pgp_entry_gpgme_l_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
525{
526#ifdef HAVE_PKG_GPGME
527 const struct CryptEntry *entry = data;
528 const struct CryptKeyInfo *key = entry->key;
529
530 return key->kobj->subkeys ? key->kobj->subkeys->length : 0;
531#else
532 return 0;
533#endif
534}
535
541static int crypt_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
542{
543 struct CryptKeyInfo **key_table = menu->mdata;
544 struct CryptEntry entry = { 0 };
545
546 entry.key = key_table[line];
547 entry.num = line + 1;
548
549 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
550 if (c_arrow_cursor)
551 {
552 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
553 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
554 }
555
556 const struct Expando *c_pgp_entry_format = cs_subset_expando(NeoMutt->sub, "pgp_entry_format");
557 return expando_render(c_pgp_entry_format, PgpEntryGpgmeRenderData, &entry,
558 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
559}
560
566static void gpgme_key_table_free(struct Menu *menu, void **ptr)
567{
568 FREE(ptr);
569}
570
575{
576 if (nc->event_type != NT_CONFIG)
577 return 0;
578 if (!nc->global_data || !nc->event_data)
579 return -1;
580
581 struct EventConfig *ev_c = nc->event_data;
582
583 if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
584 !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
585 {
586 return 0;
587 }
588
589 struct Menu *menu = nc->global_data;
591 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
592
593 return 0;
594}
595
604{
605 if (nc->event_type != NT_WINDOW)
606 return 0;
607 if (!nc->global_data || !nc->event_data)
608 return -1;
610 return 0;
611
612 struct MuttWindow *win_menu = nc->global_data;
613 struct EventWindow *ev_w = nc->event_data;
614 if (ev_w->win != win_menu)
615 return 0;
616
617 struct Menu *menu = win_menu->wdata;
618
621
622 mutt_debug(LL_DEBUG5, "window delete done\n");
623 return 0;
624}
625
637struct CryptKeyInfo *dlg_gpgme(struct CryptKeyInfo *keys, struct Address *p,
638 const char *s, unsigned int app, bool *forced_valid)
639{
640 int keymax;
641 int i;
642 sort_t f = NULL;
643 enum MenuType menu_to_use = MENU_GENERIC;
644 bool unusable = false;
645
646 /* build the key table */
647 keymax = 0;
648 i = 0;
649 struct CryptKeyInfo **key_table = NULL;
650 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
651 for (struct CryptKeyInfo *k = keys; k; k = k->next)
652 {
653 if (!c_pgp_show_unusable && (k->flags & KEYFLAG_CANTUSE))
654 {
655 unusable = true;
656 continue;
657 }
658
659 if (i == keymax)
660 {
661 keymax += 20;
662 mutt_mem_realloc(&key_table, sizeof(struct CryptKeyInfo *) * keymax);
663 }
664
665 key_table[i++] = k;
666 }
667
668 if (!i && unusable)
669 {
670 mutt_error(_("All matching keys are marked expired/revoked"));
671 return NULL;
672 }
673
674 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
675 switch (c_pgp_sort_keys & SORT_MASK)
676 {
677 case SORT_ADDRESS:
679 break;
680 case SORT_DATE:
681 f = crypt_sort_date;
682 break;
683 case SORT_KEYID:
685 break;
686 case SORT_TRUST:
687 default:
689 break;
690 }
691
692 if (key_table)
693 {
694 bool sort_reverse = c_pgp_sort_keys & SORT_REVERSE;
695 mutt_qsort_r(key_table, i, sizeof(struct CryptKeyInfo *), f, &sort_reverse);
696 }
697
698 if (app & APPLICATION_PGP)
699 menu_to_use = MENU_KEY_SELECT_PGP;
700 else if (app & APPLICATION_SMIME)
701 menu_to_use = MENU_KEY_SELECT_SMIME;
702
703 struct MuttWindow *dlg = simple_dialog_new(menu_to_use, WT_DLG_GPGME, GpgmeHelp);
704
705 struct Menu *menu = dlg->wdata;
706 menu->max = i;
708 menu->mdata = key_table;
710
711 struct GpgmeData gd = { false, menu, key_table, NULL, forced_valid };
712 dlg->wdata = &gd;
713
714 // NT_COLOR is handled by the SimpleDialog
717
718 const char *ts = NULL;
719
720 if ((app & APPLICATION_PGP) && (app & APPLICATION_SMIME))
721 ts = _("PGP and S/MIME keys matching");
722 else if ((app & APPLICATION_PGP))
723 ts = _("PGP keys matching");
724 else if ((app & APPLICATION_SMIME))
725 ts = _("S/MIME keys matching");
726 else
727 ts = _("keys matching");
728
729 char buf[1024] = { 0 };
730 if (p)
731 {
732 /* L10N: 1$s is one of the previous four entries.
733 %2$s is an address.
734 e.g. "S/MIME keys matching <john.doe@example.com>" */
735 snprintf(buf, sizeof(buf), _("%s <%s>"), ts, buf_string(p->mailbox));
736 }
737 else
738 {
739 /* L10N: e.g. 'S/MIME keys matching "John Doe".' */
740 snprintf(buf, sizeof(buf), _("%s \"%s\""), ts, s);
741 }
742
743 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
744 sbar_set_title(sbar, buf);
745
747
748 struct MuttWindow *old_focus = window_set_focus(menu->win);
749 // ---------------------------------------------------------------------------
750 // Event Loop
751 int op = OP_NULL;
752 do
753 {
754 menu_tagging_dispatcher(menu->win, op);
755 window_redraw(NULL);
756
757 op = km_dokey(menu_to_use, GETCH_NO_FLAGS);
758 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
759 if (op < 0)
760 continue;
761 if (op == OP_NULL)
762 {
763 km_error_key(menu_to_use);
764 continue;
765 }
767
768 int rc = gpgme_function_dispatcher(dlg, op);
769
770 if (rc == FR_UNKNOWN)
771 rc = menu_function_dispatcher(menu->win, op);
772 if (rc == FR_UNKNOWN)
773 rc = global_function_dispatcher(NULL, op);
774 } while (!gd.done);
775 // ---------------------------------------------------------------------------
776
777 window_set_focus(old_focus);
778 simple_dialog_free(&dlg);
779 return gd.key;
780}
781
788 // clang-format off
807 { -1, -1, NULL, NULL },
808 // clang-format on
809};
Email Address Handling.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:412
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:97
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:297
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.
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition: curs_lib.c:445
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
static char * crypt_key_abilities(KeyFlags flags)
Parse key flags into a string.
Definition: dlg_gpgme.c:243
const struct ExpandoRenderData PgpEntryGpgmeRenderData[]
Callbacks for GPGME Key Expandos.
Definition: dlg_gpgme.c:94
static char * crypt_flags(KeyFlags flags)
Parse the key flags into a single character.
Definition: dlg_gpgme.c:273
static const struct Mapping GpgmeHelp[]
Help Bar for the GPGME key selection dialog.
Definition: dlg_gpgme.c:97
@ 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:109
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
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:230
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:169
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:318
long pgp_entry_gpgme_date_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
GPGME: Date of the key - Implements ExpandoRenderData::get_number -.
Definition: dlg_gpgme.c:290
long pgp_entry_gpgme_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
GPGME: Index number - Implements ExpandoRenderData::get_number -.
Definition: dlg_gpgme.c:352
long pgp_entry_gpgme_l_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
GPGME: Key length - Implements ExpandoRenderData::get_number -.
Definition: dlg_gpgme.c:524
void pgp_entry_gpgme_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key Capabilities - Implements ExpandoRenderData::get_string -.
Definition: dlg_gpgme.c:460
void pgp_entry_gpgme_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key Flags - Implements ExpandoRenderData::get_string -.
Definition: dlg_gpgme.c:475
void pgp_entry_gpgme_i(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key fingerprint - Implements ExpandoRenderData::get_string -.
Definition: dlg_gpgme.c:490
void pgp_entry_gpgme_k(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key id - Implements ExpandoRenderData::get_string -.
Definition: dlg_gpgme.c:507
void pgp_entry_gpgme_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Trust/validity - Implements ExpandoRenderData::get_string -.
Definition: dlg_gpgme.c:380
void pgp_entry_gpgme_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key Algorithm - Implements ExpandoRenderData::get_string -.
Definition: dlg_gpgme.c:440
void pgp_entry_gpgme_p(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Protocol - Implements ExpandoRenderData::get_string -.
Definition: dlg_gpgme.c:365
void pgp_entry_gpgme_u(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: User id - Implements ExpandoRenderData::get_string -.
Definition: dlg_gpgme.c:425
void pgp_entry_gpgme_date(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Date of the key - Implements ExpandoRenderData::get_string -.
Definition: dlg_gpgme.c:303
struct CryptKeyInfo * dlg_gpgme(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:637
#define mutt_error(...)
Definition: logging2.h:92
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int crypt_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_gpgme.c:541
static void gpgme_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlg_gpgme.c:566
static int gpgme_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_gpgme.c:574
static int gpgme_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_gpgme.c:603
static int crypt_sort_trust(const void *a, const void *b, void *sdata)
Compare two keys by their trust levels - Implements sort_t -.
Definition: dlg_gpgme.c:184
static int crypt_sort_address(const void *a, const void *b, void *sdata)
Compare two keys by their addresses - Implements sort_t -.
Definition: dlg_gpgme.c:110
static int crypt_sort_date(const void *a, const void *b, void *sdata)
Compare two keys by their dates - Implements sort_t -.
Definition: dlg_gpgme.c:148
static int crypt_sort_keyid(const void *a, const void *b, void *sdata)
Compare two keys by their IDs - Implements sort_t -.
Definition: dlg_gpgme.c:129
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:185
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition: date.c:908
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_GPGME
GPGME Dialog, dlg_gpgme()
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:229
#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_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
@ 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
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
An entry in the Select-Key menu.
Definition: crypt_gpgme.h:85
struct CryptKeyInfo * key
Key.
Definition: crypt_gpgme.h:87
size_t num
Index number.
Definition: crypt_gpgme.h:86
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: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
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: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
MenuType
Types of GUI selections.
Definition: type.h:36
@ MENU_KEY_SELECT_PGP
Select a PGP key.
Definition: type.h:48
@ MENU_KEY_SELECT_SMIME
Select a SMIME key.
Definition: type.h:49
@ MENU_GENERIC
Generic selection list.
Definition: type.h:46