NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
config.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <stddef.h>
31 #include <config/lib.h>
32 #include <stdbool.h>
33 #include <stdint.h>
34 #include "private.h"
35 #include "mutt/lib.h"
36 #include "conn/lib.h"
37 
41 static int pop_auth_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef,
42  intptr_t value, struct Buffer *err)
43 {
44  const struct Slist *pop_auth_methods = (const struct Slist *) value;
45  if (!pop_auth_methods || (pop_auth_methods->count == 0))
46  return CSR_SUCCESS;
47 
48  struct ListNode *np = NULL;
49  STAILQ_FOREACH(np, &pop_auth_methods->head, entries)
50  {
51  if (pop_auth_is_valid(np->data))
52  continue;
53 #ifdef USE_SASL
54  if (sasl_auth_validator(np->data))
55  continue;
56 #endif
57  mutt_buffer_printf(err, _("Option %s: %s is not a valid authenticator"),
58  cdef->name, np->data);
59  return CSR_ERR_INVALID;
60  }
61 
62  return CSR_SUCCESS;
63 }
64 
65 static struct ConfigDef PopVars[] = {
66  // clang-format off
67  { "pop_auth_try_all", DT_BOOL, true, 0, NULL,
68  "(pop) Try all available authentication methods"
69  },
70  { "pop_authenticators", DT_SLIST|SLIST_SEP_COLON, 0, 0, pop_auth_validator,
71  "(pop) List of allowed authentication methods (colon-separated)"
72  },
73  { "pop_check_interval", DT_NUMBER|DT_NOT_NEGATIVE, 60, 0, NULL,
74  "(pop) Interval between checks for new mail"
75  },
76  { "pop_delete", DT_QUAD, MUTT_ASKNO, 0, NULL,
77  "(pop) After downloading POP messages, delete them on the server"
78  },
79  { "pop_host", DT_STRING, 0, 0, NULL,
80  "(pop) Url of the POP server"
81  },
82  { "pop_last", DT_BOOL, false, 0, NULL,
83  "(pop) Use the 'LAST' command to fetch new mail"
84  },
85  { "pop_oauth_refresh_command", DT_STRING|DT_COMMAND|DT_SENSITIVE, 0, 0, NULL,
86  "(pop) External command to generate OAUTH refresh token"
87  },
88  { "pop_pass", DT_STRING|DT_SENSITIVE, 0, 0, NULL,
89  "(pop) Password of the POP server"
90  },
91  { "pop_reconnect", DT_QUAD, MUTT_ASKYES, 0, NULL,
92  "(pop) Reconnect to the server is the connection is lost"
93  },
94  { "pop_user", DT_STRING|DT_SENSITIVE, 0, 0, NULL,
95  "(pop) Username of the POP server"
96  },
97 
98  { "pop_checkinterval", DT_SYNONYM, IP "pop_check_interval", },
99 
100  { NULL },
101  // clang-format on
102 };
103 
107 bool config_init_pop(struct ConfigSet *cs)
108 {
109  return cs_register_variables(cs, PopVars, 0);
110 }
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
Ask the user, defaulting to &#39;No&#39;.
Definition: quad.h:40
Container for lots of config items.
Definition: set.h:259
#define IP
Definition: set.h:54
#define CSR_ERR_INVALID
Value hasn&#39;t been set.
Definition: set.h:38
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
#define DT_NOT_NEGATIVE
Negative numbers are not allowed.
Definition: types.h:47
#define DT_SLIST
a list of strings
Definition: types.h:39
String list.
Definition: slist.h:46
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
Definition: set.h:63
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:37
#define DT_SENSITIVE
Contains sensitive value, e.g. password.
Definition: types.h:49
Convenience wrapper for the config headers.
bool pop_auth_is_valid(const char *authenticator)
Check if string is a valid pop authentication method.
Definition: auth.c:407
struct ListHead head
Definition: slist.h:48
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[], uint32_t flags)
Register a set of config items.
Definition: set.c:276
const char * name
User-visible name.
Definition: set.h:65
size_t count
Definition: slist.h:49
#define DT_STRING
a string
Definition: types.h:41
#define DT_COMMAND
A command.
Definition: types.h:50
Ask the user, defaulting to &#39;Yes&#39;.
Definition: quad.h:41
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
#define SLIST_SEP_COLON
Definition: slist.h:35
char * data
String.
Definition: list.h:36
#define DT_SYNONYM
synonym for another variable
Definition: types.h:42
Connection Library.
bool config_init_pop(struct ConfigSet *cs)
Register pop config variables - Implements module_init_config_t -.
Definition: config.c:107
Convenience wrapper for the library headers.
static int pop_auth_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Validate the "pop_authenticators" config variable - Implements ConfigDef::validator() -...
Definition: config.c:41
A List node for strings.
Definition: list.h:34
bool sasl_auth_validator(const char *authenticator)
Validate an auth method against Cyrus SASL methods.
Definition: sasl.c:127
#define DT_NUMBER
a number
Definition: types.h:35
#define DT_BOOL
boolean option
Definition: types.h:30
POP network mailbox.