+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
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
========
@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__ */
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 {
- (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__ */
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 {
*/
#include "SOGoMailObject.h"
+#include "SOGoMailFolder.h"
#include "SOGoMailManager.h"
#include "SOGoMailBodyPart.h"
#include <NGImap4/NGImap4Envelope.h>
password:[self imap4Password]];
}
+/* permissions */
+
+- (BOOL)isDeletionAllowed {
+ return [[self container] isDeleteAndExpungeAllowed];
+}
+
/* name lookup */
- (id)lookupImap4BodyPartKey:(NSString *)_key inContext:(id)_ctx {
# Version file
-SUBMINOR_VERSION:=84
+SUBMINOR_VERSION:=85
# v0.9.69 requires libNGMime v4.5.210
# v0.9.55 requires libNGExtensions v4.5.136