NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Gpgme Function API

Prototype for a Gpgme Function. More...

+ Collaboration diagram for Gpgme Function API:

Functions

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

Detailed Description

Prototype for a Gpgme Function.

Parameters
menuMenu
eventEvent to process
Return values
enumFunctionRetval
Precondition
menu is not NULL
event is not NULL

Function Documentation

◆ op_exit()

static int op_exit ( struct GpgmeData * gd,
const struct KeyEvent * event )
static

Exit this menu - Implements gpgme_function_t -.

Definition at line 737 of file gpgme_functions.c.

738{
739 gd->done = true;
740 return FR_SUCCESS;
741}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
bool done
Should we close the Dialog?

◆ op_generic_select_entry()

static int op_generic_select_entry ( struct GpgmeData * gd,
const struct KeyEvent * event )
static

Select the current entry - Implements gpgme_function_t -.

Definition at line 746 of file gpgme_functions.c.

747{
748 const int index = menu_get_index(gd->menu);
749 struct CryptKeyInfo **pkey = ARRAY_GET(gd->key_table, index);
750 if (!pkey)
751 return FR_ERROR;
752
753 struct CryptKeyInfo *cur_key = *pkey;
754
755 /* FIXME make error reporting more verbose - this should be
756 * easy because GPGME provides more information */
758 {
759 if (!crypt_key_is_valid(cur_key))
760 {
761 mutt_error(_("This key can't be used: expired/disabled/revoked"));
762 return FR_ERROR;
763 }
764 }
765
766 if (OptPgpCheckTrust && (!crypt_id_is_valid(cur_key) || !crypt_id_is_strong(cur_key)))
767 {
768 const char *warn_s = NULL;
769 char buf2[1024] = { 0 };
770
771 if (cur_key->flags & KEYFLAG_CANTUSE)
772 {
773 warn_s = _("ID is expired/disabled/revoked. Do you really want to use the key?");
774 }
775 else
776 {
777 warn_s = "??";
778 switch (cur_key->validity)
779 {
780 case GPGME_VALIDITY_NEVER:
781 warn_s = _("ID is not valid. Do you really want to use the key?");
782 break;
783 case GPGME_VALIDITY_MARGINAL:
784 warn_s = _("ID is only marginally valid. Do you really want to use the key?");
785 break;
786 case GPGME_VALIDITY_FULL:
787 case GPGME_VALIDITY_ULTIMATE:
788 break;
789 case GPGME_VALIDITY_UNKNOWN:
790 case GPGME_VALIDITY_UNDEFINED:
791 warn_s = _("ID has undefined validity. Do you really want to use the key?");
792 break;
793 }
794 }
795
796 snprintf(buf2, sizeof(buf2), "%s", warn_s);
797
798 if (query_yesorno(buf2, MUTT_NO) != MUTT_YES)
799 {
801 return FR_NO_ACTION;
802 }
803 }
804
805 gd->key = crypt_copy_key(cur_key);
806 gd->done = true;
807 return FR_SUCCESS;
808}
#define ARRAY_GET(head, idx)
Return the element at index.
Definition array.h:109
struct CryptKeyInfo * crypt_copy_key(struct CryptKeyInfo *key)
Return a copy of KEY.
int crypt_id_is_valid(struct CryptKeyInfo *key)
Is key ID valid.
bool crypt_id_is_strong(struct CryptKeyInfo *key)
Is the key strong.
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
bool OptPgpCheckTrust
(pseudo) used by dlg_pgp()
Definition globals.c:55
static bool crypt_key_is_valid(struct CryptKeyInfo *k)
Is the key valid.
#define mutt_error(...)
Definition logging2.h:94
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:164
#define _(a)
Definition message.h:28
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
#define KEYFLAG_CANTUSE
Definition lib.h:147
@ 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 query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
Definition question.c:326
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 CryptKeyInfoArray * key_table
Array of Keys.
struct CryptKeyInfo * key
Selected Key.
struct Menu * menu
Gpgme Menu.
+ Here is the call graph for this function:

◆ op_verify_key()

static int op_verify_key ( struct GpgmeData * gd,
const struct KeyEvent * event )
static

Verify a PGP public key - Implements gpgme_function_t -.

Definition at line 813 of file gpgme_functions.c.

814{
815 const int index = menu_get_index(gd->menu);
816 struct CryptKeyInfo **pkey = ARRAY_GET(gd->key_table, index);
817 if (!pkey)
818 return FR_ERROR;
819
820 verify_key(*pkey);
822 return FR_SUCCESS;
823}
static void verify_key(struct CryptKeyInfo *key)
Show detailed information about the selected key.
#define MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:60
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:188
+ Here is the call graph for this function:

◆ op_view_id()

static int op_view_id ( struct GpgmeData * gd,
const struct KeyEvent * event )
static

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

Definition at line 828 of file gpgme_functions.c.

829{
830 const int index = menu_get_index(gd->menu);
831 struct CryptKeyInfo **pkey = ARRAY_GET(gd->key_table, index);
832 if (!pkey)
833 return FR_ERROR;
834
835 mutt_message("%s", (*pkey)->uid);
836 return FR_SUCCESS;
837}
#define mutt_message(...)
Definition logging2.h:93
+ Here is the call graph for this function: