52
52
static struct pop3c_client *
53
pop3c_client_create_from_set(struct mail_user *user,
53
pop3c_client_create_from_set(struct mail_storage *storage,
54
54
const struct pop3c_settings *set)
56
56
struct pop3c_client_settings client_set;
60
60
client_set.host = set->pop3c_host;
61
61
client_set.port = set->pop3c_port;
62
62
client_set.username = set->pop3c_user;
63
client_set.master_user = set->pop3c_master_user;
63
64
client_set.password = set->pop3c_password;
64
65
client_set.dns_client_socket_path =
65
t_strconcat(user->set->base_dir, "/",
66
t_strconcat(storage->user->set->base_dir, "/",
66
67
DNS_CLIENT_SOCKET_NAME, NULL);
67
68
str = t_str_new(128);
68
mail_user_set_get_temp_prefix(str, user->set);
69
mail_user_set_get_temp_prefix(str, storage->user->set);
69
70
client_set.temp_path_prefix = str_c(str);
71
client_set.debug = user->mail_debug;
72
client_set.debug = storage->user->mail_debug;
72
73
client_set.rawlog_dir =
73
mail_user_home_expand(user, set->pop3c_rawlog_dir);
74
mail_user_home_expand(storage->user, set->pop3c_rawlog_dir);
75
client_set.ssl_ca_dir = set->pop3c_ssl_ca_dir;
76
client_set.ssl_ca_dir = storage->set->ssl_client_ca_dir;
77
client_set.ssl_ca_file = storage->set->ssl_client_ca_file;
76
78
client_set.ssl_verify = set->pop3c_ssl_verify;
77
79
if (strcmp(set->pop3c_ssl, "pop3s") == 0)
78
80
client_set.ssl_mode = POP3C_CLIENT_SSL_MODE_IMMEDIATE;
116
118
mbox->box.mail_vfuncs = &pop3c_mail_vfuncs;
117
119
mbox->storage = (struct pop3c_storage *)storage;
119
index_storage_mailbox_alloc(&mbox->box, vname, flags,
121
index_storage_mailbox_alloc(&mbox->box, vname, flags, MAIL_INDEX_PREFIX);
121
122
return &mbox->box;
165
166
if (strcmp(box->name, "INBOX") != 0) {
166
167
mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
167
T_MAIL_ERR_MAILBOX_NOT_FOUND(box->name));
168
T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
171
172
if (index_storage_mailbox_open(box, FALSE) < 0)
174
mbox->client = pop3c_client_create_from_set(box->storage->user,
175
mbox->client = pop3c_client_create_from_set(box->storage,
175
176
mbox->storage->set);
176
177
pop3c_client_login(mbox->client, pop3c_login_callback, mbox);
177
178
pop3c_client_run(mbox->client);
203
204
pop3c_mailbox_update(struct mailbox *box,
204
205
const struct mailbox_update *update ATTR_UNUSED)
206
mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
207
"POP3 mailbox update isn't supported");
207
if (!guid_128_is_empty(update->mailbox_guid) ||
208
update->uid_validity != 0 || update->min_next_uid != 0 ||
209
update->min_first_recent_uid != 0) {
210
mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
211
"POP3 mailbox update isn't supported");
213
return index_storage_mailbox_update(box, update);
216
static int pop3c_mailbox_get_metadata(struct mailbox *box,
217
enum mailbox_metadata_items items,
218
struct mailbox_metadata *metadata_r)
220
if ((items & MAILBOX_METADATA_GUID) != 0) {
221
/* a bit ugly way to do this, but better than nothing for now.
222
FIXME: if indexes are enabled, keep this there. */
223
mail_generate_guid_128_hash(box->name, metadata_r->guid);
224
items &= ~MAILBOX_METADATA_GUID;
227
if (index_mailbox_get_metadata(box, items, metadata_r) < 0)
211
233
static void pop3c_notify_changes(struct mailbox *box ATTR_UNUSED)
237
static struct mail_save_context *
238
pop3c_save_alloc(struct mailbox_transaction_context *t)
240
struct mail_save_context *ctx;
242
ctx = i_new(struct mail_save_context, 1);
243
ctx->transaction = t;
248
pop3c_save_begin(struct mail_save_context *ctx,
249
struct istream *input ATTR_UNUSED)
251
mail_storage_set_error(ctx->transaction->box->storage,
252
MAIL_ERROR_NOTPOSSIBLE, "POP3 doesn't support saving mails");
256
static int pop3c_save_continue(struct mail_save_context *ctx ATTR_UNUSED)
261
static int pop3c_save_finish(struct mail_save_context *ctx)
263
index_save_context_free(ctx);
268
pop3c_save_cancel(struct mail_save_context *ctx)
270
index_save_context_free(ctx);
215
273
static bool pop3c_storage_is_inconsistent(struct mailbox *box)
217
275
struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box;
250
308
index_storage_mailbox_delete,
251
309
index_storage_mailbox_rename,
252
310
index_storage_get_status,
253
index_mailbox_get_metadata,
311
pop3c_mailbox_get_metadata,
254
312
index_storage_set_subscribed,
313
index_storage_attribute_set,
314
index_storage_attribute_get,
315
index_storage_attribute_iter_init,
316
index_storage_attribute_iter_next,
317
index_storage_attribute_iter_deinit,
255
318
index_storage_list_index_has_changed,
256
319
index_storage_list_index_update_sync,
257
320
pop3c_storage_sync_init,