Monotone-Parent: 72951a15317b904c573f349f0cc5252a50749fd3

Monotone-Revision: bafe1b063c24f5ef34672c7a98260bbc66509abe

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-08-12T22:58:35
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2011-08-12 22:58:35 +00:00
parent 61f99524fc
commit 33051f01e3
5 changed files with 78 additions and 12 deletions

View File

@ -1,11 +1,21 @@
2011-08-12 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Mailer/SOGoMailFolder.m
(-prefetchCoreInfosForMessageKeys:): new method that enables the
prefetching and caching of "core infos" for messages.
(-lookupName:inContext:acquire:): looked up messages are now fed
with their cached core infos, if present.
* SoObjects/Mailer/SOGoMailObject.m: (addFlags:, removeFlags:)
release "coreInfos" rather than flagsCache, which has been
obsoleted.
(_hasFlag:): make use of "coreInfos" to fetch the flags since most
of the time the other infos will be fetch for the same object,
bringing a 30ms speedup per message.
(-setCoreInfos): new accessor that enables setting coreInfos from
an external object.
(+initialize): coreInfoKeys was renamed to SOGoMailCoreInfoKeys
and has now been published.
* OpenChange/MAPIStoreTable.m (-setHandleId:): only register the
table in the notification cache if the provided handle id is not

View File

@ -35,7 +35,7 @@
The SOGoMailFolder maps to an IMAP4 folder from NGImap4.
*/
@class NSData, NSArray, NSException, NSMutableArray;
@class NSData, NSArray, NSException, NSMutableArray, NSMutableDictionary;
@class NGImap4MailboxInfo;
@class WOResponse;
@ -44,11 +44,14 @@
NSMutableArray *filenames;
NSString *folderType;
NSDictionary *mailboxACL;
NSMutableDictionary *prefetchedInfos;
}
- (NSString *) absoluteImap4Name;
/* messages */
- (void) prefetchCoreInfosForMessageKeys: (NSArray *) keys;
- (NSArray *) toOneRelationshipKeys;
- (NSArray *) toManyRelationshipKeys;

View File

@ -46,6 +46,7 @@
#import <SOGo/DOMNode+SOGo.h>
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSString+Utilities.h>
#import <SOGo/NSString+DAV.h>
#import <SOGo/NSArray+DAV.h>
@ -123,6 +124,7 @@ static NSString *defaultUserID = @"anyone";
{
[self _adjustOwner];
mailboxACL = nil;
prefetchedInfos = nil;
}
return self;
@ -133,6 +135,7 @@ static NSString *defaultUserID = @"anyone";
[filenames release];
[folderType release];
[mailboxACL release];
[prefetchedInfos release];
[super dealloc];
}
@ -265,6 +268,43 @@ static NSString *defaultUserID = @"anyone";
}
/* messages */
- (void) prefetchCoreInfosForMessageKeys: (NSArray *) keys
{
NSDictionary *infos;
NSMutableArray *uids;
NSUInteger count, max, keyLength;
NSString *key;
if (!SOGoMailCoreInfoKeys)
{
/* ensure SOGoMailCoreInfoKeys is initialized */
[SOGoMailObject class];
}
[prefetchedInfos release];
max = [keys count];
if (max > 0)
{
uids = [NSMutableArray arrayWithCapacity: max];
for (count = 0; count < max; count++)
{
key = [keys objectAtIndex: count];
if ([key hasSuffix: @".eml"])
{
keyLength = [key length];
[uids addObject: [key substringToIndex: keyLength - 4]];
}
}
infos = (NSDictionary *) [self fetchUIDs: uids parts: SOGoMailCoreInfoKeys];
prefetchedInfos = [[NSMutableDictionary alloc] initWithCapacity: max];
[prefetchedInfos setObjects: [infos objectForKey: @"fetch"]
forKeys: uids];
}
else
prefetchedInfos = nil;
}
- (NSException *) deleteUIDs: (NSArray *) uids
useTrashFolder: (BOOL *) withTrash
@ -700,7 +740,7 @@ static NSString *defaultUserID = @"anyone";
inContext: (id)_ctx
acquire: (BOOL) _acquire
{
NSString *folderName, *fullFolderName, *className;
NSString *folderName, *fullFolderName, *className, *uid;
SOGoMailAccount *mailAccount;
id obj;
@ -736,7 +776,11 @@ static NSString *defaultUserID = @"anyone";
}
else if (isdigit ([_key characterAtIndex: 0])
&& [[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]])
obj = [SOGoMailObject objectWithName: _key inContainer: self];
{
obj = [SOGoMailObject objectWithName: _key inContainer: self];
uid = [_key substringToIndex: [_key length] - 4];
[obj setCoreInfos: [prefetchedInfos objectForKey: uid]];
}
}
if (!obj && _acquire)

View File

@ -48,6 +48,8 @@
@class NGImap4Envelope;
@class NGImap4EnvelopeAddress;
NSArray *SOGoMailCoreInfoKeys;
@interface SOGoMailObject : SOGoMailBaseObject
{
id coreInfos;
@ -63,6 +65,7 @@
- (BOOL) doesMailExist;
- (id) fetchCoreInfos; // TODO: what does it do?
- (void) setCoreInfos: (NSDictionary *) newCoreInfos;
- (NGImap4Envelope *) envelope;
- (NSString *) subject;

View File

@ -62,7 +62,7 @@
@implementation SOGoMailObject
static NSArray *coreInfoKeys = nil;
NSArray *SOGoMailCoreInfoKeys = nil;
static NSString *mailETag = nil;
static BOOL heavyDebug = NO;
static BOOL debugOn = NO;
@ -71,15 +71,16 @@ static BOOL debugSoParts = NO;
+ (void) initialize
{
if (!coreInfoKeys)
if (!SOGoMailCoreInfoKeys)
{
/* Note: see SOGoMailManager.m for allowed IMAP4 keys */
coreInfoKeys = [[NSArray alloc] initWithObjects:
@"FLAGS", @"ENVELOPE", @"BODYSTRUCTURE",
@"RFC822.SIZE",
@"RFC822.HEADER",
// not yet supported: @"INTERNALDATE",
nil];
SOGoMailCoreInfoKeys
= [[NSArray alloc] initWithObjects:
@"FLAGS", @"ENVELOPE", @"BODYSTRUCTURE",
@"RFC822.SIZE",
@"RFC822.HEADER",
// not yet supported: @"INTERNALDATE",
nil];
/* The following disabled code should not be needed, except if we use
annotations (see davEntityTag below) */
@ -219,7 +220,7 @@ static BOOL debugSoParts = NO;
if (!coreInfos)
{
msgs = [self fetchParts: coreInfoKeys]; // returns dict
msgs = [self fetchParts: SOGoMailCoreInfoKeys]; // returns dict
if (heavyDebug)
[self logWithFormat: @"M: %@", msgs];
msgs = [msgs valueForKey: @"fetch"];
@ -231,6 +232,11 @@ static BOOL debugSoParts = NO;
return coreInfos;
}
- (void) setCoreInfos: (NSDictionary *) newCoreInfos
{
ASSIGN (coreInfos, newCoreInfos);
}
- (id) bodyStructure
{
id body;