NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
config.c
Go to the documentation of this file.
1
31#include "config.h"
32#include <stddef.h>
33#include <stdbool.h>
34#include <stdint.h>
35#include "private.h"
36#include "mutt/lib.h"
37#include "config/lib.h"
38#ifdef USE_SASL_CYRUS
39#include "conn/lib.h"
40#endif
41
45static int pop_auth_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef,
46 intptr_t value, struct Buffer *err)
47{
48 const struct Slist *pop_auth_methods = (const struct Slist *) value;
49 if (!pop_auth_methods || (pop_auth_methods->count == 0))
50 return CSR_SUCCESS;
51
52 struct ListNode *np = NULL;
53 STAILQ_FOREACH(np, &pop_auth_methods->head, entries)
54 {
55 if (pop_auth_is_valid(np->data))
56 continue;
57#ifdef USE_SASL_CYRUS
59 continue;
60#endif
61 buf_printf(err, _("Option %s: %s is not a valid authenticator"), cdef->name, np->data);
62 return CSR_ERR_INVALID;
63 }
64
65 return CSR_SUCCESS;
66}
67
71static struct ConfigDef PopVars[] = {
72 // clang-format off
73 { "pop_auth_try_all", DT_BOOL, true, 0, NULL,
74 "(pop) Try all available authentication methods"
75 },
76 { "pop_authenticators", DT_SLIST|D_SLIST_SEP_COLON, 0, 0, pop_auth_validator,
77 "(pop) List of allowed authentication methods (colon-separated)"
78 },
79 { "pop_check_interval", DT_NUMBER|D_INTEGER_NOT_NEGATIVE, 60, 0, NULL,
80 "(pop) Interval between checks for new mail"
81 },
82 { "pop_delete", DT_QUAD, MUTT_ASKNO, 0, NULL,
83 "(pop) After downloading POP messages, delete them on the server"
84 },
85 { "pop_host", DT_STRING, 0, 0, NULL,
86 "(pop) Url of the POP server"
87 },
88 { "pop_last", DT_BOOL, false, 0, NULL,
89 "(pop) Use the 'LAST' command to fetch new mail"
90 },
91 { "pop_oauth_refresh_command", DT_STRING|D_STRING_COMMAND|D_SENSITIVE, 0, 0, NULL,
92 "(pop) External command to generate OAUTH refresh token"
93 },
94 { "pop_pass", DT_STRING|D_SENSITIVE, 0, 0, NULL,
95 "(pop) Password of the POP server"
96 },
97 { "pop_reconnect", DT_QUAD, MUTT_ASKYES, 0, NULL,
98 "(pop) Reconnect to the server is the connection is lost"
99 },
100 { "pop_user", DT_STRING|D_SENSITIVE, 0, 0, NULL,
101 "(pop) Username of the POP server"
102 },
103
104 { "pop_checkinterval", DT_SYNONYM, IP "pop_check_interval", IP "2021-02-11" },
105 { NULL },
106 // clang-format on
107};
108
113{
114 return cs_register_variables(cs, PopVars);
115}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
Convenience wrapper for the config headers.
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition: set.c:281
#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:45
bool config_init_pop(struct ConfigSet *cs)
Register pop config variables - Implements module_init_config_t -.
Definition: config.c:112
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:502
static struct ConfigDef PopVars[]
Config definitions for the POP library.
Definition: config.c:71
@ 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:136
GUI display the mailboxes in a side panel.
String manipulation buffer.
Definition: buffer.h:36
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:37
struct ListHead head
List containing values.
Definition: slist.h:38
size_t count
Number of values in list.
Definition: slist.h:39
#define D_SLIST_SEP_COLON
Slist items are colon-separated.
Definition: types.h:112
#define D_STRING_COMMAND
A command.
Definition: types.h:99
@ DT_NUMBER
a number
Definition: types.h:39
@ DT_SLIST
a list of strings
Definition: types.h:43
@ DT_BOOL
boolean option
Definition: types.h:32
@ DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:41
@ DT_SYNONYM
synonym for another variable
Definition: types.h:46
@ DT_STRING
a string
Definition: types.h:45
#define D_SENSITIVE
Contains sensitive value, e.g. password.
Definition: types.h:81
#define D_INTEGER_NOT_NEGATIVE
Negative numbers are not allowed.
Definition: types.h:101