mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-05 16:35:10 +00:00
Monotone-Parent: 62b78b812fed483061667782c81d44c853e623f9
Monotone-Revision: 617fa1501ed731ebbd3ccbe493d88a1bc0a7fd02 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-05-19T00:46:16 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
2007-05-18 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/Mailer/SOGoMailFolder.m: removed all the previous
|
||||
methods that would have been used to support IMAP acls. Replaced
|
||||
them with the new protocol for them that has been implemented in
|
||||
SOGo during the last few weeks.
|
||||
|
||||
* SoObjects/SOGo/SOGoContentObject.m ([SOGoContentObject
|
||||
-hasSupportForDefaultRoles]): override method by returning "YES".
|
||||
|
||||
|
||||
@@ -41,17 +41,6 @@
|
||||
NSArray *filenames;
|
||||
NSString *folderType;
|
||||
NGImap4MailboxInfo *selectInfo;
|
||||
struct {
|
||||
int didCheckMyRights:1;
|
||||
int isDeleteAndExpungeAllowed:1;
|
||||
int isReadAllowed:1;
|
||||
int isWriteAllowed:1;
|
||||
int isInsertAllowed:1;
|
||||
int isPostAllowed:1;
|
||||
int isCreateAllowed:1;
|
||||
int hasAdminAccess:1;
|
||||
int reserved:24;
|
||||
} somfFlags;
|
||||
}
|
||||
|
||||
/* messages */
|
||||
@@ -63,16 +52,6 @@
|
||||
|
||||
- (NSException *)expunge;
|
||||
|
||||
/* permissions */
|
||||
|
||||
- (BOOL)isDeleteAndExpungeAllowed;
|
||||
- (BOOL)isReadAllowed;
|
||||
- (BOOL)isWriteAllowed;
|
||||
- (BOOL)isInsertAllowed;
|
||||
- (BOOL)isPostAllowed;
|
||||
- (BOOL)isCreateAllowed;
|
||||
- (BOOL)hasAdminAccess;
|
||||
|
||||
/* flags */
|
||||
|
||||
- (NSException *)addFlagsToAllMessages:(id)_f;
|
||||
|
||||
@@ -19,13 +19,25 @@
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoMailFolder.h"
|
||||
#include "SOGoMailObject.h"
|
||||
#include "SOGoMailAccount.h"
|
||||
#include "SOGoMailManager.h"
|
||||
#include <NGImap4/NGImap4MailboxInfo.h>
|
||||
#include "SOGoMailFolderDataSource.h"
|
||||
#include "common.h"
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
|
||||
#import <NGObjWeb/NSException+HTTP.h>
|
||||
#import <NGExtensions/NSNull+misc.h>
|
||||
#import <NGExtensions/NSURL+misc.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import <NGImap4/NGImap4Connection.h>
|
||||
#import <NGImap4/NGImap4MailboxInfo.h>
|
||||
#import <NGImap4/NGImap4Client.h>
|
||||
|
||||
#import <SoObjects/SOGo/SOGoPermissions.h>
|
||||
#import <SoObjects/SOGo/NSArray+Utilities.h>
|
||||
|
||||
#import "SOGoMailObject.h"
|
||||
#import "SOGoMailAccount.h"
|
||||
#import "SOGoMailManager.h"
|
||||
#import "SOGoMailFolderDataSource.h"
|
||||
#import "SOGoMailFolder.h"
|
||||
|
||||
@implementation SOGoMailFolder
|
||||
|
||||
@@ -121,87 +133,6 @@ static BOOL useAltNamespace = NO;
|
||||
return nil; /* no error */
|
||||
}
|
||||
|
||||
/* permissions */
|
||||
|
||||
- (void)_loadACLPermissionFlags {
|
||||
NSString *rights;
|
||||
unsigned i, len;
|
||||
|
||||
if (self->somfFlags.didCheckMyRights)
|
||||
return;
|
||||
|
||||
rights = [[self imap4Connection] myRightsForMailboxAtURL:[self imap4URL]];
|
||||
if ([rights isKindOfClass:[NSException class]]) {
|
||||
[self logWithFormat:@"ERROR: could not retrieve ACL: %@", rights];
|
||||
return;
|
||||
}
|
||||
|
||||
// [self logWithFormat:@"GOT PERM: %@", rights];
|
||||
|
||||
self->somfFlags.didCheckMyRights = 1;
|
||||
|
||||
/* reset flags */
|
||||
self->somfFlags.isDeleteAndExpungeAllowed = 0;
|
||||
self->somfFlags.isReadAllowed = 0;
|
||||
self->somfFlags.isWriteAllowed = 0;
|
||||
self->somfFlags.isInsertAllowed = 0;
|
||||
self->somfFlags.isPostAllowed = 0;
|
||||
self->somfFlags.isCreateAllowed = 0;
|
||||
self->somfFlags.hasAdminAccess = 0;
|
||||
|
||||
for (i = 0, len = [rights length]; i < len; i++) {
|
||||
switch ([rights characterAtIndex:i]) {
|
||||
case 'd': self->somfFlags.isDeleteAndExpungeAllowed = 1; break;
|
||||
case 'r': self->somfFlags.isReadAllowed = 1; break;
|
||||
case 'w': self->somfFlags.isWriteAllowed = 1; break;
|
||||
case 'i': self->somfFlags.isInsertAllowed = 1; break;
|
||||
case 'p': self->somfFlags.isPostAllowed = 1; break;
|
||||
case 'c': self->somfFlags.isCreateAllowed = 1; break;
|
||||
case 'a': self->somfFlags.hasAdminAccess = 1; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isDeleteAndExpungeAllowed {
|
||||
[self _loadACLPermissionFlags];
|
||||
return self->somfFlags.isDeleteAndExpungeAllowed ? YES : NO;
|
||||
}
|
||||
- (BOOL)isReadAllowed {
|
||||
[self _loadACLPermissionFlags];
|
||||
return self->somfFlags.isReadAllowed ? YES : NO;
|
||||
}
|
||||
- (BOOL)isWriteAllowed {
|
||||
[self _loadACLPermissionFlags];
|
||||
return self->somfFlags.isWriteAllowed ? YES : NO;
|
||||
}
|
||||
- (BOOL)isInsertAllowed {
|
||||
[self _loadACLPermissionFlags];
|
||||
return self->somfFlags.isInsertAllowed ? YES : NO;
|
||||
}
|
||||
- (BOOL)isPostAllowed {
|
||||
[self _loadACLPermissionFlags];
|
||||
return self->somfFlags.isPostAllowed ? YES : NO;
|
||||
}
|
||||
|
||||
- (BOOL)isCreateAllowedInACL {
|
||||
/* we call this directly from UIxMailAccountView */
|
||||
[self _loadACLPermissionFlags];
|
||||
return self->somfFlags.isCreateAllowed ? YES : NO;
|
||||
}
|
||||
- (BOOL)isCreateAllowed {
|
||||
if (useAltNamespace) {
|
||||
/* with altnamespace, Cyrus doesn't allow mailboxes under INBOX */
|
||||
if ([[self outlookFolderClass] isEqualToString:@"IPF.Inbox"])
|
||||
return NO;
|
||||
}
|
||||
return [self isCreateAllowedInACL];
|
||||
}
|
||||
|
||||
- (BOOL)hasAdminAccess {
|
||||
[self _loadACLPermissionFlags];
|
||||
return self->somfFlags.hasAdminAccess ? YES : NO;
|
||||
}
|
||||
|
||||
/* messages */
|
||||
|
||||
- (NSArray *)fetchUIDsMatchingQualifier:(id)_q sortOrdering:(id)_so {
|
||||
@@ -387,4 +318,79 @@ static BOOL useAltNamespace = NO;
|
||||
return self->folderType;
|
||||
}
|
||||
|
||||
/* acls */
|
||||
|
||||
- (NSArray *) _imapAclsToSOGoAcls: (NSString *) imapAcls
|
||||
{
|
||||
unsigned int count, max;
|
||||
NSMutableArray *SOGoAcls;
|
||||
|
||||
SOGoAcls = [NSMutableArray array];
|
||||
max = [imapAcls length];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
switch ([imapAcls characterAtIndex: count])
|
||||
{
|
||||
case 'l':
|
||||
[SOGoAcls addObjectUniquely: SOGoRole_FolderViewer];
|
||||
break;
|
||||
case 'r':
|
||||
[SOGoAcls addObjectUniquely: SOGoRole_ObjectReader];
|
||||
break;
|
||||
case 's':
|
||||
[SOGoAcls addObjectUniquely: SOGoMailRole_SeenKeeper];
|
||||
break;
|
||||
case 'w':
|
||||
[SOGoAcls addObjectUniquely: SOGoMailRole_Writer];
|
||||
break;
|
||||
case 'i':
|
||||
[SOGoAcls addObjectUniquely: SOGoRole_ObjectCreator];
|
||||
break;
|
||||
case 'p':
|
||||
[SOGoAcls addObjectUniquely: SOGoMailRole_Poster];
|
||||
break;
|
||||
case 'k':
|
||||
[SOGoAcls addObjectUniquely: SOGoRole_FolderCreator];
|
||||
break;
|
||||
case 'x':
|
||||
[SOGoAcls addObjectUniquely: SOGoRole_FolderEraser];
|
||||
[SOGoAcls addObjectUniquely: SOGoRole_FolderCreator];
|
||||
break;
|
||||
case 't':
|
||||
[SOGoAcls addObjectUniquely: SOGoRole_ObjectEraser];
|
||||
break;
|
||||
case 'e':
|
||||
[SOGoAcls addObjectUniquely: SOGoMailRole_Expunger];
|
||||
break;
|
||||
case 'c':
|
||||
[SOGoAcls addObjectUniquely: SOGoRole_FolderCreator];
|
||||
break;
|
||||
case 'd':
|
||||
[SOGoAcls addObjectUniquely: SOGoRole_ObjectEraser];
|
||||
[SOGoAcls addObjectUniquely: SOGoMailRole_Expunger];
|
||||
break;
|
||||
case 'a':
|
||||
[SOGoAcls addObjectUniquely: SOGoMailRole_Administrator];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return SOGoAcls;
|
||||
}
|
||||
|
||||
- (NSArray *) aclUsers
|
||||
{
|
||||
NSDictionary *imapAcls;
|
||||
|
||||
imapAcls = [imap4 aclForMailboxAtURL: [self imap4URL]];
|
||||
|
||||
return [imapAcls allKeys];
|
||||
}
|
||||
|
||||
- (NSArray *) defaultAclRoles
|
||||
{
|
||||
return [NSArray arrayWithObjects: SOGoRole_FolderViewer,
|
||||
SOGoRole_FolderReader, SOGoMailRole_SeenKeeper, nil];
|
||||
}
|
||||
|
||||
@end /* SOGoMailFolder */
|
||||
|
||||
Reference in New Issue
Block a user