PoC: implemented poc methods for "release", "get_attachment_table", "get_attachment...
authorwsourdeau <wsourdeau@71d39326-ef09-db11-b2a4-00e04c779ad1>
Thu, 24 Feb 2011 18:50:04 +0000 (18:50 +0000)
committerwsourdeau <wsourdeau@71d39326-ef09-db11-b2a4-00e04c779ad1>
Thu, 24 Feb 2011 18:50:04 +0000 (18:50 +0000)
git-svn-id: https://svn.openchange.org/openchange@2687 71d39326-ef09-db11-b2a4-00e04c779ad1

branches/sogo/mapiproxy/libmapistore/mapistore.h
branches/sogo/mapiproxy/libmapistore/mapistore_backend.c
branches/sogo/mapiproxy/libmapistore/mapistore_interface.c
branches/sogo/mapiproxy/libmapistore/mapistore_private.h

index 49e57ea116a0117ecd395301807fd52bb6d39713..7becb913d255e117866e5f6d90f65509a5c0c5c5 100644 (file)
@@ -58,6 +58,7 @@ typedef       int (*init_backend_fn) (void);
 
 #define MAPISTORE_FOLDER       1
 #define        MAPISTORE_MESSAGE       2
+#define        MAPISTORE_ATTACHMENT    3
 
 #define        MAPISTORE_SOFT_DELETE           1
 #define        MAPISTORE_PERMANENT_DELETE      2
@@ -77,6 +78,12 @@ enum table_query_type {
        MAPISTORE_LIVEFILTERED_QUERY,
 };
 
+/* proof of concept: a new structure to simplify property queries */
+struct mapistore_property_data {
+        void *data;
+        int error; /* basically MAPISTORE_SUCCESS or MAPISTORE_ERR_NOT_FOUND */
+};
+
 struct mapistore_backend {
        const char      *name;
        const char      *description;
@@ -112,6 +119,35 @@ struct mapistore_backend {
        int (*op_set_sort_order)(void *, uint64_t, uint8_t, struct SSortOrderSet *, uint8_t *);
 
        int (*op_get_folders_list)(void *, uint64_t fmid, struct indexing_folders_list **folders_list);
+
+        /***
+            proof of concept
+        */
+
+        /** oxcmsg operations */
+        /** oxcstor operations */
+        struct {
+                int (*release)(void *);
+        } store;
+
+        /* note: the mid parameter will be replaced with a message object here once we have a "pocop_open_message"... */
+        struct {
+                int (*get_attachment_table)(void *, uint64_t, void **, uint32_t *);
+                int (*get_attachment)(void *, uint64_t, uint32_t, void **);
+                int (*create_attachment)(void *, uint64_t, uint32_t *, void **);
+        } message;
+
+        /** oxctabl operations */
+        struct {
+                int (*set_columns)(void *, uint16_t, enum MAPITAGS *);
+                int (*get_row)(void *, enum table_query_type, uint32_t, struct mapistore_property_data *);
+        } table;
+
+        /** oxcprpt operations */
+        struct {
+                int (*get_properties)(void *, uint16_t, enum MAPITAGS *, struct mapistore_property_data *);
+                int (*set_properties)(void *, struct SRow *);
+        } properties;
 };
 
 struct indexing_context_list;
@@ -185,6 +221,19 @@ int mapistore_get_folders_list(struct mapistore_context *, uint64_t, struct inde
 int mapistore_set_restrictions(struct mapistore_context *, uint32_t, uint64_t, uint8_t, struct mapi_SRestriction *, uint8_t *);
 int mapistore_set_sort_order(struct mapistore_context *, uint32_t, uint64_t, uint8_t, struct SSortOrderSet *, uint8_t *);
 
+/* proof of concept */
+int mapistore_pocop_get_attachment_table(struct mapistore_context *, uint32_t, uint64_t mid, void **, uint32_t *);
+int mapistore_pocop_get_attachment(struct mapistore_context *, uint32_t, uint64_t mid, uint32_t, void **);
+int mapistore_pocop_create_attachment(struct mapistore_context *, uint32_t, uint64_t mid, uint32_t *, void **);
+
+int mapistore_pocop_set_table_columns(struct mapistore_context *, uint32_t, void *, uint16_t, enum MAPITAGS *);
+int mapistore_pocop_get_table_row(struct mapistore_context *, uint32_t, void *, enum table_query_type, uint32_t, struct mapistore_property_data *);
+
+int mapistore_pocop_get_properties(struct mapistore_context *, uint32_t, void *, uint16_t, enum MAPITAGS *, struct mapistore_property_data *);
+int mapistore_pocop_set_properties(struct mapistore_context *, uint32_t, void *, struct SRow *);
+
+int mapistore_pocop_release(struct mapistore_context *, uint32_t, void *);
+
 /* definitions from mapistore_processing.c */
 int mapistore_set_mapping_path(const char *);
 
index 5cce502319e198c842c136397dda268c46fdca32..86cd7c768dfe061d1af02005fedc720bba04c012 100644 (file)
@@ -569,3 +569,54 @@ int mapistore_backend_set_sort_order(struct backend_context *bctx, uint64_t fid,
 {
         return bctx->backend->op_set_sort_order(bctx->private_data, fid, type, set, table_status);
 }
+
+
+/* proof of concept */
+int mapistore_backend_pocop_get_attachment_table(struct backend_context *bctx, uint64_t mid,
+                                                 void **table, uint32_t *row_count)
+{
+        return bctx->backend->message.get_attachment_table(bctx->private_data, mid, table, row_count);
+}
+
+int mapistore_backend_pocop_get_attachment(struct backend_context *bctx, uint64_t mid, uint32_t aid, void **attachment)
+{
+        return bctx->backend->message.get_attachment(bctx->private_data, mid, aid, attachment);
+}
+
+int mapistore_backend_pocop_create_attachment(struct backend_context *bctx, uint64_t mid, uint32_t *aid, void **attachment)
+{
+        return bctx->backend->message.create_attachment(bctx->private_data, mid, aid, attachment);
+}
+
+int mapistore_backend_pocop_set_table_columns(struct backend_context *bctx, void *table,
+                                              uint16_t count, enum MAPITAGS *properties)
+{
+        return bctx->backend->table.set_columns(table, count, properties);
+}
+
+int mapistore_backend_pocop_get_table_row(struct backend_context *bctx, void *table,
+                                          enum table_query_type query_type, uint32_t rowid,
+                                          struct mapistore_property_data *data)
+{
+        return bctx->backend->table.get_row(table, query_type, rowid, data);
+}
+
+int mapistore_backend_pocop_get_properties(struct backend_context *bctx,
+                                           void *object,
+                                           uint16_t count, enum MAPITAGS
+                                           *properties,
+                                           struct mapistore_property_data *data)
+{
+        return bctx->backend->properties.get_properties(object, count, properties, data);
+}
+
+int mapistore_backend_pocop_set_properties(struct backend_context *bctx,
+                                           void *object, struct SRow *aRow)
+{
+        return bctx->backend->properties.set_properties(object, aRow);
+}
+
+int mapistore_backend_pocop_release(struct backend_context *bctx, void *object)
+{
+        return bctx->backend->store.release(object);
+}
index 0f175b533ca1dfa49488631ae57ca381602865b7..83b5beeba902acee2941a1d750665b6d8d36b85f 100644 (file)
@@ -1200,3 +1200,164 @@ _PUBLIC_ int mapistore_set_sort_order(struct mapistore_context *mstore_ctx,
 
        return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
 }
+
+
+/* proof of concept */
+_PUBLIC_ int mapistore_pocop_get_attachment_table(struct mapistore_context *mstore_ctx, uint32_t context_id, uint64_t mid,
+                                                  void **table, uint32_t *row_count)
+{
+       struct backend_context  *backend_ctx;
+       int                     ret;
+
+       /* Sanity checks */
+       MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
+
+       /* Step 1. Search the context */
+       backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
+       MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
+
+       /* Step 2. Call backend operation */
+       ret = mapistore_backend_pocop_get_attachment_table(backend_ctx, mid, table, row_count);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
+
+_PUBLIC_ int mapistore_pocop_get_attachment(struct mapistore_context *mstore_ctx, uint32_t context_id,
+                                            uint64_t mid, uint32_t aid,
+                                            void **attachment)
+{
+       struct backend_context  *backend_ctx;
+       int                     ret;
+
+       /* Sanity checks */
+       MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
+
+       /* Step 1. Search the context */
+       backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
+       MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
+
+       /* Step 2. Call backend operation */
+       ret = mapistore_backend_pocop_get_attachment(backend_ctx, mid, aid, attachment);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
+
+_PUBLIC_ int mapistore_pocop_create_attachment(struct mapistore_context *mstore_ctx, uint32_t context_id,
+                                               uint64_t mid,
+                                               uint32_t *aid, void **attachment)
+{
+       struct backend_context  *backend_ctx;
+       int                     ret;
+
+       /* Sanity checks */
+       MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
+
+       /* Step 1. Search the context */
+       backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
+       MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
+
+       /* Step 2. Call backend operation */
+       ret = mapistore_backend_pocop_create_attachment(backend_ctx, mid, aid, attachment);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
+
+_PUBLIC_ int mapistore_pocop_set_table_columns(struct mapistore_context *mstore_ctx, uint32_t context_id, void *table, uint16_t count, enum MAPITAGS *properties)
+{
+       struct backend_context  *backend_ctx;
+       int                     ret;
+
+       /* Sanity checks */
+       MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
+
+       /* Step 1. Search the context */
+       backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
+       MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
+
+       /* Step 2. Call backend operation */
+       ret = mapistore_backend_pocop_set_table_columns(backend_ctx, table, count, properties);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
+
+_PUBLIC_ int mapistore_pocop_get_table_row(struct mapistore_context *mstore_ctx, uint32_t context_id, void *table,
+                                           enum table_query_type query_type, uint32_t rowid, struct mapistore_property_data *data)
+{
+       struct backend_context  *backend_ctx;
+       int                     ret;
+
+       /* Sanity checks */
+       MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
+
+       /* Step 1. Search the context */
+       backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
+       MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
+
+       /* Step 2. Call backend operation */
+       ret = mapistore_backend_pocop_get_table_row(backend_ctx, table, query_type, rowid, data);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
+
+_PUBLIC_ int mapistore_pocop_get_properties(struct mapistore_context
+                                            *mstore_ctx, uint32_t context_id,
+                                            void *object,
+                                            uint16_t count, enum MAPITAGS *properties,
+                                            struct mapistore_property_data *data)
+{
+       struct backend_context  *backend_ctx;
+       int                     ret;
+
+       /* Sanity checks */
+       MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
+
+       /* Step 1. Search the context */
+       backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
+       MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
+
+       /* Step 2. Call backend operation */
+       ret = mapistore_backend_pocop_get_properties(backend_ctx, object, count, properties, data);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
+
+_PUBLIC_ int mapistore_pocop_set_properties(struct mapistore_context
+                                            *mstore_ctx, uint32_t context_id,
+                                            void *object,
+                                            struct SRow *aRow)
+{
+       struct backend_context  *backend_ctx;
+       int                     ret;
+
+       /* Sanity checks */
+       MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
+
+       /* Step 1. Search the context */
+       backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
+       MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
+
+       /* Step 2. Call backend operation */
+       ret = mapistore_backend_pocop_set_properties(backend_ctx, object, aRow);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
+
+_PUBLIC_ int mapistore_pocop_release(struct mapistore_context
+                                     *mstore_ctx, uint32_t context_id,
+                                     void *object)
+{
+       struct backend_context  *backend_ctx;
+       int                     ret;
+
+       /* Sanity checks */
+       MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
+
+       /* Step 1. Search the context */
+       backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
+       MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
+
+       /* Step 2. Call backend operation */
+       ret = mapistore_backend_pocop_release(backend_ctx, object);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
index 1c9bbabfb475a453688f4d8c3cee956d295049c0..00e99adcb59cb0b825419ccd85c3c8ca2be30a95 100644 (file)
@@ -178,6 +178,19 @@ int mapistore_backend_get_folders_list(struct backend_context *, uint64_t, struc
 int mapistore_backend_set_restrictions(struct backend_context *, uint64_t, uint8_t, struct mapi_SRestriction *, uint8_t *);
 int mapistore_backend_set_sort_order(struct backend_context *, uint64_t, uint8_t, struct SSortOrderSet *, uint8_t *);
 
+/* proof of concept */
+int mapistore_backend_pocop_get_attachment_table(struct backend_context *, uint64_t, void **, uint32_t *);
+int mapistore_backend_pocop_get_attachment(struct backend_context *, uint64_t, uint32_t, void **);
+int mapistore_backend_pocop_create_attachment(struct backend_context *, uint64_t, uint32_t *, void **);
+
+int mapistore_backend_pocop_set_table_columns(struct backend_context *, void *, uint16_t, enum MAPITAGS *);
+int mapistore_backend_pocop_get_table_row(struct backend_context *, void *, enum table_query_type, uint32_t, struct mapistore_property_data *);
+
+int mapistore_backend_pocop_get_properties(struct backend_context *, void *, uint16_t, enum MAPITAGS *, struct mapistore_property_data *);
+int mapistore_backend_pocop_set_properties(struct backend_context *, void *, struct SRow *);
+
+int mapistore_backend_pocop_release(struct backend_context *, void *);
+
 /* definitions from mapistore_tdb_wrap.c */
 struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *, const char *, int, int, int, mode_t);