]> err.no Git - scalable-opengroupware.org/commitdiff
added some ACL support
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 6 Jul 2005 16:40:58 +0000 (16:40 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 6 Jul 2005 16:40:58 +0000 (16:40 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@671 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/README
SOGo/SoObjects/Mailer/SOGoMailFolder.h
SOGo/SoObjects/Mailer/SOGoMailFolder.m
SOGo/SoObjects/Mailer/SOGoMailManager.h
SOGo/SoObjects/Mailer/SOGoMailManager.m
SOGo/SoObjects/Mailer/SOGoMailObject.m
SOGo/SoObjects/Mailer/Version

index 83d15f983cb8ddf0e976a5888769b64cc6213238..b4eb1c3d3b7c5854a753a637e8a10f9d9febc1f3 100644 (file)
@@ -1,3 +1,16 @@
+2005-07-06  Helge Hess  <helge.hess@opengroupware.org>
+
+       * v0.9.85
+
+       * SOGoMailFolder.m: added ability to check certain ACL permissions (and
+         cache them for one invocation)
+
+       * SOGoMailObject.m: implemented -isDeletionAllowed by asking the folder
+         for deletion
+         
+       * SOGoMailManager.m: added methods to retrieve the ACL and the myrights
+         from an IMAP4 mailbox
+
 2005-07-06  Helge Hess  <helge.hess@opengroupware.org>
 
        * SOGoMailManager.m: detect Cyrus 'permission denied' when changing
index 62286e0f6da983b1d37bfd2c089b872f63033485..bfccb5bb2575ca2851045abbcf7e0712aafbb1cd 100644 (file)
@@ -6,6 +6,28 @@ Class Overview
 SOGoMailManager
 - backend class connecting to NGImap4, will probably move to SOGoLogic
 
+Class Hierarchy
+===============
+
+[NSObject]
+  SOGoMailerProduct
+  <SOGoObject>
+    SOGoMailAccounts
+    SOGoMailBaseObject
+      SOGoDraftObject
+      SOGoDraftsFolder
+      SOGoMailAccount
+      SOGoMailBodyPart
+        SOGoImageMailBodyPart
+        SOGoMessageMailBodyPart
+      SOGoMailFolder
+      SOGoMailObject
+  SOGoMailConnectionEntry
+  [EODataSource]
+    SOGoMailFolderDataSource
+  SOGoMailManager
+  SOGoMailboxInfo
+
 Defaults
 ========
 
index 441de7501141188a030b424c76eba7e936f8b0a8..d43607bf47d25b9f2eb59526bf192c59070892d8 100644 (file)
 
 @interface SOGoMailFolder : SOGoMailBaseObject
 {
-  NSArray  *filenames;
-  NSString *folderType;
+  NSArray         *filenames;
+  NSString        *folderType;
   SOGoMailboxInfo *selectInfo;
+  struct {
+    int didCheckACL:1;
+    int isDeleteAndExpungeAllowed:1;
+    int reserved:30;
+  } somfFlags;
 }
 
 /* messages */
 
 - (NSException *)expunge;
 
+/* permissions */
+
+- (BOOL)isDeleteAndExpungeAllowed;
+
 @end
 
 #endif /* __Mailer_SOGoMailFolder_H__ */
index 0f9a3e7ca72f585fedeff20bb092f44bc77c22d7..4a96b934c1381dc0429091d005c5ee137df01a09 100644 (file)
   return nil; /* no error */
 }
 
+/* permissions */
+
+- (void)_loadACLPermissionFlags {
+  NSString *rights;
+  
+  if (self->somfFlags.didCheckACL)
+    return;
+
+  rights = [[self mailManager] myRightsForMailboxAtURL:[self imap4URL] 
+                              password:[self imap4Password]];
+  if ([rights isKindOfClass:[NSException class]]) {
+    [self logWithFormat:@"ERROR: could not retrieve ACL: %@", rights];
+    return;
+  }
+  
+  self->somfFlags.didCheckACL = 1;
+  self->somfFlags.isDeleteAndExpungeAllowed =
+    [rights rangeOfString:@"d"].length > 0 ? 1 : 0;
+}
+
+- (BOOL)isDeleteAndExpungeAllowed {
+  [self _loadACLPermissionFlags];
+  return self->somfFlags.isDeleteAndExpungeAllowed;
+}
+
 /* messages */
 
 - (NSArray *)fetchUIDsMatchingQualifier:(id)_q sortOrdering:(id)_so {
index b7251dcf895f2f7c282ec46b1ef78f80ed85efef..fdd36f28474fd9f3c2b5cfb6605cf4264d15cd94 100644 (file)
@@ -93,6 +93,9 @@
 - (NSException *)moveMailboxAtURL:(NSURL *)_srcurl toURL:(NSURL *)_desturl
   password:(NSString *)_pwd;
 
+- (id)aclForMailboxAtURL:(NSURL *)_url password:(NSString *)_pwd;
+- (NSString *)myRightsForMailboxAtURL:(NSURL *)_url password:(NSString *)_pwd;
+
 @end
 
 #endif /* __Mailer_SOGoMailManager_H__ */
index f0af8eb2c9701d2c7a90756c61088d0b5c687a30..79dcdca2fa1e0f59b3d3c602ec081d4521a61cde 100644 (file)
@@ -972,6 +972,55 @@ static NSString       *imap4Separator  = nil;
   return nil;
 }
 
+- (NSDictionary *)aclForMailboxAtURL:(NSURL *)_url password:(NSString *)_pwd {
+  /*
+    Returns a mapping of uid => permission strings, eg:
+      guizmo.g = lrs;
+      root     = lrswipcda;
+  */
+  SOGoMailConnectionEntry *entry;
+  NSString *folderName;
+  id       result;
+  
+  if ((entry = [self entryForURL:_url password:_pwd]) == nil) {
+    // TODO: better to use an auth exception?
+    return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+                       reason:@"did not find IMAP4 folder (no entry)"];
+  }
+  
+  folderName = [self imap4FolderNameForURL:_url];
+  result     = [[entry client] getACL:folderName];
+  if (![[result valueForKey:@"result"] boolValue]) {
+    [self logWithFormat:@"ERROR: getacl failed: %@", result];
+    return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+                       reason:@"did not find ACL for IMAP4 folder"];
+  }
+  
+  return [result valueForKey:@"acl"];
+}
+
+- (NSString *)myRightsForMailboxAtURL:(NSURL *)_url password:(NSString *)_pwd {
+  SOGoMailConnectionEntry *entry;
+  NSString *folderName;
+  id       result;
+  
+  if ((entry = [self entryForURL:_url password:_pwd]) == nil) {
+    // TODO: better to use an auth exception?
+    return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+                       reason:@"did not find IMAP4 folder (no entry)"];
+  }
+  
+  folderName = [self imap4FolderNameForURL:_url];
+  result     = [[entry client] myRights:folderName];
+  if (![[result valueForKey:@"result"] boolValue]) {
+    [self logWithFormat:@"ERROR: myrights failed: %@", result];
+    return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+                       reason:@"did not find myrights for IMAP4 folder"];
+  }
+  
+  return [result valueForKey:@"myrights"];
+}
+
 /* debugging */
 
 - (BOOL)isDebuggingEnabled {
index 29a4f8d73bf39609b5261436bc35d45f20ce0b52..ba3005658712e047a74c80fda856722248bb8d5a 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "SOGoMailObject.h"
+#include "SOGoMailFolder.h"
 #include "SOGoMailManager.h"
 #include "SOGoMailBodyPart.h"
 #include <NGImap4/NGImap4Envelope.h>
@@ -502,6 +503,12 @@ static BOOL debugBodyStructure = NO;
                             password:[self imap4Password]];
 }
 
+/* permissions */
+
+- (BOOL)isDeletionAllowed {
+  return [[self container] isDeleteAndExpungeAllowed];
+}
+
 /* name lookup */
 
 - (id)lookupImap4BodyPartKey:(NSString *)_key inContext:(id)_ctx {
index 73737778ec1147876b7da34940944633568ef7c4..eca7fb4e5b741d2801b064561823e488c8afb3f7 100644 (file)
@@ -1,6 +1,6 @@
 # Version file
 
-SUBMINOR_VERSION:=84
+SUBMINOR_VERSION:=85
 
 # v0.9.69 requires libNGMime       v4.5.210
 # v0.9.55 requires libNGExtensions v4.5.136