Skip to content

Commit

Permalink
#156: basic doveadm rmb plugin
Browse files Browse the repository at this point in the history
- basic integration of rmb plugin
- lsppols as first command.
  • Loading branch information
jrse committed Jun 6, 2018
1 parent 92816fb commit d37d5a0
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/librmb/tools/rmb/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rmb_SOURCES = \
rmb-commands.cpp \
rmb-commands.h \
rmb.cpp \
rmb.h
rados-mail-box.h

rmb_LDADD = $(shlibs)

Expand Down
2 changes: 1 addition & 1 deletion src/librmb/tools/rmb/mailbox_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <string>
#include "rados-mail-object.h"
#include "rmb.h"
#include "rados-mail-box.h"

namespace librmb {
class MailboxTools {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ namespace librmb {

class RadosMailBox {
public:
RadosMailBox(std::string _mailbox_guid, int _mail_count, std::string _mbox_orig_name) : mailbox_guid(_mailbox_guid),
mail_count(_mail_count),
mbox_orig_name(_mbox_orig_name) {
RadosMailBox(std::string _mailbox_guid, int _mail_count, std::string _mbox_orig_name)
: mailbox_guid(_mailbox_guid), mail_count(_mail_count), mbox_orig_name(_mbox_orig_name) {
this->mailbox_size = 0;
this->total_mails = 0;
this->parser = nullptr;
Expand Down
1 change: 0 additions & 1 deletion src/librmb/tools/rmb/rmb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* Foundation. See file COPYING.
*/

#include "rmb.h"
#include <stdarg.h> /* va_list, va_start, va_arg, va_end */
#include <errno.h>
#include <stdlib.h>
Expand Down
32 changes: 31 additions & 1 deletion src/storage-rbox/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,41 @@

LIBSTORAGE_RBOX_PLUGIN = libstorage_rbox_plugin.la


shlibs = \
$(top_builddir)/src/librmb/librmb.la

rmbtoollibs = \
$(top_builddir)/src/librmb/tools/rmb/ls_cmd_parser.o \
$(top_builddir)/src/librmb/tools/rmb/mailbox_tools.o \
$(top_builddir)/src/librmb/tools/rmb/rmb-commands.o

libstorage_rbox_plugin_la_CPPFLAGS = \
$(LIBDOVECOT_INCLUDE) \
$(LIBDOVECOT_STORAGE_INCLUDE) \
-I$(top_srcdir)/src/librmb
-I$(top_srcdir)/src/librmb

lib10_doveadm_rbox_plugin_la_CPPFLAGS= \
$(LIBDOVECOT_INCLUDE) \
$(LIBDOVECOT_STORAGE_INCLUDE) \
-I$(top_srcdir)/src/librmb \
-I$(top_srcdir)/src/librmb/rmb \
-I$(top_srcdir)/src/doveadm

libstorage_rbox_plugin_la_DEPENDENCIES = $(LIBDOVECOT_DEPS)
libstorage_rbox_plugin_la_LDFLAGS = -module -avoid-version
libstorage_rbox_plugin_la_LIBADD = $(LIBDOVECOT) $(shlibs)

lib10_doveadm_rbox_plugin_la_DEPENDENCIES = $(LIBDOVECOT_DEPS)
lib10_doveadm_rbox_plugin_la_LDFLAGS = -module -avoid-version
lib10_doveadm_rbox_plugin_la_LIBADD = $(LIBDOVECOT) $(shlibs) $(rmbtoollibs)

module_dir = $(moduledir)
doveadm_moduledir = $(moduledir)/doveadm

doveadm_module_LTLIBRARIES = \
lib10_doveadm_rbox_plugin.la

module_LTLIBRARIES = \
$(LIBSTORAGE_RBOX_PLUGIN)

Expand Down Expand Up @@ -52,3 +74,11 @@ libstorage_rbox_plugin_la_SOURCES = \
ostream-bufferlist.h \
rbox-mailbox-list-fs.h


lib10_doveadm_rbox_plugin_la_SOURCES = \
doveadm-rbox.c \
doveadm-rbox-plugin.cpp \
doveadm-rbox-plugin.h



43 changes: 43 additions & 0 deletions src/storage-rbox/doveadm-rbox-plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Copyright (c) 2017-2018 Tallence AG and the authors
* Copyright (c) 2007-2017 Dovecot authors
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
extern "C" {
#include "lib.h"
#include "module-dir.h"
#include "str.h"
#include "hash.h"
#include "dict.h"
#include "imap-match.h"
#include "doveadm-settings.h"
#include "doveadm-mail.h"
#include "doveadm-rbox-plugin.h"
}
#include "tools/rmb/rmb-commands.h"

static int cmd_rmb_optimize_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user) {
// const char *ns_prefix = ctx->args[0];
librmb::RmbCommands::RmbCommands::lspools();
return 0;
}

static void cmd_rmb_optimize_init(struct doveadm_mail_cmd_context *ctx ATTR_UNUSED, const char *const args[]) {
if (str_array_length(args) > 0) {
doveadm_mail_help_name("rmb lspools");
}
}

struct doveadm_mail_cmd_context *cmd_rmb_lspools_alloc(void) {
struct doveadm_mail_cmd_context *ctx;
ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context);
ctx->v.run = cmd_rmb_optimize_run;
ctx->v.init = cmd_rmb_optimize_init;
return ctx;
}
17 changes: 17 additions & 0 deletions src/storage-rbox/doveadm-rbox-plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Copyright (c) 2017-2018 Tallence AG and the authors
* Copyright (c) 2007-2017 Dovecot authors
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
#ifndef SRC_DOVEADM_RBOX_PLUGIN_H
#define SRC_DOVEADM_RBOX_PLUGIN_H

extern struct doveadm_mail_cmd_context *cmd_rmb_lspools_alloc(void);

#endif // SRC_DOVEADM_RBOX_PLUGIN_H_
36 changes: 36 additions & 0 deletions src/storage-rbox/doveadm-rbox.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Copyright (c) 2017-2018 Tallence AG and the authors
* Copyright (c) 2007-2017 Dovecot authors
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
#include "lib.h"
#include "module-dir.h"
#include "str.h"
#include "hash.h"
#include "dict.h"
#include "imap-match.h"
#include "doveadm-settings.h"
#include "doveadm-mail.h"

#include "doveadm-rbox-plugin.h"

#define DOVEADM_EXPIRE_MAIL_CMD_CONTEXT(obj) MODULE_CONTEXT(obj, doveadm_expire_mail_cmd_module)
const char *doveadm_rbox_plugin_version = DOVECOT_ABI_VERSION;

static struct doveadm_mail_cmd rmb_commands[] = {{cmd_rmb_lspools_alloc, "rmb lspools", NULL}};

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]);
}
}

void doveadm_rbox_plugin_deinit(void) {}

0 comments on commit d37d5a0

Please sign in to comment.