From db9ca6854a16bbd4b0379077857717483736c8b4 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 7 Feb 2008 20:21:13 +0000 Subject: [PATCH] Monotone-Parent: 1d531bb1705a798641ec3085cc160512248523f8 Monotone-Revision: 35e3135027040fead1c91041394159c3adecf931 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-02-07T20:21:13 Monotone-Branch: ca.inverse.sogo --- SoObjects/Mailer/SOGoMailAccounts.m | 96 +++++++--------- SoObjects/Mailer/SOGoMailBaseObject.m | 2 +- SoObjects/Mailer/SOGoSharedInboxFolder.h | 44 ------- SoObjects/Mailer/SOGoSharedInboxFolder.m | 42 ------- SoObjects/Mailer/SOGoSharedMailAccount.h | 56 --------- SoObjects/Mailer/SOGoSharedMailAccount.m | 139 ----------------------- SoObjects/Mailer/product.plist | 8 +- 7 files changed, 44 insertions(+), 343 deletions(-) delete mode 100644 SoObjects/Mailer/SOGoSharedInboxFolder.h delete mode 100644 SoObjects/Mailer/SOGoSharedInboxFolder.m delete mode 100644 SoObjects/Mailer/SOGoSharedMailAccount.h delete mode 100644 SoObjects/Mailer/SOGoSharedMailAccount.m diff --git a/SoObjects/Mailer/SOGoMailAccounts.m b/SoObjects/Mailer/SOGoMailAccounts.m index 3188052ca..8a2cde7be 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SoObjects/Mailer/SOGoMailAccounts.m @@ -28,19 +28,18 @@ #import "../SOGo/NSArray+Utilities.h" #import "../SOGo/SOGoUser.h" +#import "SOGoMailAccount.h" #import "SOGoMailAccounts.h" @implementation SOGoMailAccounts -static NSString *AgenorShareLoginMarker = @".-."; - /* listing the available mailboxes */ -- (BOOL) isInHomeFolderBranchOfLoggedInAccount: (NSString *) userLogin -{ - return [[container nameInContainer] isEqualToString: userLogin]; -} +// - (BOOL) isInHomeFolderBranchOfLoggedInAccount: (NSString *) userLogin +// { +// return [[container nameInContainer] isEqualToString: userLogin]; +// } - (NSArray *) toManyRelationshipKeys { @@ -62,70 +61,53 @@ static NSString *AgenorShareLoginMarker = @".-."; return [[accounts objectsForKey: @"name"] containsObject: _key]; } -- (id) mailAccountWithName: (NSString *) _key - inContext: (id) _ctx -{ - static Class ctClass = Nil; - id ct; +// - (id) mailAccountWithName: (NSString *) _key +// inContext: (id) _ctx +// { +// static Class ctClass = Nil; +// id ct; - if (ctClass == Nil) - ctClass = NSClassFromString(@"SOGoMailAccount"); - if (ctClass == Nil) { - [self errorWithFormat:@"missing SOGoMailAccount class!"]; - return nil; - } +// if (ctClass == Nil) +// ctClass = NSClassFromString(@"SOGoMailAccount"); +// if (ctClass == Nil) { +// [self errorWithFormat:@"missing SOGoMailAccount class!"]; +// return nil; +// } - ct = [[ctClass alloc] initWithName:_key inContainer:self]; +// ct = [[ctClass alloc] initWithName:_key inContainer:self]; - return [ct autorelease]; -} - -- (id) sharedMailAccountWithName: (NSString *) _key - inContext: (id) _ctx -{ - static Class ctClass = Nil; - - if (ctClass == Nil) - ctClass = NSClassFromString (@"SOGoSharedMailAccount"); - if (ctClass == Nil) - [self errorWithFormat:@"missing SOGoSharedMailAccount class!"]; - - return [ctClass objectWithName: _key inContainer: self]; -} +// return [ct autorelease]; +// } - (id) lookupName: (NSString *) _key inContext: (id) _ctx acquire: (BOOL) _flag { id obj; - NSString *userLogin; +// NSString *userLogin; - userLogin = [[context activeUser] login]; +// userLogin = [[context activeUser] login]; +// if (![self isInHomeFolderBranchOfLoggedInAccount: userLogin]) { +// [self warnWithFormat:@ "User %@ tried to access mail hierarchy of %@", +// userLogin, [container nameInContainer]]; + +// return [NSException exceptionWithHTTPStatus:403 /* Forbidden */ +// reason:@"Tried to access the mail of another user"]; +// } + + /* first check attributes directly bound to the application */ - if ((obj = [super lookupName:_key inContext:_ctx acquire:NO])) - return obj; + obj = [super lookupName:_key inContext:_ctx acquire:NO]; + if (!obj) + { + if ([self isValidMailAccountName: _key]) + obj = [SOGoMailAccount objectWithName: _key inContainer: self]; + else + obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */]; + } - if (![self isInHomeFolderBranchOfLoggedInAccount: userLogin]) { - [self warnWithFormat:@ "User %@ tried to access mail hierarchy of %@", - userLogin, [container nameInContainer]]; - - return [NSException exceptionWithHTTPStatus:403 /* Forbidden */ - reason:@"Tried to access the mail of another user"]; - } - - if ([self isValidMailAccountName:_key]) { - BOOL isSharedKey; - - isSharedKey = [_key rangeOfString:AgenorShareLoginMarker].length > 0; - - return isSharedKey - ? [self sharedMailAccountWithName:_key inContext:_ctx] - : [self mailAccountWithName:_key inContext:_ctx]; - } - - /* return 404 to stop acquisition */ - return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; + return obj; } @end /* SOGoMailAccounts */ diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index d4387d523..ebe594625 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -132,7 +132,7 @@ static BOOL debugOn = YES; { NSURL *url; - if ([container respondsToSelector:@selector(imap4URL)]) + if ([container respondsToSelector: @selector(imap4URL)]) url = [container imap4URL]; else { diff --git a/SoObjects/Mailer/SOGoSharedInboxFolder.h b/SoObjects/Mailer/SOGoSharedInboxFolder.h deleted file mode 100644 index 8fc1f4173..000000000 --- a/SoObjects/Mailer/SOGoSharedInboxFolder.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2004-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#ifndef __Mailer_SOGoSharedInboxFolder_H__ -#define __Mailer_SOGoSharedInboxFolder_H__ - -#import - -/* - SOGoSharedInboxFolder - Parent object: the SOGoSharedMailAccount - Child objects: SOGoMailObject or SOGoMailFolder - - The SOGoSharedInboxFolder is a special SOGoMailFolder for use as the INBOX - og SOGoSharedMailAccounts. This is necessary because the INBOX location in - the IMAP4 server is different for shared boxes (its the shared user folder, - not a mapped subfolder). -*/ - -@interface SOGoSharedInboxFolder : SOGoMailFolder -{ -} - -@end - -#endif /* __Mailer_SOGoSharedInboxFolder_H__ */ diff --git a/SoObjects/Mailer/SOGoSharedInboxFolder.m b/SoObjects/Mailer/SOGoSharedInboxFolder.m deleted file mode 100644 index 5399b751e..000000000 --- a/SoObjects/Mailer/SOGoSharedInboxFolder.m +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2004-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#import "SOGoSharedInboxFolder.h" - -@implementation SOGoSharedInboxFolder - -/* listing available folders */ - -- (NSArray *)toManyRelationshipKeys { - /* - A shared INBOX has no subfolders because those are already shown as - subfolders of the account. - */ - return nil; -} - -/* IMAP4 locator */ - -- (NSURL *)imap4URL { - return [[self container] imap4URL]; -} - -@end /* SOGoSharedInboxFolder */ diff --git a/SoObjects/Mailer/SOGoSharedMailAccount.h b/SoObjects/Mailer/SOGoSharedMailAccount.h deleted file mode 100644 index 35dbbd484..000000000 --- a/SoObjects/Mailer/SOGoSharedMailAccount.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#ifndef __Mailer_SOGoSharedMailAccount_H__ -#define __Mailer_SOGoSharedMailAccount_H__ - -#include - -/* - SOGoSharedMailAccount - Parent object: SOGoMailAccounts - Child objects: SOGoMailFolder - - The SOGoSharedMailAccount represents an IMAP4 mail account which is shared - by multiple users using the ".-." login trick. - - Eg: - beatrix.b.-.evariste.e@amelie-01.ac.melanie2.i2 - - The mailbox of 'evariste.e' will be accessed using as user 'beatrix.b'. The - Cyrus server will deliver a special kind of mailbox hierarchy in this case. - - An advantage is that either Cyrus or LDAP seems to know about the ".-." - separator. -*/ - -@class NSString; - -@interface SOGoSharedMailAccount : SOGoMailAccount -{ -} - -- (BOOL)isSharedAccount; -- (NSString *)sharedAccountName; - -@end - -#endif /* __Mailer_SOGoSharedMailAccount_H__ */ diff --git a/SoObjects/Mailer/SOGoSharedMailAccount.m b/SoObjects/Mailer/SOGoSharedMailAccount.m deleted file mode 100644 index 86922604b..000000000 --- a/SoObjects/Mailer/SOGoSharedMailAccount.m +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#import -#import -#import - -#import - -#import "SOGoSharedMailAccount.h" - -@interface SOGoMailAccount(UsedPrivates) - -- (NSString *)imap4URLString; - -- (id)lookupFolder:(NSString *)_key ofClassNamed:(NSString *)_cn - inContext:(id)_cx; - -@end - -@implementation SOGoSharedMailAccount - -static NSString *otherUsersFolderName = @""; // TODO: add English default - -+ (void) initialize -{ - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - - otherUsersFolderName = [ud stringForKey:@"SOGoOtherUsersFolderName"]; - NSLog(@"Note: using other-users-folders name: '%@'", otherUsersFolderName); -} - -/* shared accounts */ - -- (BOOL)isSharedAccount { - return YES; -} - -- (NSString *)sharedAccountName { - NSString *s; - NSRange r; - - s = [self nameInContainer]; - r = [s rangeOfString:@"@"]; - if (r.length == 0) /* regular HTTP logins are never a shared mailbox */ - return nil; - - s = [s substringToIndex:r.location]; - r = [s rangeOfString:@".-."]; - if (r.length == 0) /* no shared mailbox marker */ - return nil; - - return [s substringFromIndex:(r.location + r.length)]; -} - -/* listing the available folders */ - -- (NSArray *)additionalRootFolderNames { - /* do not show Drafts folder in shared mailboxes (#1452) */ - /* Note: this also disables the Sieve folder */ - return nil; -} - -- (NSArray *)toManyRelationshipKeys { - NSMutableArray *m; - NSArray *b; - - m = [NSMutableArray arrayWithCapacity:16]; - - [m addObject:@"INBOX"]; /* special for shared, see -lookupInboxFolder:.. */ - - if ((b = [[self imap4Connection] subfoldersForURL:[self imap4URL]]) != nil) - [m addObjectsFromArray:b]; - - if ((b = [self additionalRootFolderNames]) != nil) - [m addObjectsFromArray:b]; - return m; -} - -/* IMAP4 locator */ - -- (NSString *)imap4URLString { - /* we jump in the hierarchy directly to the shared user folder */ - NSString *s; - - s = [super imap4URLString]; - s = [s stringByAppendingString:otherUsersFolderName]; - s = [s stringByAppendingString:@"/"]; - s = [s stringByAppendingString:[self sharedAccountName]]; - return s; -} - -/* lookup */ - -- (id)lookupInboxFolder:(NSString *)_key inContext:(id)_ctx { - /* - Note: We have a choice: Cyrus does both, it gives the user an own - INBOX folder, but it also provides access to the mailbox INBOX - folder. - However the mailbox INBOX folder is NOT returned as an "INBOX" - subcollection as usual, but is the primary mailbox name. - Eg: - 2 list "*" "*" - * LIST (\Noinferiors) "/" "INBOX" - * LIST (\HasChildren) "/" "Boite partag&AOk-e/alienor.a" - - The first INBOX is auto-assigned for the user by Cyrus, the second entry - is actually the INBOX of the mailbox itself (alienor.a). - */ - return [self lookupFolder:_key ofClassNamed:@"SOGoSharedInboxFolder" - inContext:_ctx]; -} - -- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { - if ([_key isEqualToString:@"INBOX"]) - return [self lookupInboxFolder:_key inContext:_ctx]; - - return [super lookupName:_key inContext:_ctx acquire:_flag]; -} - -@end /* SOGoSharedMailAccount */ diff --git a/SoObjects/Mailer/product.plist b/SoObjects/Mailer/product.plist index dccd8726f..b97c93e9b 100644 --- a/SoObjects/Mailer/product.plist +++ b/SoObjects/Mailer/product.plist @@ -31,9 +31,9 @@ "WebDAV Access" = ( "Owner", "AuthorizedSubscriber" ); }; }; - SOGoSharedMailAccount = { +/* SOGoSharedMailAccount = { superclass = "SOGoMailAccount"; - }; + }; */ SOGoMailFolder = { superclass = "SOGoMailBaseObject"; defaultRoles = { @@ -46,9 +46,9 @@ "SaveAcls" = ( "Owner", "MailAdministrator" ); }; }; - SOGoSharedInboxFolder = { +/* SOGoSharedInboxFolder = { superclass = "SOGoMailFolder"; - }; + }; */ SOGoTrashFolder = { superclass = "SOGoMailFolder"; };