Monotone-Parent: a297f80b93f195cc2534f1493b2f4e4a124cf3ca

Monotone-Revision: d9b2b0a2845a06c22e7a7b71eb7857acb44bf0e4

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-10-26T23:52:55
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2011-10-26 23:52:55 +00:00
parent cc335e8f72
commit f94d90acd2
15 changed files with 309 additions and 47 deletions

View File

@@ -1,3 +1,11 @@
2011-10-26 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreVolatileMessage.m: MAPIStoreMemMessage renamed
to MAPIStoreVolatileMessage.
* OpenChange/SOGoMAPIVolatileMessage.m: SOGoMAPIMemMessage renamed
to SOGoMAPIVolatileMessage.
2011-10-26 Francis Lachapelle <flachapelle@inverse.ca>
* SoObjects/SOGo/SQLSource.m

View File

@@ -1,4 +1,4 @@
/* EOQualifier+MAPIMem.h - this file is part of SOGo
/* EOQualifier+MAPI.h - this file is part of SOGo
*
* Copyright (C) 2010 Inverse inc.
*
@@ -20,17 +20,17 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef EOQUALIFIER_MAPIMEM_H
#define EOQUALIFIER_MAPIMEM_H
#ifndef EOQUALIFIER_MAPI_H
#define EOQUALIFIER_MAPI_H
#import <EOControl/EOQualifier.h>
@class SOGoMAPIMemMessage;
@class SOGoMAPIVolatileMessage;
@interface EOQualifier (MAPIStoreRestrictions)
- (BOOL) evaluateMAPIMemMessage: (SOGoMAPIMemMessage *) message;
- (BOOL) evaluateMAPIVolatileMessage: (SOGoMAPIVolatileMessage *) message;
@end
#endif /* EOQUALIFIER_MAPIMEM_H */
#endif /* EOQUALIFIER_MAPI_H */

View File

@@ -1,4 +1,4 @@
/* EOQualifier+MAPIMem.m - this file is part of SOGo
/* EOQualifier+MAPI.m - this file is part of SOGo
*
* Copyright (C) 2010 Inverse inc.
*
@@ -28,20 +28,20 @@
#import <NGExtensions/NSObject+Logs.h>
#import "SOGoMAPIMemMessage.h"
#import "SOGoMAPIVolatileMessage.h"
#import "EOQualifier+MAPIMem.h"
#import "EOQualifier+MAPI.h"
#import "EOBitmaskQualifier.h"
@implementation EOQualifier (MAPIStoreRestrictions)
- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties
- (BOOL) _evaluateMAPIVolatileMessageProperties: (NSDictionary *) properties
{
[self subclassResponsibility: _cmd];
return NO;
}
- (BOOL) evaluateMAPIMemMessage: (SOGoMAPIMemMessage *) message
- (BOOL) evaluateMAPIVolatileMessage: (SOGoMAPIVolatileMessage *) message
{
NSDictionary *properties;
BOOL rc;
@@ -49,7 +49,7 @@
[self logWithFormat: @"evaluating message '%@'", message];
properties = [message properties];
rc = [self _evaluateMAPIMemMessageProperties: properties];
rc = [self _evaluateMAPIVolatileMessageProperties: properties];
[self logWithFormat: @" evaluation result: %d", rc];
@@ -60,7 +60,7 @@
@implementation EOAndQualifier (MAPIStoreRestrictionsPrivate)
- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties
- (BOOL) _evaluateMAPIVolatileMessageProperties: (NSDictionary *) properties
{
NSUInteger i;
BOOL rc;
@@ -69,7 +69,7 @@
for (i = 0; rc && i < count; i++)
rc = [[qualifiers objectAtIndex: i]
_evaluateMAPIMemMessageProperties: properties];
_evaluateMAPIVolatileMessageProperties: properties];
return rc;
}
@@ -78,7 +78,7 @@
@implementation EOOrQualifier (MAPIStoreRestrictionsPrivate)
- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties
- (BOOL) _evaluateMAPIVolatileMessageProperties: (NSDictionary *) properties
{
NSUInteger i;
BOOL rc;
@@ -87,7 +87,7 @@
for (i = 0; !rc && i < count; i++)
rc = [[qualifiers objectAtIndex: i]
_evaluateMAPIMemMessageProperties: properties];
_evaluateMAPIVolatileMessageProperties: properties];
return rc;
}
@@ -96,9 +96,9 @@
@implementation EONotQualifier (MAPIStoreRestrictionsPrivate)
- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties
- (BOOL) _evaluateMAPIVolatileMessageProperties: (NSDictionary *) properties
{
return ![qualifier _evaluateMAPIMemMessageProperties: properties];
return ![qualifier _evaluateMAPIVolatileMessageProperties: properties];
}
@end
@@ -107,7 +107,7 @@
typedef BOOL (*EOComparator) (id, SEL, id);
- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties
- (BOOL) _evaluateMAPIVolatileMessageProperties: (NSDictionary *) properties
{
id finalKey;
id propValue;
@@ -136,7 +136,7 @@ typedef BOOL (*EOComparator) (id, SEL, id);
@implementation EOBitmaskQualifier (MAPIStoreRestrictionsPrivate)
- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties
- (BOOL) _evaluateMAPIVolatileMessageProperties: (NSDictionary *) properties
{
NSNumber *propTag;
id propValue;

View File

@@ -34,7 +34,7 @@ $(SOGOBACKEND)_OBJC_FILES += \
MAPIStoreTypes.m \
MAPIStorePropertySelectors.m \
\
SOGoMAPIMemMessage.m \
SOGoMAPIVolatileMessage.m \
SOGoMAPIFSFolder.m \
SOGoMAPIFSMessage.m \
\
@@ -51,7 +51,7 @@ $(SOGOBACKEND)_OBJC_FILES += \
MAPIStoreFolderTable.m \
MAPIStorePermissionsTable.m \
\
MAPIStoreMemMessage.m \
MAPIStoreVolatileMessage.m \
\
MAPIStoreFSBaseContext.m \
MAPIStoreFSFolder.m \
@@ -116,7 +116,7 @@ $(SOGOBACKEND)_OBJC_FILES += \
NSValue+MAPIStore.m \
\
EOBitmaskQualifier.m \
EOQualifier+MAPIMem.m \
EOQualifier+MAPI.m \
$(SOGOBACKEND)_RESOURCE_FILES += \

View File

@@ -27,7 +27,7 @@
#import <Foundation/NSURL.h>
#import <NGExtensions/NSObject+Logs.h>
#import <EOControl/EOQualifier.h>
#import "EOQualifier+MAPIMem.h"
#import "EOQualifier+MAPI.h"
#import "MAPIStoreFSFolderTable.h"
#import "MAPIStoreFSMessage.h"
#import "MAPIStoreFSMessageTable.h"
@@ -138,7 +138,7 @@ static Class EOKeyValueQualifierK;
subfolderKey = [entries objectAtIndex: count];
subfolder = [self lookupFolder: subfolderKey];
propertiesMessage = [subfolder propertiesMessage];
if ([qualifier evaluateMAPIMemMessage: propertiesMessage])
if ([qualifier evaluateMAPIVolatileMessage: propertiesMessage])
[filteredEntries addObject: subfolderKey];
}
entries = filteredEntries;

View File

@@ -23,9 +23,9 @@
#ifndef MAPISTOREFSMESSAGE_H
#define MAPISTOREFSMESSAGE_H
#import "MAPIStoreMemMessage.h"
#import "MAPIStoreVolatileMessage.h"
@interface MAPIStoreFSMessage : MAPIStoreMemMessage
@interface MAPIStoreFSMessage : MAPIStoreVolatileMessage
@end
#endif /* MAPISTOREFSMESSAGE_H */

View File

@@ -56,9 +56,7 @@
#import "NSString+MAPIStore.h"
#import "SOGoMAPIFSMessage.h"
/* Those are parts of a hack that enables creating mails to IMAP folders from
Exchange properties */
#import "SOGoMAPIMemMessage.h"
#import "SOGoMAPIVolatileMessage.h"
#import "MAPIStoreMailVolatileMessage.h"
#import "MAPIStoreMailFolder.h"
@@ -994,9 +992,9 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP)
- (MAPIStoreMessage *) createMessage
{
MAPIStoreMailVolatileMessage *newMessage;
SOGoMAPIMemMessage *newObject;
SOGoMAPIVolatileMessage *newObject;
newObject = [SOGoMAPIMemMessage
newObject = [SOGoMAPIVolatileMessage
objectWithName: [SOGoObject globallyUniqueObjectId]
inContainer: sogoObject];
newMessage

View File

@@ -23,9 +23,9 @@
#ifndef MAPISTOREMAILVOLATILEMESSAGE_H
#define MAPISTOREMAILVOLATILEMESSAGE_H
#import "MAPIStoreMemMessage.h"
#import "MAPIStoreVolatileMessage.h"
@interface MAPIStoreMailVolatileMessage : MAPIStoreMemMessage
@interface MAPIStoreMailVolatileMessage : MAPIStoreVolatileMessage
- (int) submitWithFlags: (enum SubmitFlags) flags;

View File

@@ -57,7 +57,7 @@
#import "MAPIStoreTypes.h"
#import "NSObject+MAPIStore.h"
#import "NSString+MAPIStore.h"
#import "SOGoMAPIMemMessage.h"
#import "SOGoMAPIVolatileMessage.h"
#import "MAPIStoreMailVolatileMessage.h"

View File

@@ -0,0 +1,35 @@
/* MAPIStoreVolatileMessage.h - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef MAPISTOREVOLATILEMESSAGE_H
#define MAPISTOREVOLATILEMESSAGE_H
#import "MAPIStoreMessage.h"
@interface MAPIStoreVolatileMessage : MAPIStoreMessage
{
BOOL fetchedAttachments;
}
@end
#endif /* MAPISTOREVOLATILEMESSAGE_H */

View File

@@ -0,0 +1,221 @@
/* MAPIStoreVolatileMessage.m - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
#import <NGExtensions/NGHashMap.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSString+Encoding.h>
#import <NGMail/NGMimeMessage.h>
#import <NGMail/NGMimeMessageGenerator.h>
#import <NGImap4/NGImap4Client.h>
#import <NGImap4/NGImap4Connection.h>
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSCalendarDate+SOGo.h>
#import <SOGo/NSString+Utilities.h>
#import <Mailer/SOGoMailFolder.h>
#import <Mailer/NSString+Mail.h>
#import "MAPIStoreContext.h"
#import "MAPIStoreMailFolder.h"
#import "MAPIStoreMapping.h"
#import "MAPIStoreTypes.h"
#import "NSData+MAPIStore.h"
#import "NSObject+MAPIStore.h"
#import "NSString+MAPIStore.h"
#import "SOGoMAPIVolatileMessage.h"
#import "MAPIStoreVolatileMessage.h"
#undef DEBUG
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>
Class NSNumberK;
@implementation MAPIStoreVolatileMessage
+ (void) initialize
{
NSNumberK = [NSNumber class];
}
- (id) init
{
if ((self = [super init]))
fetchedAttachments = NO;
return self;
}
- (int) addPropertiesFromRow: (struct SRow *) aRow
{
int rc;
rc = [super addPropertiesFromRow: aRow];
if (rc == MAPISTORE_SUCCESS)
{
[sogoObject appendProperties: properties];
[properties removeAllObjects];
}
return rc;
}
- (void) addProperties: (NSDictionary *) newProperties
{
[super addProperties: newProperties];
[sogoObject appendProperties: newProperties];
[properties removeAllObjects];
}
- (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
{
*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++)
{
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
{
[self subclassResponsibility: _cmd];
}
@end

View File

@@ -29,7 +29,7 @@
#import <NGExtensions/NSObject+Logs.h>
#import "EOQualifier+MAPIMem.h"
#import "EOQualifier+MAPI.h"
#import "SOGoMAPIFSMessage.h"
#import "SOGoMAPIFSFolder.h"
@@ -242,7 +242,7 @@ static NSString *privateDir = nil;
message = [self lookupName: messageKey
inContext: nil
acquire: NO];
if ([qualifier evaluateMAPIMemMessage: message])
if ([qualifier evaluateMAPIVolatileMessage: message])
[keys addObject: messageKey];
}
}

View File

@@ -23,12 +23,12 @@
#ifndef SOGOMAPIFSMESSAGE_H
#define SOGOMAPIFSMESSAGE_H
#import "SOGoMAPIMemMessage.h"
#import "SOGoMAPIVolatileMessage.h"
@class NSCalendarDate;
@class NSString;
@interface SOGoMAPIFSMessage : SOGoMAPIMemMessage
@interface SOGoMAPIFSMessage : SOGoMAPIVolatileMessage
{
BOOL propertiesLoaded;
NSString *completeFilename;

View File

@@ -1,4 +1,4 @@
/* SOGoMAPIMemMessage.h - this file is part of SOGo
/* SOGoMAPIVolatileMessage.h - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
@@ -20,15 +20,15 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef SOGOMAPIMEMMESSAGE_H
#define SOGOMAPIMEMMESSAGE_H
#ifndef SOGOMAPIVOLATILEMESSAGE_H
#define SOGOMAPIVOLATILEMESSAGE_H
#import <SOGo/SOGoObject.h>
@class NSDictionary;
@class NSMutableDictionary;
@interface SOGoMAPIMemMessage : SOGoObject
@interface SOGoMAPIVolatileMessage : SOGoObject
{
NSMutableDictionary *properties;
}
@@ -38,4 +38,4 @@
@end
#endif /* SOGOMAPIMEMMESSAGE_H */
#endif /* SOGOMAPIVOLATILEMESSAGE_H */

View File

@@ -1,4 +1,4 @@
/* SOGoMAPIMemMessage.m - this file is part of SOGo
/* SOGoMAPIVolatileMessage.m - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
@@ -22,9 +22,9 @@
#import <Foundation/NSDictionary.h>
#import "SOGoMAPIMemMessage.h"
#import "SOGoMAPIVolatileMessage.h"
@implementation SOGoMAPIMemMessage
@implementation SOGoMAPIVolatileMessage
- (id) init
{