mapiproxy/libmapistore/mapistore_backend_public.po \
mapiproxy/libmapistore/database/mapistoredb.po \
mapiproxy/libmapistore/database/mapistoredb_conf.po \
+ mapiproxy/libmapistore/database/mapistoredb_namedprops.po \
libmapi.$(SHLIBEXT).$(PACKAGE_VERSION)
@echo "Linking $@"
@$(CC) -o $@ $(DSOOPT) $^ -L. $(LDFLAGS) $(LIBS) $(TDB_LIBS) $(DL_LIBS) -Wl,-soname,libmapistore.$(SHLIBEXT).$(LIBMAPISTORE_SO_VERSION)
sambaprefix=@sambaprefix@
DSOOPT=-shared -fPIC
-CFLAGS=@CFLAGS@ @COMPILER_OPTIONS_C@ @ASSERT_DEFINITION@ @SUBUNIT_CFLAGS@ \
- -DDEFAULT_LDIF=\"$(datadir)/setup/profiles\" \
- -DMAPISTORE_LDIF=\"$(datadir)/setup/mapistore\" \
- -DMAPISTORE_BACKEND_INSTALLDIR=\"$(libdir)/mapistore_backends\" \
- -DMAPISTORE_MAPPING_PATH=\"$(prefix)/private/mapistore\" \
- -DMAPISTORE_DBPATH=\"$(prefix)/private/mapistore/mapistore.ldb\" \
- -DLZXPRESS_DATADIR=\"$(datadir)/mapitest/lzxpress\" \
+CFLAGS=@CFLAGS@ @COMPILER_OPTIONS_C@ @ASSERT_DEFINITION@ @SUBUNIT_CFLAGS@ \
+ -DDEFAULT_LDIF=\"$(datadir)/setup/profiles\" \
+ -DMAPISTORE_LDIF=\"$(datadir)/setup/mapistore\" \
+ -DMAPISTORE_BACKEND_INSTALLDIR=\"$(libdir)/mapistore_backends\" \
+ -DMAPISTORE_MAPPING_PATH=\"$(prefix)/private/mapistore\" \
+ -DMAPISTORE_DBPATH=\"$(prefix)/private/mapistore/mapistore.ldb\" \
+ -DMAPISTORE_DB_NAMEDPROPS_PATH=\"$(prefix)/private/mapistore/mapistore_named_properties.ldb\" \
+ -DLZXPRESS_DATADIR=\"$(datadir)/mapitest/lzxpress\" \
-DLZFU_DATADIR=\"$(datadir)/mapitest/lzfu\"
# This value should be determined by configure at some point
./libmapi/conf/mparse.pl --parser=mapicodes --outputdir=libmapi/ libmapi/conf/mapi-codes
./libmapi/conf/mparse.pl --parser=codepage_lcid --outputdir=libmapi/ libmapi/conf/codepage-lcid
-./libmapi/conf/mparse.pl --parser=mapistore_namedprops --outputdir=setup/mapistore/ libmapi/conf/mapi-named-properties
./libmapi/conf/mparse.pl --parser=pymapi_properties --outputdir=pyopenchange/ libmapi/conf/mapi-properties
\ No newline at end of file
close(FILE);
}
-#####################################################################
-# generate mapitags.h file
-sub mapitags_header($)
-{
- my $contents = shift;
- my $line;
- my @lines;
- my @prop;
- my $prop_type;
- my $prop_value;
-
- mparse "/* parser auto-generated by mparse */";
- mparse "#ifndef __MAPITAGS_H__";
- mparse "#define __MAPITAGS_H__";
- mparse "";
-
- @lines = split(/\n/, $contents);
- foreach $line (@lines) {
- $line =~ s/^\#+.*$//;
- if ($line) {
- @prop = split(/\s+/, $line);
- $prop_type = hex $prop[0];
- $prop_type &= 0xFFFF;
- $prop_value = hex $prop[0];
- $prop_value = ($prop_value >> 16) & 0xFFFF;
-
- mparse sprintf "#define %-51s PROP_TAG(%-13s, 0x%.04x) /* %s */", $prop[1], $prop_types{$prop_type}, $prop_value, $prop[0] if ($prop_types{$prop_type});
- if (($prop_type == 0x1e) || ($prop_type == 0x101e)){
- $prop_type++;
- $prop[0] = sprintf "0x%.8x", ((hex $prop[0]) & 0xFFFF0000) + $prop_type;
- mparse sprintf "#define %-51s PROP_TAG(%-13s, 0x%.04x) /* %s */", "$prop[1]_UNICODE", $prop_types{$prop_type}, $prop_value, $prop[0] if ($prop_types{$prop_type});
- }
- $prop_type = 0xa;
- $prop[0] = sprintf "0x%.8x", ((hex $prop[0]) & 0xFFFF0000) + $prop_type;
- mparse sprintf "#define %-51s PROP_TAG(%-13s, 0x%.04x) /* %s */", "$prop[1]_ERROR", $prop_types{$prop_type}, $prop_value, $prop[0] if ($prop_types{$prop_type});
- }
- }
- mparse "";
- mparse "#endif /* !__MAPITAGS_H__ */";
-
- return $ret;
-
-}
-
-
-#####################################################################
-# generate mapitags.c file
-sub mapitags_interface($)
-{
- my $contents = shift;
- my $line;
- my @lines;
- my @prop;
- my $prop_type;
- my $prop_value;
-
- mparse "/* parser auto-generated by mparse */";
- mparse "#include \"libmapi/libmapi.h\"";
- mparse "#include \"libmapi/libmapi_private.h\"";
- mparse "#include \"gen_ndr/ndr_exchange.h\"";
- mparse "#include \"libmapi/mapitags.h\"";
- mparse "";
- mparse "struct mapi_proptags";
- mparse "{";
- indent;
- mparse "uint32_t proptag;";
- mparse "uint32_t proptype;";
- mparse "const char *propname;";
- deindent;
- mparse "};";
- mparse "";
- mparse "static struct mapi_proptags mapitags[] = {";
- indent;
-
- @lines = split(/\n/, $contents);
- foreach $line (@lines) {
- $line =~ s/^\#+.*$//;
- if ($line) {
- @prop = split(/\s+/, $line);
- $prop_type = hex $prop[0];
- $prop_type &= 0xFFFF;
- $prop_value = hex $prop[0];
- $prop_value = ($prop_value >> 16) & 0xFFFF;
- if ($prop_types{$prop_type}) {
- mparse sprintf "{ %-51s, %-13s, \"%s\" },", $prop[1], $prop_types{$prop_type}, $prop[1];
- if (($prop_type == 0x1e) || ($prop_type == 0x101e)) {
- $prop_type++;
- mparse sprintf "{ %-51s, %-13s, \"%s\" },", "$prop[1]_UNICODE", $prop_types{$prop_type}, "$prop[1]_UNICODE";
- }
- $prop_type = 0xa;
- mparse sprintf "{ %-51s, %-13s, \"%s\" },", "$prop[1]_ERROR", $prop_types{$prop_type}, $prop[1];
- }
- }
- }
-
- mparse sprintf "{ %-51s, %-13d, \"NULL\"}", 0, 0;
- deindent;
- mparse "};";
- mparse "";
- mparse "_PUBLIC_ const char *get_proptag_name(uint32_t proptag)";
- mparse "{";
- indent;
- mparse "uint32_t idx;";
- mparse "";
- mparse "for (idx = 0; mapitags[idx].proptag; idx++) {";
- indent;
- mparse "if (mapitags[idx].proptag == proptag) { ";
- indent;
- mparse "return mapitags[idx].propname;";
- deindent;
- mparse "}";
- deindent;
- mparse "}";
- mparse "";
- mparse "return NULL;";
- deindent;
- mparse "}";
- mparse "";
- mparse "_PUBLIC_ uint32_t get_proptag_value(const char *propname)";
- mparse "{";
- indent;
- mparse "uint32_t idx;";
- mparse "";
- mparse "for (idx = 0; mapitags[idx].proptag; idx++) {";
- indent;
- mparse "if (!strcmp(mapitags[idx].propname, propname)) { ";
- indent;
- mparse "return mapitags[idx].proptag;";
- deindent;
- mparse "}";
- deindent;
- mparse "}";
- mparse "";
- mparse "return 0;";
- deindent;
- mparse "}";
- mparse "";
-
- return $ret;
-
-}
-
-#####################################################################
-# generate mapitags_enum.idl file
-sub mapitags_enum($)
-{
- my $contents = shift;
- my $line;
- my @lines;
- my @prop;
- my $prop_type;
- my %hash;
-
- mparse "/* parser auto-generated by mparse */";
- mparse "";
-
- mparse "typedef [v1_enum, flag(NDR_PAHEX)] enum {";
- indent;
-
- @lines = split(/\n/, $contents);
- foreach $line (@lines) {
- $line =~ s/^\#+.*$//;
- if ($line) {
- @prop = split(/\s+/, $line);
- $prop_type = hex $prop[0];
- $prop_type &= 0xFFFF;
-
- mparse sprintf "%-51s = %s,", $prop[1], $prop[0];
-
- if (($prop_type == 0x1e) || ($prop_type == 0x101e)) {
- $prop_type = hex $prop[0];
- $prop_type++;
- mparse sprintf "%-51s = 0x%.8x,", "$prop[1]_UNICODE", $prop_type;
- }
- if (!exists($hash{((hex $prop[0]) & 0xFFFF0000)})) {
- $prop_type = 0xa;
- $prop_type += ((hex $prop[0]) & 0xFFFF0000);
- mparse sprintf "%-51s = 0x%.8x,", "$prop[1]_ERROR", $prop_type;
- $hash{((hex $prop[0]) & 0xFFFF0000)} = 1;
- }
- }
- }
- mparse sprintf "%-51s = %s", "MAPI_PROP_RESERVED", "0xFFFFFFFF";
- deindent;
- mparse "} MAPITAGS;";
- mparse "";
-
- return $ret;
-}
-
-
-#####################################################################
-# generate mapi_nameid_private.h file
-sub mapi_nameid_private_header($)
-{
- my $contents = shift;
- my $line;
- my @lines;
- my @prop;
- my $prop_OOM;
- my $prop_ID;
- my $prop_Type;
- my $prop_name;
- my $prop_Kind;
- my $prop_OLEGUID;
-
- mparse "/* parser auto-generated by mparse */";
- mparse "#ifndef __MAPI_NAMEID_PRIVATE_H__";
- mparse "#define __MAPI_NAMEID_PRIVATE_H__";
- mparse "";
- mparse "static struct mapi_nameid_tags mapi_nameid_tags[] = {";
- indent;
-
- @lines = split(/\n/, $contents);
- foreach $line (@lines) {
- $line =~ s/^\#+.*$//;
- if ($line) {
- @prop = split(/\s+/, $line);
-
- if ($prop[1] ne "NULL") {
- $prop[1] = sprintf "\"%s\"", $prop[1];
- }
- if ($prop[3] ne "NULL") {
- $prop[3] = sprintf "\"%s\"", $prop[3]
- }
- if ($prop[0] eq "NULL") {
- $prop[0] = "0x00000000";
- }
- mparse sprintf "{ %-51s, %-40s, %-15s, %-30s, %-30s, %-15s, %-20s, 0x0 },",
- $prop[0], $prop[1], $prop[2], $prop[3], $prop[4], $prop[5], $prop[6];
- }
- }
-
- mparse sprintf "{ 0x00000000, NULL, 0x0, NULL, PT_UNSPECIFIED, 0x0, NULL, 0x0 }";
- deindent;
- mparse "};";
- mparse "";
- mparse "#endif /* !MAPI_NAMEID_PRIVATE_H__ */";
-
- return $ret;
-}
-
-#####################################################################
-# generate mapi_nameid.h file
-sub mapi_nameid_header($)
-{
- my $contents = shift;
- my $line;
- my @lines;
- my @prop;
- my $propID;
- my $proptype;
- my $property;
- my $counter = 0;
-
- mparse "/* parser auto-generated by mparse */";
- mparse "#ifndef __MAPI_NAMEID_H__";
- mparse "#define __MAPI_NAMEID_H__";
- mparse "";
-
- mparse "/* NOTE TO DEVELOPERS: If this is a MNID_STRING named property,";
- mparse " * then we use the arbitrary 0xa000-0afff property ID range for";
- mparse " * internal mapping purpose only.";
- mparse " */";
-
- mparse "";
- mparse "struct mapi_nameid_tags {";
- indent;
- mparse "uint32_t proptag;";
- mparse "const char *OOM;";
- mparse "uint16_t lid;";
- mparse "const char *Name;";
- mparse "uint32_t propType;";
- mparse "uint8_t ulKind;";
- mparse "const char *OLEGUID;";
- mparse "uint32_t position;";
- deindent;
- mparse "};";
- mparse "";
- mparse "struct mapi_nameid {";
- indent;
- mparse "struct MAPINAMEID *nameid;";
- mparse "uint16_t count;";
- mparse "struct mapi_nameid_tags *entries;";
- deindent;
- mparse "};";
- mparse "";
-
- @lines = split(/\n/, $contents);
- foreach $line (@lines) {
- $line =~ s/^\#+.*$//;
- if ($line) {
- @prop = split(/\s+/, $line);
- if ($prop[0] ne "NULL") {
- $proptype = $prop_names{$prop[4]};
- $propID = hex $prop[2];
- if ($propID == 0) {
- # 40960 == 0xa000
- $propID = 40960 + $counter;
- $counter++;
- }
- $property = sprintf "0x%.8x", ($propID << 16) | $proptype;
- mparse sprintf "#define %-51s %s", $prop[0], $property;
- }
- }
- }
-
- mparse "";
- mparse "#endif /* !MAPI_NAMEID_H__ */";
-
- return $ret;
-}
-
#####################################################################
# generate mapicode.c file
mparse "}";
}
-
-#####################################################################
-# generate mapistore_namedprops.ldif file
-sub mapistore_namedprops($)
-{
- my $contents = shift;
- my $line;
- my @lines;
- my @prop;
-
- mparse "# LDIF file auto-generated by mparse ";
- mparse "";
-
- mparse sprintf "dn: CN=default";
- mparse sprintf "objectClass: top";
- mparse sprintf "cn: default";
- mparse sprintf "";
-
- mparse sprintf "dn: CN=custom";
- mparse sprintf "objectClass: top";
- mparse sprintf "cn: custom";
- mparse sprintf "";
-
- for my $key ( keys %oleguid ) {
- my $value = $oleguid{$key};
-
- mparse sprintf "dn: CN=%s,CN=default", $value;
- mparse sprintf "cn: %s", $value;
- mparse sprintf "name: %s", $key;
- mparse sprintf "oleguid: %s", $value;
- mparse "";
- }
-
- @lines = split(/\n/, $contents);
- foreach $line (@lines) {
- $line =~ s/^\#+.*$//;
- if ($line) {
- @prop = split(/\s+/, $line);
- if ($prop[5] eq "MNID_ID" && $prop[7]) {
- mparse sprintf "dn: CN=%s,CN=%s,CN=default", $prop[2], $oleguid{$prop[6]};
- mparse sprintf "objectClass: %s", $prop[5];
- mparse sprintf "cn: %s", $prop[2];
- mparse sprintf "canonical: %s", $prop[0];
- mparse sprintf "oleguid: %s", $oleguid{$prop[6]};
- mparse sprintf "mapped_id: %s", $prop[7];
- mparse sprintf "prop_id: %s", $prop[2];
- mparse sprintf "prop_type: %s", $prop_names{$prop[4]};
- mparse sprintf "oom: %s", $prop[1];
- mparse sprintf "";
- } elsif ($prop[5] eq "MNID_STRING" && $prop[7]) {
- mparse sprintf "dn: CN=%s,CN=%s,CN=default", $prop[3], $oleguid{$prop[6]};
- mparse sprintf "objectClass: %s", $prop[5];
- mparse sprintf "cn: %s", $prop[3];
- mparse sprintf "canonical: %s", $prop[0];
- mparse sprintf "oleguid: %s", $oleguid{$prop[6]};
- mparse sprintf "mapped_id: %s", $prop[7];
- mparse sprintf "prop_id: 0x0";
- mparse sprintf "prop_type: %s", $prop[4];
- mparse sprintf "prop_name: %s", $prop[3];
- mparse sprintf "";
- }
- }
- }
- return $ret;
-}
-
sub process_file($)
{
my $mapi_file = shift;
my $contents = FileLoad($mapi_file);
defined $contents || return undef;
-
- if ($opt_parser eq "mapitags") {
- print "Generating $outputdir" . "mapitags.h\n";
- my $parser = ("$outputdir/mapitags.h");
- FileSave($parser, mapitags_header($contents));
-
- print "Generating $outputdir" . "mapitags.c\n";
- $ret = '';
- my $code_parser = ("$outputdir/mapitags.c");
- FileSave($code_parser, mapitags_interface($contents));
-
- print "Generating mapitags_enum.h\n";
- $ret = '';
- my $enum_parser = ("mapitags_enum.h");
- FileSave($enum_parser, mapitags_enum($contents));
- }
-
if ($opt_parser eq "mapicodes") {
print "Generating $outputdir" . "mapicode.c\n";
$ret = '';
FileSave($enum_parser, mapicodes_enum($contents));
}
- if ($opt_parser eq "mapi_nameid") {
- print "Generating $outputdir" . "mapi_nameid_private.h\n";
- $ret = '';
- my $parser = ("$outputdir/mapi_nameid_private.h");
- FileSave($parser, mapi_nameid_private_header($contents));
-
- print "Generating $outputdir" . "mapi_nameid.h\n";
- $ret = '';
- my $nameid_parser = ("$outputdir/mapi_nameid.h");
- FileSave($nameid_parser, mapi_nameid_header($contents));
- }
-
if ($opt_parser eq "codepage_lcid") {
print "Generating $outputdir" . "codepage_lcid.c\n";
$ret = '';
FileSave($openchangedb_parser, openchangedb_property($contents));
}
- if ($opt_parser eq "mapistore_namedprops") {
- print "Generating $outputdir" . "mapistore_namedprops.ldif\n";
- my $mapistore_parser = ("$outputdir/mapistore_namedprops.ldif");
- FileSave($mapistore_parser, mapistore_namedprops($contents));
- }
-
if ($opt_parser eq "pymapi_properties") {
print "Generating $outputdir" . "pymapi_properties.c\n";
my $pymapi_parser = ("$outputdir/pymapi_properties.c");
mapistore_set_database_path(mdb_ctx->param->db_path);
mapistore_set_mapping_path(mdb_ctx->param->mstore_path);
+ mapistore_set_named_properties_database_path(mdb_ctx->param->db_named_path);
mdb_ctx->mstore_ctx = mapistore_init(mdb_ctx, NULL);
if (!mdb_ctx->mstore_ctx) {
DEBUG(5, ("! [%s:%d][%s]: Failed to initialize mapistore context\n", __FILE__, __LINE__, __FUNCTION__));
--- /dev/null
+/*
+ OpenChange Storage Abstraction Layer library
+
+ OpenChange Project
+
+ Copyright (C) Julien Kerihuel 2011
+
+ 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_errors.h"
+#include "mapiproxy/libmapistore/mapistore.h"
+#include "mapiproxy/libmapistore/mapistore_private.h"
+#include "mapiproxy/libmapistore/mapistore_common.h"
+
+/**
+ \file mapistoredb_namedprops.c
+
+ \brief MAPIStore named properties database provisioning interface
+ */
+
+static const char *mapistoredb_namedprops_get_ldif_path(void)
+{
+ return MAPISTORE_LDIF;
+}
+
+
+/**
+ \details Provision the default named properties database for mapistore
+
+ \param mdb_ctx pointer to the mapistore database context
+
+ \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
+ */
+enum MAPISTORE_ERROR mapistoredb_namedprops_provision(struct mapistoredb_context *mdb_ctx)
+{
+ enum MAPISTORE_ERROR retval;
+ TALLOC_CTX *mem_ctx;
+ int ret;
+ struct stat sb;
+ char *ldif;
+
+ /* Sanity checks */
+ MAPISTORE_RETVAL_IF(!mdb_ctx, MAPISTORE_ERR_NOT_INITIALIZED, NULL);
+ MAPISTORE_RETVAL_IF(!mdb_ctx->mstore_ctx, MAPISTORE_ERR_NOT_INITIALIZED, NULL);
+ MAPISTORE_RETVAL_IF(!mdb_ctx->mstore_ctx->mapistore_nprops_ctx, MAPISTORE_ERR_NOT_INITIALIZED, NULL);
+
+ ret = stat(mapistore_get_named_properties_database_path(), &sb);
+ MAPISTORE_RETVAL_IF(ret == -1, MAPISTORE_ERR_DATABASE_INIT, NULL);
+
+ mem_ctx = talloc_named(NULL, 0, "mapistoredb_namedprops_provision");
+ MAPISTORE_RETVAL_IF(!mem_ctx, MAPISTORE_ERR_NO_MEMORY, NULL);
+
+ /* Step 1. Retrieve the path to the LDIF file */
+ ldif = talloc_asprintf(mem_ctx, "%s/%s", mapistoredb_namedprops_get_ldif_path(), MAPISTORE_DB_NAMED_V2_LDIF);
+ ret = stat(ldif, &sb);
+ MAPISTORE_RETVAL_IF(ret == -1, MAPISTORE_ERR_DATABASE_INIT, mem_ctx);
+
+ /* Step 2. Add database schema */
+ retval = mapistore_ldb_write_ldif_string_to_store(mdb_ctx->mstore_ctx->mapistore_nprops_ctx,
+ MDB_NPROPS_INIT_LDIF_TMPL);
+ MAPISTORE_RETVAL_IF(retval, retval, mem_ctx);
+
+ /* Step 3. Add RootDSE schema */
+ retval = mapistore_ldb_write_ldif_string_to_store(mdb_ctx->mstore_ctx->mapistore_nprops_ctx,
+ MDB_NPROPS_ROOTDSE_LDIF_TMPL);
+ MAPISTORE_RETVAL_IF(retval, retval, mem_ctx);
+
+ /* Step 2. Commit the database structure and default set of named properties */
+ retval = mapistore_ldb_write_ldif_file_to_store(mdb_ctx->mstore_ctx->mapistore_nprops_ctx, ldif);
+ MAPISTORE_RETVAL_IF(retval, retval, mem_ctx);
+
+ talloc_free(ldif);
+ talloc_free(mem_ctx);
+
+ return MAPISTORE_SUCCESS;
+}
+
+/**
+ Add an entry for the user within the named properties database
+
+ \param mdb_ctx pointer to the mapistore database context
+ \param username pointer to the username entry to create
+
+ \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
+ */
+enum MAPISTORE_ERROR mapistoredb_namedprops_provision_user(struct mapistoredb_context *mdb_ctx,
+ const char *username)
+{
+ return MAPISTORE_SUCCESS;
+}
+
+enum MAPISTORE_ERROR mapistoredb_namedprops_register_application(struct mapistoredb_context *mdb_ctx,
+ const char *username,
+ const char *app_name,
+ const char *app_GUID,
+ const char *ldif)
+{
+ return MAPISTORE_SUCCESS;
+}
+
+enum MAPISTORE_ERROR mapistoredb_namedprops_unregister_application(struct mapistoredb_context *mdb_ctx,
+ const char *username,
+ const char *app_name,
+ const char *app_GUID,
+ const char *ldif)
+{
+ return MAPISTORE_SUCCESS;
+}
/* MAPISTORE_v2 */
struct mapistore_indexing_context_list *mapistore_indexing_list;
+ struct ldb_context *mapistore_nprops_ctx;
/* !MAPISTORE_v2 */
void *nprops_ctx;
const char* mapistoredb_get_firstorg(struct mapistoredb_context *);
const char* mapistoredb_get_firstou(struct mapistoredb_context *);
+/* definitions from mapistoredb_namedprops.c */
+enum MAPISTORE_ERROR mapistoredb_namedprops_provision(struct mapistoredb_context *);
+enum MAPISTORE_ERROR mapistoredb_namedprops_provision_user(struct mapistoredb_context *, const char *);
+enum MAPISTORE_ERROR mapistoredb_namedprops_register_application(struct mapistoredb_context *, const char *,
+ const char *, const char *, const char *);
+enum MAPISTORE_ERROR mapistoredb_namedprops_unregister_application(struct mapistoredb_context *, const char *,
+ const char *, const char *, const char *);
+
/* definitions from mapistore_indexing.c */
/* MAPISTORE_v1 */
MAPISTORE_ERR_INVALID_OBJECT = 17, /*!< The specified object is invalid */
MAPISTORE_ERR_INVALID_CONTEXT = 18, /*!< The specified context is invalid */
MAPISTORE_ERR_INVALID_URI = 19, /*!< The specified URI is invalid */
+ MAPISTORE_ERR_NOT_IMPLEMENTED = 20, /*!< The function is not implemented */
};
#endif /* ! __MAPISTORE_ERRORS_H */
#include "mapistore.h"
#include "mapistore_private.h"
#include "mapistore_backend.h"
+#include "mapistore_common.h"
#include <dlinklist.h>
#include "libmapi/libmapi_private.h"
retval = mapistore_init_mapping_context(mstore_ctx->processing_ctx);
if (retval != MAPISTORE_SUCCESS) {
- DEBUG(5, ("[%s:%d]: %s\n", __FUNCTION__, __LINE__, mapistore_errstr(retval)));
+ MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL, "mapistore mapping context init failed: %s\n",
+ mapistore_errstr(retval));
talloc_free(mstore_ctx);
return NULL;
}
retval = mapistore_backend_init(mstore_ctx, path);
if (retval != MAPISTORE_SUCCESS) {
- DEBUG(5, ("[%s:%d]: %s\n", __FUNCTION__, __LINE__, mapistore_errstr(retval)));
+ MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL, "mapistore backend init failed: %s\n", mapistore_errstr(retval));
talloc_free(mstore_ctx);
return NULL;
}
/* MAPISTORE_v2 */
mstore_ctx->mapistore_indexing_list = talloc_zero(mstore_ctx, struct mapistore_indexing_context_list);
+
+ mstore_ctx->mapistore_nprops_ctx = NULL;
+ retval = mapistore_namedprops_init(mstore_ctx, &(mstore_ctx->mapistore_nprops_ctx));
+ if (retval != MAPISTORE_SUCCESS) {
+ MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL,
+ "mapistore named properties database init failed: %s\n",
+ mapistore_errstr(retval));
+ talloc_free(mstore_ctx);
+ return NULL;
+ }
/* MAPISTORE_v2 */
- mstore_ctx->nprops_ctx = NULL;
- retval = mapistore_namedprops_init(mstore_ctx, &(mstore_ctx->nprops_ctx));
+ /* mstore_ctx->nprops_ctx = NULL; */
+ /* retval = mapistore_namedprops_init(mstore_ctx, &(mstore_ctx->nprops_ctx)); */
return mstore_ctx;
}
return "Invalid mapistore context";
case MAPISTORE_ERR_INVALID_URI:
return "Invalid mapistore URI";
+ case MAPISTORE_ERR_NOT_IMPLEMENTED:
+ return "Not implemented";
}
return "Unknown error";
#include <sys/stat.h>
-static const char *mapistore_namedprops_get_ldif_path(void)
-{
- return MAPISTORE_LDIF;
-}
-
/**
\details Initialize the named properties database or return pointer
to the existing one if already initialized/opened.
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
*/
-enum MAPISTORE_ERROR mapistore_namedprops_init(TALLOC_CTX *mem_ctx, void **_ldb_ctx)
+enum MAPISTORE_ERROR mapistore_namedprops_init(TALLOC_CTX *mem_ctx, struct ldb_context **_ldb_ctx)
{
- int ret;
struct stat sb;
struct ldb_context *ldb_ctx = NULL;
- struct ldb_ldif *ldif;
- char *filename;
- FILE *f;
struct tevent_context *ev;
char *database;
ev = tevent_context_init(mem_ctx);
MAPISTORE_RETVAL_IF(!ev, MAPISTORE_ERR_NO_MEMORY, NULL);
- database = talloc_asprintf(mem_ctx, "%s/%s", mapistore_get_mapping_path(), MAPISTORE_DB_NAMED);
- DEBUG(0, ("database = %s\n", database));
-
- /* Step 1. Stat the database and populate it if it doesn't exist */
- if (stat(database, &sb) == -1) {
- ldb_ctx = mapistore_ldb_wrap_connect(ldb_ctx, ev, database, 0);
- talloc_free(database);
- MAPISTORE_RETVAL_IF(!ldb_ctx, MAPISTORE_ERR_DATABASE_INIT, NULL);
-
- filename = talloc_asprintf(mem_ctx, "%s/mapistore_namedprops.ldif",
- mapistore_namedprops_get_ldif_path());
- f = fopen(filename, "r");
- talloc_free(filename);
- MAPISTORE_RETVAL_IF(!f, MAPISTORE_ERROR, NULL);
-
- while ((ldif = ldb_ldif_read_file(ldb_ctx, f))) {
- struct ldb_message *normalized_msg;
- ret = ldb_msg_normalize(ldb_ctx, mem_ctx, ldif->msg, &normalized_msg);
- MAPISTORE_RETVAL_IF(ret, MAPISTORE_ERR_DATABASE_INIT, NULL);
- ret = ldb_add(ldb_ctx, normalized_msg);
- talloc_free(normalized_msg);
- if (ret != LDB_SUCCESS) {
- fclose(f);
- MAPISTORE_RETVAL_IF(ret, MAPISTORE_ERR_DATABASE_INIT, NULL);
- }
- ldb_ldif_read_free(ldb_ctx, ldif);
- }
- fclose(f);
-
- } else {
- ldb_ctx = mapistore_ldb_wrap_connect(ldb_ctx, ev, database, 0);
- talloc_free(database);
- MAPISTORE_RETVAL_IF(!ldb_ctx, MAPISTORE_ERR_DATABASE_INIT, NULL);
- }
+ database = talloc_strdup(mem_ctx, mapistore_get_named_properties_database_path());
+ MSTORE_DEBUG_INFO(MSTORE_LEVEL_DEBUG, "Full path to mapistore named properties database is: %s\n",
+ database);
+
+ ldb_ctx = mapistore_ldb_wrap_connect(ldb_ctx, ev, database, 0);
+ talloc_free(database);
+ MAPISTORE_RETVAL_IF(!ldb_ctx, MAPISTORE_ERR_DATABASE_INIT, NULL);
*_ldb_ctx = ldb_ctx;
"mapistore_uri: %s\n" \
"distinguishedName: %s\n"
+/** Named properties database ldif */
+#define MDB_NPROPS_INIT_LDIF_TMPL \
+ "dn: @OPTIONS\n" \
+ "checkBaseOnSearch: TRUE\n\n" \
+ "dn: @INDEXLIST\n" \
+ "@IDXATTR: cn\n" \
+ "@IDXATTR: objectClass\n" \
+ "@IDXATTR: mapped_id\n\n" \
+ "dn: @ATTRIBUTES@\n" \
+ "cn: CASE_INSENSITIVE\n" \
+ "dn: CASE_INSENSITIVE\n\n"
+
+#define MDB_NPROPS_ROOTDSE_LDIF_TMPL \
+ "dn: @ROOTDSE\n" \
+ "defaultNamingContext: DC=server\n" \
+ "rootDomainNamingContext: DC=server\n" \
+ "vendorName: OpenChange Project (http://www.openchange.org)\n\n"
+
+
/**
Identifier mapping context.
#define MAPISTORE_DB_NAMED "named_properties.ldb"
#define MAPISTORE_DB_NAMED_V2 "mapistore_named_properties.ldb"
+#define MAPISTORE_DB_NAMED_V2_LDIF "mapistore_namedprops_v2.ldif"
#define MAPISTORE_DB_INDEXING "indexing.tdb"
#define MAPISTORE_SOFT_DELETED_TAG "SOFT_DELETED:"
/* mapistore_v2 */
enum MAPISTORE_ERROR mapistore_ldb_write_ldif_string_to_store(struct ldb_context *, const char *);
enum MAPISTORE_ERROR mapistore_write_ldif_string_to_store(struct processing_context *, const char *);
+enum MAPISTORE_ERROR mapistore_ldb_write_ldif_file_to_store(struct ldb_context *, const char *);
enum MAPISTORE_ERROR mapistore_get_new_fmid(struct processing_context *, const char *, uint64_t *);
enum MAPISTORE_ERROR mapistore_get_new_allocation_range(struct processing_context *, const char *, uint64_t, uint64_t *, uint64_t *);
enum MAPISTORE_ERROR mapistore_get_mailbox_uri(struct processing_context *, const char *, char **);
/* !MAPISTORE_v2 */
/* definitions from mapistore_namedprops.c */
-enum MAPISTORE_ERROR mapistore_namedprops_init(TALLOC_CTX *, void **);
+enum MAPISTORE_ERROR mapistore_namedprops_init(TALLOC_CTX *, struct ldb_context **);
__END_DECLS
*/
const char *mapistore_get_named_properties_database_path(void)
{
- return (!mapistore_nprops_dbpath) ? NULL : mapistore_nprops_dbpath;
+ return (!mapistore_nprops_dbpath) ? MAPISTORE_DB_NAMEDPROPS_PATH : mapistore_nprops_dbpath;
}
}
+enum MAPISTORE_ERROR mapistore_ldb_write_ldif_file_to_store(struct ldb_context *ldb_ctx, const char *ldif_path)
+{
+ int ret;
+ FILE *f;
+ struct ldb_ldif *ldif;
+ TALLOC_CTX *mem_ctx;
+
+ /* Sanity checks */
+ MAPISTORE_RETVAL_IF(!ldb_ctx, MAPISTORE_ERR_NOT_INITIALIZED, NULL);
+ MAPISTORE_RETVAL_IF(!ldif_path, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
+
+ f = fopen(ldif_path, "r");
+ MAPISTORE_RETVAL_IF(!f, MAPISTORE_ERR_DATABASE_INIT, NULL);
+
+ mem_ctx = talloc_named(NULL, 0, "mapistore_ldb_write_ldif_file_to_store");
+
+ while ((ldif = ldb_ldif_read_file(ldb_ctx, f))) {
+ struct ldb_message *normalized_msg;
+
+ ret = ldb_msg_normalize(ldb_ctx, mem_ctx, ldif->msg, &normalized_msg);
+ MAPISTORE_RETVAL_IF(ret != LDB_SUCCESS, MAPISTORE_ERR_DATABASE_OPS, mem_ctx);
+ ret = ldb_add(ldb_ctx, normalized_msg);
+ if (ret != LDB_SUCCESS) {
+ fclose(f);
+ MAPISTORE_RETVAL_IF(ret != LDB_SUCCESS, MAPISTORE_ERR_DATABASE_OPS, mem_ctx);
+ }
+ ldb_ldif_read_free(ldb_ctx, ldif);
+ talloc_free(normalized_msg);
+ }
+
+ fclose(f);
+ talloc_free(mem_ctx);
+
+ return MAPISTORE_SUCCESS;
+}
+
+
/**
\details Retrieve the next available folder or message identifier
return PyInt_FromLong(mapistoredb_provision(self->mdb_ctx));
}
+static PyObject *py_MAPIStoreDB_provision_named_properties(PyMAPIStoreDBObject *self, PyObject *args)
+{
+ return PyInt_FromLong(mapistoredb_namedprops_provision(self->mdb_ctx));
+}
static PyObject *py_MAPIStoreDB_get_mapistore_uri(PyObject *module, PyObject *args, PyObject *kwargs)
{
static PyMethodDef mapistoredb_methods[] = {
{ "dump_configuration", (PyCFunction)py_MAPIStoreDB_dump_configuration, METH_VARARGS },
{ "provision", (PyCFunction)py_MAPIStoreDB_provision, METH_KEYWORDS },
+ { "provision_named_properties", (PyCFunction)py_MAPIStoreDB_provision_named_properties, METH_VARARGS },
{ "get_mapistore_uri", (PyCFunction)py_MAPIStoreDB_get_mapistore_uri, METH_KEYWORDS },
{ "get_new_fid", (PyCFunction)py_MAPIStoreDB_get_new_fid, METH_VARARGS },
{ "get_new_allocation_range", (PyCFunction)py_MAPIStoreDB_get_new_allocation_range, METH_VARARGS },
username = "jkerihuel"
indent = 1
+title_nb = 1
os.mkdir("/tmp/mapistoredb");
def newTitle(title, separator):
+ global title_nb
+ ftitle = "[Step %d]. %s" % (title_nb, title)
print ""
- print "%s" % title
- print separator * len(title)
+ print ftitle
+ print separator * len(ftitle)
+ title_nb += 1
def TreeRoot(name):
print ""
indent -= 1
def start():
- newTitle("[Step 1]. Initializing mapistore database", '=')
+ newTitle("Initializing mapistore database", '=')
MAPIStoreDB = mapistoredb.mapistoredb("/tmp/mapistoredb")
- newTitle("[Step 2]. Provisioning mapistore database", '=')
+ newTitle("Provisioning mapistore database", '=')
ret = MAPIStoreDB.provision(netbiosname = "server",
firstorg = "OpenChange Project",
firstou = "OpenChange Development Unit")
if (ret == 0):
print "\t* Provisioning: SUCCESS"
else:
- print "\t* Provisioning: FAILURE"
+ print "\t* Provisioning: FAILURE (ret = %d)" % ret
- newTitle("[Step 3]. Create a new mailbox", '=')
+ newTitle("Create mapistore named properties database", '=')
+ ret = MAPIStoreDB.provision_named_properties()
+ if (ret == 0):
+ print "\t* Provisioning: SUCCESS"
+ else:
+ print "\t* Provisioning: FAILURE (ret = %d)" % ret
+
+ newTitle("Create a new mailbox", '=')
mailbox_root = MAPIStoreDB.get_mapistore_uri(folder=mapistoredb.MDB_ROOT_FOLDER,
username=username,
namespace="mstoredb://")
retval = MAPIStoreDB.new_mailbox(username, mailbox_root)
print "\t* Mailbox Root: %s" % mailbox_root
- newTitle("[Step 4]. Get and Set a new allocation range to the mailbox", '=')
+ newTitle("Get and Set a new allocation range to the mailbox", '=')
(retval, rstart,rend) = MAPIStoreDB.get_new_allocation_range(username,
0x1000);
if retval == 0:
else:
print "\t * Error while setting allocation range to the mailbox"
- newTitle("[Step 5]. Uninitializing mapistore database context", '=')
+ newTitle("Uninitializing mapistore database context", '=')
MAPIStoreDB.release()
- newTitle("[Step 6]. Initializing mapistore context", '=')
+ newTitle("Initializing mapistore context", '=')
mapistore.set_mapping_path("/tmp/mapistoredb/mapistore")
MAPIStore = mapistore.mapistore()
- newTitle("[Step 7]. Adding a context over Mailbox Root Folder", '=')
+ newTitle("Adding a context over Mailbox Root Folder", '=')
context_id = MAPIStore.add_context(username, mailbox_root)
print "\t* context_id = %s" % context_id
- newTitle("[Step 8]. Create the mailbox hierarchy", '=')
+ newTitle("Create the mailbox hierarchy", '=')
TreeRoot("Mailbox Root Folder")
folder_name="")
TreeLeafStatus("Reminders", retval)
- newTitle("[Step 9]. Setting mailbox folders to fsocpf", '=')
+ newTitle("Setting mailbox folders to fsocpf", '=')
new_uri = MAPIStore.get_mapistore_uri(mapistoredb.MDB_INBOX,
username,
"fsocpf://")