+2005-07-08 Helge Hess <helge.hess@opengroupware.org>
+
+ * v0.9.92
+
+ * SOGoMailManager.m, SOGoMailConnectionEntry.m: added caching of
+ per-folder permissions to avoid an IMAP4 query on each folder click
+
+ * SOGoMailFolder.m: fixed an inconsistency in the naming of flags
+
2005-07-07 Helge Hess <helge.hess@opengroupware.org>
* SOGoMailManager.m, SOGoMailFolder.m: added methods to "bulk add"
SOGoMailConnectionEntry
A cached connection to an IMAP4 server plus some cached objects.
+
+ It caches:
+ - the folder hierarchy
+ - uid sets?
+ - 'myrights' permissions of mailboxes
+ ?
*/
-@class NSString, NSDate, NSArray, NSDictionary, NSURL;
+@class NSString, NSDate, NSArray, NSDictionary, NSURL, NSMutableDictionary;
@class NGImap4Client;
@interface SOGoMailConnectionEntry : NSObject
NGImap4Client *client;
NSString *password;
NSDate *creationTime;
+
+ /* hierarchy cache */
NSDictionary *subfolders;
+
+ /* permission cache */
+ NSMutableDictionary *urlToRights;
/* uids cache */
NSArray *cachedUIDs;
- (void)cacheUIDs:(NSArray *)_uids forURL:(NSURL *)_url
qualifier:(id)_q sortOrdering:(id)_so;
+- (NSString *)cachedMyRightsForURL:(NSURL *)_url;
+- (void)cacheMyRights:(NSString *)_rights forURL:(NSURL *)_url;
+
- (void)flushMailCaches;
@end
}
- (void)dealloc {
+ [self->urlToRights release];
[self->cachedUIDs release];
[self->uidFolderURL release];
[self->uidSortOrdering release];
return self->subfolders;
}
- (void)flushFolderHierarchyCache {
- [self->subfolders release];
- self->subfolders = nil;
+ [self->subfolders release]; self->subfolders = nil;
+ [self->urlToRights release]; self->urlToRights = nil;
}
+/* rights */
+
+- (NSString *)cachedMyRightsForURL:(NSURL *)_url {
+ return (_url != nil) ? [self->urlToRights objectForKey:_url] : nil;
+}
+- (void)cacheMyRights:(NSString *)_rights forURL:(NSURL *)_url {
+ if (self->urlToRights == nil)
+ self->urlToRights = [[NSMutableDictionary alloc] initWithCapacity:8];
+ [self->urlToRights setObject:_rights forKey:_url];
+}
+
+/* UIDs */
+
- (id)cachedUIDsForURL:(NSURL *)_url qualifier:(id)_q sortOrdering:(id)_so {
if (_q != nil)
return nil;
}
- (void)flushMailCaches {
- ASSIGNCOPY(self->uidSortOrdering, nil);
- ASSIGNCOPY(self->uidFolderURL, nil);
- ASSIGNCOPY(self->cachedUIDs, nil);
+ ASSIGN(self->uidSortOrdering, nil);
+ ASSIGN(self->uidFolderURL, nil);
+ ASSIGN(self->cachedUIDs, nil);
}
@end /* SOGoMailConnectionEntry */
NSString *folderType;
SOGoMailboxInfo *selectInfo;
struct {
- int didCheckACL:1;
+ int didCheckMyRights:1;
int isDeleteAndExpungeAllowed:1;
int reserved:30;
} somfFlags;
- (void)_loadACLPermissionFlags {
NSString *rights;
- if (self->somfFlags.didCheckACL)
+ if (self->somfFlags.didCheckMyRights)
return;
rights = [[self mailManager] myRightsForMailboxAtURL:[self imap4URL]
return;
}
- self->somfFlags.didCheckACL = 1;
+ self->somfFlags.didCheckMyRights = 1;
self->somfFlags.isDeleteAndExpungeAllowed =
[rights rangeOfString:@"d"].length > 0 ? 1 : 0;
}
static BOOL poolingOff = NO;
static BOOL alwaysSelect = NO;
static BOOL onlyFetchInbox = NO;
-static NSTimeInterval PoolScanInterval = 5 * 60;
+static NSTimeInterval PoolScanInterval = 5 * 60 /* every five minutes */;
static NSString *imap4Separator = nil;
+ (void)initialize {
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
reason:@"did not find IMAP4 folder (no entry)"];
}
+
+ /* check cache */
+
+ if ((result = [entry cachedMyRightsForURL:_url]) != nil)
+ return result;
+
+ /* run IMAP4 op */
folderName = [self imap4FolderNameForURL:_url];
result = [[entry client] myRights:folderName];
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
reason:@"did not find myrights for IMAP4 folder"];
}
+
+ /* cache results */
- return [result valueForKey:@"myrights"];
+ if ((result = [result valueForKey:@"myrights"]) != nil)
+ [entry cacheMyRights:result forURL:_url];
+ return result;
}
/* bulk flag adding (eg used for empty/trash) */
# Version file
-SUBMINOR_VERSION:=91
+SUBMINOR_VERSION:=92
# v0.9.91 requires libNGMime v4.5.222
# v0.9.69 requires libNGMime v4.5.210