NeoMutt  2023-05-17-16-g61469c
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
41static 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_CYRUS
55 continue;
56#endif
57 buf_printf(err, _("Option %s: %s is not a valid authenticator"), cdef->name, np->data);
58 return CSR_ERR_INVALID;
59 }
60
61 return CSR_SUCCESS;
62}
63
67static struct ConfigDef PopVars[] = {
68 // clang-format off
69 { "pop_auth_try_all", DT_BOOL, true, 0, NULL,
70 "(pop) Try all available authentication methods"
71 },
72 { "pop_authenticators", DT_SLIST|SLIST_SEP_COLON, 0, 0, pop_auth_validator,
73 "(pop) List of allowed authentication methods (colon-separated)"
74 },
75 { "pop_check_interval", DT_NUMBER|DT_NOT_NEGATIVE, 60, 0, NULL,
76 "(pop) Interval between checks for new mail"
77 },
78 { "pop_delete", DT_QUAD, MUTT_ASKNO, 0, NULL,
79 "(pop) After downloading POP messages, delete them on the server"
80 },
81 { "pop_host", DT_STRING, 0, 0, NULL,
82 "(pop) Url of the POP server"
83 },
84 { "pop_last", DT_BOOL, false, 0, NULL,
85 "(pop) Use the 'LAST' command to fetch new mail"
86 },
87 { "pop_oauth_refresh_command", DT_STRING|DT_COMMAND|DT_SENSITIVE, 0, 0, NULL,
88 "(pop) External command to generate OAUTH refresh token"
89 },
90 { "pop_pass", DT_STRING|DT_SENSITIVE, 0, 0, NULL,
91 "(pop) Password of the POP server"
92 },
93 { "pop_reconnect", DT_QUAD, MUTT_ASKYES, 0, NULL,
94 "(pop) Reconnect to the server is the connection is lost"
95 },
96 { "pop_user", DT_STRING|DT_SENSITIVE, 0, 0, NULL,
97 "(pop) Username of the POP server"
98 },
99
100 { "pop_checkinterval", DT_SYNONYM, IP "pop_check_interval", IP "2021-02-11" },
101 { NULL },
102 // clang-format on
103};
104
109{
111}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:171
Convenience wrapper for the config headers.
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[], uint32_t flags)
Register a set of config items.
Definition: set.c:279
#define CSR_ERR_INVALID
Value hasn't been set.
Definition: set.h:38
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
#define IP
Definition: set.h:54
Connection Library.
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
bool config_init_pop(struct ConfigSet *cs)
Register pop config variables - Implements module_init_config_t -.
Definition: config.c:108
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
bool pop_auth_is_valid(const char *authenticator)
Check if string is a valid pop authentication method.
Definition: auth.c:501
static struct ConfigDef PopVars[]
Config definitions for the POP library.
Definition: config.c:67
@ MUTT_ASKNO
Ask the user, defaulting to 'No'.
Definition: quad.h:40
@ MUTT_ASKYES
Ask the user, defaulting to 'Yes'.
Definition: quad.h:41
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
bool sasl_auth_validator(const char *authenticator)
Validate an auth method against Cyrus SASL methods.
Definition: sasl.c:133
GUI display the mailboxes in a side panel.
#define SLIST_SEP_COLON
Definition: slist.h:35
String manipulation buffer.
Definition: buffer.h:34
Definition: set.h:64
const char * name
User-visible name.
Definition: set.h:65
Container for lots of config items.
Definition: set.h:252
A List node for strings.
Definition: list.h:35
char * data
String.
Definition: list.h:36
String list.
Definition: slist.h:47
struct ListHead head
List containing values.
Definition: slist.h:48
size_t count
Number of values in list.
Definition: slist.h:49
#define DT_SLIST
a list of strings
Definition: types.h:39
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:37
#define DT_BOOL
boolean option
Definition: types.h:30
#define DT_STRING
a string
Definition: types.h:41
#define DT_COMMAND
A command.
Definition: types.h:53
#define DT_SYNONYM
synonym for another variable
Definition: types.h:42
#define DT_NO_FLAGS
No flags are set.
Definition: types.h:47
#define DT_NOT_NEGATIVE
Negative numbers are not allowed.
Definition: types.h:50
#define DT_SENSITIVE
Contains sensitive value, e.g. password.
Definition: types.h:52
#define DT_NUMBER
a number
Definition: types.h:35