mailbox += strlen(ns->prefix);
}
- if ((cmd->client->workarounds & WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
+ if ((cmd->client->set->parsed_workarounds &
+ WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
*mailbox != '\0' && mailbox[strlen(mailbox)-1] ==
mailbox_list_get_hierarchy_sep(ns->list)) {
/* verify the validity without the trailing '/' */
struct timeout *to_idle, *to_idle_output;
const struct imap_settings *set;
- enum client_workarounds workarounds;
string_t *capability_string;
struct mail_user *user;
}
mailbox_len = strlen(mailbox);
- if ((cmd->client->workarounds & WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
+ if ((cmd->client->set->parsed_workarounds &
+ WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
mailbox[mailbox_len-1] == mailbox_list_get_hierarchy_sep(ns->list)) {
/* drop the extra trailing hierarchy separator */
mailbox = t_strndup(mailbox, mailbox_len-1);
/* Disconnect client when it sends too many bad commands in a row */
#define CLIENT_MAX_BAD_COMMANDS 20
-enum client_workarounds {
- WORKAROUND_DELAY_NEWMAIL = 0x01,
- WORKAROUND_NETSCAPE_EOH = 0x04,
- WORKAROUND_TB_EXTRA_MAILBOX_SEP = 0x08
-};
-
#include "lib.h"
#include "imap-client.h"
#include "imap-settings.h"
i_stream_seek(ctx->cur_input, old_offset);
if (!ctx->cur_have_eoh &&
- (ctx->client->workarounds & WORKAROUND_NETSCAPE_EOH) != 0) {
+ (ctx->client->set->parsed_workarounds & WORKAROUND_NETSCAPE_EOH) != 0) {
/* Netscape 4.x doesn't like if end of headers line is
missing. */
msg_size.virtual_size += 2;
#include <stdlib.h>
#include <unistd.h>
+static bool imap_settings_verify(void *_set, pool_t pool,
+ const char **error_r);
+
#undef DEF
#undef DEFLIST
#define DEF(type, name) \
MEMBER(parent_offset) (size_t)-1,
MEMBER(type_offset) (size_t)-1,
MEMBER(struct_size) sizeof(struct imap_settings),
- MEMBER(check_func) NULL,
+ MEMBER(check_func) imap_settings_verify,
MEMBER(dependencies) imap_setting_dependencies
};
+
+/* <settings checks> */
+struct imap_client_workaround_list {
+ const char *name;
+ enum imap_client_workarounds num;
+};
+
+static struct imap_client_workaround_list imap_client_workaround_list[] = {
+ { "delay-newmail", WORKAROUND_DELAY_NEWMAIL },
+ { "outlook-idle", 0 }, /* only for backwards compatibility */
+ { "netscape-eoh", WORKAROUND_NETSCAPE_EOH },
+ { "tb-extra-mailbox-sep", WORKAROUND_TB_EXTRA_MAILBOX_SEP },
+ { NULL, 0 }
+};
+
+static int
+imap_settings_parse_workarounds(struct imap_settings *set,
+ const char **error_r)
+{
+ enum imap_client_workarounds client_workarounds = 0;
+ struct imap_client_workaround_list *list;
+ const char *const *str;
+
+ str = t_strsplit_spaces(set->imap_client_workarounds, " ,");
+ for (; *str != NULL; str++) {
+ list = imap_client_workaround_list;
+ for (; list->name != NULL; list++) {
+ if (strcasecmp(*str, list->name) == 0) {
+ client_workarounds |= list->num;
+ break;
+ }
+ }
+ if (list->name == NULL) {
+ *error_r = t_strdup_printf("imap_client_workarounds: "
+ "Unknown workaround: %s", *str);
+ return -1;
+ }
+ }
+ set->parsed_workarounds = client_workarounds;
+ return 0;
+}
+
+
+static bool
+imap_settings_verify(void *_set, pool_t pool ATTR_UNUSED, const char **error_r)
+{
+ struct imap_settings *set = _set;
+
+ if (imap_settings_parse_workarounds(set, error_r) < 0)
+ return FALSE;
+ return TRUE;
+}
+/* </settings checks> */
struct mail_user_settings;
+/* <settings checks> */
+enum imap_client_workarounds {
+ WORKAROUND_DELAY_NEWMAIL = 0x01,
+ WORKAROUND_NETSCAPE_EOH = 0x04,
+ WORKAROUND_TB_EXTRA_MAILBOX_SEP = 0x08
+};
+/* </settings checks> */
+
struct imap_settings {
bool mail_debug;
bool shutdown_clients;
const char *imap_logout_format;
const char *imap_id_send;
const char *imap_id_log;
+
+ enum imap_client_workarounds parsed_workarounds;
};
extern struct setting_parser_info imap_setting_parser_info;
get_common_sync_flags(client, &flags, &imap_flags);
client->sync_counter++;
- no_newmail = (client->workarounds & WORKAROUND_DELAY_NEWMAIL) != 0 &&
+ no_newmail = (client->set->parsed_workarounds & WORKAROUND_DELAY_NEWMAIL) != 0 &&
(imap_flags & IMAP_SYNC_FLAG_SAFE) == 0;
if (no_newmail) {
/* expunges might break the client just as badly as new mail
#define IS_STANDALONE() \
(getenv("CLIENT_INPUT") == NULL)
-struct client_workaround_list {
- const char *name;
- enum client_workarounds num;
-};
-
-static struct client_workaround_list client_workaround_list[] = {
- { "delay-newmail", WORKAROUND_DELAY_NEWMAIL },
- { "outlook-idle", 0 }, /* only for backwards compatibility */
- { "netscape-eoh", WORKAROUND_NETSCAPE_EOH },
- { "tb-extra-mailbox-sep", WORKAROUND_TB_EXTRA_MAILBOX_SEP },
- { NULL, 0 }
-};
-
void (*hook_client_created)(struct client **client) = NULL;
-static enum client_workarounds
-parse_workarounds(const struct imap_settings *set)
-{
- enum client_workarounds client_workarounds = 0;
- struct client_workaround_list *list;
- const char *const *str;
-
- str = t_strsplit_spaces(set->imap_client_workarounds, " ,");
- for (; *str != NULL; str++) {
- list = client_workaround_list;
- for (; list->name != NULL; list++) {
- if (strcasecmp(*str, list->name) == 0) {
- client_workarounds |= list->num;
- break;
- }
- }
- if (list->name == NULL)
- i_fatal("Unknown client workaround: %s", *str);
- }
-
- return client_workarounds;
-}
-
static void client_add_input(struct client *client, const char *input)
{
buffer_t *buf;
master_service_set_die_with_master(master_service, TRUE);
client = client_create(0, 1, user, set);
- client->workarounds = parse_workarounds(set);
if (dump_capability) {
printf("%s\n", str_c(client->capability_string));
transaction. This allows the mailbox to become unlocked. */
#define CLIENT_COMMIT_TIMEOUT_MSECS (10*1000)
-struct client_workaround_list {
- const char *name;
- enum client_workarounds num;
-};
-
-static struct client_workaround_list client_workaround_list[] = {
- { "outlook-no-nuls", WORKAROUND_OUTLOOK_NO_NULS },
- { "oe-ns-eoh", WORKAROUND_OE_NS_EOH },
- { NULL, 0 }
-};
-
static struct client *pop3_clients;
static void client_input(struct client *client);
return FALSE;
}
-static enum client_workarounds
-parse_workarounds(const struct pop3_settings *set)
-{
- enum client_workarounds client_workarounds = 0;
- struct client_workaround_list *list;
- const char *const *str;
-
- str = t_strsplit_spaces(set->pop3_client_workarounds, " ,");
- for (; *str != NULL; str++) {
- list = client_workaround_list;
- for (; list->name != NULL; list++) {
- if (strcasecmp(*str, list->name) == 0) {
- client_workarounds |= list->num;
- break;
- }
- }
- if (list->name == NULL)
- i_fatal("Unknown client workaround: %s", *str);
- }
- return client_workarounds;
-}
-
static enum uidl_keys parse_uidl_keymask(const char *format)
{
enum uidl_keys mask = 0;
return NULL;
}
- client->workarounds = parse_workarounds(set);
client->uidl_keymask =
parse_uidl_keymask(client->mail_set->pop3_uidl_format);
if (client->uidl_keymask == 0)
/* settings: */
const struct pop3_settings *set;
const struct mail_storage_settings *mail_set;
- enum client_workarounds workarounds;
enum uidl_keys uidl_keymask;
unsigned int disconnected:1;
add = '.';
break;
} else if (data[i] == '\0' &&
- (client->workarounds &
+ (client->set->parsed_workarounds &
WORKAROUND_OUTLOOK_NO_NULS) != 0) {
add = 0x80;
break;
}
if (!ctx->in_body &&
- (client->workarounds & WORKAROUND_OE_NS_EOH) != 0) {
+ (client->set->parsed_workarounds & WORKAROUND_OE_NS_EOH) != 0) {
/* Add the missing end of headers line. */
(void)o_stream_send(client->output, "\r\n", 2);
}
#ifndef POP3_COMMON_H
#define POP3_COMMON_H
-enum client_workarounds {
- WORKAROUND_OUTLOOK_NO_NULS = 0x01,
- WORKAROUND_OE_NS_EOH = 0x02
-};
-
enum uidl_keys {
UIDL_UIDVALIDITY = 0x01,
UIDL_UID = 0x02,
#include <stdlib.h>
#include <unistd.h>
+static bool pop3_settings_verify(void *_set, pool_t pool,
+ const char **error_r);
+
#undef DEF
#undef DEFLIST
#define DEF(type, name) \
MEMBER(parent_offset) (size_t)-1,
MEMBER(type_offset) (size_t)-1,
MEMBER(struct_size) sizeof(struct pop3_settings),
- MEMBER(check_func) NULL,
+ MEMBER(check_func) pop3_settings_verify,
MEMBER(dependencies) pop3_setting_dependencies
};
+
+/* <settings checks> */
+struct pop3_client_workaround_list {
+ const char *name;
+ enum pop3_client_workarounds num;
+};
+
+static struct pop3_client_workaround_list pop3_client_workaround_list[] = {
+ { "outlook-no-nuls", WORKAROUND_OUTLOOK_NO_NULS },
+ { "oe-ns-eoh", WORKAROUND_OE_NS_EOH },
+ { NULL, 0 }
+};
+
+static int
+pop3_settings_parse_workarounds(struct pop3_settings *set,
+ const char **error_r)
+{
+ enum pop3_client_workarounds client_workarounds = 0;
+ struct pop3_client_workaround_list *list;
+ const char *const *str;
+
+ str = t_strsplit_spaces(set->pop3_client_workarounds, " ,");
+ for (; *str != NULL; str++) {
+ list = pop3_client_workaround_list;
+ for (; list->name != NULL; list++) {
+ if (strcasecmp(*str, list->name) == 0) {
+ client_workarounds |= list->num;
+ break;
+ }
+ }
+ if (list->name == NULL) {
+ *error_r = t_strdup_printf("pop3_client_workarounds: "
+ "Unknown workaround: %s", *str);
+ return -1;
+ }
+ }
+ set->parsed_workarounds = client_workarounds;
+ return 0;
+}
+
+static bool
+pop3_settings_verify(void *_set, pool_t pool ATTR_UNUSED, const char **error_r)
+{
+ struct pop3_settings *set = _set;
+
+ if (pop3_settings_parse_workarounds(set, error_r) < 0)
+ return FALSE;
+ return TRUE;
+}
+/* </settings checks> */
struct mail_user_settings;
+/* <settings checks> */
+enum pop3_client_workarounds {
+ WORKAROUND_OUTLOOK_NO_NULS = 0x01,
+ WORKAROUND_OE_NS_EOH = 0x02
+};
+/* </settings checks> */
+
struct pop3_settings {
bool mail_debug;
bool shutdown_clients;
bool pop3_lock_session;
const char *pop3_client_workarounds;
const char *pop3_logout_format;
+
+ enum pop3_client_workarounds parsed_workarounds;
};
extern struct setting_parser_info pop3_setting_parser_info;