Some interim work on GetPropertiesSpecific call.
authorbradh <bradh@71d39326-ef09-db11-b2a4-00e04c779ad1>
Wed, 5 Jan 2011 09:01:23 +0000 (09:01 +0000)
committerbradh <bradh@71d39326-ef09-db11-b2a4-00e04c779ad1>
Wed, 5 Jan 2011 09:01:23 +0000 (09:01 +0000)
git-svn-id: https://svn.openchange.org/openchange@2475 71d39326-ef09-db11-b2a4-00e04c779ad1

branches/mapistore_v2/mapiproxy/libmapistore/backends/mapistore_mstoredb.c
branches/mapistore_v2/mapiproxy/libmapistore/tests/mapistore_provision.c
branches/mapistore_v2/mapiproxy/servers/default/emsmdb/dcesrv_exchange_emsmdb.h
branches/mapistore_v2/mapiproxy/servers/default/emsmdb/emsmdbp_object.c
branches/mapistore_v2/mapiproxy/servers/default/emsmdb/oxcprpt.c
branches/mapistore_v2/mapiproxy/servers/default/emsmdb/oxcstor.c

index 8cd4f010aca985f8712d99d9b49647af08af9e56..b7d7cea19f8f0d69031aec6648aef3406eaa82c9 100644 (file)
@@ -475,7 +475,7 @@ static enum MAPISTORE_ERROR mstoredb_op_getprops(void *private_data, uint64_t fm
        }
 
        /* extract results and return them */
-       /* TODO: this needs to be completed */
+       /* TODO: this needs to be completed, and to handle the case where we don't find the property */
        for (i = 0; i < proptags->cValues; ++i) {
                struct SPropValue               prop;
                prop.ulPropTag = proptags->aulPropTag[i];
@@ -483,6 +483,12 @@ static enum MAPISTORE_ERROR mstoredb_op_getprops(void *private_data, uint64_t fm
                case PT_SHORT:
                        prop.value.i = ldb_msg_find_attr_as_uint(res->msgs[0], get_proptag_name(proptags->aulPropTag[i]), 0);
                        break;
+               case PT_STRING8:
+                       prop.value.lpszA = ldb_msg_find_attr_as_string(res->msgs[0], get_proptag_name(proptags->aulPropTag[i]), NULL);
+                       break;
+               case PT_UNICODE:
+                       prop.value.lpszW = ldb_msg_find_attr_as_string(res->msgs[0], get_proptag_name(proptags->aulPropTag[i]), NULL);
+                       break;
                case PT_I8:
                        prop.value.d = ldb_msg_find_attr_as_uint64(res->msgs[0], get_proptag_name(proptags->aulPropTag[i]), 0);
                        break;
index bbb0864e0e020e405807984751be30b885793214..da2984c02a73bddf87f88ca4407153c839242535 100644 (file)
@@ -1,9 +1,10 @@
 /*
-   OpenChange Storage Abstraction Layer library test tool
+   OpenChange Storage Abstraction Layer library provisioning test tool
 
    OpenChange Project
 
    Copyright (C) Julien Kerihuel 2009
+   Copyright (C) Brad Hards <bradh@openchange.org> 2010
 
    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
@@ -161,13 +162,15 @@ static int do_user_mailbox(TALLOC_CTX *mem_ctx, const char *username, const char
        }
        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); 
+       retval = mapistore_get_context_fid(mstoredb_ctx->mstore_ctx, mailbox_context_id, &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)));
+               DEBUG(0, ("mapistore_get_context_fid() 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));
 
+       // TODO: retval = mapistore_indexing_record_get_fid() somehow
+       
        add_special_folders(mstoredb_ctx->mstore_ctx, mailbox_context_id, mailbox_root_fid);
 
        mapistoredb_release(mstoredb_ctx);
index 328e14ab3b7eb0a98730648d43b848cbcb3e4af5..040f8adeae0c033a4c37f5ef53317f88709fd302 100644 (file)
@@ -73,8 +73,10 @@ enum emsmdbp_object_type {
        EMSMDBP_OBJECT_STREAM           = 0x5
 };
 
+/* TODO: perhaps we could merge mailbox and folder */
 struct emsmdbp_object_mailbox {
        uint64_t                        folderID;
+       uint32_t                        contextID;
        char                            *owner_Name;
        char                            *owner_EssDN;
        char                            *szUserDN;
@@ -184,7 +186,7 @@ bool                      emsmdbp_is_mailboxstore(struct mapi_handles *);
 uint32_t             emsmdbp_get_contextID(struct mapi_handles *);
 struct mapi_handles   *emsmdbp_object_get_folder_handle_by_fid(struct mapi_handles_context *, uint64_t);
 struct emsmdbp_object *emsmdbp_object_init(TALLOC_CTX *, struct emsmdbp_context *);
-struct emsmdbp_object *emsmdbp_object_mailbox_init(TALLOC_CTX *, struct emsmdbp_context *, struct EcDoRpc_MAPI_REQ *, bool);
+struct emsmdbp_object *emsmdbp_object_mailbox_init(TALLOC_CTX *, struct emsmdbp_context *, struct EcDoRpc_MAPI_REQ *, uint64_t, bool);
 struct emsmdbp_object *emsmdbp_object_folder_init(TALLOC_CTX *, struct emsmdbp_context *, uint64_t, struct mapi_handles *);
 struct emsmdbp_object *emsmdbp_object_table_init(TALLOC_CTX *, struct emsmdbp_context *, struct mapi_handles *);
 struct emsmdbp_object *emsmdbp_object_message_init(TALLOC_CTX *, struct emsmdbp_context *, uint64_t, struct mapi_handles *);
index f28c7e94d672604e91b57806972d00c84b288b5d..886f309a51a7802b7d88ad2b710a97e3f65df622 100644 (file)
@@ -140,7 +140,7 @@ uint32_t emsmdbp_get_contextID(struct mapi_handles *handles)
 
        switch (object->type) {
        case EMSMDBP_OBJECT_MAILBOX:
-               return -1;
+               return object->object.mailbox->contextID;
        case EMSMDBP_OBJECT_FOLDER:
                return object->object.folder->contextID;
        case EMSMDBP_OBJECT_MESSAGE:
@@ -254,6 +254,7 @@ _PUBLIC_ struct emsmdbp_object *emsmdbp_object_init(TALLOC_CTX *mem_ctx, struct
    \param mem_ctx pointer to the memory context
    \param emsmdbp_ctx pointer to the emsmdb provider context
    \param request pointer to the Logon MAPI request
+   \param folderID the folderID of the mailbox root
    \param mailboxstore boolean which specifies whether the mailbox
    object is a PF store or a private mailbox store
 
@@ -262,6 +263,7 @@ _PUBLIC_ struct emsmdbp_object *emsmdbp_object_init(TALLOC_CTX *mem_ctx, struct
 _PUBLIC_ struct emsmdbp_object *emsmdbp_object_mailbox_init(TALLOC_CTX *mem_ctx,
                                                            struct emsmdbp_context *emsmdbp_ctx,
                                                            struct EcDoRpc_MAPI_REQ *request,
+                                                           uint64_t folderID,
                                                            bool mailboxstore)
 {
        struct emsmdbp_object           *object;
@@ -288,9 +290,10 @@ _PUBLIC_ struct emsmdbp_object *emsmdbp_object_mailbox_init(TALLOC_CTX *mem_ctx,
        object->object.mailbox->owner_Name = NULL;
        object->object.mailbox->owner_EssDN = NULL;
        object->object.mailbox->szUserDN = NULL;
-       object->object.mailbox->folderID = 0x0;
+       object->object.mailbox->folderID = folderID;
+       object->object.mailbox->contextID = -1;
        object->object.mailbox->mailboxstore = mailboxstore;
-
+       
        if (mailboxstore == true) {
                object->object.mailbox->owner_EssDN = talloc_strdup(object->object.mailbox, 
                                                                    request->u.mapi_Logon.EssDN);
index 81cfd17429c76798c92446730b65c8ef3815c27d..6326d70803c2d4a44eb6c16a9da84c6a5afd295c 100644 (file)
@@ -30,6 +30,7 @@
 #include "mapiproxy/libmapiserver/libmapiserver.h"
 #include "dcesrv_exchange_emsmdb.h"
 
+/* TODO: all of the GetPropertiesSpecific code could probably become an single function */
 /**
    \details Retrieve properties on a mapistore object
    
@@ -37,7 +38,7 @@
    \param emsmdbp_ctx pointer to the emsmdb provider context
    \param request GetProps request
    \param response pointer to the GetProps reply
-   \param private_data pointer tot eh private data stored for this
+   \param private_data pointer to the private data stored for this
    object
 
    \note We do not handle anything yet. This is just a skeleton.
@@ -65,28 +66,39 @@ static enum MAPISTATUS RopGetPropertiesSpecific_mapistore(TALLOC_CTX *mem_ctx,
        object = (struct emsmdbp_object *) private_data;
        if (object) {
                switch (object->type) {
+               case EMSMDBP_OBJECT_MAILBOX:
+                       DEBUG(0, ("[%s] object type mailbox, contextID: 0x%x\n", __FUNCTION__, object->object.mailbox->contextID));
+                       contextID = object->object.mailbox->contextID;
+                       fmid  = object->object.folder->folderID;
+                       type = MAPISTORE_FOLDER;
+                       break;
                case EMSMDBP_OBJECT_FOLDER:
+                       DEBUG(0, ("[%s] object type folder\n", __FUNCTION__));
                        /* contextID = object->object.folder->contextID; */
                        /* fmid = object->object.folder->folderID; */
                        /* type = MAPISTORE_FOLDER; */
                        break;
                case EMSMDBP_OBJECT_MESSAGE:
+                       DEBUG(0, ("[%s] object type message\n", __FUNCTION__));
                        contextID = object->object.message->contextID;
                        fmid = object->object.message->messageID;
                        type = MAPISTORE_MESSAGE;
                        break;
                default:
+                       DEBUG(0, ("[%s] object type unknown: %i\n", __FUNCTION__, object->type));
                        break;
                }
        }
 
        SPropTagArray.cValues = request.prop_count;
        SPropTagArray.aulPropTag = request.properties;
+       mapidump_SPropTagArray(&SPropTagArray);
 
        if (contextID != -1) {
                aRow = talloc_zero(mem_ctx, struct SRow);
                aRow->cValues = 0;
                mapistore_getprops(emsmdbp_ctx->mstore_ctx, contextID, fmid, type, &SPropTagArray, aRow);
+               mapidump_SRow(aRow, "\t");
                /* Check if we need the layout */
                for (i = 0; i < request.prop_count; i++) {
                        for (j = 0; j < aRow->cValues; j++) {
@@ -130,7 +142,7 @@ static enum MAPISTATUS RopGetPropertiesSpecific_mapistore(TALLOC_CTX *mem_ctx,
        return MAPI_E_SUCCESS;
 }
 
-
+#if 0
 /**
    \details Retrieve properties on a mailbox object.
 
@@ -322,7 +334,7 @@ static enum MAPISTATUS RopGetPropertiesSpecific_SystemSpecialFolder(TALLOC_CTX *
 
        return MAPI_E_SUCCESS;
 }
-
+#endif
 
 /**
    \details EcDoRpc GetPropertiesSpecific (0x07) Rop. This operation
@@ -381,6 +393,7 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopGetPropertiesSpecific(TALLOC_CTX *mem_ctx,
 
        retval = mapi_handles_get_private_data(rec, &private_data);
 
+#if 0
        mapistore = emsmdbp_is_mapistore(rec);
        /* Nasty hack */
        if (!private_data) {
@@ -411,12 +424,14 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopGetPropertiesSpecific(TALLOC_CTX *mem_ctx,
                        }
                        break;
                case true:
+#endif
                        /* folder or messages handled by mapistore */
                        retval = RopGetPropertiesSpecific_mapistore(mem_ctx, emsmdbp_ctx, request, &response, private_data);
+#if 0
                        break;
                }
        }
-
+#endif
        mapi_repl->error_code = MAPI_E_SUCCESS;
        mapi_repl->u.mapi_GetProps = response;
 
index ec1e3a5232bbf3935e735f2c94a7f0f8114d3223..de8055a75319c9cf4c7cd848942a9d3e9f0225e8 100644 (file)
@@ -44,13 +44,17 @@ int lpcfg_server_role(struct loadparm_context *lp_ctx);
    \param mapi_req pointer to the RopLogon EcDoRpc_MAPI_REQ structure
    \param mapi_repl pointer to the RopLogon EcDoRpc_MAPI_REPL
    structure the function returns
+   \param context_id the context_id assocaited with the root folder
+   \param root_fid the mailbox root folder ID.
 
    \return MAPI_E_SUCCESS on success, otherwise MAPI error
  */
 static enum MAPISTATUS RopLogon_Mailbox(TALLOC_CTX *mem_ctx,
                                        struct emsmdbp_context *emsmdbp_ctx,
                                        struct EcDoRpc_MAPI_REQ *mapi_req,
-                                       struct EcDoRpc_MAPI_REPL *mapi_repl)
+                                       struct EcDoRpc_MAPI_REPL *mapi_repl,
+                                       uint32_t *context_id,
+                                       uint64_t *root_fid)
 {
        enum MAPISTATUS         retval;
        char                    *recipient;
@@ -59,8 +63,7 @@ static enum MAPISTATUS RopLogon_Mailbox(TALLOC_CTX *mem_ctx,
        struct tm               *LogonTime;
        time_t                  t;
        NTTIME                  nttime;
-       uint32_t                context_id;
-       TALLOC_CTX              *ou_subcontext = talloc_init(mem_ctx);
+       TALLOC_CTX              *ou_subcontext = talloc_new(mem_ctx);
        char                    *domaindn = NULL;
        const char              *firstorgdn = NULL;
        const char              *uri = NULL;
@@ -106,7 +109,7 @@ static enum MAPISTATUS RopLogon_Mailbox(TALLOC_CTX *mem_ctx,
                                                     domaindn));
        uri = talloc_asprintf(mem_ctx, MDB_MAILBOX_TMPL_URI, recipient, firstorgdn);
 
-       retval = mapistore_add_context(emsmdbp_ctx->mstore_ctx, recipient, uri, &context_id);
+       retval = mapistore_add_context(emsmdbp_ctx->mstore_ctx, recipient, uri, context_id);
        talloc_free(ou_subcontext);
        talloc_free((TALLOC_CTX*)uri);
 
@@ -119,20 +122,21 @@ static enum MAPISTATUS RopLogon_Mailbox(TALLOC_CTX *mem_ctx,
        response.LogonFlags = request.LogonFlags;
 
        /* Build FolderIds list */
-       mstore_retval = mapistore_get_SystemFolderIDs(emsmdbp_ctx->mstore_ctx, context_id, &(response.LogonType.store_mailbox.FolderIds));
+       mstore_retval = mapistore_get_SystemFolderIDs(emsmdbp_ctx->mstore_ctx, *context_id, &(response.LogonType.store_mailbox.FolderIds));
        if (mstore_retval != MAPISTORE_SUCCESS) {
                DEBUG(0, ("[%s] failed to fetch system folder IDs: 0x%08x\n", __FUNCTION__, mstore_retval));
                return MAPI_E_NOT_FOUND;
        }
+       *root_fid = response.LogonType.store_mailbox.FolderIds[0];
 
        /* Set ResponseFlags */
        response.LogonType.store_mailbox.ResponseFlags = ResponseFlags_Reserved | ResponseFlags_OwnerRight | ResponseFlags_SendAsRight;
 
        /* Retrieve MailboxGuid */
-       mapistore_get_MailboxGuid(emsmdbp_ctx->mstore_ctx, context_id, &response.LogonType.store_mailbox.MailboxGuid);
+       mapistore_get_MailboxGuid(emsmdbp_ctx->mstore_ctx, *context_id, &response.LogonType.store_mailbox.MailboxGuid);
 
        /* Retrieve mailbox replication information */
-       mapistore_get_MailboxReplica(emsmdbp_ctx->mstore_ctx, context_id,
+       mapistore_get_MailboxReplica(emsmdbp_ctx->mstore_ctx, *context_id,
                                                 &response.LogonType.store_mailbox.ReplId,
                                                 &response.LogonType.store_mailbox.ReplGUID);
 
@@ -236,6 +240,8 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopLogon(TALLOC_CTX *mem_ctx,
        struct mapi_handles             *rec = NULL;
        struct emsmdbp_object           *object;
        bool                            mailboxstore = true;
+       uint32_t                        context_id = 0;
+       uint64_t                        root_fid = 0;
 
        DEBUG(4, ("exchange_emsmdb: [OXCSTOR] Logon (0xFE)\n"));
 
@@ -253,7 +259,7 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopLogon(TALLOC_CTX *mem_ctx,
        mapi_repl->handle_idx = mapi_req->handle_idx;
 
        if (request.LogonFlags & LogonPrivate) {
-               retval = RopLogon_Mailbox(mem_ctx, emsmdbp_ctx, mapi_req, mapi_repl);
+               retval = RopLogon_Mailbox(mem_ctx, emsmdbp_ctx, mapi_req, mapi_repl, &context_id, &root_fid);
                mapi_repl->error_code = retval;
                *size = libmapiserver_RopLogon_size(mapi_req, mapi_repl);
        } else {
@@ -265,7 +271,8 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopLogon(TALLOC_CTX *mem_ctx,
 
        if (!mapi_repl->error_code) {
                retval = mapi_handles_add(emsmdbp_ctx->handles_ctx, 0, &rec);
-               object = emsmdbp_object_mailbox_init((TALLOC_CTX *)rec, emsmdbp_ctx, mapi_req, mailboxstore);
+               object = emsmdbp_object_mailbox_init((TALLOC_CTX *)rec, emsmdbp_ctx, mapi_req, root_fid, mailboxstore);
+               object->object.mailbox->contextID = context_id;
                retval = mapi_handles_set_private_data(rec, object);
 
                handles[mapi_repl->handle_idx] = rec->handle;