NeoMutt  2024-04-25-91-gb0e085
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 <gpgme.h>
73#include <locale.h>
74#include <stdbool.h>
75#include <stdio.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 "expando/lib.h"
85#include "key/lib.h"
86#include "menu/lib.h"
87#include "crypt_gpgme.h"
88#include "gpgme_functions.h"
89#include "mutt_logging.h"
90#include "pgplib.h"
91#include "sort.h"
92
94
96static const struct Mapping GpgmeHelp[] = {
97 // clang-format off
98 { N_("Exit"), OP_EXIT },
99 { N_("Select"), OP_GENERIC_SELECT_ENTRY },
100 { N_("Check key"), OP_VERIFY_KEY },
101 { N_("Help"), OP_HELP },
102 { NULL, 0 },
103 // clang-format on
104};
105
109static int crypt_sort_address(const void *a, const void *b, void *sdata)
110{
111 struct CryptKeyInfo *s = *(struct CryptKeyInfo **) a;
112 struct CryptKeyInfo *t = *(struct CryptKeyInfo **) b;
113 const bool sort_reverse = *(bool *) sdata;
114
115 int rc = mutt_istr_cmp(s->uid, t->uid);
116 if (rc != 0)
117 goto done;
118
120
121done:
122 return sort_reverse ? -rc : rc;
123}
124
128static int crypt_sort_keyid(const void *a, const void *b, void *sdata)
129{
130 struct CryptKeyInfo *s = *(struct CryptKeyInfo **) a;
131 struct CryptKeyInfo *t = *(struct CryptKeyInfo **) b;
132 const bool sort_reverse = *(bool *) sdata;
133
135 if (rc != 0)
136 goto done;
137
138 rc = mutt_istr_cmp(s->uid, t->uid);
139
140done:
141 return sort_reverse ? -rc : rc;
142}
143
147static int crypt_sort_date(const void *a, const void *b, void *sdata)
148{
149 struct CryptKeyInfo *s = *(struct CryptKeyInfo **) a;
150 struct CryptKeyInfo *t = *(struct CryptKeyInfo **) b;
151 const bool sort_reverse = *(bool *) sdata;
152
153 unsigned long ts = 0;
154 unsigned long tt = 0;
155 int rc = 0;
156
157 if (s->kobj->subkeys && (s->kobj->subkeys->timestamp > 0))
158 ts = s->kobj->subkeys->timestamp;
159 if (t->kobj->subkeys && (t->kobj->subkeys->timestamp > 0))
160 tt = t->kobj->subkeys->timestamp;
161
162 if (ts > tt)
163 {
164 rc = 1;
165 goto done;
166 }
167
168 if (ts < tt)
169 {
170 rc = -1;
171 goto done;
172 }
173
174 rc = mutt_istr_cmp(s->uid, t->uid);
175
176done:
177 return sort_reverse ? -rc : rc;
178}
179
183static int crypt_sort_trust(const void *a, const void *b, void *sdata)
184{
185 struct CryptKeyInfo *s = *(struct CryptKeyInfo **) a;
186 struct CryptKeyInfo *t = *(struct CryptKeyInfo **) b;
187 const bool sort_reverse = *(bool *) sdata;
188
189 unsigned long ts = 0;
190 unsigned long tt = 0;
191
193 if (rc != 0)
194 goto done;
195
196 // Note: reversed
198 if (rc != 0)
199 return rc;
200
201 ts = 0;
202 tt = 0;
203 if (s->kobj->subkeys)
204 ts = s->kobj->subkeys->length;
205 if (t->kobj->subkeys)
206 tt = t->kobj->subkeys->length;
207
208 // Note: reversed
209 rc = mutt_numeric_cmp(tt, ts);
210 if (rc != 0)
211 goto done;
212
213 ts = 0;
214 tt = 0;
215 if (s->kobj->subkeys && (s->kobj->subkeys->timestamp > 0))
216 ts = s->kobj->subkeys->timestamp;
217 if (t->kobj->subkeys && (t->kobj->subkeys->timestamp > 0))
218 tt = t->kobj->subkeys->timestamp;
219
220 // Note: reversed
221 rc = mutt_numeric_cmp(tt, ts);
222 if (rc != 0)
223 goto done;
224
225 rc = mutt_istr_cmp(s->uid, t->uid);
226 if (rc != 0)
227 goto done;
228
230
231done:
232 return sort_reverse ? -rc : rc;
233}
234
243{
244 static char buf[3];
245
246 if (!(flags & KEYFLAG_CANENCRYPT))
247 buf[0] = '-';
248 else if (flags & KEYFLAG_PREFER_SIGNING)
249 buf[0] = '.';
250 else
251 buf[0] = 'e';
252
253 if (!(flags & KEYFLAG_CANSIGN))
254 buf[1] = '-';
256 buf[1] = '.';
257 else
258 buf[1] = 's';
259
260 buf[2] = '\0';
261
262 return buf;
263}
264
273{
275 return "R";
277 return "X";
279 return "d";
281 return "c";
282
283 return " ";
284}
285
289long pgp_entry_gpgme_date_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
290{
291#ifdef HAVE_PKG_GPGME
292 const struct CryptEntry *entry = data;
293 const struct CryptKeyInfo *key = entry->key;
294 return key->kobj->subkeys->timestamp;
295#endif
296 return 0;
297}
298
302void pgp_entry_gpgme_date(const struct ExpandoNode *node, void *data,
303 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
304{
305#ifdef HAVE_PKG_GPGME
306 const struct CryptEntry *entry = data;
307 const struct CryptKeyInfo *key = entry->key;
308
309 char tmp[128] = { 0 };
310 char datestr[128] = { 0 };
311
312 int len = node->end - node->start;
313 const char *start = node->start;
314 bool use_c_locale = false;
315 if (*start == '!')
316 {
317 use_c_locale = true;
318 start++;
319 len--;
320 }
321
322 ASSERT(len < sizeof(datestr));
323 mutt_strn_copy(datestr, start, len, sizeof(datestr));
324
325 struct tm tm = { 0 };
326 if (key->kobj->subkeys && (key->kobj->subkeys->timestamp > 0))
327 {
328 tm = mutt_date_localtime(key->kobj->subkeys->timestamp);
329 }
330 else
331 {
332 tm = mutt_date_localtime(0); // Default to 1970-01-01
333 }
334
335 if (use_c_locale)
336 {
337 strftime_l(tmp, sizeof(tmp), datestr, &tm, NeoMutt->time_c_locale);
338 }
339 else
340 {
341 strftime(tmp, sizeof(tmp), datestr, &tm);
342 }
343
344 buf_strcpy(buf, tmp);
345#endif
346}
347
351long pgp_entry_gpgme_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
352{
353#ifdef HAVE_PKG_GPGME
354 const struct CryptEntry *entry = data;
355 return entry->num;
356#else
357 return 0;
358#endif
359}
360
364void pgp_entry_gpgme_p(const struct ExpandoNode *node, void *data,
365 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
366{
367#ifdef HAVE_PKG_GPGME
368 const struct CryptEntry *entry = data;
369 const struct CryptKeyInfo *key = entry->key;
370
371 const char *s = gpgme_get_protocol_name(key->kobj->protocol);
372 buf_strcpy(buf, s);
373#endif
374}
375
379void pgp_entry_gpgme_t(const struct ExpandoNode *node, void *data,
380 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
381{
382#ifdef HAVE_PKG_GPGME
383 const struct CryptEntry *entry = data;
384 const struct CryptKeyInfo *key = entry->key;
385
386 const char *s = "";
387 if ((key->flags & KEYFLAG_ISX509))
388 {
389 s = "x";
390 }
391 else
392 {
393 switch (key->validity)
394 {
395 case GPGME_VALIDITY_FULL:
396 s = "f";
397 break;
398 case GPGME_VALIDITY_MARGINAL:
399 s = "m";
400 break;
401 case GPGME_VALIDITY_NEVER:
402 s = "n";
403 break;
404 case GPGME_VALIDITY_ULTIMATE:
405 s = "u";
406 break;
407 case GPGME_VALIDITY_UNDEFINED:
408 s = "q";
409 break;
410 case GPGME_VALIDITY_UNKNOWN:
411 default:
412 s = "?";
413 break;
414 }
415 }
416
417 buf_strcpy(buf, s);
418#endif
419}
420
424void pgp_entry_gpgme_u(const struct ExpandoNode *node, void *data,
425 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
426{
427#ifdef HAVE_PKG_GPGME
428 const struct CryptEntry *entry = data;
429 const struct CryptKeyInfo *key = entry->key;
430
431 const char *s = key->uid;
432 buf_strcpy(buf, s);
433#endif
434}
435
439void pgp_entry_gpgme_a(const struct ExpandoNode *node, void *data,
440 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
441{
442#ifdef HAVE_PKG_GPGME
443 const struct CryptEntry *entry = data;
444 const struct CryptKeyInfo *key = entry->key;
445
446 const char *s = NULL;
447 if (key->kobj->subkeys)
448 s = gpgme_pubkey_algo_name(key->kobj->subkeys->pubkey_algo);
449 else
450 s = "?";
451
452 buf_strcpy(buf, s);
453#endif
454}
455
459void pgp_entry_gpgme_c(const struct ExpandoNode *node, void *data,
460 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
461{
462#ifdef HAVE_PKG_GPGME
463 const struct CryptEntry *entry = data;
464 const struct CryptKeyInfo *key = entry->key;
465
466 const char *s = crypt_key_abilities(key->flags);
467 buf_strcpy(buf, s);
468#endif
469}
470
474void pgp_entry_gpgme_f(const struct ExpandoNode *node, void *data,
475 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
476{
477#ifdef HAVE_PKG_GPGME
478 const struct CryptEntry *entry = data;
479 const struct CryptKeyInfo *key = entry->key;
480
481 const char *s = crypt_flags(key->flags);
482 buf_strcpy(buf, s);
483#endif
484}
485
489void pgp_entry_gpgme_i(const struct ExpandoNode *node, void *data,
490 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
491{
492#ifdef HAVE_PKG_GPGME
493 const struct CryptEntry *entry = data;
494 struct CryptKeyInfo *key = entry->key;
495
496 /* fixme: we need a way to distinguish between main and subkeys.
497 * Store the idx in entry? */
498 const char *s = crypt_fpr_or_lkeyid(key);
499 buf_strcpy(buf, s);
500#endif
501}
502
506void pgp_entry_gpgme_k(const struct ExpandoNode *node, void *data,
507 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
508{
509#ifdef HAVE_PKG_GPGME
510 const struct CryptEntry *entry = data;
511 struct CryptKeyInfo *key = entry->key;
512
513 /* fixme: we need a way to distinguish between main and subkeys.
514 * Store the idx in entry? */
515 const char *s = crypt_keyid(key);
516 buf_strcpy(buf, s);
517#endif
518}
519
523long pgp_entry_gpgme_l_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
524{
525#ifdef HAVE_PKG_GPGME
526 const struct CryptEntry *entry = data;
527 const struct CryptKeyInfo *key = entry->key;
528
529 return key->kobj->subkeys ? key->kobj->subkeys->length : 0;
530#else
531 return 0;
532#endif
533}
534
540static int crypt_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
541{
542 struct CryptKeyInfo **key_table = menu->mdata;
543 struct CryptEntry entry = { 0 };
544
545 entry.key = key_table[line];
546 entry.num = line + 1;
547
548 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
549 if (c_arrow_cursor)
550 {
551 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
552 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
553 }
554
555 const struct Expando *c_pgp_entry_format = cs_subset_expando(NeoMutt->sub, "pgp_entry_format");
556 return expando_filter(c_pgp_entry_format, PgpEntryGpgmeRenderData, &entry,
557 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
558}
559
565static void gpgme_key_table_free(struct Menu *menu, void **ptr)
566{
567 FREE(ptr);
568}
569
574{
575 if (nc->event_type != NT_CONFIG)
576 return 0;
577 if (!nc->global_data || !nc->event_data)
578 return -1;
579
580 struct EventConfig *ev_c = nc->event_data;
581
582 if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
583 !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
584 {
585 return 0;
586 }
587
588 struct Menu *menu = nc->global_data;
590 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
591
592 return 0;
593}
594
603{
604 if (nc->event_type != NT_WINDOW)
605 return 0;
606 if (!nc->global_data || !nc->event_data)
607 return -1;
609 return 0;
610
611 struct MuttWindow *win_menu = nc->global_data;
612 struct EventWindow *ev_w = nc->event_data;
613 if (ev_w->win != win_menu)
614 return 0;
615
616 struct Menu *menu = win_menu->wdata;
617
620
621 mutt_debug(LL_DEBUG5, "window delete done\n");
622 return 0;
623}
624
636struct CryptKeyInfo *dlg_gpgme(struct CryptKeyInfo *keys, struct Address *p,
637 const char *s, unsigned int app, bool *forced_valid)
638{
639 int keymax;
640 int i;
641 sort_t f = NULL;
642 enum MenuType menu_to_use = MENU_GENERIC;
643 bool unusable = false;
644
645 /* build the key table */
646 keymax = 0;
647 i = 0;
648 struct CryptKeyInfo **key_table = NULL;
649 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
650 for (struct CryptKeyInfo *k = keys; k; k = k->next)
651 {
652 if (!c_pgp_show_unusable && (k->flags & KEYFLAG_CANTUSE))
653 {
654 unusable = true;
655 continue;
656 }
657
658 if (i == keymax)
659 {
660 keymax += 20;
661 mutt_mem_realloc(&key_table, sizeof(struct CryptKeyInfo *) * keymax);
662 }
663
664 key_table[i++] = k;
665 }
666
667 if (!i && unusable)
668 {
669 mutt_error(_("All matching keys are marked expired/revoked"));
670 return NULL;
671 }
672
673 const 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 = crypt_sort_date;
681 break;
682 case SORT_KEYID:
684 break;
685 case SORT_TRUST:
686 default:
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 CryptKeyInfo *), f, &sort_reverse);
695 }
696
697 if (app & APPLICATION_PGP)
698 menu_to_use = MENU_KEY_SELECT_PGP;
699 else if (app & APPLICATION_SMIME)
700 menu_to_use = MENU_KEY_SELECT_SMIME;
701
702 struct MuttWindow *dlg = simple_dialog_new(menu_to_use, WT_DLG_GPGME, GpgmeHelp);
703
704 struct Menu *menu = dlg->wdata;
705 menu->max = i;
707 menu->mdata = key_table;
709
710 struct GpgmeData gd = { false, menu, key_table, NULL, forced_valid };
711 dlg->wdata = &gd;
712
713 // NT_COLOR is handled by the SimpleDialog
716
717 const char *ts = NULL;
718
719 if ((app & APPLICATION_PGP) && (app & APPLICATION_SMIME))
720 ts = _("PGP and S/MIME keys matching");
721 else if ((app & APPLICATION_PGP))
722 ts = _("PGP keys matching");
723 else if ((app & APPLICATION_SMIME))
724 ts = _("S/MIME keys matching");
725 else
726 ts = _("keys matching");
727
728 char buf[1024] = { 0 };
729 if (p)
730 {
731 /* L10N: 1$s is one of the previous four entries.
732 %2$s is an address.
733 e.g. "S/MIME keys matching <john.doe@example.com>" */
734 snprintf(buf, sizeof(buf), _("%s <%s>"), ts, buf_string(p->mailbox));
735 }
736 else
737 {
738 /* L10N: e.g. 'S/MIME keys matching "John Doe".' */
739 snprintf(buf, sizeof(buf), _("%s \"%s\""), ts, s);
740 }
741
742 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
743 sbar_set_title(sbar, buf);
744
746
747 struct MuttWindow *old_focus = window_set_focus(menu->win);
748 // ---------------------------------------------------------------------------
749 // Event Loop
750 int op = OP_NULL;
751 do
752 {
753 menu_tagging_dispatcher(menu->win, op);
754 window_redraw(NULL);
755
756 op = km_dokey(menu_to_use, GETCH_NO_FLAGS);
757 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
758 if (op < 0)
759 continue;
760 if (op == OP_NULL)
761 {
762 km_error_key(menu_to_use);
763 continue;
764 }
766
767 int rc = gpgme_function_dispatcher(dlg, op);
768
769 if (rc == FR_UNKNOWN)
770 rc = menu_function_dispatcher(menu->win, op);
771 if (rc == FR_UNKNOWN)
772 rc = global_function_dispatcher(NULL, op);
773 } while (!gd.done);
774 // ---------------------------------------------------------------------------
775
776 window_set_focus(old_focus);
777 simple_dialog_free(&dlg);
778 return gd.key;
779}
780
787 // clang-format off
806 { -1, -1, NULL, NULL },
807 // clang-format on
808};
Email Address Handling.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:266
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
Definition: config_type.c:357
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
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:443
@ 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:242
const struct ExpandoRenderData PgpEntryGpgmeRenderData[]
Callbacks for GPGME Key Expandos.
Definition: dlg_gpgme.c:93
static char * crypt_flags(KeyFlags flags)
Parse the key flags into a single character.
Definition: dlg_gpgme.c:272
static const struct Mapping GpgmeHelp[]
Help Bar for the GPGME key selection dialog.
Definition: dlg_gpgme.c:96
@ ED_PGP
Pgp ED_PGP_ ExpandoDataPgp.
Definition: domain.h:51
@ ED_PGP_KEY
Pgp_Key ED_PGK_ ExpandoDataPgpKey.
Definition: domain.h:53
int expando_filter(const struct Expando *exp, const struct ExpandoRenderData *rdata, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando and run the result through a filter.
Definition: filter.c:141
Parse Expando string.
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition: get.c:464
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: get.c:294
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: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_gpgme_date_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
GPGME: Date of the key - Implements ExpandoRenderData::get_number() -.
Definition: dlg_gpgme.c:289
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:351
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:523
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:459
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:474
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:489
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:506
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:379
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:439
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:364
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:424
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:302
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:636
#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:540
static void gpgme_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlg_gpgme.c:565
static int gpgme_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_gpgme.c:573
static int gpgme_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_gpgme.c:602
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:183
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:109
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:147
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:128
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:168
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:132
Manage keymappings.
#define GETCH_NO_FLAGS
No flags are set.
Definition: lib.h:51
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:115
#define FREE(x)
Definition: memory.h:45
GUI present the user with a selectable list.
#define MENU_REDRAW_FULL
Redraw everything.
Definition: lib.h:59
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:184
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition: date.c:906
Convenience wrapper for the library headers.
#define N_(a)
Definition: message.h:32
#define _(a)
Definition: message.h:28
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:230
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:191
int mutt_istr_cmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:412
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
char * mutt_strn_copy(char *dest, const char *src, size_t len, size_t dsize)
Copy a sub-string into a buffer.
Definition: string.c:360
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
NeoMutt Logging.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:633
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:683
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:532
@ 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:101
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:228
#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 ASSERT(COND)
Definition: signal2.h:58
#define SORT_MASK
Mask for the sort id.
Definition: sort2.h:70
@ SORT_TRUST
Sort by encryption key's trust level.
Definition: sort2.h:48
@ SORT_KEYID
Sort by the encryption key's ID.
Definition: sort2.h:47
@ SORT_DATE
Sort by the date the email was sent.
Definition: sort2.h:35
@ SORT_ADDRESS
Sort by email address.
Definition: sort2.h:46
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:71
Assorted sorting methods.
#define mutt_numeric_cmp(a, b)
Definition: sort.h:35
Key value store.
An email address.
Definition: address.h:36
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
String manipulation buffer.
Definition: buffer.h:36
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
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:238
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:239
Basic Expando Node.
Definition: node.h:69
const char * end
End of string data.
Definition: node.h:80
const char * start
Start of string data.
Definition: node.h:79
Parsed Expando trees.
Definition: expando.h:41
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:144
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:137
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
locale_t time_c_locale
Current locale but LC_TIME=C.
Definition: neomutt.h:48
Data passed to a notification function.
Definition: observer.h:34
void * event_data
Data from notify_send()
Definition: observer.h:38
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:36
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:37
void * global_data
Data from notify_observer_add()
Definition: observer.h:39
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