NeoMutt  2022-04-29-247-gc6aae8
Teaching an old dog new tricks
dlg_smime.c File Reference

SMIME Key Selection Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "private.h"
#include "mutt/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "menu/lib.h"
#include "keymap.h"
#include "mutt_logging.h"
#include "opcodes.h"
#include "smime.h"
#include "smime_functions.h"
+ Include dependency graph for dlg_smime.c:

Go to the source code of this file.


static char * smime_key_flags (KeyFlags flags)
 Turn SMIME key flags into a string. More...
static void smime_make_entry (struct Menu *menu, char *buf, size_t buflen, int line)
 Format a menu item for the smime key list - Implements Menu::make_entry() -. More...
static void smime_key_table_free (struct Menu *menu, void **ptr)
 Free the key table - Implements Menu::mdata_free() -. More...
struct SmimeKeydlg_select_smime_key (struct SmimeKey *keys, const char *query)
 Get the user to select a key. More...


static const struct Mapping SmimeHelp []
 Help Bar for the Smime key selection dialog. More...

Detailed Description

SMIME Key Selection Dialog.

  • Richard Russon

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

Definition in file dlg_smime.c.

Function Documentation

◆ smime_key_flags()

static char * smime_key_flags ( KeyFlags  flags)

Turn SMIME key flags into a string.

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

Definition at line 89 of file dlg_smime.c.

91 static char buf[3];
93 if (!(flags & KEYFLAG_CANENCRYPT))
94 buf[0] = '-';
95 else
96 buf[0] = 'e';
98 if (!(flags & KEYFLAG_CANSIGN))
99 buf[1] = '-';
100 else
101 buf[1] = 's';
103 buf[2] = '\0';
105 return buf;
Key is suitable for encryption.
Definition: lib.h:128
Key is suitable for signing.
Definition: lib.h:127
+ Here is the caller graph for this function:

◆ dlg_select_smime_key()

struct SmimeKey * dlg_select_smime_key ( struct SmimeKey keys,
const char *  query 

Get the user to select a key.

keysList of keys to select from
queryString to match
Return values
ptrKey selected by user

Definition at line 194 of file dlg_smime.c.

196 struct SmimeKey **table = NULL;
197 int table_size = 0;
198 int table_index = 0;
199 struct SmimeKey *key = NULL;
201 for (table_index = 0, key = keys; key; key = key->next)
202 {
203 if (table_index == table_size)
204 {
205 table_size += 5;
206 mutt_mem_realloc(&table, sizeof(struct SmimeKey *) * table_size);
207 }
209 table[table_index++] = key;
210 }
214 struct Menu *menu = dlg->wdata;
215 menu->max = table_index;
217 menu->mdata = table;
219 /* sorting keys might be done later - TODO */
221 struct SmimeData sd = { false, menu, table, NULL };
222 dlg->wdata = &sd;
224 char title[256] = { 0 };
225 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
226 snprintf(title, sizeof(title), _("S/MIME certificates matching \"%s\""), query);
227 sbar_set_title(sbar, title);
231 // ---------------------------------------------------------------------------
232 // Event Loop
233 int op = OP_NULL;
234 do
235 {
236 menu_tagging_dispatcher(menu->win, op);
237 window_redraw(NULL);
239 op = km_dokey(MENU_SMIME);
240 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
241 if (op < 0)
242 continue;
243 if (op == OP_NULL)
244 {
246 continue;
247 }
250 int rc = smime_function_dispatcher(dlg, op);
252 if (rc == FR_UNKNOWN)
253 rc = menu_function_dispatcher(menu->win, op);
254 if (rc == FR_UNKNOWN)
255 rc = global_function_dispatcher(NULL, op);
256 } while (!sd.done);
258 simple_dialog_free(&dlg);
259 return sd.key;
Unknown function.
Definition: dispatcher.h:33
static const struct Mapping SmimeHelp[]
Help Bar for the Smime key selection dialog.
Definition: dlg_smime.c:73
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:320
int smime_function_dispatcher(struct MuttWindow *win, int op)
Perform a Smime function - Implements function_dispatcher_t -.
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
static void smime_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the smime key list - Implements Menu::make_entry() -.
Definition: dlg_smime.c:111
static void smime_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlg_smime.c:183
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:166
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:129
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:795
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
Log at debug level 1.
Definition: logging.h:40
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
#define _(a)
Definition: message.h:28
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:604
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:522
Smime Dialog, dlg_select_smime_key()
Definition: mutt_window.h:92
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:46
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
Definition: lib.h:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:96
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
void * mdata
Private data.
Definition: lib.h:137
int max
Number of entries in the menu.
Definition: lib.h:71
void * wdata
Private data.
Definition: mutt_window.h:145
Data to pass to the Smime Functions.
struct SmimeKey * key
Selected Key.
bool done
Should we close the Dialog?
struct Menu * menu
Smime Menu.
struct SmimeKey ** table
Array of Keys.
An SIME key.
Definition: smime.h:44
struct SmimeKey * next
Definition: smime.h:51
SMIME encryption menu.
Definition: type.h:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ SmimeHelp

const struct Mapping SmimeHelp[]
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
#define N_(a)
Definition: message.h:32

Help Bar for the Smime key selection dialog.

Definition at line 73 of file dlg_smime.c.