NeoMutt  2024-04-25-89-g194907
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 <stdbool.h>
33#include <stddef.h>
34#include <stdint.h>
35#include "mutt/lib.h"
36#include "config/lib.h"
37#include "auth.h"
38#ifdef USE_SASL_CYRUS
39#include "conn/lib.h"
40#endif
41
45static int imap_auth_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef,
46 intptr_t value, struct Buffer *err)
47{
48 const struct Slist *imap_auth_methods = (const struct Slist *) value;
49 if (!imap_auth_methods || (imap_auth_methods->count == 0))
50 return CSR_SUCCESS;
51
52 struct ListNode *np = NULL;
53 STAILQ_FOREACH(np, &imap_auth_methods->head, entries)
54 {
55 if (imap_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 ImapVars[] = {
72 // clang-format off
73 { "imap_check_subscribed", DT_BOOL, false, 0, NULL,
74 "(imap) When opening a mailbox, ask the server for a list of subscribed folders"
75 },
76 { "imap_condstore", DT_BOOL, false, 0, NULL,
77 "(imap) Enable the CONDSTORE extension"
78 },
79 { "imap_authenticators", DT_SLIST|D_SLIST_SEP_COLON, 0, 0, imap_auth_validator,
80 "(imap) List of allowed IMAP authentication methods (colon-separated)"
81 },
82 { "imap_delim_chars", DT_STRING, IP "/.", 0, NULL,
83 "(imap) Characters that denote separators in IMAP folders"
84 },
85 { "imap_fetch_chunk_size", DT_LONG|D_INTEGER_NOT_NEGATIVE, 0, 0, NULL,
86 "(imap) Download headers in blocks of this size"
87 },
88 { "imap_headers", DT_STRING, 0, 0, NULL,
89 "(imap) Additional email headers to download when getting index"
90 },
91 { "imap_idle", DT_BOOL, false, 0, NULL,
92 "(imap) Use the IMAP IDLE extension to check for new mail"
93 },
94 { "imap_login", DT_STRING|D_SENSITIVE, 0, 0, NULL,
95 "(imap) Login name for the IMAP server (defaults to `$imap_user`)"
96 },
97 { "imap_oauth_refresh_command", DT_STRING|D_STRING_COMMAND|D_SENSITIVE, 0, 0, NULL,
98 "(imap) External command to generate OAUTH refresh token"
99 },
100 { "imap_pass", DT_STRING|D_SENSITIVE, 0, 0, NULL,
101 "(imap) Password for the IMAP server"
102 },
103 { "imap_pipeline_depth", DT_NUMBER|D_INTEGER_NOT_NEGATIVE, 15, 0, NULL,
104 "(imap) Number of IMAP commands that may be queued up"
105 },
106 { "imap_rfc5161", DT_BOOL, true, 0, NULL,
107 "(imap) Use the IMAP ENABLE extension to select capabilities"
108 },
109 { "imap_server_noise", DT_BOOL, true, 0, NULL,
110 "(imap) Display server warnings as error messages"
111 },
112 { "imap_keep_alive", DT_NUMBER|D_INTEGER_NOT_NEGATIVE, 300, 0, NULL,
113 "(imap) Time to wait before polling an open IMAP connection"
114 },
115 { "imap_list_subscribed", DT_BOOL, false, 0, NULL,
116 "(imap) When browsing a mailbox, only display subscribed folders"
117 },
118 { "imap_passive", DT_BOOL, true, 0, NULL,
119 "(imap) Reuse an existing IMAP connection to check for new mail"
120 },
121 { "imap_peek", DT_BOOL, true, 0, NULL,
122 "(imap) Don't mark messages as read when fetching them from the server"
123 },
124 { "imap_poll_timeout", DT_NUMBER|D_INTEGER_NOT_NEGATIVE, 15, 0, NULL,
125 "(imap) Maximum time to wait for a server response"
126 },
127 { "imap_qresync", DT_BOOL, false, 0, NULL,
128 "(imap) Enable the QRESYNC extension"
129 },
130 { "imap_send_id", DT_BOOL, false, 0, NULL,
131 "(imap) Send ID command when logging in"
132 },
133 { "imap_user", DT_STRING|D_SENSITIVE, 0, 0, NULL,
134 "(imap) Username for the IMAP server"
135 },
136
137 { "imap_keepalive", DT_SYNONYM, IP "imap_keep_alive", IP "2023-05-31" },
138 { "imap_servernoise", DT_SYNONYM, IP "imap_server_noise", IP "2021-02-11" },
139 { NULL },
140 // clang-format on
141};
142
143#if defined(USE_ZLIB)
147static struct ConfigDef ImapVarsZlib[] = {
148 // clang-format off
149 { "imap_deflate", DT_BOOL, true, 0, NULL,
150 "(imap) Compress network traffic"
151 },
152 { NULL },
153 // clang-format on
154};
155#endif
156
161{
162 bool rc = cs_register_variables(cs, ImapVars);
163
164#if defined(USE_ZLIB)
166#endif
167
168 return rc;
169}
IMAP authenticator multiplexor.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
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 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:45
bool config_init_imap(struct ConfigSet *cs)
Register imap config variables - Implements module_init_config_t -.
Definition: config.c:160
bool imap_auth_is_valid(const char *authenticator)
Check if string is a valid imap authentication method.
Definition: auth.c:95
static struct ConfigDef ImapVars[]
Config definitions for the IMAP library.
Definition: config.c:71
static struct ConfigDef ImapVarsZlib[]
Config definitions for IMAP compression.
Definition: config.c:147
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:136
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:37
char * data
String.
Definition: list.h:38
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_SYNONYM
synonym for another variable
Definition: types.h:46
@ DT_STRING
a string
Definition: types.h:45
@ DT_LONG
a number (long)
Definition: types.h:36
#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