From 31405e6b90cb16258f89538d6d14a7ab8c0af371 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 30 May 2007 20:23:54 +0000 Subject: [PATCH] Monotone-Parent: f68507cb25828e3c8fa1e14516883fc016c0e607 Monotone-Revision: 60409fdcefdda5e0651856c8f403c47df652a85c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-05-30T20:23:54 Monotone-Branch: ca.inverse.sogo --- SoObjects/Mailer/SOGoMailFolder.h | 1 - SoObjects/Mailer/SOGoMailFolder.m | 100 +++++++++++++++++++++--------- SoObjects/SOGo/SOGoFolder.m | 9 ++- 3 files changed, 77 insertions(+), 33 deletions(-) diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index 287335508..f6fd2f538 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -40,7 +40,6 @@ { NSArray *filenames; NSString *folderType; - NGImap4MailboxInfo *selectInfo; } /* messages */ diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index abe60cec1..f3b86ab15 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -25,11 +25,13 @@ #import #import #import +#import #import #import #import +#import #import #import "SOGoMailObject.h" @@ -340,6 +342,10 @@ static BOOL useAltNamespace = NO; } /* folder type */ +- (NSString *) folderType +{ + return @"Mail"; +} - (NSString *) outlookFolderClass { @@ -468,7 +474,7 @@ static BOOL useAltNamespace = NO; NSArray *users; NSDictionary *imapAcls; - imapAcls = [imap4 aclForMailboxAtURL: [self imap4URL]]; + imapAcls = [[self imap4Connection] aclForMailboxAtURL: [self imap4URL]]; if ([imapAcls isKindOfClass: [NSDictionary class]]) users = [imapAcls allKeys]; else @@ -481,31 +487,21 @@ static BOOL useAltNamespace = NO; { NSMutableArray *acls; SOGoMailAccount *mailAccount; - NSString *path, *sharedPath, *othersPath; + NSString *path; NSArray *names; unsigned int count; acls = [NSMutableArray array]; mailAccount = [self mailAccountFolder]; - sharedPath = [NSString stringWithFormat: @"/%@", - [mailAccount sharedFolderName]]; - othersPath = [NSString stringWithFormat: @"/%@", - [mailAccount otherUsersFolderName]]; - path = [[self imap4URL] path]; + path = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]]; names = [path componentsSeparatedByString: @"/"]; count = [names count]; - if ([path hasPrefix: sharedPath]) - { - if (count == 2) - [acls addObject: SOGoRole_ObjectViewer]; - } - else if ([path hasPrefix: othersPath]) - { - if (count == 2 || count == 3) - [acls addObject: SOGoRole_ObjectViewer]; - } + if ([path hasPrefix: [mailAccount sharedFolderName]]) + [acls addObject: SOGoRole_ObjectViewer]; + else if ([path hasPrefix: [mailAccount otherUsersFolderName]]) + [acls addObject: SOGoRole_ObjectViewer]; else [acls addObject: SoRole_Owner]; @@ -519,7 +515,7 @@ static BOOL useAltNamespace = NO; NSString *userAcls; acls = [self _sharesACLs]; - imapAcls = [imap4 aclForMailboxAtURL: [self imap4URL]]; + imapAcls = [[self imap4Connection] aclForMailboxAtURL: [self imap4URL]]; if ([imapAcls isKindOfClass: [NSDictionary class]]) { userAcls = [imapAcls objectForKey: uid]; @@ -539,7 +535,7 @@ static BOOL useAltNamespace = NO; NSString *folderName; NGImap4Client *client; - folderName = [imap4 imap4FolderNameForURL: [self imap4URL]]; + folderName = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]]; client = [imap4 client]; uids = [users objectEnumerator]; @@ -557,7 +553,7 @@ static BOOL useAltNamespace = NO; NSString *acls, *folderName; acls = [self _sogoAclsToImapAcls: roles]; - folderName = [imap4 imap4FolderNameForURL: [self imap4URL]]; + folderName = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]]; [[imap4 client] setACL: folderName rights: acls uid: uid]; } @@ -569,23 +565,19 @@ static BOOL useAltNamespace = NO; - (NSString *) ownerInContext: (WOContext *) localContext { SOGoMailAccount *mailAccount; - NSString *path, *sharedPath, *othersPath, *owner; + NSString *path, *owner; NSArray *names; mailAccount = [self mailAccountFolder]; - sharedPath = [NSString stringWithFormat: @"/%@", - [mailAccount sharedFolderName]]; - othersPath = [NSString stringWithFormat: @"/%@", - [mailAccount otherUsersFolderName]]; - path = [[self imap4URL] path]; + path = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]]; - if (sharedPath && [path hasPrefix: sharedPath]) + if ([path hasPrefix: [mailAccount sharedFolderName]]) owner = @"anyone"; - else if (othersPath && [path hasPrefix: othersPath]) + else if ([path hasPrefix: [mailAccount otherUsersFolderName]]) { names = [path componentsSeparatedByString: @"/"]; - if ([names count] > 2) - owner = [names objectAtIndex: 2]; + if ([names count] > 1) + owner = [names objectAtIndex: 1]; else owner = @"anyone"; } @@ -595,4 +587,52 @@ static BOOL useAltNamespace = NO; return owner; } +- (NSString *) otherUsersPathToFolder +{ + NSString *userPath, *selfPath, *otherUsers, *sharedFolders; + SOGoMailAccount *account; + + account = [self mailAccountFolder]; + otherUsers = [account otherUsersFolderName]; + sharedFolders = [account sharedFolderName]; + + selfPath = [[self imap4URL] path]; + if ([selfPath hasPrefix: [NSString stringWithFormat: @"/%@", otherUsers]] + || [selfPath hasPrefix: + [NSString stringWithFormat: @"/%@", sharedFolders]]) + userPath = selfPath; + else + userPath = [NSString stringWithFormat: @"/%@/%@%@", + [otherUsers stringByEscapingURL], + [self ownerInContext: context], + selfPath]; + + return userPath; +} + +- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid; +{ + SOGoUser *user; + + user = [SOGoUser userWithLogin: uid roles: nil]; + + return [NSString stringWithFormat: @"%@/%@%@", + [self soURLToBaseContainerForUser: uid], + [user primaryIMAP4AccountString], + [self otherUsersPathToFolder]]; +} + +- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid; +{ + NSURL *selfURL, *userURL; + + selfURL = [self imap4URL]; + userURL = [[NSURL alloc] initWithScheme: [selfURL scheme] + host: [selfURL host] + path: [self otherUsersPathToFolder]]; + [userURL autorelease]; + + return [userURL absoluteString]; +} + @end /* SOGoMailFolder */ diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index 2e3b7469f..cf5b25c2e 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -452,9 +452,14 @@ static NSString *defaultUserID = @""; return defaultUserID; } -- (BOOL) hasSupportForDefaultRoles +- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid { - return YES; + return [[self soURL] absoluteString]; +} + +- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid +{ + return [[self davURL] absoluteString]; } /* WebDAV */