NeoMutt  2024-04-25-34-g585158
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_pgp.c File Reference

PGP Key Selection Dialog. More...

#include "config.h"
#include <assert.h>
#include <locale.h>
#include <stdbool.h>
#include <stdio.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 "mutt_logging.h"
#include "pgp.h"
#include "pgp_functions.h"
#include "pgpkey.h"
#include "pgplib.h"
#include "sort.h"
+ Include dependency graph for dlg_pgp.c:

Go to the source code of this file.

Functions

static int pgp_sort_address (const void *a, const void *b, void *sdata)
 Compare two keys by their addresses - Implements sort_t -.
 
static int pgp_sort_date (const void *a, const void *b, void *sdata)
 Compare two keys by their dates - Implements sort_t -.
 
static int pgp_sort_keyid (const void *a, const void *b, void *sdata)
 Compare two keys by their IDs - Implements sort_t -.
 
static int pgp_sort_trust (const void *a, const void *b, void *sdata)
 Compare two keys by their trust levels - Implements sort_t -.
 
static char * pgp_key_abilities (KeyFlags flags)
 Turn PGP key abilities into a string.
 
static char pgp_flags (KeyFlags flags)
 Turn PGP key flags into a string.
 
long pgp_entry_pgp_date_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 PGP: Date of the key - Implements ExpandoRenderData::get_number() -.
 
void pgp_entry_pgp_date (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Date of the key - Implements ExpandoRenderData::get_string() -.
 
long pgp_entry_pgp_n_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 PGP: Index number - Implements ExpandoRenderData::get_number() -.
 
void pgp_entry_pgp_t (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Trust/validity - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_pgp_u (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: User id - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_pgp_a (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Key Algorithm - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_pgp_A (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Principal Key Algorithm - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_pgp_c (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Key Capabilities - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_pgp_C (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Principal Key Capabilities - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_pgp_f (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Key Flags - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_pgp_F (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Principal Key Flags - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_pgp_k (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Key id - Implements ExpandoRenderData::get_string() -.
 
void pgp_entry_pgp_K (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Principal Key id - Implements ExpandoRenderData::get_string() -.
 
long pgp_entry_pgp_l_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 PGP: Key length - Implements ExpandoRenderData::get_number() -.
 
long pgp_entry_pgp_L_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 PGP: Principal Key length - Implements ExpandoRenderData::get_number() -.
 
void pgp_entry_ignore (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 PGP: Field not supported - Implements ExpandoRenderData::get_string() -.
 
static int pgp_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 pgp_key_table_free (struct Menu *menu, void **ptr)
 Free the key table - Implements Menu::mdata_free() -.
 
static int pgp_key_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static int pgp_key_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
struct PgpKeyInfodlg_pgp (struct PgpKeyInfo *keys, struct Address *p, const char *s)
 Let the user select a key to use -.
 

Variables

const struct ExpandoRenderData PgpEntryRenderData []
 PgpEntryRenderData- Callbacks for PGP Key Expandos.
 
static const struct Mapping PgpHelp []
 Help Bar for the PGP key selection dialog.
 
static const char TrustFlags [] = "?- +"
 Characters used to show the trust level for PGP keys.
 

Detailed Description

PGP Key Selection Dialog.

Authors
  • Richard Russon
  • наб
  • 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_pgp.c.

Function Documentation

◆ pgp_key_abilities()

static char * pgp_key_abilities ( KeyFlags  flags)
static

Turn PGP key abilities into a string.

Parameters
flagsFlags, see KeyFlags
Return values
ptrAbilities string
Note
This returns a pointer to a static buffer

Definition at line 211 of file dlg_pgp.c.

212{
213 static char buf[3];
214
215 if (!(flags & KEYFLAG_CANENCRYPT))
216 buf[0] = '-';
217 else if (flags & KEYFLAG_PREFER_SIGNING)
218 buf[0] = '.';
219 else
220 buf[0] = 'e';
221
222 if (!(flags & KEYFLAG_CANSIGN))
223 buf[1] = '-';
224 else if (flags & KEYFLAG_PREFER_ENCRYPTION)
225 buf[1] = '.';
226 else
227 buf[1] = 's';
228
229 buf[2] = '\0';
230
231 return buf;
232}
#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:

◆ pgp_flags()

static char pgp_flags ( KeyFlags  flags)
static

Turn PGP key flags into a string.

Parameters
flagsFlags, see KeyFlags
Return values
charFlag character

Definition at line 239 of file dlg_pgp.c.

240{
241 if (flags & KEYFLAG_REVOKED)
242 return 'R';
243 if (flags & KEYFLAG_EXPIRED)
244 return 'X';
245 if (flags & KEYFLAG_DISABLED)
246 return 'd';
247 if (flags & KEYFLAG_CRITICAL)
248 return 'c';
249
250 return ' ';
251}
#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

◆ PgpEntryRenderData

const struct ExpandoRenderData PgpEntryRenderData
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_pgp_l_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
PGP: Key length - Implements ExpandoRenderData::get_number() -.
Definition: dlg_pgp.c:492
long pgp_entry_pgp_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
PGP: Index number - Implements ExpandoRenderData::get_number() -.
Definition: dlg_pgp.c:312
long pgp_entry_pgp_date_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
PGP: Date of the key - Implements ExpandoRenderData::get_number() -.
Definition: dlg_pgp.c:256
long pgp_entry_pgp_L_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
PGP: Principal Key length - Implements ExpandoRenderData::get_number() -.
Definition: dlg_pgp.c:508
void pgp_entry_pgp_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Key Flags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:424
void pgp_entry_pgp_k(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Key id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:459
void pgp_entry_pgp_date(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Date of the key - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:271
void pgp_entry_pgp_C(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Principal Key Capabilities - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:405
void pgp_entry_pgp_u(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: User id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:339
void pgp_entry_pgp_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Trust/validity - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:325
void pgp_entry_pgp_F(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Principal Key Flags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:441
void pgp_entry_pgp_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Key Algorithm - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:354
void pgp_entry_pgp_A(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Principal Key Algorithm - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:370
void pgp_entry_pgp_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Key Capabilities - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:387
void pgp_entry_pgp_K(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Principal Key id - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:475
void pgp_entry_ignore(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
PGP: Field not supported - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pgp.c:525
@ 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

PgpEntryRenderData- Callbacks for PGP Key Expandos.

See also
PgpEntryFormatDef, ExpandoDataGlobal, ExpandoDataPgp, ExpandoDataPgpKey

Definition at line 92 of file dlg_pgp.c.

◆ PgpHelp

const struct Mapping PgpHelp[]
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 PGP key selection dialog.

Definition at line 95 of file dlg_pgp.c.

◆ TrustFlags

const char TrustFlags[] = "?- +"
static

Characters used to show the trust level for PGP keys.

Definition at line 106 of file dlg_pgp.c.