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 "mutt/lib.h"
35#include "auth.h"
36#ifdef USE_SASL_CYRUS
37#include "conn/lib.h"
38#endif
39
43static int imap_auth_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef,
44 intptr_t value, struct Buffer *err)
45{
46 const struct Slist *imap_auth_methods = (const struct Slist *) value;
47 if (!imap_auth_methods || (imap_auth_methods->count == 0))
48 return CSR_SUCCESS;
49
50 struct ListNode *np = NULL;
51 STAILQ_FOREACH(np, &imap_auth_methods->head, entries)
52 {
53 if (imap_auth_is_valid(np->data))
54 continue;
55#ifdef USE_SASL_CYRUS
57 continue;
58#endif
59 buf_printf(err, _("Option %s: %s is not a valid authenticator"), cdef->name, np->data);
60 return CSR_ERR_INVALID;
61 }
62
63 return CSR_SUCCESS;
64}
65
69static struct ConfigDef ImapVars[] = {
70 // clang-format off
71 { "imap_check_subscribed", DT_BOOL, false, 0, NULL,
72 "(imap) When opening a mailbox, ask the server for a list of subscribed folders"
73 },
74 { "imap_condstore", DT_BOOL, false, 0, NULL,
75 "(imap) Enable the CONDSTORE extension"
76 },
77 { "imap_authenticators", DT_SLIST|SLIST_SEP_COLON, 0, 0, imap_auth_validator,
78 "(imap) List of allowed IMAP authentication methods (colon-separated)"
79 },
80 { "imap_delim_chars", DT_STRING, IP "/.", 0, NULL,
81 "(imap) Characters that denote separators in IMAP folders"
82 },
83 { "imap_fetch_chunk_size", DT_LONG|DT_NOT_NEGATIVE, 0, 0, NULL,
84 "(imap) Download headers in blocks of this size"
85 },
86 { "imap_headers", DT_STRING|R_INDEX, 0, 0, NULL,
87 "(imap) Additional email headers to download when getting index"
88 },
89 { "imap_idle", DT_BOOL, false, 0, NULL,
90 "(imap) Use the IMAP IDLE extension to check for new mail"
91 },
92 { "imap_login", DT_STRING|DT_SENSITIVE, 0, 0, NULL,
93 "(imap) Login name for the IMAP server (defaults to `$imap_user`)"
94 },
95 { "imap_oauth_refresh_command", DT_STRING|DT_COMMAND|DT_SENSITIVE, 0, 0, NULL,
96 "(imap) External command to generate OAUTH refresh token"
97 },
98 { "imap_pass", DT_STRING|DT_SENSITIVE, 0, 0, NULL,
99 "(imap) Password for the IMAP server"
100 },
101 { "imap_pipeline_depth", DT_NUMBER|DT_NOT_NEGATIVE, 15, 0, NULL,
102 "(imap) Number of IMAP commands that may be queued up"
103 },
104 { "imap_rfc5161", DT_BOOL, true, 0, NULL,
105 "(imap) Use the IMAP ENABLE extension to select capabilities"
106 },
107 { "imap_server_noise", DT_BOOL, true, 0, NULL,
108 "(imap) Display server warnings as error messages"
109 },
110 { "imap_keepalive", DT_NUMBER|DT_NOT_NEGATIVE, 300, 0, NULL,
111 "(imap) Time to wait before polling an open IMAP connection"
112 },
113 { "imap_list_subscribed", DT_BOOL, false, 0, NULL,
114 "(imap) When browsing a mailbox, only display subscribed folders"
115 },
116 { "imap_passive", DT_BOOL, true, 0, NULL,
117 "(imap) Reuse an existing IMAP connection to check for new mail"
118 },
119 { "imap_peek", DT_BOOL, true, 0, NULL,
120 "(imap) Don't mark messages as read when fetching them from the server"
121 },
122 { "imap_poll_timeout", DT_NUMBER|DT_NOT_NEGATIVE, 15, 0, NULL,
123 "(imap) Maximum time to wait for a server response"
124 },
125 { "imap_qresync", DT_BOOL, false, 0, NULL,
126 "(imap) Enable the QRESYNC extension"
127 },
128 { "imap_send_id", DT_BOOL, false, 0, NULL,
129 "(imap) Send ID command when logging in"
130 },
131 { "imap_user", DT_STRING|DT_SENSITIVE, 0, 0, NULL,
132 "(imap) Username for the IMAP server"
133 },
134
135 { "imap_servernoise", DT_SYNONYM, IP "imap_server_noise", IP "2021-02-11" },
136 { NULL },
137 // clang-format on
138};
139
140#if defined(USE_ZLIB)
144static struct ConfigDef ImapVarsZlib[] = {
145 // clang-format off
146 { "imap_deflate", DT_BOOL, true, 0, NULL,
147 "(imap) Compress network traffic"
148 },
149 { NULL },
150 // clang-format on
151};
152#endif
153
158{
160
161#if defined(USE_ZLIB)
163#endif
164
165 return rc;
166}
IMAP authenticator multiplexor.
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 imap_auth_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Validate the "imap_authenticators" config variable - Implements ConfigDef::validator() -.
Definition: config.c:43
bool config_init_imap(struct ConfigSet *cs)
Register imap config variables - Implements module_init_config_t -.
Definition: config.c:157
bool imap_auth_is_valid(const char *authenticator)
Check if string is a valid imap authentication method.
Definition: auth.c:90
static struct ConfigDef ImapVars[]
Config definitions for the IMAP library.
Definition: config.c:69
static struct ConfigDef ImapVarsZlib[]
Config definitions for IMAP compression.
Definition: config.c:144
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
#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
#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_LONG
a number (long)
Definition: types.h:33
#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 R_INDEX
Redraw the index menu (MENU_INDEX)
Definition: types.h:68
#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