]> err.no Git - scalable-opengroupware.org/commitdiff
added caching of ACL entries
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 8 Jul 2005 08:46:10 +0000 (08:46 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 8 Jul 2005 08:46:10 +0000 (08:46 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@694 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/SOGoMailConnectionEntry.h
SOGo/SoObjects/Mailer/SOGoMailConnectionEntry.m
SOGo/SoObjects/Mailer/SOGoMailFolder.h
SOGo/SoObjects/Mailer/SOGoMailFolder.m
SOGo/SoObjects/Mailer/SOGoMailManager.m
SOGo/SoObjects/Mailer/Version

index 43def422408e62e318fb3587e63494696bf51e95..438b09cedf2f4ae1e35c20230f5cad3a312b7d97 100644 (file)
@@ -1,3 +1,12 @@
+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" 
index 4b8a90175198d12e2c8255ca04785f2275d19bf4..0e3fcfc2e6e549cc3d30a8e8b30004dbae4dcd33 100644 (file)
    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;
@@ -64,6 +75,9 @@
 - (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
index 9875bd9d4def0fc3ba49660cfe28e17cd0b1e19e..a113fda7e0fe5590fdf16fd2d55ea64e9bd001df 100644 (file)
@@ -43,6 +43,7 @@
 }
 
 - (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 */
index 1978a001cf3cfe6d537ca7da4a81c427e41f340f..c4e4961277fc25734693439cea15920f776a2268 100644 (file)
@@ -42,7 +42,7 @@
   NSString        *folderType;
   SOGoMailboxInfo *selectInfo;
   struct {
-    int didCheckACL:1;
+    int didCheckMyRights:1;
     int isDeleteAndExpungeAllowed:1;
     int reserved:30;
   } somfFlags;
index c901e19f6003f00297f3a59197a87792af7b91be..262278f0af1c9fd8ea812ff3bd9e5a056091e19a 100644 (file)
 - (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;
 }
index 4a36a024f08f6525baac6d0e7e33119e1a824bf1..ea9e1fcf38b0b266a14273f441685c9d8222a916 100644 (file)
@@ -43,7 +43,7 @@ static BOOL           debugKeys  = NO;
 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 {
@@ -1009,6 +1009,13 @@ static NSString       *imap4Separator  = nil;
     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];
@@ -1017,8 +1024,12 @@ static NSString       *imap4Separator  = nil;
     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) */
index 94cce5eab7c97cf67bcce9e3977eeefdac335a07..8fcde6b1f497679e55ffb5a0cc2f3dc13c1dfc70 100644 (file)
@@ -1,6 +1,6 @@
 # Version file
 
-SUBMINOR_VERSION:=91
+SUBMINOR_VERSION:=92
 
 # v0.9.91 requires libNGMime       v4.5.222
 # v0.9.69 requires libNGMime       v4.5.210