NeoMutt  2024-03-23-142-g2b2e76
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_gpgme.c File Reference

GPGME Key Selection Dialog. More...

#include "config.h"
#include <assert.h>
#include <gpgme.h>
#include <locale.h>
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
#include "private.h"
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "expando/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "crypt_gpgme.h"
#include "gpgme_functions.h"
#include "mutt_logging.h"
#include "pgplib.h"
#include "sort.h"
+ Include dependency graph for dlg_gpgme.c:

Go to the source code of this file.

Functions

static int crypt_sort_address (const void *a, const void *b, void *sdata)
 Compare two keys by their addresses - Implements sort_t -.
 
static int crypt_sort_keyid (const void *a, const void *b, void *sdata)
 Compare two keys by their IDs - Implements sort_t -.
 
static int crypt_sort_date (const void *a, const void *b, void *sdata)
 Compare two keys by their dates - Implements sort_t -.
 
static int crypt_sort_trust (const void *a, const void *b, void *sdata)
 Compare two keys by their trust levels - Implements sort_t -.
 
static char * crypt_key_abilities (KeyFlags flags)
 Parse key flags into a string.
 
static char * crypt_flags (KeyFlags flags)
 Parse the key flags into a single character.
 
long pgp_entry_gpgme_date_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 GPGME: Date of the key - Implements ExpandoRenderData::get_number() -.
 
void pgp_entry_gpgme_date (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 GPGME: Date of the key - Implements ExpandoRenderData::get_string() -.
 
long pgp_entry_gpgme_n_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 GPGME: Index number - Implements ExpandoRenderData::get_number() -.
 
void pgp_entry_gpgme_p (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 GPGME: Protocol - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_gpgme_t (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 GPGME: Trust/validity - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_gpgme_u (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 GPGME: User id - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_gpgme_a (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 GPGME: Key Algorithm - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_gpgme_c (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 GPGME: Key Capabilities - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_gpgme_f (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 GPGME: Key Flags - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_gpgme_i (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 GPGME: Key fingerprint - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_gpgme_k (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 GPGME: Key id - Implements ExpandoRenderData::get_string() -.
 
long pgp_entry_gpgme_l_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 GPGME: Key length - Implements ExpandoRenderData::get_number() -.
 
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() -.
 
static void gpgme_key_table_free (struct Menu *menu, void **ptr)
 Free the key table - Implements Menu::mdata_free() -.
 
static int gpgme_key_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static int gpgme_key_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
struct CryptKeyInfodlg_gpgme (struct CryptKeyInfo *keys, struct Address *p, const char *s, unsigned int app, bool *forced_valid)
 Get the user to select a key -.
 

Variables

const struct ExpandoRenderData PgpEntryGpgmeRenderData []
 Callbacks for GPGME Key Expandos.
 
static const struct Mapping GpgmeHelp []
 Help Bar for the GPGME key selection dialog.
 

Detailed Description

GPGME Key Selection Dialog.

Authors
  • Richard Russon
  • Rayford Shireman
  • наб
  • Tóth János

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file dlg_gpgme.c.

Function Documentation

◆ crypt_key_abilities()

static char * crypt_key_abilities ( KeyFlags  flags)
static

Parse key flags into a string.

Parameters
flagsFlags, see KeyFlags
Return values
ptrFlag string
Note
The string is statically allocated.

Definition at line 243 of file dlg_gpgme.c.

244{
245 static char buf[3];
246
247 if (!(flags & KEYFLAG_CANENCRYPT))
248 buf[0] = '-';
249 else if (flags & KEYFLAG_PREFER_SIGNING)
250 buf[0] = '.';
251 else
252 buf[0] = 'e';
253
254 if (!(flags & KEYFLAG_CANSIGN))
255 buf[1] = '-';
256 else if (flags & KEYFLAG_PREFER_ENCRYPTION)
257 buf[1] = '.';
258 else
259 buf[1] = 's';
260
261 buf[2] = '\0';
262
263 return buf;
264}
#define KEYFLAG_CANENCRYPT
Key is suitable for encryption.
Definition: lib.h:128
#define KEYFLAG_PREFER_SIGNING
Key's owner prefers signing.
Definition: lib.h:137
#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
+ Here is the caller graph for this function:

◆ crypt_flags()

static char * crypt_flags ( KeyFlags  flags)
static

Parse the key flags into a single character.

Parameters
flagsFlags, see KeyFlags
Return values
charFlag character

The returned character describes the most important flag.

Definition at line 273 of file dlg_gpgme.c.

274{
275 if (flags & KEYFLAG_REVOKED)
276 return "R";
277 if (flags & KEYFLAG_EXPIRED)
278 return "X";
279 if (flags & KEYFLAG_DISABLED)
280 return "d";
281 if (flags & KEYFLAG_CRITICAL)
282 return "c";
283
284 return " ";
285}
#define KEYFLAG_EXPIRED
Key is expired.
Definition: lib.h:131
#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
+ Here is the caller graph for this function:

Variable Documentation

◆ PgpEntryGpgmeRenderData

const struct ExpandoRenderData PgpEntryGpgmeRenderData
Initial value:
= {
{ -1, -1, NULL, NULL },
}
@ ED_PGP
Pgp ED_PGP_ ExpandoDataPgp.
Definition: domain.h:52
@ ED_PGP_KEY
Pgp_Key ED_PGK_ ExpandoDataPgpKey.
Definition: domain.h:54
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:290
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:352
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:524
void pgp_entry_gpgme_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key Capabilities - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:460
void pgp_entry_gpgme_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key Flags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:475
void pgp_entry_gpgme_i(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key fingerprint - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:490
void pgp_entry_gpgme_k(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:507
void pgp_entry_gpgme_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Trust/validity - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:380
void pgp_entry_gpgme_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Key Algorithm - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:440
void pgp_entry_gpgme_p(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Protocol - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:365
void pgp_entry_gpgme_u(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: User id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:425
void pgp_entry_gpgme_date(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
GPGME: Date of the key - Implements ExpandoRenderData::get_string() -.
Definition: dlg_gpgme.c:303
@ 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
@ 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

Callbacks for GPGME Key Expandos.

See also
PgpEntryFormatDef, ExpandoDataGlobal, ExpandoDataPgpKeyGpgme

Definition at line 94 of file dlg_gpgme.c.

◆ GpgmeHelp

const struct Mapping GpgmeHelp[]
static
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("Select"), OP_GENERIC_SELECT_ENTRY },
{ N_("Check key"), OP_VERIFY_KEY },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}
#define N_(a)
Definition: message.h:32

Help Bar for the GPGME key selection dialog.

Definition at line 97 of file dlg_gpgme.c.