NeoMutt  2025-09-05-2-g4bf191
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, int op)
 Exit this menu - Implements gpgme_function_t -.
 
static int op_generic_select_entry (struct GpgmeData *gd, int op)
 Select the current entry - Implements gpgme_function_t -.
 
static int op_verify_key (struct GpgmeData *gd, int op)
 Verify a PGP public key - Implements gpgme_function_t -.
 
static int op_view_id (struct GpgmeData *gd, int op)
 View the key's user id - Implements gpgme_function_t -.
 

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 735 of file gpgme_functions.c.

736{
737 gd->done = true;
738 return FR_SUCCESS;
739}
@ 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 744 of file gpgme_functions.c.

745{
746 const int index = menu_get_index(gd->menu);
747 struct CryptKeyInfo **pkey = ARRAY_GET(gd->key_table, index);
748 if (!pkey)
749 return FR_ERROR;
750
751 struct CryptKeyInfo *cur_key = *pkey;
752
753 /* FIXME make error reporting more verbose - this should be
754 * easy because GPGME provides more information */
756 {
757 if (!crypt_key_is_valid(cur_key))
758 {
759 mutt_error(_("This key can't be used: expired/disabled/revoked"));
760 return FR_ERROR;
761 }
762 }
763
764 if (OptPgpCheckTrust && (!crypt_id_is_valid(cur_key) || !crypt_id_is_strong(cur_key)))
765 {
766 const char *warn_s = NULL;
767 char buf2[1024] = { 0 };
768
769 if (cur_key->flags & KEYFLAG_CANTUSE)
770 {
771 warn_s = _("ID is expired/disabled/revoked. Do you really want to use the key?");
772 }
773 else
774 {
775 warn_s = "??";
776 switch (cur_key->validity)
777 {
778 case GPGME_VALIDITY_NEVER:
779 warn_s = _("ID is not valid. Do you really want to use the key?");
780 break;
781 case GPGME_VALIDITY_MARGINAL:
782 warn_s = _("ID is only marginally valid. Do you really want to use the key?");
783 break;
784 case GPGME_VALIDITY_FULL:
785 case GPGME_VALIDITY_ULTIMATE:
786 break;
787 case GPGME_VALIDITY_UNKNOWN:
788 case GPGME_VALIDITY_UNDEFINED:
789 warn_s = _("ID has undefined validity. Do you really want to use the key?");
790 break;
791 }
792 }
793
794 snprintf(buf2, sizeof(buf2), "%s", warn_s);
795
796 if (query_yesorno(buf2, MUTT_NO) != MUTT_YES)
797 {
799 return FR_NO_ACTION;
800 }
801 }
802
803 gd->key = crypt_copy_key(cur_key);
804 gd->done = true;
805 return FR_SUCCESS;
806}
#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.
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
bool OptPgpCheckTrust
(pseudo) used by dlg_pgp()
Definition: globals.c:66
static bool crypt_key_is_valid(struct CryptKeyInfo *k)
Is the key valid.
#define mutt_error(...)
Definition: logging2.h:93
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:160
#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:145
@ 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,
int  op 
)
static

Verify a PGP public key - Implements gpgme_function_t -.

Definition at line 811 of file gpgme_functions.c.

812{
813 const int index = menu_get_index(gd->menu);
814 struct CryptKeyInfo **pkey = ARRAY_GET(gd->key_table, index);
815 if (!pkey)
816 return FR_ERROR;
817
818 verify_key(*pkey);
820 return FR_SUCCESS;
821}
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:184
+ 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 826 of file gpgme_functions.c.

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