NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
dlgverifycert.c File Reference

Certificate Verification Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "gui/lib.h"
#include "menu/lib.h"
#include "opcodes.h"
#include "options.h"
#include "ssl.h"
+ Include dependency graph for dlgverifycert.c:

Go to the source code of this file.

Functions

int dlg_verify_certificate (const char *title, struct ListHead *list, bool allow_always, bool allow_skip)
 Ask the user to validate the certificate. More...
 

Variables

static const struct Mapping VerifyHelp []
 Help Bar for the Certificate Verification dialog. More...
 

Detailed Description

Certificate Verification Dialog.

Authors
  • 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 http://www.gnu.org/licenses/.

Definition in file dlgverifycert.c.

Function Documentation

◆ dlg_verify_certificate()

int dlg_verify_certificate ( const char *  title,
struct ListHead *  list,
bool  allow_always,
bool  allow_skip 
)

Ask the user to validate the certificate.

Parameters
titleMenu title
listCertificate text to display
allow_alwaysIf true, allow the user to always accept the certificate
allow_skipIf true, allow the user to skip the verification
Return values
1Reject certificate (or menu aborted)
2Accept certificate once
3Accept certificate always/skip (see notes)
4Accept certificate skip

The possible retvals will depend on the parameters. The options are given in the order: Reject, Once, Always, Skip. The retval represents the chosen option.

Definition at line 92 of file dlgverifycert.c.

94 {
96 
97  struct Menu *menu = dlg->wdata;
98 
99  struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
100  sbar_set_title(sbar, title);
101 
102  struct ListNode *np = NULL;
103  STAILQ_FOREACH(np, list, entries)
104  {
105  menu_add_dialog_row(menu, NONULL(np->data));
106  }
107 
108  if (allow_always)
109  {
110  if (allow_skip)
111  {
112  menu->prompt = _("(r)eject, accept (o)nce, (a)ccept always, (s)kip");
113  /* L10N: The letters correspond to the choices in the string:
114  "(r)eject, accept (o)nce, (a)ccept always, (s)kip"
115  This is an interactive certificate confirmation prompt for an SSL connection. */
116  menu->keys = _("roas");
117  }
118  else
119  {
120  menu->prompt = _("(r)eject, accept (o)nce, (a)ccept always");
121  /* L10N: The letters correspond to the choices in the string:
122  "(r)eject, accept (o)nce, (a)ccept always"
123  This is an interactive certificate confirmation prompt for an SSL connection. */
124  menu->keys = _("roa");
125  }
126  }
127  else
128  {
129  if (allow_skip)
130  {
131  menu->prompt = _("(r)eject, accept (o)nce, (s)kip");
132  /* L10N: The letters correspond to the choices in the string:
133  "(r)eject, accept (o)nce, (s)kip"
134  This is an interactive certificate confirmation prompt for an SSL connection. */
135  menu->keys = _("ros");
136  }
137  else
138  {
139  menu->prompt = _("(r)eject, accept (o)nce");
140  /* L10N: The letters correspond to the choices in the string:
141  "(r)eject, accept (o)nce"
142  This is an interactive certificate confirmation prompt for an SSL connection. */
143  menu->keys = _("ro");
144  }
145  }
146 
147  bool old_ime = OptIgnoreMacroEvents;
148  OptIgnoreMacroEvents = true;
149 
150  int rc = 0;
151  while (rc == 0)
152  {
153  switch (menu_loop(menu))
154  {
155  case -1: // Abort: Ctrl-G
156  case OP_EXIT: // Q)uit
157  case OP_MAX + 1: // R)eject
158  rc = 1;
159  break;
160  case OP_MAX + 2: // O)nce
161  rc = 2;
162  break;
163  case OP_MAX + 3: // A)lways / S)kip
164  rc = 3;
165  break;
166  case OP_MAX + 4: // S)kip
167  rc = 4;
168  break;
169  }
170  }
171  OptIgnoreMacroEvents = old_ime;
172 
173  simple_dialog_free(&dlg);
174 
175  return rc;
176 }
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:550
#define NONULL(x)
Definition: string2.h:37
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:165
Definition: lib.h:67
Generic selection list.
Definition: type.h:45
char * prompt
Prompt for user, similar to mutt_multi_choice.
Definition: lib.h:85
#define _(a)
Definition: message.h:28
WHERE bool OptIgnoreMacroEvents
(pseudo) don&#39;t process macro/push/exec events while set
Definition: options.h:37
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
static const struct Mapping VerifyHelp[]
Help Bar for the Certificate Verification dialog.
Definition: dlgverifycert.c:67
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:221
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
char * keys
Keys used in the prompt.
Definition: lib.h:86
char * data
String.
Definition: list.h:36
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:128
A List node for strings.
Definition: list.h:34
Certificate Dialog, dlg_verify_certificate()
Definition: mutt_window.h:81
void * wdata
Private data.
Definition: mutt_window.h:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ VerifyHelp

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

Help Bar for the Certificate Verification dialog.

Definition at line 67 of file dlgverifycert.c.