NeoMutt  2024-11-14-34-g5aaf0d
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, struct Buffer *buf)
304{
305#ifdef HAVE_PKG_GPGME
306 const struct CryptEntry *entry = data;
307 const struct CryptKeyInfo *key = entry->key;
308
309 const char *text = node->text;
310 bool use_c_locale = false;
311 if (*text == '!')
312 {
313 use_c_locale = true;
314 text++;
315 }
316
317 struct tm tm = { 0 };
318 if (key->kobj->subkeys && (key->kobj->subkeys->timestamp > 0))
319 {
320 tm = mutt_date_localtime(key->kobj->subkeys->timestamp);
321 }
322 else
323 {
324 tm = mutt_date_localtime(0); // Default to 1970-01-01
325 }
326
327 char tmp[128] = { 0 };
328 if (use_c_locale)
329 {
330 strftime_l(tmp, sizeof(tmp), text, &tm, NeoMutt->time_c_locale);
331 }
332 else
333 {
334 strftime(tmp, sizeof(tmp), text, &tm);
335 }
336
337 buf_strcpy(buf, tmp);
338#endif
339}
340
344long pgp_entry_gpgme_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
345{
346#ifdef HAVE_PKG_GPGME
347 const struct CryptEntry *entry = data;
348 return entry->num;
349#else
350 return 0;
351#endif
352}
353
357void pgp_entry_gpgme_p(const struct ExpandoNode *node, void *data,
358 MuttFormatFlags flags, struct Buffer *buf)
359{
360#ifdef HAVE_PKG_GPGME
361 const struct CryptEntry *entry = data;
362 const struct CryptKeyInfo *key = entry->key;
363
364 const char *s = gpgme_get_protocol_name(key->kobj->protocol);
365 buf_strcpy(buf, s);
366#endif
367}
368
372void pgp_entry_gpgme_t(const struct ExpandoNode *node, void *data,
373 MuttFormatFlags flags, struct Buffer *buf)
374{
375#ifdef HAVE_PKG_GPGME
376 const struct CryptEntry *entry = data;
377 const struct CryptKeyInfo *key = entry->key;
378
379 const char *s = "";
380 if ((key->flags & KEYFLAG_ISX509))
381 {
382 s = "x";
383 }
384 else
385 {
386 switch (key->validity)
387 {
388 case GPGME_VALIDITY_FULL:
389 s = "f";
390 break;
391 case GPGME_VALIDITY_MARGINAL:
392 s = "m";
393 break;
394 case GPGME_VALIDITY_NEVER:
395 s = "n";
396 break;
397 case GPGME_VALIDITY_ULTIMATE:
398 s = "u";
399 break;
400 case GPGME_VALIDITY_UNDEFINED:
401 s = "q";
402 break;
403 case GPGME_VALIDITY_UNKNOWN:
404 default:
405 s = "?";
406 break;
407 }
408 }
409
410 buf_strcpy(buf, s);
411#endif
412}
413
417void pgp_entry_gpgme_u(const struct ExpandoNode *node, void *data,
418 MuttFormatFlags flags, struct Buffer *buf)
419{
420#ifdef HAVE_PKG_GPGME
421 const struct CryptEntry *entry = data;
422 const struct CryptKeyInfo *key = entry->key;
423
424 const char *s = key->uid;
425 buf_strcpy(buf, s);
426#endif
427}
428
432void pgp_entry_gpgme_a(const struct ExpandoNode *node, void *data,
433 MuttFormatFlags flags, struct Buffer *buf)
434{
435#ifdef HAVE_PKG_GPGME
436 const struct CryptEntry *entry = data;
437 const struct CryptKeyInfo *key = entry->key;
438
439 const char *s = NULL;
440 if (key->kobj->subkeys)
441 s = gpgme_pubkey_algo_name(key->kobj->subkeys->pubkey_algo);
442 else
443 s = "?";
444
445 buf_strcpy(buf, s);
446#endif
447}
448
452void pgp_entry_gpgme_c(const struct ExpandoNode *node, void *data,
453 MuttFormatFlags flags, struct Buffer *buf)
454{
455#ifdef HAVE_PKG_GPGME
456 const struct CryptEntry *entry = data;
457 const struct CryptKeyInfo *key = entry->key;
458
459 const char *s = crypt_key_abilities(key->flags);
460 buf_strcpy(buf, s);
461#endif
462}
463
467void pgp_entry_gpgme_f(const struct ExpandoNode *node, void *data,
468 MuttFormatFlags flags, struct Buffer *buf)
469{
470#ifdef HAVE_PKG_GPGME
471 const struct CryptEntry *entry = data;
472 const struct CryptKeyInfo *key = entry->key;
473
474 const char *s = crypt_flags(key->flags);
475 buf_strcpy(buf, s);
476#endif
477}
478
482void pgp_entry_gpgme_i(const struct ExpandoNode *node, void *data,
483 MuttFormatFlags flags, struct Buffer *buf)
484{
485#ifdef HAVE_PKG_GPGME
486 const struct CryptEntry *entry = data;
487 struct CryptKeyInfo *key = entry->key;
488
489 /* fixme: we need a way to distinguish between main and subkeys.
490 * Store the idx in entry? */
491 const char *s = crypt_fpr_or_lkeyid(key);
492 buf_strcpy(buf, s);
493#endif
494}
495
499void pgp_entry_gpgme_k(const struct ExpandoNode *node, void *data,
500 MuttFormatFlags flags, struct Buffer *buf)
501{
502#ifdef HAVE_PKG_GPGME
503 const struct CryptEntry *entry = data;
504 struct CryptKeyInfo *key = entry->key;
505
506 /* fixme: we need a way to distinguish between main and subkeys.
507 * Store the idx in entry? */
508 const char *s = crypt_keyid(key);
509 buf_strcpy(buf, s);
510#endif
511}
512
516long pgp_entry_gpgme_l_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
517{
518#ifdef HAVE_PKG_GPGME
519 const struct CryptEntry *entry = data;
520 const struct CryptKeyInfo *key = entry->key;
521
522 return key->kobj->subkeys ? key->kobj->subkeys->length : 0;
523#else
524 return 0;
525#endif
526}
527
533static int crypt_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
534{
535 struct GpgmeData *gd = menu->mdata;
536 struct CryptKeyInfo **pinfo = ARRAY_GET(gd->key_table, line);
537 if (!pinfo)
538 return 0;
539
540 struct CryptEntry entry = { line + 1, *pinfo };
541
542 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
543 if (c_arrow_cursor)
544 {
545 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
546 if (max_cols > 0)
547 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
548 }
549
550 const struct Expando *c_pgp_entry_format = cs_subset_expando(NeoMutt->sub, "pgp_entry_format");
551 return expando_filter(c_pgp_entry_format, PgpEntryGpgmeRenderData, &entry,
552 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
553}
554
559{
560 if (nc->event_type != NT_CONFIG)
561 return 0;
562 if (!nc->global_data || !nc->event_data)
563 return -1;
564
565 struct EventConfig *ev_c = nc->event_data;
566
567 if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
568 !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
569 {
570 return 0;
571 }
572
573 struct Menu *menu = nc->global_data;
575 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
576
577 return 0;
578}
579
588{
589 if (nc->event_type != NT_WINDOW)
590 return 0;
591 if (!nc->global_data || !nc->event_data)
592 return -1;
594 return 0;
595
596 struct MuttWindow *win_menu = nc->global_data;
597 struct EventWindow *ev_w = nc->event_data;
598 if (ev_w->win != win_menu)
599 return 0;
600
601 struct Menu *menu = win_menu->wdata;
602
605
606 mutt_debug(LL_DEBUG5, "window delete done\n");
607 return 0;
608}
609
621struct CryptKeyInfo *dlg_gpgme(struct CryptKeyInfo *keys, struct Address *p,
622 const char *s, unsigned int app, bool *forced_valid)
623{
624 /* build the key table */
625 struct CryptKeyInfoArray ckia = ARRAY_HEAD_INITIALIZER;
626 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
627 bool unusable = false;
628 for (struct CryptKeyInfo *k = keys; k; k = k->next)
629 {
630 if (!c_pgp_show_unusable && (k->flags & KEYFLAG_CANTUSE))
631 {
632 unusable = true;
633 continue;
634 }
635
636 ARRAY_ADD(&ckia, k);
637 }
638
639 if ((ARRAY_SIZE(&ckia) == 0) && unusable)
640 {
641 mutt_error(_("All matching keys are marked expired/revoked"));
642 return NULL;
643 }
644
645 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
646 sort_t fn = NULL;
647 switch (c_pgp_sort_keys & SORT_MASK)
648 {
649 case SORT_ADDRESS:
651 break;
652 case SORT_DATE:
653 fn = crypt_sort_date;
654 break;
655 case SORT_KEYID:
656 fn = crypt_sort_keyid;
657 break;
658 case SORT_TRUST:
659 default:
660 fn = crypt_sort_trust;
661 break;
662 }
663
664 if (ARRAY_SIZE(&ckia) > 1)
665 {
666 bool sort_reverse = c_pgp_sort_keys & SORT_REVERSE;
667 ARRAY_SORT(&ckia, fn, &sort_reverse);
668 }
669
670 enum MenuType menu_to_use = MENU_GENERIC;
671 if (app & APPLICATION_PGP)
672 menu_to_use = MENU_KEY_SELECT_PGP;
673 else if (app & APPLICATION_SMIME)
674 menu_to_use = MENU_KEY_SELECT_SMIME;
675
677
678 struct Menu *menu = sdw.menu;
679 struct GpgmeData gd = { false, menu, &ckia, NULL, forced_valid };
680
681 menu->max = ARRAY_SIZE(&ckia);
683 menu->mdata = &gd;
684 menu->mdata_free = NULL; // Menu doesn't own the data
685
686 // NT_COLOR is handled by the SimpleDialog
689
690 const char *ts = NULL;
691
692 if ((app & APPLICATION_PGP) && (app & APPLICATION_SMIME))
693 ts = _("PGP and S/MIME keys matching");
694 else if ((app & APPLICATION_PGP))
695 ts = _("PGP keys matching");
696 else if ((app & APPLICATION_SMIME))
697 ts = _("S/MIME keys matching");
698 else
699 ts = _("keys matching");
700
701 char buf[1024] = { 0 };
702 if (p)
703 {
704 /* L10N: 1$s is one of the previous four entries.
705 %2$s is an address.
706 e.g. "S/MIME keys matching <john.doe@example.com>" */
707 snprintf(buf, sizeof(buf), _("%s <%s>"), ts, buf_string(p->mailbox));
708 }
709 else
710 {
711 /* L10N: e.g. 'S/MIME keys matching "John Doe".' */
712 snprintf(buf, sizeof(buf), _("%s \"%s\""), ts, s);
713 }
714
715 sbar_set_title(sdw.sbar, buf);
716
718
719 struct MuttWindow *old_focus = window_set_focus(menu->win);
720 // ---------------------------------------------------------------------------
721 // Event Loop
722 int op = OP_NULL;
723 do
724 {
725 menu_tagging_dispatcher(menu->win, op);
726 window_redraw(NULL);
727
728 op = km_dokey(menu_to_use, GETCH_NO_FLAGS);
729 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
730 if (op < 0)
731 continue;
732 if (op == OP_NULL)
733 {
734 km_error_key(menu_to_use);
735 continue;
736 }
738
739 int rc = gpgme_function_dispatcher(sdw.dlg, op);
740
741 if (rc == FR_UNKNOWN)
742 rc = menu_function_dispatcher(menu->win, op);
743 if (rc == FR_UNKNOWN)
744 rc = global_function_dispatcher(NULL, op);
745 } while (!gd.done);
746 // ---------------------------------------------------------------------------
747
748 ARRAY_FREE(&ckia);
749 window_set_focus(old_focus);
751 return gd.key;
752}
753
760 // clang-format off
779 { -1, -1, NULL, NULL },
780 // clang-format on
781};
Email Address Handling.
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition: array.h:279
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:156
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:109
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition: array.h:58
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:138
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:344
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:516
void pgp_entry_gpgme_k(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
GPGME: Key id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:499
void pgp_entry_gpgme_p(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
GPGME: Protocol - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:357
void pgp_entry_gpgme_date(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
GPGME: Date of the key - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:302
void pgp_entry_gpgme_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
GPGME: Trust/validity - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:372
void pgp_entry_gpgme_i(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
GPGME: Key fingerprint - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:482
void pgp_entry_gpgme_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
GPGME: Key Algorithm - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:432
void pgp_entry_gpgme_u(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
GPGME: User id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:417
void pgp_entry_gpgme_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
GPGME: Key Capabilities - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:452
void pgp_entry_gpgme_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
GPGME: Key Flags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:467
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:621
#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:533
static int gpgme_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_gpgme.c:558
static int gpgme_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_gpgme.c:587
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 SimpleDialogWindows 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
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
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
@ WT_DLG_GPGME
GPGME Dialog, dlg_gpgme()
Definition: mutt_window.h:83
@ 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:70
@ ED_PGK_KEY_FINGERPRINT
PgpKeyInfo.fingerprint.
Definition: pgplib.h:71
@ ED_PGK_PKEY_LENGTH
pgp_principal_key(), PgpKeyInfo.keylen
Definition: pgplib.h:80
@ ED_PGK_PKEY_ALGORITHM
pgp_principal_key(), PgpKeyInfo.algorithm
Definition: pgplib.h:75
@ ED_PGK_DATE
PgpKeyInfo.gen_time.
Definition: pgplib.h:68
@ ED_PGK_PKEY_FINGERPRINT
pgp_principal_key(), PgpKeyInfo.fingerprint
Definition: pgplib.h:77
@ ED_PGK_KEY_ID
PgpKeyInfo, pgp_this_keyid()
Definition: pgplib.h:73
@ ED_PGK_PROTOCOL
PgpKeyInfo.
Definition: pgplib.h:81
@ ED_PGK_PKEY_CAPABILITIES
pgp_principal_key(), PgpKeyInfo.flags, pgp_key_abilities()
Definition: pgplib.h:76
@ ED_PGK_KEY_FLAGS
PgpKeyInfo.kflags, pgp_flags()
Definition: pgplib.h:72
@ ED_PGK_PKEY_ID
pgp_principal_key(), PgpKeyInfo, pgp_this_keyid()
Definition: pgplib.h:79
@ ED_PGK_KEY_ALGORITHM
PgpKeyInfo.algorithm.
Definition: pgplib.h:69
@ ED_PGK_KEY_LENGTH
PgpKeyInfo.keylen.
Definition: pgplib.h:74
@ ED_PGK_PKEY_FLAGS
pgp_principal_key(), PgpKeyInfo.kflags, pgp_flags()
Definition: pgplib.h:78
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:87
struct CryptKeyInfo * key
Key.
Definition: crypt_gpgme.h:89
size_t num
Index number.
Definition: crypt_gpgme.h:88
A stored PGP key.
Definition: crypt_gpgme.h:45
gpgme_validity_t validity
uid validity (cached for convenience)
Definition: crypt_gpgme.h:51
KeyFlags flags
global and per uid flags (for convenience)
Definition: crypt_gpgme.h:50
struct CryptKeyInfo * next
Linked list.
Definition: crypt_gpgme.h:46
const char * uid
and for convenience point to this user ID
Definition: crypt_gpgme.h:49
gpgme_key_t kobj
Definition: crypt_gpgme.h:47
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:67
const char * text
Node-specific text.
Definition: node.h:73
Parsed Expando trees.
Definition: expando.h:41
Data to pass to the Gpgme Functions.
struct CryptKeyInfoArray * key_table
Array of Keys.
bool * forced_valid
User insists on out-of-date key.
struct CryptKeyInfo * key
Selected Key.
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
Tuple for the results of simple_dialog_new()
Definition: simple.h:35
struct MuttWindow * sbar
Simple Bar.
Definition: simple.h:37
struct Menu * menu
Menu.
Definition: simple.h:38
struct MuttWindow * dlg
Main Dialog Window.
Definition: simple.h:36
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