diff --git a/ChangeLog b/ChangeLog index 3b91687b7..5ddbfd576 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2008-05-31 Wolfgang Sourdeau + + * 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 * SoObjects/SOGo/SOGoUserFolder.m ([SOGoUserFolder diff --git a/Main/SOGo.m b/Main/SOGo.m index 4f42cb1f5..673dc377b 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -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; } diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index 6ad7defa9..49e1fe654 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -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 */ diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 1486c00c0..41ef8c725 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -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; } diff --git a/UI/MailerUI/UIxMailUserRightsEditor.m b/UI/MailerUI/UIxMailUserRightsEditor.m index 1965eec7d..ca2dc5fdb 100644 --- a/UI/MailerUI/UIxMailUserRightsEditor.m +++ b/UI/MailerUI/UIxMailUserRightsEditor.m @@ -23,12 +23,22 @@ #import #import #import +#import #import #import "UIxMailUserRightsEditor.h" @implementation UIxMailUserRightsEditor +- (BOOL) conformsToRFC4314 +{ + SOGoMailFolder *co; + + co = [self clientObject]; + + return ([[co class] imapAclStyle] == rfc4314); +} + - (void) setUserCanReadMails: (BOOL) userCanReadMails { if (userCanReadMails) diff --git a/UI/Templates/MailerUI/UIxMailUserRightsEditor.wox b/UI/Templates/MailerUI/UIxMailUserRightsEditor.wox index d751f9ab4..765ac1961 100644 --- a/UI/Templates/MailerUI/UIxMailUserRightsEditor.wox +++ b/UI/Templates/MailerUI/UIxMailUserRightsEditor.wox @@ -52,21 +52,23 @@ var:checked="userCanCreateSubfolders"/>
- -

+ + +

+