fully converted the table backend api to the poc api, so as to enable the handling...
authorwsourdeau <wsourdeau@71d39326-ef09-db11-b2a4-00e04c779ad1>
Mon, 7 Mar 2011 18:47:29 +0000 (18:47 +0000)
committerwsourdeau <wsourdeau@71d39326-ef09-db11-b2a4-00e04c779ad1>
Mon, 7 Mar 2011 18:47:29 +0000 (18:47 +0000)
git-svn-id: https://svn.openchange.org/openchange@2725 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_notification.c [new file with mode: 0644]
branches/sogo/mapiproxy/libmapistore/mapistore_private.h
branches/sogo/mapiproxy/servers/default/emsmdb/oxcfold.c
branches/sogo/mapiproxy/servers/default/emsmdb/oxctabl.c

index 7becb913d255e117866e5f6d90f65509a5c0c5c5..f532082a2c412db33a6f3031f8675220a1e0d689 100644 (file)
@@ -51,14 +51,16 @@ typedef     int (*init_backend_fn) (void);
 
 #define        MAPISTORE_INIT_MODULE   "mapistore_init_backend"
 
-#define        MAPISTORE_FOLDER_TABLE  1
-#define        MAPISTORE_MESSAGE_TABLE 2
-#define        MAPISTORE_FAI_TABLE     3
-#define        MAPISTORE_RULE_TABLE    4
+#define        MAPISTORE_FOLDER_TABLE          1
+#define        MAPISTORE_MESSAGE_TABLE         2
+#define        MAPISTORE_FAI_TABLE             3
+#define        MAPISTORE_RULE_TABLE            4
+#define        MAPISTORE_ATTACHMENT_TABLE      5
 
-#define MAPISTORE_FOLDER       1
+#define MAPISTORE_FOLDER        1
 #define        MAPISTORE_MESSAGE       2
 #define        MAPISTORE_ATTACHMENT    3
+#define        MAPISTORE_TABLE         4
 
 #define        MAPISTORE_SOFT_DELETE           1
 #define        MAPISTORE_PERMANENT_DELETE      2
@@ -124,12 +126,17 @@ struct mapistore_backend {
             proof of concept
         */
 
-        /** oxcmsg operations */
         /** oxcstor operations */
         struct {
                 int (*release)(void *);
         } store;
 
+        /** oxcfold operations */
+        struct {
+                int (*open_table)(void *, uint64_t, uint8_t, uint32_t, void **, uint32_t *);
+        } folder;
+
+        /** oxcmsg operations */
         /* 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 *);
@@ -140,7 +147,10 @@ struct mapistore_backend {
         /** oxctabl operations */
         struct {
                 int (*set_columns)(void *, uint16_t, enum MAPITAGS *);
+                int (*set_restrictions)(void *, struct mapi_SRestriction *, uint8_t *);
+                int (*set_sort_order)(void *, struct SSortOrderSet *, uint8_t *);
                 int (*get_row)(void *, enum table_query_type, uint32_t, struct mapistore_property_data *);
+                int (*get_row_count)(void *, uint32_t *);
         } table;
 
         /** oxcprpt operations */
@@ -222,11 +232,15 @@ int mapistore_set_restrictions(struct mapistore_context *, uint32_t, uint64_t, u
 int mapistore_set_sort_order(struct mapistore_context *, uint32_t, uint64_t, uint8_t, struct SSortOrderSet *, uint8_t *);
 
 /* proof of concept */
+int mapistore_pocop_open_table(struct mapistore_context *, uint32_t, uint64_t, uint8_t, uint32_t, void **, uint32_t *);
+
 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_set_restrictions(struct mapistore_context *, uint32_t, void *, struct mapi_SRestriction *, uint8_t *);
+int mapistore_pocop_set_sort_order(struct mapistore_context *, uint32_t, void *, struct SSortOrderSet *, uint8_t *);
 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 *);
index 86cd7c768dfe061d1af02005fedc720bba04c012..095bb0df684a999694301d923439bd34103a39b3 100644 (file)
@@ -572,6 +572,12 @@ int mapistore_backend_set_sort_order(struct backend_context *bctx, uint64_t fid,
 
 
 /* proof of concept */
+int mapistore_backend_pocop_open_table(struct backend_context *bctx, uint64_t fid, uint8_t table_type,
+                                       uint32_t handle_id, void **table, uint32_t *row_count)
+{
+        return bctx->backend->folder.open_table(bctx->private_data, fid, table_type, handle_id, table, row_count);
+}
+
 int mapistore_backend_pocop_get_attachment_table(struct backend_context *bctx, uint64_t mid,
                                                  void **table, uint32_t *row_count)
 {
@@ -594,6 +600,18 @@ int mapistore_backend_pocop_set_table_columns(struct backend_context *bctx, void
         return bctx->backend->table.set_columns(table, count, properties);
 }
 
+int mapistore_backend_pocop_set_table_restrictions(struct backend_context *bctx, void *table,
+                                                   struct mapi_SRestriction *restrictions, uint8_t *table_status)
+{
+        return bctx->backend->table.set_restrictions(table, restrictions, table_status);
+}
+
+int mapistore_backend_pocop_set_table_sort_order(struct backend_context *bctx, void *table,
+                                                 struct SSortOrderSet *sort_order, uint8_t *table_status)
+{
+        return bctx->backend->table.set_sort_order(table, sort_order, table_status);
+}
+
 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)
index 83b5beeba902acee2941a1d750665b6d8d36b85f..f3b54e612340d3af620fbc1cf6d42189ab94af04 100644 (file)
@@ -1203,6 +1203,25 @@ _PUBLIC_ int mapistore_set_sort_order(struct mapistore_context *mstore_ctx,
 
 
 /* proof of concept */
+int mapistore_pocop_open_table(struct mapistore_context *mstore_ctx, uint32_t context_id, uint64_t folder_id,
+                               uint8_t table_type, uint32_t handle_id, 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_open_table(backend_ctx, folder_id, table_type, handle_id, table, row_count);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
+
 _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)
 {
@@ -1280,6 +1299,42 @@ _PUBLIC_ int mapistore_pocop_set_table_columns(struct mapistore_context *mstore_
        return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
 }
 
+_PUBLIC_ int mapistore_pocop_set_restrictions(struct mapistore_context *mstore_ctx, uint32_t context_id, void *table, struct mapi_SRestriction *restrictions, uint8_t *table_status)
+{
+       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_restrictions(backend_ctx, table, restrictions, table_status);
+
+       return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
+}
+
+_PUBLIC_ int mapistore_pocop_set_sort_order(struct mapistore_context *mstore_ctx, uint32_t context_id, void *table, struct SSortOrderSet *sort_order, uint8_t *table_status)
+{
+       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_sort_order(backend_ctx, table, sort_order, table_status);
+
+       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)
 {
diff --git a/branches/sogo/mapiproxy/libmapistore/mapistore_notification.c b/branches/sogo/mapiproxy/libmapistore/mapistore_notification.c
new file mode 100644 (file)
index 0000000..e69de29
index 00e99adcb59cb0b825419ccd85c3c8ca2be30a95..9b469d6418396afcdb79c3fb951b6353f940397b 100644 (file)
@@ -179,11 +179,15 @@ int mapistore_backend_set_restrictions(struct backend_context *, uint64_t, uint8
 int mapistore_backend_set_sort_order(struct backend_context *, uint64_t, uint8_t, struct SSortOrderSet *, uint8_t *);
 
 /* proof of concept */
+int mapistore_backend_pocop_open_table(struct backend_context *, uint64_t, uint8_t, uint32_t, void **, uint32_t *);
+
 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_set_table_restrictions(struct backend_context *, void *, struct mapi_SRestriction *, uint8_t *);
+int mapistore_backend_pocop_set_table_sort_order(struct backend_context *, void *, struct SSortOrderSet *, uint8_t *);
 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 *);
index cdd32d54b9165a9f29da75fbe1babe372b55a72b..ecfc2dd73e83bacf2e26aa147e8f452118e989a4 100644 (file)
@@ -345,7 +345,14 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopGetContentsTable(TALLOC_CTX *mem_ctx,
        }
 
        /* GetContentsTable can only be called for folder objects */
-       mapi_handles_get_private_data(parent, &data);
+       retval = mapi_handles_get_private_data(parent, &data);
+       if (retval) {
+               mapi_repl->error_code = retval;
+               DEBUG(5, ("  handle data not found, idx = %x\n", mapi_req->handle_idx));
+               *size += libmapiserver_RopGetContentsTable_size(NULL);
+               return MAPI_E_SUCCESS;
+       }
+
        object = (struct emsmdbp_object *)data;
        if (!object) {
                mapi_repl->error_code = MAPI_E_NO_SUPPORT;
@@ -374,19 +381,6 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopGetContentsTable(TALLOC_CTX *mem_ctx,
                table_type = EMSMDBP_TABLE_MESSAGE_TYPE;
        }
 
-       mapistore = emsmdbp_is_mapistore(parent);
-       switch (mapistore) {
-       case false:
-               /* system/special folder */
-               mapi_repl->u.mapi_GetContentsTable.RowCount = 0;
-               break;
-       case true:
-               /* handled by mapistore */
-               retval = mapistore_get_message_count(emsmdbp_ctx->mstore_ctx, contextID, folderID, table_type,
-                                                    &mapi_repl->u.mapi_GetContentsTable.RowCount);
-               break;
-       }
-
        /* Initialize Table object */
        handle = handles[mapi_req->handle_idx];
        retval = mapi_handles_add(emsmdbp_ctx->handles_ctx, handle, &rec);
@@ -395,6 +389,20 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopGetContentsTable(TALLOC_CTX *mem_ctx,
        object = emsmdbp_object_table_init((TALLOC_CTX *)rec, emsmdbp_ctx, parent);
        if (object) {
                retval = mapi_handles_set_private_data(rec, object);
+
+                mapistore = emsmdbp_is_mapistore(parent);
+                switch (mapistore) {
+                case false:
+                        /* system/special folder */
+                        mapi_repl->u.mapi_GetContentsTable.RowCount = 0;
+                        break;
+                case true:
+                        object->poc_api = true;
+                        retval = mapistore_pocop_open_table(emsmdbp_ctx->mstore_ctx, contextID, folderID, table_type, rec->handle,
+                                                            &object->poc_backend_object, &mapi_repl->u.mapi_GetContentsTable.RowCount);
+                        break;
+                }
+
                object->object.table->denominator = mapi_repl->u.mapi_GetHierarchyTable.RowCount;
                object->object.table->ulType = table_type;
        }
index e0a2f2f8894725f4d0050581fa08527832a4d8c3..95518813bd33620eab0fe7b72d0280326701878e 100644 (file)
@@ -220,9 +220,15 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopSortTable(TALLOC_CTX *mem_ctx,
        if (table->mapistore) {
                status = TBLSTAT_COMPLETE;
                 request = mapi_req->u.mapi_SortTable;
-               retval = mapistore_set_sort_order(emsmdbp_ctx->mstore_ctx, table->contextID, 
-                                                  table->folderID, table->ulType, &request.lpSortCriteria, &status);
-               if (retval) {
+                if (object->poc_api) {
+                        retval = mapistore_pocop_set_sort_order(emsmdbp_ctx->mstore_ctx, table->contextID,
+                                                                object->poc_backend_object, &request.lpSortCriteria, &status);
+                }
+                else {
+                        retval = mapistore_set_sort_order(emsmdbp_ctx->mstore_ctx, table->contextID, 
+                                                          table->folderID, table->ulType, &request.lpSortCriteria, &status);
+                }
+                if (retval) {
                        mapi_repl->error_code = retval;
                        goto end;
                }
@@ -319,10 +325,16 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopRestrict(TALLOC_CTX *mem_ctx,
        /* If parent folder has a mapistore context */
        if (table->mapistore) {
                status = TBLSTAT_COMPLETE;
-               retval = mapistore_set_restrictions(emsmdbp_ctx->mstore_ctx, table->contextID, 
-                                                   table->folderID, table->ulType, &request.restrictions, &status);
-               if (retval) {
-                       mapi_repl->error_code = retval;
+                if (object->poc_api) {
+                        retval = mapistore_pocop_set_restrictions(emsmdbp_ctx->mstore_ctx, table->contextID,
+                                                                  object->poc_backend_object, &request.restrictions, &status);
+                }
+                else {
+                        retval = mapistore_set_restrictions(emsmdbp_ctx->mstore_ctx, table->contextID, 
+                                                            table->folderID, table->ulType, &request.restrictions, &status);
+                }
+                if (retval) {
+                        mapi_repl->error_code = retval;
                        goto end;
                }
                
@@ -475,7 +487,7 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopQueryRows(TALLOC_CTX *mem_ctx,
                                                 else if (properties[j].error == MAPISTORE_ERR_NO_MEMORY)
                                                         retvals[j] = MAPI_E_NOT_ENOUGH_MEMORY;
                                                 else {
-                                                        DEBUG (4, ("%s: unknown mapistore error: %.8x", __PRETTY_FUNCTION__, properties[i].error));
+                                                        DEBUG (4, ("%s: unknown mapistore error: %.8x", __PRETTY_FUNCTION__, properties[j].error));
                                                 }
                                         }
                                         else {
@@ -490,6 +502,7 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopQueryRows(TALLOC_CTX *mem_ctx,
                                                 flagged = 1;
                                         }
                                 }
+                                talloc_free(properties);
                         }
                         else {
                                 for (j = 0; j < table->prop_count; j++) {
@@ -711,12 +724,7 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopQueryPosition(TALLOC_CTX *mem_ctx,
        table = object->object.table;
        if (!table->folderID) goto end;
 
-       if (table->numerator < table->denominator) {
-               mapi_repl->u.mapi_QueryPosition.Numerator = table->numerator;
-       }
-       else {
-               mapi_repl->u.mapi_QueryPosition.Numerator = 0xffffffff;
-       }
+        mapi_repl->u.mapi_QueryPosition.Numerator = table->numerator;
        mapi_repl->u.mapi_QueryPosition.Denominator = table->denominator;
        mapi_repl->error_code = MAPI_E_SUCCESS;
 
@@ -807,6 +815,7 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopSeekRow(TALLOC_CTX *mem_ctx,
                 next_position = table->denominator - 1 + mapi_req->u.mapi_SeekRow.offset;
        }
        else {
+                next_position = 0;
                mapi_repl->error_code = MAPI_E_NOT_FOUND;
                DEBUG(5, ("  unhandled 'origin' type: %d\n", mapi_req->u.mapi_SeekRow.origin));
        }
@@ -863,6 +872,7 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopFindRow(TALLOC_CTX *mem_ctx,
        void                            *data = NULL;
        enum MAPISTATUS                 *retvals;
        void                            **data_pointers;
+        struct                          mapistore_property_data *properties;
        uint32_t                        handle;
        DATA_BLOB                       row;
        uint32_t                        property;
@@ -941,84 +951,141 @@ _PUBLIC_ enum MAPISTATUS EcDoRpc_RopFindRow(TALLOC_CTX *mem_ctx,
                memset (&row, 0, sizeof(DATA_BLOB));
 
                /* Restrict rows to be fetched */
-               retval = mapistore_set_restrictions(emsmdbp_ctx->mstore_ctx, table->contextID,
-                                                   table->folderID,
-                                                   table->ulType,
-                                                   &request.res, &status);
+                if (object->poc_api) {
+                        retval = mapistore_pocop_set_restrictions(emsmdbp_ctx->mstore_ctx, table->contextID,
+                                                                  object->poc_backend_object, &request.res, &status);
+                }
+                else {
+                        retval = mapistore_set_restrictions(emsmdbp_ctx->mstore_ctx, table->contextID,
+                                                            table->folderID,
+                                                            table->ulType,
+                                                            &request.res, &status);
+                }
                /* Then fetch rows */
                /* Lookup the properties and check if we need to flag the PropertyRow blob */
-               for (i = 0; !found && table->numerator < table->denominator; i++) {
-                       flagged = 0;
+                data_pointers = talloc_array(mem_ctx, void *, table->prop_count);
+                retvals = talloc_array(mem_ctx, enum MAPISTATUS, table->prop_count);
+                memset(data_pointers, 0, sizeof(void *) * table->prop_count);
+                memset(retvals, 0, sizeof(uint32_t) * table->prop_count);
+                properties = talloc_array(mem_ctx, struct mapistore_property_data, table->prop_count);
 
-                       retval = mapistore_get_table_property(emsmdbp_ctx->mstore_ctx, table->contextID,
-                                                             table->ulType,
-                                                             MAPISTORE_LIVEFILTERED_QUERY,
-                                                             table->folderID,
-                                                             (table->ulType == MAPISTORE_MESSAGE_TABLE) ? PR_MID : PR_FID,
-                                                             table->numerator, &data);
-                       if (retval == MAPI_E_INVALID_OBJECT) {
-                               table->numerator++;
-                       }
-                       else {
-                               data_pointers = talloc_array(mem_ctx, void *, table->prop_count);
-                               retvals = talloc_array(mem_ctx, enum MAPISTATUS, table->prop_count);
-
-                               found = true;
-                               flagged = 0;
-
-                               /* Lookup for flagged property row */
-                               for (j = 0; j < table->prop_count; j++) {
-                                       retval = mapistore_get_table_property(emsmdbp_ctx->mstore_ctx, table->contextID,
-                                                                             table->ulType,
-                                                                             MAPISTORE_LIVEFILTERED_QUERY,
-                                                                             table->folderID, 
-                                                                             table->properties[j],
-                                                                             table->numerator, data_pointers + j);
-                                       retvals[j] = retval;
-                                       if (retval == MAPI_E_NOT_FOUND) {
-                                               flagged = 1;
-                                       }
-                               }
+               for (i = 0; !found && table->numerator < table->denominator; i++) {
+                        flagged = 0;
 
-                               if (flagged) {
-                                       libmapiserver_push_property(mem_ctx, 
-                                                                   lpcfg_iconv_convenience(emsmdbp_ctx->lp_ctx),
-                                                                   0x0000000b, (const void *)&flagged,
-                                                                   &row, 0, 0, 0);
-                               }
-                               else {
-                                       libmapiserver_push_property(mem_ctx, 
-                                                                   lpcfg_iconv_convenience(emsmdbp_ctx->lp_ctx),
-                                                                   0x00000000, (const void *)&flagged,
-                                                                   &row, 0, 1, 0);
-                               }
+                        if (object->poc_api) {
+                                memset(properties, 0, sizeof(struct mapistore_property_data) * table->prop_count);
+                                retval = mapistore_pocop_get_table_row(emsmdbp_ctx->mstore_ctx, table->contextID,
+                                                                       object->poc_backend_object,
+                                                                       MAPISTORE_PREFILTERED_QUERY,
+                                                                       table->numerator,
+                                                                       properties);
+                                if (retval == MAPI_E_INVALID_OBJECT) {
+                                        table->numerator++;
+                                        continue;
+                                }
+                                else {
+                                        found = true;
+                                        for (j = 0; j < table->prop_count; j++) {
+                                                retvals[j] = MAPI_E_SUCCESS;
+                                                if (properties[j].error) {
+                                                        if (properties[j].error == MAPISTORE_ERR_NOT_FOUND)
+                                                                retvals[j] = MAPI_E_NOT_FOUND;
+                                                        else if (properties[j].error == MAPISTORE_ERR_NO_MEMORY)
+                                                                retvals[j] = MAPI_E_NOT_ENOUGH_MEMORY;
+                                                        else {
+                                                                DEBUG (4, ("%s: unknown mapistore error: %.8x", __PRETTY_FUNCTION__, properties[j].error));
+                                                        }
+                                                }
+                                                else {
+                                                        if (properties[j].data == NULL)
+                                                                retvals[j] = MAPI_E_NOT_FOUND;
+                                                        else
+                                                                talloc_steal(data_pointers, properties[j].data);
+                                                }
+                                                
+                                                *(data_pointers + j) = properties[j].data;
+                                                if (retvals[j] != MAPI_E_SUCCESS) {
+                                                        flagged = 1;
+                                                }
+                                        }
+                                }
+                        }
+                        else {
+                                retval = mapistore_get_table_property(emsmdbp_ctx->mstore_ctx, table->contextID,
+                                                                      table->ulType,
+                                                                      MAPISTORE_LIVEFILTERED_QUERY,
+                                                                      table->folderID,
+                                                                      (table->ulType == MAPISTORE_MESSAGE_TABLE) ? PR_MID : PR_FID,
+                                                                      table->numerator, &data);
 
-                               /* Push the properties */
-                               for (j = 0; j < table->prop_count; j++) {
-                                       property = table->properties[j];
-                                       retval = retvals[j];
-                                       if (retval == MAPI_E_NOT_FOUND) {
-                                               property = (property & 0xFFFF0000) + PT_ERROR;
-                                               data = &retval;
-                                       }
-                                       else {
-                                               data = data_pointers[j];
-                                       }
-
-                                       libmapiserver_push_property(mem_ctx, lpcfg_iconv_convenience(emsmdbp_ctx->lp_ctx),
-                                                                   property, data, &row,
-                                                                   flagged?PT_ERROR:0, flagged, 0);
-                               }
+                                if (retval == MAPI_E_INVALID_OBJECT) {
+                                        table->numerator++;
+                                        continue;
+                                }
+                                else {
+                                        found = true;
+                                        flagged = 0;
+                                        
+                                        for (j = 0; j < table->prop_count; j++) {
+                                                retval = mapistore_get_table_property(emsmdbp_ctx->mstore_ctx, table->contextID,
+                                                                                      table->ulType,
+                                                                                      MAPISTORE_LIVEFILTERED_QUERY,
+                                                                                      table->folderID, 
+                                                                                      table->properties[j],
+                                                                                      table->numerator, data_pointers + j);
+                                                retvals[j] = retval;
+                                                if (retval == MAPI_E_NOT_FOUND) {
+                                                        flagged = 1;
+                                                }
+                                        }
+                                }
+                        }
 
-                               talloc_free(retvals);
-                               talloc_free(data_pointers);
+                        if (flagged) {
+                                libmapiserver_push_property(mem_ctx, 
+                                                            lpcfg_iconv_convenience(emsmdbp_ctx->lp_ctx),
+                                                            0x0000000b, (const void *)&flagged,
+                                                            &row, 0, 0, 0);
+                        }
+                        else {
+                                libmapiserver_push_property(mem_ctx, 
+                                                            lpcfg_iconv_convenience(emsmdbp_ctx->lp_ctx),
+                                                            0x00000000, (const void *)&flagged,
+                                                            &row, 0, 1, 0);
+                        }
+                                
+                        /* Push the properties */
+                        for (j = 0; j < table->prop_count; j++) {
+                                property = table->properties[j];
+                                retval = retvals[j];
+                                if (retval == MAPI_E_NOT_FOUND) {
+                                        property = (property & 0xFFFF0000) + PT_ERROR;
+                                        data = &retval;
+                                }
+                                else {
+                                        data = data_pointers[j];
+                                }
+                                
+                                libmapiserver_push_property(mem_ctx, lpcfg_iconv_convenience(emsmdbp_ctx->lp_ctx),
+                                                            property, data, &row,
+                                                            flagged?PT_ERROR:0, flagged, 0);
                        }
                }
 
-               retval = mapistore_set_restrictions(emsmdbp_ctx->mstore_ctx, table->contextID,
-                                                   table->folderID,
-                                                   table->ulType,
-                                                   NULL, &status);
+                talloc_free(retvals);
+                talloc_free(data_pointers);
+                talloc_free(properties);
+
+                if (object->poc_api) {
+                        retval = mapistore_pocop_set_restrictions(emsmdbp_ctx->mstore_ctx, table->contextID,
+                                                                  object->poc_backend_object, NULL, &status);
+                }
+                else {
+                        retval = mapistore_set_restrictions(emsmdbp_ctx->mstore_ctx, table->contextID,
+                                                            table->folderID,
+                                                            table->ulType,
+                                                            NULL, &status);
+                }
 
                /* Adjust parameters */
                if (row.length) {