Monotone-Parent: b062a471e751aff2d35891675a50d0fff8918047

Monotone-Revision: ab9f5dfc9882f0fa2e4df964b47cb60942c58c9a

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-04-19T22:22:26
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2011-04-19 22:22:26 +00:00
parent 6e03acd9a8
commit f805951939
7 changed files with 17 additions and 244 deletions

View File

@ -1,5 +1,18 @@
2011-04-19 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreMailMessage.m (-getPrBody:): no longer check
the size of the returned content, as streams are now handled
internally by OpenChange.
(-getPrHtml): same as above.
* OpenChange/MAPIStoreTypes.m (NSObjectFromStreamData): removed
helper function as it's no longer used.
* OpenChange/MAPIStoreSOGo.m (sogo_op_set_property_from_fd)
(sogo_op_get_property_into_fd): those backend methods are no
longer used, as OpenChange handles the property streams internally
now.
* OpenChange/gen-property-selectors.py: added code to generate
MAPIStoreSupportedProperties as the array of properties that are
handled by OpenChange and MAPIStoreSupportedPropertiesCount as the

View File

@ -133,14 +133,6 @@
- (int) setPropertiesWithFMID: (uint64_t) fmid
ofTableType: (uint8_t) tableType
inRow: (struct SRow *) aRow;
- (int) setProperty: (enum MAPITAGS) property
withFMID: (uint64_t) fmid
ofTableType: (uint8_t) tableType
fromFile: (NSFileHandle *) aFile;
- (int) getProperty: (enum MAPITAGS) property
withFMID: (uint64_t) fmid
ofTableType: (uint8_t) tableType
intoFile: (NSFileHandle *) aFile;
- (int) modifyRecipientsWithMID: (uint64_t) mid
inRows: (struct ModifyRecipientRow *) rows
withCount: (NSUInteger) max;

View File

@ -21,7 +21,6 @@
*/
#import <Foundation/NSDictionary.h>
#import <Foundation/NSFileHandle.h>
#import <Foundation/NSNull.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSThread.h>
@ -848,14 +847,14 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
{
if (propRc == MAPISTORE_ERR_NOT_FOUND)
propRc = MAPI_E_NOT_FOUND;
else if (propRc == MAPISTORE_ERR_NO_MEMORY)
propRc = MAPI_E_NOT_ENOUGH_MEMORY;
// else if (propRc == MAPISTORE_ERR_NO_MEMORY)
// propRc = MAPI_E_NOT_ENOUGH_MEMORY;
if (propValue)
talloc_free (propValue);
propValue = MAPILongValue (memCtx, propRc);
tag = (tag & 0xffff0000) | 0x000a;
}
set_SPropValue_proptag (aRow->lpProps + count, tag, propValue);
set_SPropValue_proptag (aRow->lpProps + count, tag, propValue);
}
}
talloc_free (data);
@ -982,120 +981,6 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
return rc;
}
- (int) setProperty: (enum MAPITAGS) property
withFMID: (uint64_t) fmid
ofTableType: (uint8_t) tableType
fromFile: (NSFileHandle *) aFile
{
MAPIStoreMessage *message;
NSNumber *midKey;
NSData *fileData;
const char *propName;
int rc;
propName = get_proptag_name (property);
if (!propName)
propName = "<unknown>";
[self logWithFormat: @"METHOD '%s' -- property: %s(%.8x), fmid: 0x%.16x, tableType: %d",
__FUNCTION__, propName, property, fmid, tableType];
fileData = [aFile readDataToEndOfFile];
switch (tableType)
{
case MAPISTORE_MESSAGE:
midKey = [NSNumber numberWithUnsignedLongLong: fmid];
message = [messages objectForKey: midKey];
if (message)
{
[message addNewProperties:
[NSDictionary
dictionaryWithObject: NSObjectFromStreamData (property,
fileData)
forKey: MAPIPropertyKey (property)]];
rc = MAPISTORE_SUCCESS;
}
else
rc = MAPISTORE_ERR_NOT_FOUND;
break;
case MAPISTORE_FOLDER:
default:
[self errorWithFormat: @"%s: value of tableType not handled: %d",
__FUNCTION__, tableType];
rc = MAPISTORE_ERROR;
}
return rc;
}
- (int) getProperty: (enum MAPITAGS) property
withFMID: (uint64_t) fmid
ofTableType: (uint8_t) tableType
intoFile: (NSFileHandle *) aFile
{
MAPIStoreMessage *message;
NSNumber *midKey;
NSData *fileData;
const char *propName;
enum MAPISTATUS rc;
propName = get_proptag_name (property);
if (!propName)
propName = "<unknown>";
[self logWithFormat: @"METHOD '%s' -- property: %s(%.8x), fmid: 0x%.16x, tableType: %d",
__FUNCTION__, propName, property, fmid, tableType];
switch (tableType)
{
case MAPISTORE_MESSAGE:
midKey = [NSNumber numberWithUnsignedLongLong: fmid];
message = [messages objectForKey: midKey];
if (message)
{
fileData = [[message newProperties] objectForKey: MAPIPropertyKey (property)];
if ([fileData isKindOfClass: NSStringK])
fileData = [fileData dataUsingEncoding: NSUTF16LittleEndianStringEncoding];
if (fileData)
{
if (![fileData isKindOfClass: NSDataK])
[self
errorWithFormat: @"data class not handled for streams: %@",
NSStringFromClass ([fileData class])];
[aFile writeData: fileData];
rc = MAPI_E_SUCCESS;
}
else
{
[self errorWithFormat: @"no data for property %s(%.8x)"
@" in mid %.16x", propName, property, fmid];
rc = MAPI_E_NOT_FOUND;
}
}
else
{
[self errorWithFormat: @"no message found with mid %.16x", fmid];
rc = MAPI_E_INVALID_OBJECT;
}
break;
// [message setObject: NSObjectFromStreamData (property, fileData)
// forKey: MAPIPropertyNumber (property)];
// rc = MAPISTORE_SUCCESS;
// }
// else
case MAPISTORE_FOLDER:
[self errorWithFormat: @"%s: folder properties not handled yet",
__FUNCTION__];
rc = MAPI_E_NOT_FOUND;
break;
default:
[self errorWithFormat: @"%s: value of tableType not handled: %d",
__FUNCTION__, tableType];
rc = MAPI_E_INVALID_OBJECT;
}
return rc;
}
- (NSDictionary *) _convertRecipientFromRow: (struct RecipientRow *) row
{
NSMutableDictionary *recipient;

View File

@ -512,16 +512,6 @@ static Class NSExceptionK, MAPIStoreSentItemsFolderK, MAPIStoreDraftsFolderK;
bodyStringFromCharset: charset];
*data = [stringValue asUnicodeInMemCtx: memCtx];
if (strlen (*data) > 16384)
{
/* TODO: currently a hack to transfer properties as
streams */
[newProperties setObject: stringValue
forKey: MAPIPropertyKey (PR_BODY_UNICODE)];
*data = NULL;
rc = MAPI_E_NOT_ENOUGH_MEMORY;
[self logWithFormat: @"PR_BODY data too wide"];
}
}
else
rc = MAPISTORE_ERR_NOT_FOUND;
@ -581,19 +571,7 @@ static Class NSExceptionK, MAPIStoreSentItemsFolderK, MAPIStoreDraftsFolderK;
= [sogoObject lookupInfoForBodyPart: [key _strippedBodyKey]];
encoding = [partHeaderData objectForKey: @"encoding"];
content = [content bodyDataFromEncoding: encoding];
if ([content length] > 16384)
{
/* TODO: currently a hack to transfer properties as
streams */
[newProperties setObject: content
forKey: MAPIPropertyKey (PR_HTML)];
*data = NULL;
rc = MAPI_E_NOT_ENOUGH_MEMORY;
[self logWithFormat: @"PR_HTML data too wide"];
}
else
*data = [content asBinaryInMemCtx: memCtx];
*data = [content asBinaryInMemCtx: memCtx];
}
else
{

View File

@ -632,68 +632,6 @@ sogo_op_setprops(void *private_data,
return rc;
}
static int
sogo_op_set_property_from_fd(void *private_data,
uint64_t fmid, uint8_t type,
uint32_t property, int fd)
{
NSAutoreleasePool *pool;
sogo_context *cContext;
MAPIStoreContext *context;
NSFileHandle *fileHandle;
int rc;
DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__));
pool = [NSAutoreleasePool new];
cContext = private_data;
context = cContext->objcContext;
[context setupRequest];
fileHandle = [[NSFileHandle alloc] initWithFileDescriptor: fd
closeOnDealloc: NO];
rc = [context setProperty: property withFMID: fmid ofTableType: type
fromFile: fileHandle];
[fileHandle release];
[context tearDownRequest];
[pool release];
return rc;
}
static int
sogo_op_get_property_into_fd(void *private_data,
uint64_t fmid, uint8_t type,
uint32_t property, int fd)
{
NSAutoreleasePool *pool;
sogo_context *cContext;
MAPIStoreContext *context;
NSFileHandle *fileHandle;
int rc;
DEBUG (5, ("[SOGo: %s:%d]\n", __FUNCTION__, __LINE__));
pool = [NSAutoreleasePool new];
cContext = private_data;
context = cContext->objcContext;
[context setupRequest];
fileHandle = [[NSFileHandle alloc] initWithFileDescriptor: fd
closeOnDealloc: NO];
rc = [context getProperty: property withFMID: fmid ofTableType: type
intoFile: fileHandle];
[fileHandle release];
[context tearDownRequest];
[pool release];
return rc;
}
static int
sogo_op_modifyrecipients(void *private_data,
uint64_t mid,
@ -1291,8 +1229,6 @@ int mapistore_init_backend(void)
backend.op_setprops = sogo_op_setprops;
backend.op_getprops = sogo_op_getprops;
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.folder.open_table = sogo_pocop_open_table;

View File

@ -38,7 +38,6 @@ double *MAPIDoubleValue (void *memCtx, double value);
id NSObjectFromSPropValue (const struct SPropValue *);
id NSObjectFromMAPISPropValue (const struct mapi_SPropValue *);
id NSObjectFromStreamData (enum MAPITAGS property, NSData *streamData);
static inline NSNumber *
MAPIPropertyKey (enum MAPITAGS propTag)

View File

@ -204,36 +204,6 @@ NSObjectFromSPropValue (const struct SPropValue *value)
return result;
}
id NSObjectFromStreamData (enum MAPITAGS property, NSData* streamData)
{
short int valueType;
id result;
valueType = (property & 0xffff);
switch (valueType)
{
case PT_UNICODE:
case PT_STRING8:
result = [NSString stringWithCharacters: (unichar *) [streamData bytes]
length: [streamData length] / 2];
break;
case PT_BINARY:
result = streamData;
break;
case PT_OBJECT:
result = [NSNull null];
NSLog (@"%s: object type not handled: %d (0x%.4x)",
__PRETTY_FUNCTION__, valueType, valueType);
break;
default:
[NSException raise: @"MAPIStoreStreamTypeException"
format: @"invalid data type"];
result = nil;
}
return result;
}
void
MAPIStoreDumpMessageProperties (NSDictionary *properties)
{