NeoMutt  2025-12-11-987-ge86aa1
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_quit (struct GpgmeData *gd, const struct KeyEvent *event)
 Save changes and exit this dialog - 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_quit()

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

Save changes and exit this dialog - Implements gpgme_function_t -.

Definition at line 744 of file functions_gpgme.c.

745{
746 gd->done = true;
747 return FR_SUCCESS;
748}
@ 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 753 of file functions_gpgme.c.

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

821{
822 const int index = menu_get_index(gd->menu);
823 struct CryptKeyInfo **pkey = ARRAY_GET(gd->key_table, index);
824 if (!pkey)
825 return FR_ERROR;
826
827 verify_key(*pkey);
829 return FR_SUCCESS;
830}
static void verify_key(struct CryptKeyInfo *key)
Show detailed information about the selected key.
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:177
@ MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:64
+ 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 835 of file functions_gpgme.c.

836{
837 const int index = menu_get_index(gd->menu);
838 struct CryptKeyInfo **pkey = ARRAY_GET(gd->key_table, index);
839 if (!pkey)
840 return FR_ERROR;
841
842 mutt_message("%s", (*pkey)->uid);
843 return FR_SUCCESS;
844}
#define mutt_message(...)
Definition logging2.h:93
+ Here is the call graph for this function: