#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
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 *);
/** 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 */
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 *);
/* 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)
{
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)
/* 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)
{
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)
{
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 *);
}
/* 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;
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);
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;
}
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;
}
/* 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;
}
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 {
flagged = 1;
}
}
+ talloc_free(properties);
}
else {
for (j = 0; j < table->prop_count; j++) {
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;
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));
}
void *data = NULL;
enum MAPISTATUS *retvals;
void **data_pointers;
+ struct mapistore_property_data *properties;
uint32_t handle;
DATA_BLOB row;
uint32_t property;
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) {