NeoMutt  2024-10-02-34-g9dd811
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 CryptKeyInfo **key_table = menu->mdata;
536 struct CryptEntry entry = { 0 };
537
538 entry.key = key_table[line];
539 entry.num = line + 1;
540
541 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
542 if (c_arrow_cursor)
543 {
544 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
545 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
546 }
547
548 const struct Expando *c_pgp_entry_format = cs_subset_expando(NeoMutt->sub, "pgp_entry_format");
549 return expando_filter(c_pgp_entry_format, PgpEntryGpgmeRenderData, &entry,
550 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
551}
552
558static void gpgme_key_table_free(struct Menu *menu, void **ptr)
559{
560 FREE(ptr);
561}
562
567{
568 if (nc->event_type != NT_CONFIG)
569 return 0;
570 if (!nc->global_data || !nc->event_data)
571 return -1;
572
573 struct EventConfig *ev_c = nc->event_data;
574
575 if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
576 !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
577 {
578 return 0;
579 }
580
581 struct Menu *menu = nc->global_data;
583 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
584
585 return 0;
586}
587
596{
597 if (nc->event_type != NT_WINDOW)
598 return 0;
599 if (!nc->global_data || !nc->event_data)
600 return -1;
602 return 0;
603
604 struct MuttWindow *win_menu = nc->global_data;
605 struct EventWindow *ev_w = nc->event_data;
606 if (ev_w->win != win_menu)
607 return 0;
608
609 struct Menu *menu = win_menu->wdata;
610
613
614 mutt_debug(LL_DEBUG5, "window delete done\n");
615 return 0;
616}
617
629struct CryptKeyInfo *dlg_gpgme(struct CryptKeyInfo *keys, struct Address *p,
630 const char *s, unsigned int app, bool *forced_valid)
631{
632 int keymax;
633 int i;
634 sort_t f = NULL;
635 enum MenuType menu_to_use = MENU_GENERIC;
636 bool unusable = false;
637
638 /* build the key table */
639 keymax = 0;
640 i = 0;
641 struct CryptKeyInfo **key_table = NULL;
642 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
643 for (struct CryptKeyInfo *k = keys; k; k = k->next)
644 {
645 if (!c_pgp_show_unusable && (k->flags & KEYFLAG_CANTUSE))
646 {
647 unusable = true;
648 continue;
649 }
650
651 if (i == keymax)
652 {
653 keymax += 20;
654 mutt_mem_realloc(&key_table, sizeof(struct CryptKeyInfo *) * keymax);
655 }
656
657 key_table[i++] = k;
658 }
659
660 if (!i && unusable)
661 {
662 mutt_error(_("All matching keys are marked expired/revoked"));
663 return NULL;
664 }
665
666 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
667 switch (c_pgp_sort_keys & SORT_MASK)
668 {
669 case SORT_ADDRESS:
671 break;
672 case SORT_DATE:
673 f = crypt_sort_date;
674 break;
675 case SORT_KEYID:
677 break;
678 case SORT_TRUST:
679 default:
681 break;
682 }
683
684 if (key_table)
685 {
686 bool sort_reverse = c_pgp_sort_keys & SORT_REVERSE;
687 mutt_qsort_r(key_table, i, sizeof(struct CryptKeyInfo *), f, &sort_reverse);
688 }
689
690 if (app & APPLICATION_PGP)
691 menu_to_use = MENU_KEY_SELECT_PGP;
692 else if (app & APPLICATION_SMIME)
693 menu_to_use = MENU_KEY_SELECT_SMIME;
694
695 struct MuttWindow *dlg = simple_dialog_new(menu_to_use, WT_DLG_GPGME, GpgmeHelp);
696
697 struct Menu *menu = dlg->wdata;
698 menu->max = i;
700 menu->mdata = key_table;
702
703 struct GpgmeData gd = { false, menu, key_table, NULL, forced_valid };
704 dlg->wdata = &gd;
705
706 // NT_COLOR is handled by the SimpleDialog
709
710 const char *ts = NULL;
711
712 if ((app & APPLICATION_PGP) && (app & APPLICATION_SMIME))
713 ts = _("PGP and S/MIME keys matching");
714 else if ((app & APPLICATION_PGP))
715 ts = _("PGP keys matching");
716 else if ((app & APPLICATION_SMIME))
717 ts = _("S/MIME keys matching");
718 else
719 ts = _("keys matching");
720
721 char buf[1024] = { 0 };
722 if (p)
723 {
724 /* L10N: 1$s is one of the previous four entries.
725 %2$s is an address.
726 e.g. "S/MIME keys matching <john.doe@example.com>" */
727 snprintf(buf, sizeof(buf), _("%s <%s>"), ts, buf_string(p->mailbox));
728 }
729 else
730 {
731 /* L10N: e.g. 'S/MIME keys matching "John Doe".' */
732 snprintf(buf, sizeof(buf), _("%s \"%s\""), ts, s);
733 }
734
735 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
736 sbar_set_title(sbar, buf);
737
739
740 struct MuttWindow *old_focus = window_set_focus(menu->win);
741 // ---------------------------------------------------------------------------
742 // Event Loop
743 int op = OP_NULL;
744 do
745 {
746 menu_tagging_dispatcher(menu->win, op);
747 window_redraw(NULL);
748
749 op = km_dokey(menu_to_use, GETCH_NO_FLAGS);
750 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
751 if (op < 0)
752 continue;
753 if (op == OP_NULL)
754 {
755 km_error_key(menu_to_use);
756 continue;
757 }
759
760 int rc = gpgme_function_dispatcher(dlg, op);
761
762 if (rc == FR_UNKNOWN)
763 rc = menu_function_dispatcher(menu->win, op);
764 if (rc == FR_UNKNOWN)
765 rc = global_function_dispatcher(NULL, op);
766 } while (!gd.done);
767 // ---------------------------------------------------------------------------
768
769 window_set_focus(old_focus);
770 simple_dialog_free(&dlg);
771 return gd.key;
772}
773
780 // clang-format off
799 { -1, -1, NULL, NULL },
800 // clang-format on
801};
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: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:629
#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 void gpgme_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlg_gpgme.c:558
static int gpgme_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_gpgme.c:566
static int gpgme_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_gpgme.c:595
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
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 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: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.
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