diff --git a/ChangeLog b/ChangeLog index 4b6a7c83c..b175cd97d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2011-02-24 Wolfgang Sourdeau + * OpenChange/MAPIStoreSOGo.m: + (sogo_pocop_get_attachment_table, sogo_pocop_get_attachment) + (sogo_pocop_create_attachment, sogo_pocop_set_table_columns) + (sogo_pocop_get_table_row, sogo_pocop_get_properties) + (sogo_pocop_set_properties, sogo_pocop_release): new backend + methods (with counterparts in SOGoContext) that are used as part + of the new proof-of-concept API, where objects are accessed + directly from memory instead of needed to be resolved via their + fid, mid or aid identifiers. + * OpenChange/MAPIStoreAttachment.m: new super class, derived from MAPIStoreObject and used for MAPI attachment objects. diff --git a/OpenChange/MAPIStoreSOGo.h b/OpenChange/MAPIStoreSOGo.h index dd7024616..1fae02c8c 100644 --- a/OpenChange/MAPIStoreSOGo.h +++ b/OpenChange/MAPIStoreSOGo.h @@ -22,9 +22,6 @@ #ifndef __MAPISTORE_SOGO_H #define __MAPISTORE_SOGO_H -#include -#include - @class MAPIStoreContext; typedef struct { diff --git a/OpenChange/MAPIStoreSOGo.m b/OpenChange/MAPIStoreSOGo.m index d16a219d8..d6f8f38c9 100644 --- a/OpenChange/MAPIStoreSOGo.m +++ b/OpenChange/MAPIStoreSOGo.m @@ -25,20 +25,24 @@ #import #import #import - #import - #import - #import #import #import "MAPIApplication.h" #import "MAPIStoreContext.h" +#import "MAPIStoreObject.h" +#import "MAPIStoreTable.h" + +#import "MAPIStoreSOGo.h" #undef DEBUG - -#include "MAPIStoreSOGo.h" +#include +#include +#include +#include +#include /** \details Initialize sogo mapistore backend @@ -500,8 +504,8 @@ sogo_op_createmessage(void *private_data, context = cContext->objcContext; [context setupRequest]; - rc = [context createMessagePropertiesWithMID: mid inFID: fid - isAssociated: associated]; + rc = [context createMessageWithMID: mid inFID: fid + isAssociated: associated]; [context tearDownRequest]; [pool release]; @@ -832,6 +836,230 @@ sogo_op_set_sort_order (void *private_data, uint64_t fid, uint8_t type, return rc; } +/** + proof of concept +*/ +static int +sogo_pocop_get_attachment_table (void *private_data, uint64_t mid, void **table_object, uint32_t *row_count) +{ + NSAutoreleasePool *pool; + sogo_context *cContext; + MAPIStoreContext *context; + int rc; + + DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__)); + + pool = [NSAutoreleasePool new]; + + cContext = private_data; + context = cContext->objcContext; + if (context) + { + [context setupRequest]; + rc = [context getAttachmentTable: table_object + andRowCount: row_count + withMID: mid]; + [context tearDownRequest]; + [pool release]; + } + else + { + NSLog (@" UNEXPECTED WEIRDNESS: RECEIVED NO CONTEXT"); + rc = MAPI_E_NOT_FOUND; + } + + return rc; +} + +static int +sogo_pocop_get_attachment (void *private_data, uint64_t mid, uint32_t aid, void **attachment_object) +{ + NSAutoreleasePool *pool; + sogo_context *cContext; + MAPIStoreContext *context; + int rc; + + DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__)); + + pool = [NSAutoreleasePool new]; + + cContext = private_data; + context = cContext->objcContext; + if (context) + { + [context setupRequest]; + rc = [context getAttachment: attachment_object withAID: aid inMID: mid]; + [context tearDownRequest]; + [pool release]; + } + else + { + NSLog (@" UNEXPECTED WEIRDNESS: RECEIVED NO CONTEXT"); + rc = MAPI_E_NOT_FOUND; + } + + return rc; +} + +static int +sogo_pocop_create_attachment (void *private_data, uint64_t mid, uint32_t *aid, void **attachment_object) +{ + NSAutoreleasePool *pool; + sogo_context *cContext; + MAPIStoreContext *context; + int rc; + + DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__)); + + pool = [NSAutoreleasePool new]; + + cContext = private_data; + context = cContext->objcContext; + if (context) + { + [context setupRequest]; + rc = [context createAttachment: attachment_object inAID: aid withMessage: mid]; + [context tearDownRequest]; + [pool release]; + } + else + { + NSLog (@" UNEXPECTED WEIRDNESS: RECEIVED NO CONTEXT"); + rc = MAPI_E_NOT_FOUND; + } + + return rc; +} + +static int +sogo_pocop_set_table_columns (void *table_object, uint16_t count, enum MAPITAGS *properties) +{ + NSAutoreleasePool *pool; + MAPIStoreTable *table; + int rc; + + DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__)); + + table = table_object; + if (table) + { + pool = [NSAutoreleasePool new]; + rc = [table setColumns: properties + withCount: count]; + [pool release]; + } + else + { + NSLog (@" UNEXPECTED WEIRDNESS: RECEIVED NO DATA"); + rc = MAPI_E_NOT_FOUND; + } + + return rc; +} + +static int +sogo_pocop_get_table_row (void *table_object, enum table_query_type query_type, uint32_t row_id, struct mapistore_property_data *data) +{ + NSAutoreleasePool *pool; + MAPIStoreTable *table; + int rc; + + DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__)); + + table = table_object; + if (table) + { + pool = [NSAutoreleasePool new]; + rc = [table getRow: data withRowID: row_id andQueryType: query_type]; + [pool release]; + } + else + { + NSLog (@" UNEXPECTED WEIRDNESS: RECEIVED NO DATA"); + rc = MAPI_E_NOT_FOUND; + } + + return rc; +} + +static int +sogo_pocop_get_properties (void *object, + uint16_t count, enum MAPITAGS *properties, + struct mapistore_property_data *data) +{ + NSAutoreleasePool *pool; + MAPIStoreObject *propObject; + int rc; + + DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__)); + + propObject = object; + if (propObject) + { + pool = [NSAutoreleasePool new]; + rc = [propObject getProperties: data withTags: properties andCount: count]; + [pool release]; + } + else + { + NSLog (@" UNEXPECTED WEIRDNESS: RECEIVED NO DATA"); + rc = MAPI_E_NOT_FOUND; + } + + return rc; +} + +static int +sogo_pocop_set_properties (void *object, struct SRow *aRow) +{ + NSAutoreleasePool *pool; + MAPIStoreObject *propObject; + int rc; + + DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__)); + + propObject = object; + if (propObject) + { + pool = [NSAutoreleasePool new]; + rc = [propObject setProperties: aRow]; + [pool release]; + } + else + { + NSLog (@" bad object pointer"); + rc = MAPI_E_NOT_FOUND; + } + + return rc; +} + +static int +sogo_pocop_release (void *object) +{ + NSAutoreleasePool *pool; + MAPIStoreObject *propObject; + int rc; + + DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__)); + + propObject = object; + if (propObject) + { + pool = [NSAutoreleasePool new]; + [propObject release]; + [pool release]; + rc = MAPI_E_SUCCESS; + } + else + { + NSLog (@" UNEXPECTED WEIRDNESS: RECEIVED NO DATA"); + rc = MAPI_E_NOT_FOUND; + } + + return rc; +} + /** \details Entry point for mapistore SOGO backend @@ -885,6 +1113,16 @@ int mapistore_init_backend(void) backend.op_set_property_from_fd = sogo_op_set_property_from_fd; backend.op_get_property_into_fd = sogo_op_get_property_into_fd; + /* proof of concept */ + backend.message.get_attachment_table = sogo_pocop_get_attachment_table; + backend.message.get_attachment = sogo_pocop_get_attachment; + backend.message.create_attachment = sogo_pocop_create_attachment; + backend.table.set_columns = sogo_pocop_set_table_columns; + backend.table.get_row = sogo_pocop_get_table_row; + backend.properties.get_properties = sogo_pocop_get_properties; + backend.properties.set_properties = sogo_pocop_set_properties; + backend.store.release = sogo_pocop_release; + /* Register ourselves with the MAPISTORE subsystem */ ret = mapistore_backend_register(&backend); if (ret != MAPISTORE_SUCCESS) {