From e2457472b411c4cb9d204861524054d63ea77568 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 25 Oct 2011 17:36:51 +0000 Subject: [PATCH] Monotone-Parent: dfb6501f2203375a52c674747ac8caa6ab2ca7d3 Monotone-Revision: 08c6872fb6a9c8bafc542d62b81e555faf5e1c05 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-10-25T17:36:51 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 + OpenChange/MAPIStoreAttachment.m | 38 ++-- OpenChange/MAPIStoreCalendarAttachment.m | 50 +++--- OpenChange/MAPIStoreMailAttachment.m | 213 ++++++++++++++--------- 4 files changed, 174 insertions(+), 133 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72fa67811..911f7d29c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2011-10-25 Wolfgang Sourdeau + * OpenChange/MAPIStoreAttachment.m, + OpenChange/MAPIStoreCalendarAttachment.m, + OpenChange/MAPIStoreMailAttachment.m: replaced the + getProperty:withTag:inMemCtx: method with its switch case to make + use of the more recent dynamic property getters API. + * OpenChange/gen-property-selectors.py: added a few exclusions, which are either undocumented or unused. diff --git a/OpenChange/MAPIStoreAttachment.m b/OpenChange/MAPIStoreAttachment.m index 04377d256..e36ea9434 100644 --- a/OpenChange/MAPIStoreAttachment.m +++ b/OpenChange/MAPIStoreAttachment.m @@ -65,30 +65,28 @@ return mimeAttachTag; } -- (int) getProperty: (void **) data - withTag: (enum MAPITAGS) propTag - inMemCtx: (TALLOC_CTX *) memCtx +- (int) getPrMid: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx { - int rc; + *data = MAPILongLongValue (memCtx, [container objectId]); - rc = MAPISTORE_SUCCESS; - switch (propTag) - { - case PR_MID: - *data = MAPILongLongValue (memCtx, [container objectId]); - break; - case PR_ATTACH_NUM: - *data = MAPILongValue (memCtx, aid); - break; - case PR_RENDERING_POSITION: - *data = MAPILongValue (memCtx, 0xffffffff); - break; + return MAPISTORE_SUCCESS; +} - default: - rc = [super getProperty: data withTag: propTag inMemCtx: memCtx]; - } +- (int) getPrAttachNum: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = MAPILongValue (memCtx, aid); - return rc; + return MAPISTORE_SUCCESS; +} + +- (int) getPrRenderingPosition: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = MAPILongValue (memCtx, 0xffffffff); + + return MAPISTORE_SUCCESS; } - (int) openEmbeddedMessage: (MAPIStoreAttachmentMessage **) messagePtr diff --git a/OpenChange/MAPIStoreCalendarAttachment.m b/OpenChange/MAPIStoreCalendarAttachment.m index 640865854..5bfce054b 100644 --- a/OpenChange/MAPIStoreCalendarAttachment.m +++ b/OpenChange/MAPIStoreCalendarAttachment.m @@ -34,36 +34,34 @@ @implementation MAPIStoreCalendarAttachment -- (int) getProperty: (void **) data - withTag: (enum MAPITAGS) propTag - inMemCtx: (TALLOC_CTX *) localMemCtx +- (int) getPrAttachmentHidden: (void **) data + inMemCtx: (TALLOC_CTX *) localMemCtx { - int rc; + *data = MAPIBoolValue (localMemCtx, YES); - rc = MAPISTORE_SUCCESS; - switch (propTag) - { - case PR_ATTACHMENT_HIDDEN: - *data = MAPIBoolValue (localMemCtx, YES); - break; - case PR_ATTACHMENT_FLAGS: - *data = MAPILongValue (localMemCtx, 0x00000002); /* afException */ - break; - case PR_ATTACH_METHOD: - *data = MAPILongValue (localMemCtx, 0x00000005); /* afEmbeddedMessage */ - break; - - // case PidTagExceptionStartTime: - // case PidTagExceptionEndTime: - // case PidTagExceptionReplaceTime: - - default: - rc = [super getProperty: data withTag: propTag inMemCtx: localMemCtx]; - } - - return rc; + return MAPISTORE_SUCCESS; } +- (int) getPrAttachmentFlags: (void **) data + inMemCtx: (TALLOC_CTX *) localMemCtx +{ + *data = MAPILongValue (localMemCtx, 0x00000002); /* afException */ + + return MAPISTORE_SUCCESS; +} + +- (int) getPrAttachmMethod: (void **) data + inMemCtx: (TALLOC_CTX *) localMemCtx +{ + *data = MAPILongValue (localMemCtx, 0x00000005); /* afEmbeddedMessage */ + + return MAPISTORE_SUCCESS; +} + +// case PidTagExceptionStartTime: +// case PidTagExceptionEndTime: +// case PidTagExceptionReplaceTime: + /* subclasses */ - (MAPIStoreEmbeddedMessage *) openEmbeddedMessage { diff --git a/OpenChange/MAPIStoreMailAttachment.m b/OpenChange/MAPIStoreMailAttachment.m index 8bd42358a..1fbae730a 100644 --- a/OpenChange/MAPIStoreMailAttachment.m +++ b/OpenChange/MAPIStoreMailAttachment.m @@ -21,6 +21,7 @@ */ #import +#import #import #import #import @@ -67,100 +68,138 @@ ASSIGN (bodyInfo, newBodyInfo); } -- (int) getProperty: (void **) data - withTag: (enum MAPITAGS) propTag - inMemCtx: (TALLOC_CTX *) localMemCtx +- (int) getPrAttachMethod: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = MAPILongValue (memCtx, 0x00000001); // afByValue + + return MAPISTORE_SUCCESS; +} + +- (int) getPrAttachTag: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = [[self mimeAttachTag] asBinaryInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (int) getPrAttachSize: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + uint32_t longValue; + + longValue = [[bodyInfo objectForKey: @"size"] longValue]; + *data = MAPILongValue (memCtx, longValue); + + return MAPISTORE_SUCCESS; +} + +- (int) getPrRecordKey: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx { static char recordBytes[] = {0xd9, 0xd8, 0x11, 0xa3, 0xe2, 0x90, 0x18, 0x41, - 0x9e, 0x04, 0x58, 0x46, 0x9d, 0x6d, 0x1b, 0x68}; - uint32_t longValue; - NSString *stringValue; - NSCalendarDate *date; + 0x9e, 0x04, 0x58, 0x46, 0x9d, 0x6d, 0x1b, + 0x68}; + + *data = [[NSData dataWithBytes: recordBytes length: 16] + asBinaryInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (NSString *) _fileName +{ + NSString *fileName; NSDictionary *parameters; - int rc; - rc = MAPISTORE_SUCCESS; - switch (propTag) + fileName = [[bodyInfo objectForKey: @"parameterList"] + objectForKey: @"name"]; + if (!fileName) { - case PR_ATTACH_METHOD: - *data = MAPILongValue (localMemCtx, 0x00000001); // afByValue - break; - case PR_ATTACH_TAG: - *data = [[self mimeAttachTag] - asBinaryInMemCtx: localMemCtx]; - break; - case PR_ATTACH_SIZE: - longValue = [[bodyInfo objectForKey: @"size"] longValue]; - *data = MAPILongValue (localMemCtx, longValue); - break; - - case PR_RECORD_KEY: - *data = [[NSData dataWithBytes: recordBytes length: 16] - asBinaryInMemCtx: localMemCtx]; - break; - - // PR_RECORD_KEY (0xFF90102) D9 D8 11 A3 E2 90 18 41 9E 04 58 46 9D 6D 1B 68 - - case PR_ATTACH_LONG_FILENAME_UNICODE: - case PR_ATTACH_FILENAME_UNICODE: - stringValue = [[bodyInfo objectForKey: @"parameterList"] - objectForKey: @"name"]; - if (!stringValue) - { - parameters = [[bodyInfo objectForKey: @"disposition"] - objectForKey: @"parameterList"]; - stringValue = [parameters objectForKey: @"filename"]; - } - - if (propTag == PR_ATTACH_FILENAME_UNICODE) - { - NSString *baseName, *ext; - - baseName = [stringValue stringByDeletingPathExtension]; - if ([baseName length] > 8) - baseName = [baseName substringToIndex: 8]; - - ext = [stringValue pathExtension]; - if ([ext length] > 3) - ext = [ext substringToIndex: 3]; - stringValue = [NSString stringWithFormat: @"%@.%@", baseName, ext]; - } - - *data = [stringValue asUnicodeInMemCtx: localMemCtx]; - break; - - case PR_DISPLAY_NAME_UNICODE: /* TODO: check if description ? */ - stringValue = [bodyInfo objectForKey: @"description"]; - *data = [stringValue asUnicodeInMemCtx: localMemCtx]; - break; - - case PR_ATTACH_CONTENT_ID_UNICODE: - stringValue = [bodyInfo objectForKey: @"bodyId"]; - *data = [stringValue asUnicodeInMemCtx: localMemCtx]; - break; - - case PR_ATTACH_MIME_TAG_UNICODE: - stringValue = [NSString stringWithFormat: @"%@/%@", - [bodyInfo objectForKey: @"type"], - [bodyInfo objectForKey: @"subtype"]]; - *data = [[stringValue lowercaseString] asUnicodeInMemCtx: localMemCtx]; - break; - - case PR_CREATION_TIME: - case PR_LAST_MODIFICATION_TIME: - date = [[container sogoObject] date]; - *data = [date asFileTimeInMemCtx: localMemCtx]; - break; - - case PR_ATTACH_DATA_BIN: - *data = [[sogoObject fetchBLOB] asBinaryInMemCtx: localMemCtx]; - break; - - default: - rc = [super getProperty: data withTag: propTag inMemCtx: localMemCtx]; + parameters = [[bodyInfo objectForKey: @"disposition"] + objectForKey: @"parameterList"]; + fileName = [parameters objectForKey: @"filename"]; } - return rc; + return fileName; +} + +- (int) getPrAttachLongFilename: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = [[self _fileName] asUnicodeInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (int) getPrAttachFilename: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + NSString *fileName, *baseName, *ext; + + fileName = [self _fileName]; + baseName = [fileName stringByDeletingPathExtension]; + if ([baseName length] > 8) + baseName = [baseName substringToIndex: 8]; + + ext = [fileName pathExtension]; + if ([ext length] > 3) + ext = [ext substringToIndex: 3]; + fileName = [NSString stringWithFormat: @"%@.%@", baseName, ext]; + + *data = [fileName asUnicodeInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (int) getPrDisplayName: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = [[bodyInfo objectForKey: @"description"] + asUnicodeInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (int) getPrAttachContentId: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = [[bodyInfo objectForKey: @"bodyId"] + asUnicodeInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (int) getPrAttachMimeTag: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + NSString *mimeTag; + + mimeTag = [NSString stringWithFormat: @"%@/%@", + [bodyInfo objectForKey: @"type"], + [bodyInfo objectForKey: @"subtype"]]; + *data = [[mimeTag lowercaseString] asUnicodeInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (int) getPrAttachDataBin: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = [[sogoObject fetchBLOB] asBinaryInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (NSDate *) creationTime +{ + return [[container sogoObject] date]; +} + +- (NSDate *) lastModificationTime +{ + return [[container sogoObject] date]; } @end