Monotone-Parent: 03c1031b520e0b1094e5e7cf635bc6be4d30dac3

Monotone-Revision: 935cf293ec636367ef64469ec9130956087caa1e

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2008-05-31T21:04:56
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2008-05-31 21:04:56 +00:00
parent 28572594d9
commit 07ff561da2
6 changed files with 174 additions and 28 deletions

View File

@ -1,3 +1,24 @@
2008-05-31 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Mailer/SOGoMailFolder.m ([SOGoMailFolder
+initialize]): new method where we read the three new defaults
variables "SOGoIMAPAclStyle", "SOGoIMAPAclUsernamesAreQuoted",
"SOGoIMAPAclConformsToIMAPExt".
([SOGoMailFolder +imapAclStyle]): new method that returns the rfc
number to which the imap server conforms to regarding the acl.
([SOGoMailFolder -aclsForUser:uid]): added right 'c' and 'd' from
rfc2086.
([SOGoMailFolder -setRoles:rolesforUser:uid]): convert SOGo
permissions to the acl rights conforming to the RFC configured
with SOGoIMAPAclStyle.
([SOGoMailFolder -aclUsers]): unquote usernames if
"SOGoIMAPAclUsernamesAreQuoted" is set. Remove usernames listed as
special usernames in
http://www.tools.ietf.org/wg/imapext/draft-ietf-imapext-acl/ if
"SOGoIMAPAclConformsToIMAPExt" is set.
* UI/MailerUI/UIxMailUserRightsEditor.m ([UIxMailUserRightsEditor conformsToRFC4314]): new template getter.
2008-05-22 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoUserFolder.m ([SOGoUserFolder

View File

@ -393,6 +393,7 @@ static BOOL debugObjectAllocation = NO;
static NSArray *runLoopModes = nil;
WOResponse *resp;
NSLog (@"request start");
cache = [SOGoCache sharedCache];
resp = [super dispatchRequest: _request];
[SOGoCache killCache];
@ -408,6 +409,7 @@ static BOOL debugObjectAllocation = NO;
target: self argument: nil
order:1 modes:runLoopModes];
}
NSLog (@"request stop");
return resp;
}

View File

@ -36,6 +36,12 @@
@class NSData, NSArray, NSException, NSMutableArray;
@class NGImap4MailboxInfo;
typedef enum {
undefined = -1,
rfc2086 = 0,
rfc4314
} SOGoIMAPAclStyle;
@interface SOGoMailFolder : SOGoMailBaseObject
{
NSMutableArray *filenames;
@ -43,6 +49,8 @@
NSDictionary *mailboxACL;
}
+ (SOGoIMAPAclStyle) imapAclStyle;
- (NSString *) absoluteImap4Name;
/* messages */

View File

@ -44,8 +44,40 @@
static NSString *defaultUserID = @"anyone";
#warning this could be detected from the capabilities
static SOGoIMAPAclStyle aclStyle = undefined;
static BOOL aclUsernamesAreQuoted = NO;
/* http://www.tools.ietf.org/wg/imapext/draft-ietf-imapext-acl/ */
static BOOL aclConformsToIMAPExt = NO;
@implementation SOGoMailFolder
+ (void) initialize
{
NSUserDefaults *ud;
NSString *aclStyleStr;
if (aclStyle == undefined)
{
ud = [NSUserDefaults standardUserDefaults];
aclStyleStr = [ud stringForKey: @"SOGoIMAPAclStyle"];
if ([aclStyleStr isEqualToString: @"rfc2086"])
aclStyle = rfc2086;
else
aclStyle = rfc4314;
aclUsernamesAreQuoted
= [ud boolForKey: @"SOGoIMAPAclUsernamesAreQuoted"];
aclConformsToIMAPExt
= [ud boolForKey: @"SOGoIMAPAclConformsToIMAPExt"];
}
}
+ (SOGoIMAPAclStyle) imapAclStyle
{
return aclStyle;
}
- (void) _adjustOwner
{
SOGoMailAccount *mailAccount;
@ -469,12 +501,14 @@ static NSString *defaultUserID = @"anyone";
case 'p':
[SOGoAcls addObjectUniquely: SOGoMailRole_Poster];
break;
case 'c':
case 'k':
[SOGoAcls addObjectUniquely: SOGoRole_FolderCreator];
break;
case 'x':
[SOGoAcls addObjectUniquely: SOGoRole_FolderEraser];
break;
case 'd':
case 't':
[SOGoAcls addObjectUniquely: SOGoRole_ObjectEraser];
break;
@ -490,6 +524,38 @@ static NSString *defaultUserID = @"anyone";
return SOGoAcls;
}
- (char) _rfc2086StyleRight: (NSString *) sogoRight
{
char character;
if ([sogoRight isEqualToString: SOGoRole_FolderCreator])
character = 'c';
else if ([sogoRight isEqualToString: SOGoRole_ObjectEraser])
character = 'd';
else
character = 0;
return character;
}
- (char) _rfc4314StyleRight: (NSString *) sogoRight
{
char character;
if ([sogoRight isEqualToString: SOGoRole_FolderCreator])
character = 'k';
else if ([sogoRight isEqualToString: SOGoRole_FolderEraser])
character = 'x';
else if ([sogoRight isEqualToString: SOGoRole_ObjectEraser])
character = 't';
else if ([sogoRight isEqualToString: SOGoMailRole_Expunger])
character = 'e';
else
character = 0;
return character;
}
- (NSString *) _sogoAclsToImapAcls: (NSArray *) sogoAcls
{
NSMutableString *imapAcls;
@ -499,8 +565,7 @@ static NSString *defaultUserID = @"anyone";
imapAcls = [NSMutableString string];
acls = [sogoAcls objectEnumerator];
currentAcl = [acls nextObject];
while (currentAcl)
while ((currentAcl = [acls nextObject]))
{
if ([currentAcl isEqualToString: SOGoRole_ObjectViewer])
{
@ -515,33 +580,76 @@ static NSString *defaultUserID = @"anyone";
character = 'i';
else if ([currentAcl isEqualToString: SOGoMailRole_Poster])
character = 'p';
else if ([currentAcl isEqualToString: SOGoRole_FolderCreator])
character = 'k';
else if ([currentAcl isEqualToString: SOGoRole_FolderEraser])
character = 'x';
else if ([currentAcl isEqualToString: SOGoRole_ObjectEraser])
character = 't';
else if ([currentAcl isEqualToString: SOGoMailRole_Expunger])
character = 'e';
else if ([currentAcl isEqualToString: SOGoMailRole_Administrator])
character = 'a';
else
character = 0;
{
if (aclStyle == rfc2086)
character = [self _rfc2086StyleRight: currentAcl];
else if (aclStyle == rfc4314)
character = [self _rfc4314StyleRight: currentAcl];
else
character = 0;
}
if (character)
[imapAcls appendFormat: @"%c", character];
currentAcl = [acls nextObject];
}
return imapAcls;
}
- (void) _unquoteACLUsernames
{
NSMutableDictionary *newIMAPAcls;
NSEnumerator *usernames;
NSString *username, *unquoted;
newIMAPAcls = [NSMutableDictionary new];
usernames = [[mailboxACL allKeys] objectEnumerator];
while ((username = [usernames nextObject]))
{
unquoted = [username substringFromRange:
NSMakeRange(1, [username length] - 2)];
[newIMAPAcls setObject: [mailboxACL objectForKey: username]
forKey: unquoted];
}
[mailboxACL release];
mailboxACL = newIMAPAcls;
}
- (void) _removeIMAPExtUsernames
{
NSMutableDictionary *newIMAPAcls;
NSEnumerator *usernames;
NSString *username;
newIMAPAcls = [NSMutableDictionary new];
usernames = [[mailboxACL allKeys] objectEnumerator];
while ((username = [usernames nextObject]))
if (!([username isEqualToString: @"administrators"]
|| [username isEqualToString: @"owner"]
|| [username isEqualToString: @"anonymous"]
|| [username isEqualToString: @"authuser"]))
[newIMAPAcls setObject: [mailboxACL objectForKey: username]
forKey: username];
[mailboxACL release];
mailboxACL = newIMAPAcls;
}
- (void) _readMailboxACL
{
mailboxACL
= [[self imap4Connection] aclForMailboxAtURL: [self imap4URL]];
[mailboxACL release];
mailboxACL = [[self imap4Connection] aclForMailboxAtURL: [self imap4URL]];
[mailboxACL retain];
if (aclUsernamesAreQuoted)
[self _unquoteACLUsernames];
if (aclConformsToIMAPExt)
[self _removeIMAPExtUsernames];
}
- (NSArray *) subscriptionRoles
@ -624,20 +732,15 @@ static NSString *defaultUserID = @"anyone";
- (void) removeAclsForUsers: (NSArray *) users
{
NSEnumerator *uids;
NSString *currentUID;
NSString *folderName;
NSString *currentUID, *folderName;
NGImap4Client *client;
folderName = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]];
client = [imap4 client];
uids = [users objectEnumerator];
currentUID = [uids nextObject];
while (currentUID)
{
[client deleteACL: folderName uid: currentUID];
currentUID = [uids nextObject];
}
while ((currentUID = [uids nextObject]))
[client deleteACL: folderName uid: currentUID];
[mailboxACL release];
mailboxACL = nil;
}

View File

@ -23,12 +23,22 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSEnumerator.h>
#import <NGObjWeb/WORequest.h>
#import <SoObjects/Mailer/SOGoMailFolder.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import "UIxMailUserRightsEditor.h"
@implementation UIxMailUserRightsEditor
- (BOOL) conformsToRFC4314
{
SOGoMailFolder *co;
co = [self clientObject];
return ([[co class] imapAclStyle] == rfc4314);
}
- (void) setUserCanReadMails: (BOOL) userCanReadMails
{
if (userCanReadMails)

View File

@ -52,21 +52,23 @@
var:checked="userCanCreateSubfolders"/><var:string
label:value="Add subfolders to this folder"/></label>
<br/>
<label><input type="checkbox" class="checkBox"
const:name="FolderEraser"
var:checked="userCanRemoveFolder"/><var:string
label:value="Remove this folder"/></label>
<br/>
<label><input type="checkbox" class="checkBox"
const:name="ObjectEraser"
var:checked="userCanEraseMails"/><var:string
label:value="Erase mails from this folder"/></label>
<br/>
<var:if condition="conformsToRFC4314">
<label><input type="checkbox" class="checkBox"
const:name="FolderEraser"
var:checked="userCanRemoveFolder"/><var:string
label:value="Remove this folder"/></label>
<br/>
<label><input type="checkbox" class="checkBox"
const:name="MailExpunger"
var:checked="userCanExpungeFolder"/><var:string
label:value="Expunge this folder"/></label>
<br/>
</var:if>
<label><input type="checkbox" class="checkBox"
const:name="MailAdministrator"
var:checked="userIsAdministrator"/><var:string