Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapted for 2.3.19 #377

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/dict-rados/dict-rados.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern "C" {
#include "../librmb/rados-guid-generator.h"
#include "../librmb/rados-util.h"

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
#define dict_lookup(dict, pool, key, value_r, error_r) dict_lookup(dict, pool, key, value_r, error_r)
#else
#define dict_lookup(dict, pool, key, value_r, error_r) dict_lookup(dict, pool, key, value_r)
Expand Down Expand Up @@ -143,11 +143,15 @@ int rados_dict_init(struct dict *driver, const char *uri, const struct dict_sett
}
}

string username(set->username);

string username("");
#if !DOVECOT_PREREQ(2, 3, 19)
username = set->username;
if (username.find(DICT_USERNAME_SEPARATOR) != string::npos) {
/* escape user name */
username = dict_escape_string(username.c_str());
}
#endif

dict = i_new(struct rados_dict, 1);
dict->cluster = new librmb::RadosClusterImpl();
Expand Down Expand Up @@ -197,7 +201,7 @@ void rados_dict_deinit(struct dict *_dict) {

static void rados_lookup_complete_callback(rados_completion_t comp, void *arg);

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
void rados_dict_wait(struct dict *_dict)
#else
int rados_dict_wait(struct dict *_dict)
Expand All @@ -207,7 +211,7 @@ int rados_dict_wait(struct dict *_dict)
// JRSE: not required with remote update? = > yes due to async lookup
dict->d->wait_for_completions();

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
return;
#else
return 0;
Expand Down Expand Up @@ -307,7 +311,7 @@ void rados_dict_lookup_async(struct dict *_dict, const char *key, dict_lookup_ca
}
}

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
int rados_dict_lookup(struct dict *_dict, pool_t pool, const char *key, const char **value_r, const char **error_r) {
#else
int rados_dict_lookup(struct dict *_dict, pool_t pool, const char *key, const char **value_r) {
Expand Down Expand Up @@ -529,7 +533,7 @@ void rados_dict_set_timestamp(struct dict_transaction_context *_ctx, const struc
void (*transaction_commit)(struct dict_transaction_context *ctx, bool async,
dict_transaction_commit_callback_t *callback, void *context);

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
void rados_dict_transaction_commit(struct dict_transaction_context *_ctx, bool async,
dict_transaction_commit_callback_t *callback, void *context)
#else
Expand All @@ -553,7 +557,7 @@ int rados_dict_transaction_commit(struct dict_transaction_context *_ctx, bool as
ret =
ctx->atomic_inc_not_found ? RADOS_COMMIT_RET_NOTFOUND : (failed ? RADOS_COMMIT_RET_FAILED : RADOS_COMMIT_RET_OK);
if (callback != nullptr) {
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
struct dict_commit_result result = {static_cast<dict_commit_ret>(ret), nullptr}; // TODO(p.mauritius): text?
callback(&result, ctx->context);
#else
Expand All @@ -564,7 +568,7 @@ int rados_dict_transaction_commit(struct dict_transaction_context *_ctx, bool as
delete ctx;
ctx = NULL;

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
return;
#else
return ret;
Expand Down Expand Up @@ -863,7 +867,7 @@ bool rados_dict_iterate(struct dict_iterate_context *ctx, const char **key_r, co
return TRUE;
}

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
int rados_dict_iterate_deinit(struct dict_iterate_context *ctx, const char **error_r)
#else
int rados_dict_iterate_deinit(struct dict_iterate_context *ctx)
Expand Down
6 changes: 3 additions & 3 deletions src/dict-rados/dict-rados.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern int rados_dict_init(struct dict *driver, const char *uri, const struct di
const char **error_r);
extern void rados_dict_deinit(struct dict *_dict);

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
extern void rados_dict_wait(struct dict *dict);
extern int rados_dict_lookup(struct dict *_dict, pool_t pool, const char *key, const char **value_r,
const char **error_r);
Expand All @@ -28,7 +28,7 @@ extern int rados_dict_lookup(struct dict *_dict, pool_t pool, const char *key, c
extern void rados_dict_lookup_async(struct dict *_dict, const char *key, dict_lookup_callback_t *callback,
void *context);
extern struct dict_transaction_context *rados_dict_transaction_init(struct dict *_dict);
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
extern void rados_dict_transaction_commit(struct dict_transaction_context *_ctx, bool async,
dict_transaction_commit_callback_t *callback, void *context);
#else
Expand All @@ -44,7 +44,7 @@ extern void rados_dict_atomic_inc(struct dict_transaction_context *_ctx, const c
extern struct dict_iterate_context *rados_dict_iterate_init(struct dict *_dict, const char *const *paths,
enum dict_iterate_flags flags);
extern bool rados_dict_iterate(struct dict_iterate_context *ctx, const char **key_r, const char **value_r);
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
extern int rados_dict_iterate_deinit(struct dict_iterate_context *ctx, const char **error_r);
#else
extern int rados_dict_iterate_deinit(struct dict_iterate_context *ctx);
Expand Down
1 change: 1 addition & 0 deletions src/librmb/rados-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <cctype>
#include <algorithm>
#include "encoding.h"
#include <iterator>

namespace librmb {

Expand Down
22 changes: 11 additions & 11 deletions src/storage-rbox/doveadm-rbox-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ static int restore_index_entry(struct mail_user *user, const char *mailbox_name,
i_error("Error opening mailbox %s", mailbox_name);
return -1;
}
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
char reason[256];
memset(reason, '\0', sizeof(reason));
struct mailbox_transaction_context *trans = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_EXTERNAL, reason);
Expand Down Expand Up @@ -526,15 +526,15 @@ static int doveadm_rmb_mail_next_user(struct doveadm_mail_cmd_context *ctx,
}
return ret;
}
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
ret = mail_storage_service_next(ctx->storage_service, cur_service_user, cur_mail_user, error_r);

#else
ret = mail_storage_service_next(ctx->storage_service, cur_service_user, cur_mail_user);
#endif
if (ret < 0) {
*error_r = "User init failed";
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
mail_storage_service_user_unref(&cur_service_user);
#else
mail_storage_service_user_free(&cur_service_user);
Expand All @@ -558,7 +558,7 @@ static int doveadm_rmb_mail_next_user(struct doveadm_mail_cmd_context *ctx,
}
mail_user_unref(cur_mail_user);

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
mail_storage_service_user_unref(&cur_service_user);
#else
mail_storage_service_user_free(&cur_service_user);
Expand Down Expand Up @@ -631,7 +631,7 @@ static int iterate_mailbox(const struct mail_namespace *ns, const struct mailbox
return -1;
}

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
char reason[256];
memset(reason, '\0', sizeof(reason));
mailbox_transaction = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_EXTERNAL, reason);
Expand Down Expand Up @@ -945,7 +945,7 @@ static int cmd_mailbox_delete_run(struct doveadm_mail_cmd_context *_ctx, struct
const ARRAY_TYPE(const_string) *mailboxes = &ctx->mailboxes;
uint8_t m_flags = 0;
int ret = 0, ret2;
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (ctx->unsafe)
m_flags |= MAILBOX_FLAG_DELETE_UNSAFE;
#endif
Expand All @@ -968,13 +968,13 @@ static int cmd_mailbox_delete_run(struct doveadm_mail_cmd_context *_ctx, struct
const char *name = *namep;
ns = mail_namespace_find(user->namespaces, name);
box = mailbox_alloc(ns->list, name, static_cast<enum mailbox_flags>(m_flags));
#if DOVECOT_PREREQ(2, 3)
mailbox_set_reason(box, "doveadm rmb mailbox delete");
#if DOVECOT_PREREQ(2, 3, 19)
//mailbox_set_reason(box, "doveadm rmb mailbox delete");
struct mail_storage *storage = mailbox_get_storage(box);
#endif
ret2 = ctx->require_empty ? mailbox_delete_empty(box) : mailbox_delete(box);
if (ret2 < 0) {
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
i_error("Can't delete mailbox %s: %s", name, mailbox_get_last_internal_error(box, NULL));
#else
i_error("Can't delete mailbox %s %d", name, ret2);
Expand All @@ -984,7 +984,7 @@ static int cmd_mailbox_delete_run(struct doveadm_mail_cmd_context *_ctx, struct
}
if (ctx->subscriptions) {
if (mailbox_set_subscribed(box, FALSE) < 0) {
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
i_error("Can't unsubscribe mailbox %s: %s", name, mail_storage_get_last_internal_error(storage, NULL));
#else
i_error("Can't unsubscribe mailbox %s ", name);
Expand Down Expand Up @@ -1203,7 +1203,7 @@ static bool cmd_mailbox_delete_parse_arg(struct doveadm_mail_cmd_context *_ctx,
case 'e':
ctx->require_empty = TRUE;
break;
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
case 'Z':
ctx->unsafe = TRUE;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/storage-rbox/doveadm-rbox-plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct delete_cmd_context {
ARRAY_TYPE(const_string) mailboxes;
bool recursive;
bool require_empty;
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
bool unsafe;
#endif
bool subscriptions;
Expand Down
4 changes: 4 additions & 0 deletions src/storage-rbox/doveadm-rbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@ static struct doveadm_mail_cmd rmb_commands[] = {
{cmd_rmb_create_ceph_index_alloc, "rmb create ceph index", "-d"},
{cmd_rmb_mailbox_delete_alloc, "rmb mailbox delete", "-r <mailbox> [...]"}};

#if !DOVECOT_PREREQ(2, 3, 19)
struct doveadm_cmd doveadm_cmd_rbox[] = {{(void *)cmd_rmb_config_show, "rmb config show", NULL},
{(void *)cmd_rmb_config_create, "rmb config create", NULL},
{(void *)cmd_rmb_config_update, "rmb config update", "key=value"},
{(void *)cmd_rmb_lspools, "rmb lspools", ""},
{(void *)cmd_rmb_version, "rmb version", ""}};
#endif

void doveadm_rbox_plugin_init(struct module *module ATTR_UNUSED) {
unsigned int i;
for (i = 0; i < N_ELEMENTS(rmb_commands); i++) {
doveadm_mail_register_cmd(&rmb_commands[i]);
}

#if !DOVECOT_PREREQ(2, 3, 19)
for (i = 0; i < N_ELEMENTS(doveadm_cmd_rbox); i++)
doveadm_register_cmd(&doveadm_cmd_rbox[i]);
#endif
}
void doveadm_rbox_plugin_deinit(void) {}
2 changes: 1 addition & 1 deletion src/storage-rbox/istream-bufferlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct istream *i_stream_create_from_bufferlist(librados::bufferlist *data, cons
bstream->istream.iostream.destroy = rbox_istream_destroy;
bstream->bl = data;

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
i_stream_create(&bstream->istream, NULL, -1, ISTREAM_CREATE_FLAG_NOOP_SNAPSHOT);
#else
i_stream_create(&bstream->istream, NULL, -1);
Expand Down
2 changes: 1 addition & 1 deletion src/storage-rbox/rbox-copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ int rbox_mail_storage_copy(struct mail_save_context *ctx, struct mail *mail) {
#endif
r_ctx->finished = TRUE;

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (ctx->data.keywords != NULL) {
/* keywords gets unreferenced twice: first in
mailbox_save_cancel()/_finish() and second time in
Expand Down
10 changes: 5 additions & 5 deletions src/storage-rbox/rbox-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C" {
#include "debug-helper.h"
#include "limits.h"
#include "macros.h"
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
#include "index-pop3-uidl.h"
#endif
}
Expand Down Expand Up @@ -801,14 +801,14 @@ static int rbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field
*value_r = "";
return 0;
}
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (!index_pop3_uidl_can_exist(_mail)) {
*value_r = "";
return 0;
}
#endif
ret = rbox_get_cached_metadata(mail, rbox_metadata_key::RBOX_METADATA_POP3_UIDL, MAIL_CACHE_POP3_UIDL, value_r);
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (ret == 0) {
index_pop3_uidl_update_exists(&mail->imail.mail.mail, (*value_r)[0] != '\0');
}
Expand All @@ -820,7 +820,7 @@ static int rbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field
*value_r = "";
return 0;
}
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (!index_pop3_uidl_can_exist(_mail)) {
/* we're assuming that if there's a POP3 order, there's
also a UIDL */
Expand Down Expand Up @@ -915,7 +915,7 @@ struct mail_vfuncs rbox_mail_vfuncs = {rbox_mail_close,
rbox_mail_get_stream,
index_mail_get_binary_stream,
rbox_mail_get_special,
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
index_mail_get_backend_mail,
#else
index_mail_get_real_mail,
Expand Down
6 changes: 3 additions & 3 deletions src/storage-rbox/rbox-mailbox-list-fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int rbox_fs_list_get_mailbox_flags(struct mailbox_list *list, const char *dir, c
const char *path;

*flags_r = static_cast<mailbox_info_flags>(0);
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (*list->set.maildir_name != '\0' && !list->set.iter_from_index_dir) {
#else
if (*list->set.maildir_name != '\0') {
Expand All @@ -168,7 +168,7 @@ int rbox_fs_list_get_mailbox_flags(struct mailbox_list *list, const char *dir, c
We're here also when iterating from index directory, because even
though maildir_name is set, it's not used for index directory.
*/
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (!list->set.iter_from_index_dir &&
#else
if (
Expand Down Expand Up @@ -260,7 +260,7 @@ int rbox_fs_list_get_mailbox_flags(struct mailbox_list *list, const char *dir, c
return 1;
}

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (list->v.is_internal_name == NULL || list->set.iter_from_index_dir) {
#else
if (list->v.is_internal_name == NULL) {
Expand Down
12 changes: 6 additions & 6 deletions src/storage-rbox/rbox-save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern "C" {
#include "rbox-sync.h"
#include "rados-types.h"
#include "debug-helper.h"
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
#include "index-pop3-uidl.h"
#endif
}
Expand Down Expand Up @@ -269,7 +269,7 @@ int rbox_save_continue(struct mail_save_context *_ctx) {
return -1;
}

#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (index_storage_save_continue(_ctx, r_ctx->input, _ctx->dest_mail) < 0) {
r_ctx->failed = TRUE;
FUNC_END();
Expand Down Expand Up @@ -334,7 +334,7 @@ static int rbox_save_mail_set_metadata(struct rbox_save_context *r_ctx, librmb::
RadosMetadata xattr(rbox_metadata_key::RBOX_METADATA_POP3_UIDL, mdata->pop3_uidl);
mail_object->add_metadata(xattr);
r_ctx->have_pop3_uidls = TRUE;
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
r_ctx->highest_pop3_uidl_seq = I_MAX(r_ctx->highest_pop3_uidl_seq, r_ctx->seq);
#endif
}
Expand All @@ -344,7 +344,7 @@ static int rbox_save_mail_set_metadata(struct rbox_save_context *r_ctx, librmb::
RadosMetadata xattr(rbox_metadata_key::RBOX_METADATA_POP3_ORDER, mdata->pop3_order);
mail_object->add_metadata(xattr);
r_ctx->have_pop3_orders = TRUE;
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
r_ctx->highest_pop3_uidl_seq = I_MAX(r_ctx->highest_pop3_uidl_seq, r_ctx->seq);
#endif
}
Expand Down Expand Up @@ -557,7 +557,7 @@ int rbox_save_finish(struct mail_save_context *_ctx) {
bool zlib_plugin_active = false;

// clean stream if still open
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
int ret = 0;
//#355 we need to write zipl trailer even the stream is empty!
if (r_ctx->ctx.data.output != r_ctx->output_stream ) {
Expand Down Expand Up @@ -715,7 +715,7 @@ static int rbox_save_assign_uids(struct rbox_save_context *r_ctx, const ARRAY_TY
return -1;
}
}
#if DOVECOT_PREREQ(2, 3)
#if DOVECOT_PREREQ(2, 3, 19)
if (r_ctx->highest_pop3_uidl_seq == n + 1) {
index_pop3_uidl_set_max_uid(&r_ctx->mbox->box, r_ctx->trans, uid);
}
Expand Down
Loading