# mapistore test tools
#######################
-mapistore_test: bin/mapistore_test
+mapistore_test: bin/mapistore_test bin/mapistore_provision
bin/mapistore_test: mapiproxy/libmapistore/tests/mapistore_test.o \
mapiproxy/libmapistore.$(SHLIBEXT).$(PACKAGE_VERSION)
@echo "Linking $@"
@$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) -lpopt -L. libmapi.$(SHLIBEXT).$(PACKAGE_VERSION)
+bin/mapistore_provision: mapiproxy/libmapistore/tests/mapistore_provision.o \
+ mapiproxy/libmapistore.$(SHLIBEXT).$(PACKAGE_VERSION)
+ @echo "Linking $@"
+ @$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) -lpopt -L. libmapi.$(SHLIBEXT).$(PACKAGE_VERSION)
+
mapistoretest_clean:
rm -f mapiproxy/libmapistore/tests/*.o
rm -f mapiproxy/libmapistore/tests/*.gcno
rm -f mapiproxy/libmapistore/tests/*.gcda
rm -f bin/mapistore_test
+ rm -f bin/mapistore_provision
clean:: mapistoretest_clean
return MAPISTORE_SUCCESS;
}
-
+#if 0
/**
\details Add a root folder to user mailbox
return MAPISTORE_SUCCESS;
}
+#endif
#define MDB_JUNK_EMAIL 27
#define MDB_RSS_FEEDS 28
#define MDB_CONVERSATION_ACT 29
+#define MDB_LAST_SPECIALFOLDER MDB_CONVERSATION_ACT
#define MDB_CUSTOM 999
struct mailbox_special_folder {
enum MAPISTORE_ERROR mapistore_release_record(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
enum MAPISTORE_ERROR mapistore_search_context_by_uri(struct mapistore_context *, const char *, uint32_t *);
const char* mapistore_errstr(enum MAPISTORE_ERROR);
-enum MAPISTORE_ERROR mapistore_root_mkdir(struct mapistore_context *, uint32_t, uint32_t, const char *, const char *);
+enum MAPISTORE_ERROR mapistore_root_mkdir(struct mapistore_context *, uint32_t, uint32_t, uint64_t, const char *, const char *);
enum MAPISTORE_ERROR mapistore_create_mapistoreURI(struct mapistore_context *, const char *, uint64_t *, char **);
enum MAPISTORE_ERROR mapistore_get_context_fid(struct mapistore_context *, uint32_t, uint64_t *);
/* enum MAPISTORE_ERROR mapistore_add_context_indexing(struct mapistore_context *, const char *, uint32_t); */
enum MAPISTORE_ERROR mapistore_get_child_fids(struct mapistore_context *, uint32_t, uint64_t, uint64_t **, uint32_t *);
enum MAPISTORE_ERROR mapistore_deletemessage(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
enum MAPISTORE_ERROR mapistore_get_next_fmid(struct mapistore_context *mstore_ctx, uint64_t *fmid);
+enum MAPISTORE_ERROR mapistore_get_SystemFolderID(struct mapistore_context *mstore_ctx, char *recipient, uint32_t SystemIdx, uint64_t *FolderId);
/* definitions from mapistore_processing.c */
enum MAPISTORE_ERROR mapistore_set_mapping_path(const char *);
enum MAPISTORE_ERROR mapistoredb_new_mailbox(struct mapistoredb_context *, const char *, uint32_t *);
enum MAPISTORE_ERROR mapistoredb_add_mailbox_default_folder(struct mapistoredb_context *, uint32_t,
uint32_t, const char *, const char *);
+#if 0
enum MAPISTORE_ERROR mapistoredb_add_mailbox_folder(struct mapistoredb_context *, uint32_t, uint32_t,
const char *, const char *);
+#endif
/* definitions from mapistoredb_conf.c */
void mapistoredb_dump_conf(struct mapistoredb_context *);
\param context_id the context identifier referencing the backend
where the root directory will be created
\param index the indexing referencing this system/special folder
+ \param parent_fid parent Folder ID for the new folder. Pass 0 to add below
+ the root of the context.
\param name optional name to be used instead of the default one
\param uri the optional mapistore uri to use for this folder
_PUBLIC_ enum MAPISTORE_ERROR mapistore_root_mkdir(struct mapistore_context *mstore_ctx,
uint32_t context_id,
uint32_t index,
+ uint64_t parent_fid,
const char *name,
const char *mapistore_uri)
{
struct backend_context *backend_ctx;
enum MAPISTORE_ERROR ret;
uint64_t fid;
- uint64_t parent_fid;
/* Sanity checks */
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
DEBUG(8, ("[%s] backend_ctx is %s (%s)\n", __FUNCTION__, backend_ctx->uri, backend_ctx->username));
- /* Retrieve the parent fid matching the context */
- mapistore_get_context_fid(mstore_ctx, context_id, &parent_fid);
- DEBUG(4, ("[%s] context FID: 0x%016"PRIx64"\n", __FUNCTION__, parent_fid));
+ if (parent_fid == 0) {
+ /* Retrieve the parent fid matching the context */
+ mapistore_get_context_fid(mstore_ctx, context_id, &parent_fid);
+ DEBUG(4, ("[%s] context FID: 0x%016"PRIx64"\n", __FUNCTION__, parent_fid));
+ }
- /* Generate a fid for this folder */
+ /* Generate a new fid for this folder */
mapistore_get_next_fmid(mstore_ctx, &fid);
/* Fill in the name if not provided */
talloc_free(mem_ctx);
return ret;
}
+
+/**
+ \details Retrieve the mailbox FolderID for given recipient from
+ mapistore database
+
+ \param mstore_ctx pointer to the mapistore context
+ \param recipient the mailbox username
+ \param SystemIdx the system folder index
+ \param FolderId pointer to the folder identifier that the function returns
+
+ \return MAPI_E_SUCCESS on success, otherwise MAPI error
+ */
+_PUBLIC_ enum MAPISTORE_ERROR mapistore_get_SystemFolderID(struct mapistore_context *mstore_ctx,
+ char *recipient, uint32_t SystemIdx,
+ uint64_t *FolderId)
+{
+ // TODO: this is just a stub implementation.
+ *FolderId = 0xDEADBEEF;
+
+ return MAPI_E_SUCCESS;
+}
--- /dev/null
+/*
+ OpenChange Storage Abstraction Layer library test tool
+
+ OpenChange Project
+
+ Copyright (C) Julien Kerihuel 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mapiproxy/libmapistore/mapistore.h"
+/* TODO: we shouldn't need to do this... */
+#include "mapiproxy/libmapistore/mapistore_private.h"
+#include <talloc.h>
+#include <core/ntstatus.h>
+#include <samba/popt.h>
+#include <param.h>
+#include <util/debug.h>
+
+/**
+ \file mapistore_provision.c
+
+ \brief Demo mapistore provisioning
+ */
+
+/* TODO: the path probably should be a parameter */
+static int do_initialisation(TALLOC_CTX *mem_ctx)
+{
+ struct mapistoredb_context *mstoredb_ctx;
+ enum MAPISTORE_ERROR retval;
+
+ // TODO: perhaps we should init() in the main() function
+ // TODO: probably need to mkdir if it doesn't already exist
+ mstoredb_ctx = mapistoredb_init(mem_ctx, "/usr/local/samba/private/mapistore");
+ if (mstoredb_ctx == NULL) {
+ DEBUG(0, ("mapistoredb_init returned NULL\n"));
+ return -1;
+ }
+
+ retval = mapistoredb_provision(mstoredb_ctx);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistoredb_provision() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ return -2;
+ }
+
+ mapistoredb_release(mstoredb_ctx);
+
+ return 0;
+}
+
+static void add_special_folders(struct mapistore_context *mstore_ctx, uint32_t context_id, uint64_t root_fid)
+{
+ int i = 0;
+ enum MAPISTORE_ERROR retval;
+ uint64_t index_to_fid_map[MDB_LAST_SPECIALFOLDER + 1];
+
+ for (i = 0; mailbox_special_folders[i].name != NULL; ++i) {
+ if (mailbox_special_folders[i].parent_specialindex == MDB_ROOT_FOLDER) {
+ retval = mapistore_root_mkdir(mstore_ctx, context_id, mailbox_special_folders[i].index, root_fid, NULL, NULL);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_root_mkdir() for %s returned %i (%s)\n", mailbox_special_folders[i].name, retval, mapistore_errstr(retval)));
+ return;
+ }
+ mapistore_get_fid_by_name(mstore_ctx, context_id, root_fid, mailbox_special_folders[i].name,
+ &(index_to_fid_map[mailbox_special_folders[i].index]));
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_get_fid_by_name for %s returned %i (%s)\n", mailbox_special_folders[i].name, retval, mapistore_errstr(retval)));
+ return;
+ }
+ } else {
+ retval = mapistore_root_mkdir(mstore_ctx, context_id, mailbox_special_folders[i].index,
+ index_to_fid_map[mailbox_special_folders[i].parent_specialindex],
+ NULL, NULL);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_root_mkdir() for %s returned %i (%s)\n", mailbox_special_folders[i].name, retval, mapistore_errstr(retval)));
+ return;
+ }
+ mapistore_get_fid_by_name(mstore_ctx, context_id, index_to_fid_map[mailbox_special_folders[i].parent_specialindex],
+ mailbox_special_folders[i].name, &(index_to_fid_map[mailbox_special_folders[i].index]));
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_get_fid_by_name for %s returned %i (%s)\n", mailbox_special_folders[i].name, retval, mapistore_errstr(retval)));
+ return;
+ }
+ }
+ }
+}
+
+static int do_user_mailbox(TALLOC_CTX *mem_ctx, const char *username)
+{
+ struct mapistoredb_context *mstoredb_ctx;
+ enum MAPISTORE_ERROR retval;
+ uint32_t mailbox_context_id = 0;
+ uint64_t mailbox_root_fid = 0;
+
+ mstoredb_ctx = mapistoredb_init(mem_ctx, "/usr/local/samba/private/mapistore");
+ if (mstoredb_ctx == NULL) {
+ DEBUG(0, ("mapistoredb_init returned NULL\n"));
+ return -1;
+ }
+
+ retval = mapistoredb_new_mailbox(mstoredb_ctx, username, &mailbox_context_id);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistoredb_new_mailbox() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ return -2;
+ }
+ DEBUG(3, ("%s context ID: 0x%x\n", username, mailbox_context_id));
+
+ retval = mapistore_get_fid_by_name(mstoredb_ctx->mstore_ctx, mailbox_context_id, 0, username, &mailbox_root_fid);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_get_fid_by_name() on %s root folder returned %i (%s)\n", username, retval, mapistore_errstr(retval)));
+ return -3;
+ }
+ DEBUG(3, ("%s root folder has fid: 0x%016"PRIx64"\n", username, mailbox_root_fid));
+
+ add_special_folders(mstoredb_ctx->mstore_ctx, mailbox_context_id, mailbox_root_fid);
+
+ mapistoredb_release(mstoredb_ctx);
+
+ return 0;
+
+}
+
+int main(int argc, const char *argv[])
+{
+ TALLOC_CTX *mem_ctx;
+ struct loadparm_context *lp_ctx;
+ poptContext pc;
+ int opt;
+ const char *opt_debug = NULL;
+ bool opt_init = false;
+ const char *opt_mailbox = NULL;
+#if 0
+ uint32_t mailbox2_context_id = 0;
+ uint64_t testuser2_fid = 0;
+ uint64_t jk_fid = 0;
+ uint32_t testuser2_folder_count = 0;
+ uint32_t jk_folder_count = 0;
+ uint64_t planning_subfolder_fid = 0;
+ struct SRow planning_subfolder_props;
+#endif
+ enum { OPT_DEBUG=1000, OPT_INIT, OPT_MAILBOX };
+
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ { "init", 'i', POPT_ARG_NONE, NULL, OPT_INIT, "initialise the database", NULL },
+ { "mailbox", 'm', POPT_ARG_STRING, NULL, OPT_MAILBOX, "create a user mailbox", NULL },
+ { "debuglevel", 'd', POPT_ARG_STRING, NULL, OPT_DEBUG, "set the debug level", NULL },
+ { NULL, 0, 0, NULL, 0, NULL, NULL }
+ };
+
+ /* TODO : chase down the leaks reported by this */
+ // talloc_enable_leak_report_full();
+ mem_ctx = talloc_named(NULL, 0, "mapistore_test");
+ lp_ctx = loadparm_init(mem_ctx);
+ lpcfg_load_default(lp_ctx);
+ setup_logging(NULL, DEBUG_STDOUT);
+
+ pc = poptGetContext("mapistore_test", argc, argv, long_options, 0);
+ while ((opt = poptGetNextOpt(pc)) != -1) {
+ switch (opt) {
+ case OPT_DEBUG:
+ opt_debug = poptGetOptArg(pc);
+ break;
+ case OPT_INIT:
+ opt_init = true;
+ break;
+ case OPT_MAILBOX:
+ opt_mailbox = poptGetOptArg(pc);
+ break;
+ }
+ }
+
+ poptFreeContext(pc);
+
+ if (opt_debug) {
+ lpcfg_set_cmdline(lp_ctx, "log level", opt_debug);
+ }
+
+ if (opt_init) {
+ do_initialisation(mem_ctx);
+ }
+
+ if (opt_mailbox) {
+ do_user_mailbox(mem_ctx, opt_mailbox);
+ }
+
+#if 0
+ // TODO: more features we could add....
+
+ retval = mapistoredb_set_netbiosname(mstoredb_ctx, "nbname");
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistoredb_set_netbiosname() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+
+
+
+ retval = mapistoredb_provision_publicfolders(mstoredb_ctx);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistoredb_provision_publicfolders() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+
+ retval = mapistoredb_new_mailbox(mstoredb_ctx, "testuser1", &mailbox1_context_id);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistoredb_new_mailbox() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+ DEBUG(2, ("testuser1 context ID: 0x%x\n", mailbox1_context_id));
+
+ retval = mapistoredb_new_mailbox(mstoredb_ctx, "testuser2", &mailbox2_context_id);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistoredb_new_mailbox() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+ DEBUG(2, ("testuser2 context ID: 0x%x\n", mailbox2_context_id));
+
+ /* try adding the default Outbox folder */
+ retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_OUTBOX, NULL, NULL);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_root_mkdir() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+
+ /* try adding the Journal folder with a non-standard name*/
+ retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_JOURNAL, "MyJournal", NULL);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_root_mkdir() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+
+ /* try an adding a folder with the fsocpf backend */
+ retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_IPM_SUBTREE, "MyMessages", "fsocpf://tmp/testuser2/mymessages");
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_root_mkdir() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+
+ /* try adding a generic folder */
+ retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_CUSTOM, "From Julien", NULL);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_root_mkdir() for generic folder returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+
+ /* try opening the testuser2 root folder */
+ /* TODO consider whether we really want a hack like fid == 0 means open root folder for this context */
+ retval = mapistore_opendir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, 0, 0);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_opendir() on root folder returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+
+ retval = mapistore_get_fid_by_name(mstoredb_ctx->mstore_ctx, mailbox2_context_id, 0, "testuser2", &testuser2_fid);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_get_fid_by_name() on testuser2 root folder returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+ DEBUG(0, ("testuser2 root folder has fid: 0x%016"PRIx64"\n", jk_fid));
+
+ retval = mapistore_get_fid_by_name(mstoredb_ctx->mstore_ctx, mailbox2_context_id, testuser2_fid, "From Julien", &jk_fid);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_opendir() on root folder returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+ DEBUG(0, ("\"From Julien\" folder has fid: 0x%016"PRIx64"\n", jk_fid));
+
+ retval = mapistore_get_folder_count(mstoredb_ctx->mstore_ctx, mailbox2_context_id, testuser2_fid, &testuser2_folder_count);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_get_folder_count() on root folder returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+ DEBUG(0, ("testuser2 root folder has %i subfolders\n", testuser2_folder_count));
+
+ retval = mapistore_get_folder_count(mstoredb_ctx->mstore_ctx, mailbox2_context_id, jk_fid, &jk_folder_count);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_get_folder_count() on \"From Julien\" folder returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+ DEBUG(0, ("\"From Julien\" folder has %i subfolder(s)\n", jk_folder_count));
+
+ retval = mapistore_get_next_fmid(mstoredb_ctx->mstore_ctx, &planning_subfolder_fid);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_get_next_fmid() returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+ DEBUG(0, ("\"Planning January 2011\" subfolder will use FID: 0x%016"PRIx64"\n", planning_subfolder_fid));
+
+ planning_subfolder_props.cValues = 1;
+ planning_subfolder_props.lpProps = talloc_zero_array(mem_ctx, struct SPropValue, planning_subfolder_props.cValues);
+ planning_subfolder_props.lpProps[0].ulPropTag = PR_DISPLAY_NAME;
+ planning_subfolder_props.lpProps[0].value.lpszA = "Planning January 2011";
+
+ retval = mapistore_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, jk_fid, planning_subfolder_fid, &planning_subfolder_props);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_mkdir() on planning subfolder returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+ DEBUG(0, ("Created \"Planning January 2011\" subfolder under \"From Julien\" subfolder\n"));
+
+ retval = mapistore_get_folder_count(mstoredb_ctx->mstore_ctx, mailbox2_context_id, jk_fid, &jk_folder_count);
+ if (retval != MAPISTORE_SUCCESS) {
+ DEBUG(0, ("mapistore_get_folder_count() on \"From Julien\" folder returned %i (%s)\n", retval, mapistore_errstr(retval)));
+ exit(1);
+ }
+ DEBUG(0, ("\"From Julien\" folder now has %i subfolder(s)\n", jk_folder_count));
+
+ /* TODO: clean up mailbox contexts */
+
+#endif
+
+ talloc_free(lp_ctx);
+ talloc_report(mem_ctx, stdout);
+ talloc_free(mem_ctx);
+ return 0;
+}
DEBUG(2, ("testuser2 context ID: 0x%x\n", mailbox2_context_id));
/* try adding the default Outbox folder */
- retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_OUTBOX, NULL, NULL);
+ retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_OUTBOX, 0, NULL, NULL);
if (retval != MAPISTORE_SUCCESS) {
DEBUG(0, ("mapistore_root_mkdir() returned %i (%s)\n", retval, mapistore_errstr(retval)));
exit(1);
}
/* try adding the Journal folder with a non-standard name*/
- retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_JOURNAL, "MyJournal", NULL);
+ retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_JOURNAL, 0, "MyJournal", NULL);
if (retval != MAPISTORE_SUCCESS) {
DEBUG(0, ("mapistore_root_mkdir() returned %i (%s)\n", retval, mapistore_errstr(retval)));
exit(1);
}
/* try an adding a folder with the fsocpf backend */
- retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_IPM_SUBTREE, "MyMessages", "fsocpf://tmp/testuser2/mymessages");
+ retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_IPM_SUBTREE, 0, "MyMessages", "fsocpf://tmp/testuser2/mymessages");
if (retval != MAPISTORE_SUCCESS) {
DEBUG(0, ("mapistore_root_mkdir() returned %i (%s)\n", retval, mapistore_errstr(retval)));
exit(1);
}
/* try adding a generic folder */
- retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_CUSTOM, "From Julien", NULL);
+ retval = mapistore_root_mkdir(mstoredb_ctx->mstore_ctx, mailbox2_context_id, MDB_CUSTOM, 0, "From Julien", NULL);
if (retval != MAPISTORE_SUCCESS) {
DEBUG(0, ("mapistore_root_mkdir() for generic folder returned %i (%s)\n", retval, mapistore_errstr(retval)));
exit(1);
/* Step 1. Initialize the emsmdbp context */
emsmdbp_ctx = emsmdbp_init(dce_call->conn->dce_ctx->lp_ctx,
dce_call->context->conn->auth_state.session_info->server_info->account_name,
- openchange_ldb_ctx);
+ 0);
if (!emsmdbp_ctx) {
smb_panic("unable to initialize emsmdbp context");
OPENCHANGE_RETVAL_IF(!emsmdbp_ctx, MAPI_E_FAILONEPROVIDER, NULL);
emsmdb_session = talloc_zero(dce_ctx, struct exchange_emsmdb_session);
if (!emsmdb_session) return NT_STATUS_NO_MEMORY;
emsmdb_session->session = NULL;
-
+#if 0
/* Open read/write context on OpenChange dispatcher database */
openchange_ldb_ctx = emsmdbp_openchange_ldb_init(dce_ctx->lp_ctx);
if (!openchange_ldb_ctx) {
smb_panic("unable to initialize 'openchange.ldb' context");
}
-
+#endif
return NT_STATUS_OK;
}
#endif
#endif
+/* TODO: remove the oc_ctx */
struct emsmdbp_context {
char *szUserDN;
char *szDisplayName;
\return Allocated emsmdbp_context pointer on success, otherwise
NULL
*/
+/* TODO: remove ldb context argument */
_PUBLIC_ struct emsmdbp_context *emsmdbp_init(struct loadparm_context *lp_ctx,
const char *username,
void *ldb_ctx)
struct EcDoRpc_MAPI_REQ *mapi_req,
struct EcDoRpc_MAPI_REPL *mapi_repl)
{
- enum MAPISTATUS retval;
+ // enum MAPISTATUS retval;
char *recipient;
struct Logon_req request;
struct Logon_repl response;
response.LogonFlags = request.LogonFlags;
/* Step 3. Build FolderIds list */
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_MAILBOX_ROOT, &response.LogonType.store_mailbox.FolderIds[0]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_DEFERRED_ACTIONS, &response.LogonType.store_mailbox.FolderIds[1]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_SPOOLER_QUEUE, &response.LogonType.store_mailbox.FolderIds[2]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_TOP_INFORMATION_STORE, &response.LogonType.store_mailbox.FolderIds[3]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_INBOX, &response.LogonType.store_mailbox.FolderIds[4]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_OUTBOX, &response.LogonType.store_mailbox.FolderIds[5]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_SENT_ITEMS, &response.LogonType.store_mailbox.FolderIds[6]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_DELETED_ITEMS, &response.LogonType.store_mailbox.FolderIds[7]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_COMMON_VIEWS, &response.LogonType.store_mailbox.FolderIds[8]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_SCHEDULE, &response.LogonType.store_mailbox.FolderIds[9]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_SEARCH, &response.LogonType.store_mailbox.FolderIds[10]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_VIEWS, &response.LogonType.store_mailbox.FolderIds[11]);
- retval = openchangedb_get_SystemFolderID(emsmdbp_ctx->oc_ctx, recipient, EMSMDBP_SHORTCUTS, &response.LogonType.store_mailbox.FolderIds[12]);
-
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_ROOT_FOLDER, &response.LogonType.store_mailbox.FolderIds[0]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_DEFERRED_ACTIONS, &response.LogonType.store_mailbox.FolderIds[1]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_SPOOLER_QUEUE, &response.LogonType.store_mailbox.FolderIds[2]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_IPM_SUBTREE, &response.LogonType.store_mailbox.FolderIds[3]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_INBOX, &response.LogonType.store_mailbox.FolderIds[4]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_OUTBOX, &response.LogonType.store_mailbox.FolderIds[5]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_SENT_ITEMS, &response.LogonType.store_mailbox.FolderIds[6]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_DELETED_ITEMS, &response.LogonType.store_mailbox.FolderIds[7]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_COMMON_VIEWS, &response.LogonType.store_mailbox.FolderIds[8]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_SCHEDULE, &response.LogonType.store_mailbox.FolderIds[9]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_SEARCH, &response.LogonType.store_mailbox.FolderIds[10]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_VIEWS, &response.LogonType.store_mailbox.FolderIds[11]);
+ mapistore_get_SystemFolderID(emsmdbp_ctx->mstore_ctx, recipient, MDB_SHORTCUTS, &response.LogonType.store_mailbox.FolderIds[12]);
+
+ DEBUG(0, ("[%s] Finished with system folder ids: 0x%016"PRIx64"\n", __FUNCTION__, response.LogonType.store_mailbox.FolderIds[0]));
/* Step 4. Set ResponseFlags */
response.LogonType.store_mailbox.ResponseFlags = ResponseFlags_Reserved | ResponseFlags_OwnerRight | ResponseFlags_SendAsRight;
+#if 0
+ /* TODO */
/* Step 5. Retrieve MailboxGuid */
- retval = openchangedb_get_MailboxGuid(emsmdbp_ctx->oc_ctx, recipient, &response.LogonType.store_mailbox.MailboxGuid);
+ mapistore_get_MailboxGuid(emsmdbp_ctx->mstore_ctx, recipient, &response.LogonType.store_mailbox.MailboxGuid);
/* Step 6. Retrieve mailbox replication information */
- retval = openchangedb_get_MailboxReplica(emsmdbp_ctx->oc_ctx, recipient,
+ mapistore_get_MailboxReplica(emsmdbp_ctx->mstore_ctx, recipient,
&response.LogonType.store_mailbox.ReplId,
&response.LogonType.store_mailbox.ReplGUID);
+#endif
/* Step 7. Set LogonTime both in openchange dispatcher database and reply */
t = time(NULL);
#include <Python.h>
#include "mapiproxy/libmapistore/mapistore.h"
+#include "mapiproxy/libmapistore/mapistore_private.h"
typedef struct {
PyObject_HEAD
DEBUG(0, ("[py_MAPIStoreDB_newdefaultdolder] name = %s\n", name));
DEBUG(0, ("[py_MAPIStoreDB_newdefaultdolder] mapistore_uri = %s\n", mapistore_uri));
- return PyInt_FromLong(mapistoredb_add_mailbox_folder(self->mdb_ctx, contextID, index,
- name, mapistore_uri));
+ return PyInt_FromLong(mapistore_root_mkdir(self->mdb_ctx->mstore_ctx, contextID, index, 0, name, mapistore_uri));
}
static int PyMAPIStoreDB_setParameter(PyObject *_self, PyObject *value, void *data)
import os
import openchange
import openchange.mapistoredb as mapistoredb
+import openchange.mapistore as mapistore
+from openchange import mapi
os.mkdir("/tmp/mapistoredb");
print "D. Create a new system/special default folder"
print "---------------------------------------------"
MAPIStoreDB.newdefaultfolder(contextID, mapistoredb.IPM_SUBTREE, "test", "mstoredb://")
+
+print "[Step 7]. Testing mapistore tie-in"
+print "=================================="
+
+print "A. Testing mkdir"
+MAPIStore = mapistore.mapistore()
+mapistore.set_mapping_path("/tmp/mapistore")
+ctx_id = MAPIStore.add_context("openchange", "mstoredb://CN=openchange2,CN=OpenChange Development Unit,CN=OpenChange Project,CN=server,CN=kubuntu1010")
+SPropValue = mapi.SPropValue()
+SPropValue.add(mapi.PR_PARENT_FID, 0x0000000000035001)
+SPropValue.add(mapi.PR_DISPLAY_NAME, "test")
+SPropValue.add(mapi.PR_COMMENT, "test folder")
+SPropValue.add(mapi.PR_FOLDER_TYPE, 1)
+MAPIStore.mkdir(contextID2, 0x0000000000035001, 0x0000000000036001, SPropValue)