NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
Gpgme Function API

Prototype for a Gpgme Function. More...

+ Collaboration diagram for Gpgme Function API:

Functions

static int op_exit (struct GpgmeData *gd, int op)
 Exit this menu - Implements gpgme_function_t -. More...
 
static int op_generic_select_entry (struct GpgmeData *gd, int op)
 Select the current entry - Implements gpgme_function_t -. More...
 
static int op_verify_key (struct GpgmeData *gd, int op)
 Verify a PGP public key - Implements gpgme_function_t -. More...
 
static int op_view_id (struct GpgmeData *gd, int op)
 View the key's user id - Implements gpgme_function_t -. More...
 

Detailed Description

Prototype for a Gpgme Function.

Parameters
menuMenu
opOperation to perform, e.g. OP_GENERIC_SELECT_ENTRY
Return values
enumFunctionRetval

Function Documentation

◆ op_exit()

static int op_exit ( struct GpgmeData gd,
int  op 
)
static

Exit this menu - Implements gpgme_function_t -.

Definition at line 704 of file gpgme_functions.c.

705{
706 gd->done = true;
707 return FR_SUCCESS;
708}
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
bool done
Should we close the Dialog?

◆ op_generic_select_entry()

static int op_generic_select_entry ( struct GpgmeData gd,
int  op 
)
static

Select the current entry - Implements gpgme_function_t -.

Definition at line 713 of file gpgme_functions.c.

714{
715 const int index = menu_get_index(gd->menu);
716 struct CryptKeyInfo *cur_key = gd->key_table[index];
717 /* FIXME make error reporting more verbose - this should be
718 * easy because GPGME provides more information */
720 {
721 if (!crypt_key_is_valid(cur_key))
722 {
723 mutt_error(_("This key can't be used: expired/disabled/revoked"));
724 return FR_ERROR;
725 }
726 }
727
728 if (OptPgpCheckTrust && (!crypt_id_is_valid(cur_key) || !crypt_id_is_strong(cur_key)))
729 {
730 const char *warn_s = NULL;
731 char buf2[1024];
732
733 if (cur_key->flags & KEYFLAG_CANTUSE)
734 {
735 warn_s = _("ID is expired/disabled/revoked. Do you really want to use the key?");
736 }
737 else
738 {
739 warn_s = "??";
740 switch (cur_key->validity)
741 {
742 case GPGME_VALIDITY_NEVER:
743 warn_s = _("ID is not valid. Do you really want to use the key?");
744 break;
745 case GPGME_VALIDITY_MARGINAL:
746 warn_s = _("ID is only marginally valid. Do you really want to use the key?");
747 break;
748 case GPGME_VALIDITY_FULL:
749 case GPGME_VALIDITY_ULTIMATE:
750 break;
751 case GPGME_VALIDITY_UNKNOWN:
752 case GPGME_VALIDITY_UNDEFINED:
753 warn_s = _("ID has undefined validity. Do you really want to use the key?");
754 break;
755 }
756 }
757
758 snprintf(buf2, sizeof(buf2), "%s", warn_s);
759
760 if (mutt_yesorno(buf2, MUTT_NO) != MUTT_YES)
761 {
763 return FR_NO_ACTION;
764 }
765 }
766
767 gd->key = crypt_copy_key(cur_key);
768 gd->done = true;
769 return FR_SUCCESS;
770}
struct CryptKeyInfo * crypt_copy_key(struct CryptKeyInfo *key)
Return a copy of KEY.
Definition: crypt_gpgme.c:234
int crypt_id_is_valid(struct CryptKeyInfo *key)
Is key ID valid.
Definition: crypt_gpgme.c:310
bool crypt_id_is_strong(struct CryptKeyInfo *key)
Is the key strong.
Definition: crypt_gpgme.c:275
@ FR_ERROR
Valid function - error occurred.
Definition: dispatcher.h:38
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
static bool crypt_key_is_valid(struct CryptKeyInfo *k)
Is the key valid.
#define mutt_error(...)
Definition: logging.h:87
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:154
#define _(a)
Definition: message.h:28
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
#define KEYFLAG_CANTUSE
Definition: lib.h:139
bool OptPgpCheckTrust
(pseudo) used by dlg_select_pgp_key()
Definition: options.h:54
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition: quad.h:38
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: question.c:194
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 * key
Selected Key.
struct CryptKeyInfo ** key_table
Array of Keys.
struct Menu * menu
Gpgme Menu.
+ Here is the call graph for this function:

◆ op_verify_key()

static int op_verify_key ( struct GpgmeData gd,
int  op 
)
static

Verify a PGP public key - Implements gpgme_function_t -.

Definition at line 775 of file gpgme_functions.c.

776{
777 const int index = menu_get_index(gd->menu);
778 struct CryptKeyInfo *cur_key = gd->key_table[index];
779 verify_key(cur_key);
781 return FR_SUCCESS;
782}
static void verify_key(struct CryptKeyInfo *key)
Show detailed information about the selected key.
#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:178
+ Here is the call graph for this function:

◆ op_view_id()

static int op_view_id ( struct GpgmeData gd,
int  op 
)
static

View the key's user id - Implements gpgme_function_t -.

Definition at line 787 of file gpgme_functions.c.

788{
789 const int index = menu_get_index(gd->menu);
790 struct CryptKeyInfo *cur_key = gd->key_table[index];
791 mutt_message("%s", cur_key->uid);
792 return FR_SUCCESS;
793}
#define mutt_message(...)
Definition: logging.h:86
const char * uid
and for convenience point to this user ID
Definition: crypt_gpgme.h:48
+ Here is the call graph for this function: