Monotone-Parent: f68507cb25828e3c8fa1e14516883fc016c0e607

Monotone-Revision: 60409fdcefdda5e0651856c8f403c47df652a85c

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-05-30T20:23:54
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau 2007-05-30 20:23:54 +00:00
parent 84dd67c794
commit 31405e6b90
3 changed files with 77 additions and 33 deletions

View file

@ -40,7 +40,6 @@
{ {
NSArray *filenames; NSArray *filenames;
NSString *folderType; NSString *folderType;
NGImap4MailboxInfo *selectInfo;
} }
/* messages */ /* messages */

View file

@ -25,11 +25,13 @@
#import <NGExtensions/NSNull+misc.h> #import <NGExtensions/NSNull+misc.h>
#import <NGExtensions/NSURL+misc.h> #import <NGExtensions/NSURL+misc.h>
#import <NGExtensions/NSObject+Logs.h> #import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSString+misc.h>
#import <NGImap4/NGImap4Connection.h> #import <NGImap4/NGImap4Connection.h>
#import <NGImap4/NGImap4Client.h> #import <NGImap4/NGImap4Client.h>
#import <SoObjects/SOGo/SOGoPermissions.h> #import <SoObjects/SOGo/SOGoPermissions.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/NSArray+Utilities.h> #import <SoObjects/SOGo/NSArray+Utilities.h>
#import "SOGoMailObject.h" #import "SOGoMailObject.h"
@ -340,6 +342,10 @@ static BOOL useAltNamespace = NO;
} }
/* folder type */ /* folder type */
- (NSString *) folderType
{
return @"Mail";
}
- (NSString *) outlookFolderClass - (NSString *) outlookFolderClass
{ {
@ -468,7 +474,7 @@ static BOOL useAltNamespace = NO;
NSArray *users; NSArray *users;
NSDictionary *imapAcls; NSDictionary *imapAcls;
imapAcls = [imap4 aclForMailboxAtURL: [self imap4URL]]; imapAcls = [[self imap4Connection] aclForMailboxAtURL: [self imap4URL]];
if ([imapAcls isKindOfClass: [NSDictionary class]]) if ([imapAcls isKindOfClass: [NSDictionary class]])
users = [imapAcls allKeys]; users = [imapAcls allKeys];
else else
@ -481,31 +487,21 @@ static BOOL useAltNamespace = NO;
{ {
NSMutableArray *acls; NSMutableArray *acls;
SOGoMailAccount *mailAccount; SOGoMailAccount *mailAccount;
NSString *path, *sharedPath, *othersPath; NSString *path;
NSArray *names; NSArray *names;
unsigned int count; unsigned int count;
acls = [NSMutableArray array]; acls = [NSMutableArray array];
mailAccount = [self mailAccountFolder]; mailAccount = [self mailAccountFolder];
sharedPath = [NSString stringWithFormat: @"/%@", path = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]];
[mailAccount sharedFolderName]];
othersPath = [NSString stringWithFormat: @"/%@",
[mailAccount otherUsersFolderName]];
path = [[self imap4URL] path];
names = [path componentsSeparatedByString: @"/"]; names = [path componentsSeparatedByString: @"/"];
count = [names count]; count = [names count];
if ([path hasPrefix: sharedPath]) if ([path hasPrefix: [mailAccount sharedFolderName]])
{ [acls addObject: SOGoRole_ObjectViewer];
if (count == 2) else if ([path hasPrefix: [mailAccount otherUsersFolderName]])
[acls addObject: SOGoRole_ObjectViewer]; [acls addObject: SOGoRole_ObjectViewer];
}
else if ([path hasPrefix: othersPath])
{
if (count == 2 || count == 3)
[acls addObject: SOGoRole_ObjectViewer];
}
else else
[acls addObject: SoRole_Owner]; [acls addObject: SoRole_Owner];
@ -519,7 +515,7 @@ static BOOL useAltNamespace = NO;
NSString *userAcls; NSString *userAcls;
acls = [self _sharesACLs]; acls = [self _sharesACLs];
imapAcls = [imap4 aclForMailboxAtURL: [self imap4URL]]; imapAcls = [[self imap4Connection] aclForMailboxAtURL: [self imap4URL]];
if ([imapAcls isKindOfClass: [NSDictionary class]]) if ([imapAcls isKindOfClass: [NSDictionary class]])
{ {
userAcls = [imapAcls objectForKey: uid]; userAcls = [imapAcls objectForKey: uid];
@ -539,7 +535,7 @@ static BOOL useAltNamespace = NO;
NSString *folderName; NSString *folderName;
NGImap4Client *client; NGImap4Client *client;
folderName = [imap4 imap4FolderNameForURL: [self imap4URL]]; folderName = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]];
client = [imap4 client]; client = [imap4 client];
uids = [users objectEnumerator]; uids = [users objectEnumerator];
@ -557,7 +553,7 @@ static BOOL useAltNamespace = NO;
NSString *acls, *folderName; NSString *acls, *folderName;
acls = [self _sogoAclsToImapAcls: roles]; acls = [self _sogoAclsToImapAcls: roles];
folderName = [imap4 imap4FolderNameForURL: [self imap4URL]]; folderName = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]];
[[imap4 client] setACL: folderName rights: acls uid: uid]; [[imap4 client] setACL: folderName rights: acls uid: uid];
} }
@ -569,23 +565,19 @@ static BOOL useAltNamespace = NO;
- (NSString *) ownerInContext: (WOContext *) localContext - (NSString *) ownerInContext: (WOContext *) localContext
{ {
SOGoMailAccount *mailAccount; SOGoMailAccount *mailAccount;
NSString *path, *sharedPath, *othersPath, *owner; NSString *path, *owner;
NSArray *names; NSArray *names;
mailAccount = [self mailAccountFolder]; mailAccount = [self mailAccountFolder];
sharedPath = [NSString stringWithFormat: @"/%@", path = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]];
[mailAccount sharedFolderName]];
othersPath = [NSString stringWithFormat: @"/%@",
[mailAccount otherUsersFolderName]];
path = [[self imap4URL] path];
if (sharedPath && [path hasPrefix: sharedPath]) if ([path hasPrefix: [mailAccount sharedFolderName]])
owner = @"anyone"; owner = @"anyone";
else if (othersPath && [path hasPrefix: othersPath]) else if ([path hasPrefix: [mailAccount otherUsersFolderName]])
{ {
names = [path componentsSeparatedByString: @"/"]; names = [path componentsSeparatedByString: @"/"];
if ([names count] > 2) if ([names count] > 1)
owner = [names objectAtIndex: 2]; owner = [names objectAtIndex: 1];
else else
owner = @"anyone"; owner = @"anyone";
} }
@ -595,4 +587,52 @@ static BOOL useAltNamespace = NO;
return owner; 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 */ @end /* SOGoMailFolder */

View file

@ -452,9 +452,14 @@ static NSString *defaultUserID = @"<default>";
return defaultUserID; return defaultUserID;
} }
- (BOOL) hasSupportForDefaultRoles - (NSString *) httpURLForAdvisoryToUser: (NSString *) uid
{ {
return YES; return [[self soURL] absoluteString];
}
- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid
{
return [[self davURL] absoluteString];
} }
/* WebDAV */ /* WebDAV */