Monotone-Parent: c2bdfbc593f7ac0758ee78b63baee4d5b409e6bd

Monotone-Revision: a297f80b93f195cc2534f1493b2f4e4a124cf3ca

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-10-26T21:33:51
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2011-10-26 21:33:51 +00:00
parent 75e3dac9b6
commit cc335e8f72
12 changed files with 592 additions and 1306 deletions

View File

@@ -20,36 +20,24 @@
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSData.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
#import <NGExtensions/NSObject+Logs.h>
#import "MAPIStoreContext.h"
#import "MAPIStorePropertySelectors.h"
#import "MAPIStoreTypes.h"
#import "NSData+MAPIStore.h"
#import "NSObject+MAPIStore.h"
#import "NSString+MAPIStore.h"
#import "SOGoMAPIFSMessage.h"
#import "MAPIStoreFSMessage.h"
#import "MAPIStoreTypes.h"
#import "NSData+MAPIStore.h"
#undef DEBUG
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>
Class NSNumberK;
@implementation MAPIStoreFSMessage
+ (void) initialize
{
NSNumberK = [NSNumber class];
}
+ (int) getAvailableProperties: (struct SPropTagArray **) propertiesP
inMemCtx: (TALLOC_CTX *) memCtx
{
@@ -77,145 +65,6 @@ Class NSNumberK;
return MAPISTORE_SUCCESS;
}
- (id) init
{
if ((self = [super init]))
fetchedAttachments = NO;
return self;
}
- (uint64_t) objectVersion
{
NSNumber *version;
version = [[sogoObject properties] objectForKey: @"version"];
return (version
? exchange_globcnt ([version unsignedLongLongValue])
: ULLONG_MAX);
}
- (int) getProperty: (void **) data
withTag: (enum MAPITAGS) propTag
inMemCtx: (TALLOC_CTX *) memCtx
{
id value;
int rc;
value = [[sogoObject properties] objectForKey: MAPIPropertyKey (propTag)];
if (value)
rc = [value getMAPIValue: data forTag: propTag inMemCtx: memCtx];
else
rc = [super getProperty: data withTag: propTag inMemCtx: memCtx];
return rc;
}
- (int) getPrSubject: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
{
/* if we get here, it means that the properties file didn't contain a
relevant value */
return [self getEmptyString: data inMemCtx: memCtx];
}
- (int) getPrMessageClass: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
{
/* if we get here, it means that the properties file didn't contain a
relevant value */
*data = [@"IPM.Note" asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
}
- (int) getPrChangeKey: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
{
NSData *changeKey;
int rc;
changeKey = [[sogoObject properties]
objectForKey: MAPIPropertyKey (PR_CHANGE_KEY)];
if (changeKey)
{
*data = [changeKey asBinaryInMemCtx: memCtx];
rc = MAPISTORE_SUCCESS;
}
else
rc = [super getPrChangeKey: data inMemCtx: memCtx];
return rc;
}
- (int) getAvailableProperties: (struct SPropTagArray **) propertiesP
inMemCtx: (TALLOC_CTX *) memCtx
{
NSArray *keys;
NSUInteger count, max;
NSString *key;
struct SPropTagArray *availableProps;
keys = [[sogoObject properties] allKeys];
max = [keys count];
availableProps = talloc_zero (NULL, struct SPropTagArray);
availableProps->cValues = max;
availableProps->aulPropTag = talloc_array (availableProps, enum MAPITAGS, max);
for (count = 0; count < max; count++)
{
// #if (GS_SIZEOF_LONG == 4)
// return [NSNumber numberWithUnsignedLong: propTag];
// #elif (GS_SIZEOF_INT == 4)
// return [NSNumber numberWithUnsignedInt: propTag];
// #else
key = [keys objectAtIndex: count];
if ([key isKindOfClass: NSNumberK])
{
#if (GS_SIZEOF_LONG == 4)
availableProps->aulPropTag[count] = [[keys objectAtIndex: count] unsignedLongValue];
#elif (GS_SIZEOF_INT == 4)
availableProps->aulPropTag[count] = [[keys objectAtIndex: count] unsignedIntValue];
#endif
}
}
*propertiesP = availableProps;
return MAPISTORE_SUCCESS;
}
- (NSArray *) attachmentsKeysMatchingQualifier: (EOQualifier *) qualifier
andSortOrderings: (NSArray *) sortOrderings
{
NSDictionary *attachments;
NSArray *keys;
NSString *key, *newKey;
NSUInteger count, max, aid;
MAPIStoreAttachment *attachment;
if (!fetchedAttachments)
{
attachments = [[sogoObject properties] objectForKey: @"attachments"];
keys = [attachments allKeys];
max = [keys count];
if (max > 0)
{
aid = [keys count];
for (count = 0; count < max; count++)
{
key = [keys objectAtIndex: count];
attachment = [attachments objectForKey: key];
newKey = [NSString stringWithFormat: @"%ul", (aid + count)];
[attachmentParts setObject: attachment forKey: newKey];
}
}
fetchedAttachments = YES;
}
return [super attachmentKeysMatchingQualifier: qualifier
andSortOrderings: sortOrderings];
}
- (void) save
{
uint64_t newVersion;