+2005-07-14 Helge Hess <helge.hess@opengroupware.org>
+
+ * v0.9.100
+
+ * SOGoMailAccounts.m: create an object of class SOGoSharedMailAccount
+ in case the lookup-key contains an ".-."
+
+ * SOGoMailAccount.[hm]: added some functionality to deal with shared
+ mail accounts
+
+ * added SOGoSharedMailAccount class for shared mailboxes
+
2005-07-12 Helge Hess <helge.hess@opengroupware.org>
* SOGoMailAccounts.m: use new SoUser API instead of AgenorUserManager
SOGoMailBaseObject.m \
SOGoMailAccounts.m \
SOGoMailAccount.m \
+ SOGoSharedMailAccount.m \
SOGoMailFolder.m \
SOGoMailObject.m \
SOGoMailFolderDataSource.m \
SOGoMailFolder *trashFolder;
}
+/* folder pathes */
+
- (NSArray *)allFolderPathes;
+- (NSArray *)additionalRootFolderNames; /* stuff like filters and drafts */
+
+/* shared accounts */
+
+- (BOOL)isSharedAccount;
+- (NSString *)sharedAccountName;
/* special folders */
@implementation SOGoMailAccount
-static NSArray *rootFolderNames = nil;
-static NSString *inboxFolderName = @"INBOX";
-static NSString *draftsFolderName = @"Drafts";
-static NSString *sieveFolderName = @"Filters";
-static BOOL useAltNamespace = NO;
+static NSArray *rootFolderNames = nil;
+static NSString *inboxFolderName = @"INBOX";
+static NSString *draftsFolderName = @"Drafts";
+static NSString *sieveFolderName = @"Filters";
+static NSString *sharedFolderName = @""; // TODO: add English default
+static NSString *otherUsersFolderName = @""; // TODO: add English default
+static BOOL useAltNamespace = NO;
+ (void)initialize {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
useAltNamespace = [ud boolForKey:@"SOGoSpecialFoldersInRoot"];
+ sharedFolderName = [ud stringForKey:@"SOGoSharedFolderName"];
+ otherUsersFolderName = [ud stringForKey:@"SOGoOtherUsersFolderName"];
+
+ NSLog(@"Note: using shared-folders name: '%@'", sharedFolderName);
+ NSLog(@"Note: using other-users-folders name: '%@'", otherUsersFolderName);
+
if ([ud boolForKey:@"SOGoEnableSieveFolder"]) {
rootFolderNames = [[NSArray alloc] initWithObjects:
draftsFolderName,
}
}
+/* shared accounts */
+
+- (BOOL)isSharedAccount {
+ NSString *s;
+ NSRange r;
+
+ s = [self nameInContainer];
+ r = [s rangeOfString:@"@"];
+ if (r.length == 0) /* regular HTTP logins are never a shared mailbox */
+ return NO;
+
+ s = [s substringToIndex:r.location];
+ return [s rangeOfString:@".-."].length > 0 ? YES : NO;
+}
+
+- (NSString *)sharedAccountName {
+ return nil;
+}
+
/* listing the available folders */
+- (NSArray *)additionalRootFolderNames {
+ return rootFolderNames;
+}
+
- (NSArray *)toManyRelationshipKeys {
NSArray *a, *b;
-
- a = rootFolderNames;
+
+ a = [self additionalRootFolderNames];
b = [[self imap4Connection] subfoldersForURL:[self imap4URL]];
return [b count] > 0 ? [b arrayByAddingObjectsFromArray:a] : a;
return [creds objectAtIndex:0]; /* the user */
}
-- (NSURL *)imap4URL {
- /* imap://agenortest@mail.opengroupware.org/INBOX/withsubdirs/subdir1 */
+- (NSString *)imap4URLString {
+ /* private, overridden by SOGoSharedMailAccount */
NSString *s;
NSRange r;
- if (self->imap4URL != nil)
- return self->imap4URL;
-
s = [self nameInContainer];
r = [s rangeOfString:@"@"];
if (r.length == 0) {
s = [([self useSSL] ? @"imaps://" : @"imap://") stringByAppendingString:s];
s = [s stringByAppendingString:@"/"];
+ return s;
+}
+
+- (NSURL *)imap4URL {
+ /* imap://agenortest@mail.opengroupware.org/ */
+ NSString *s;
+
+ if (self->imap4URL != nil)
+ return self->imap4URL;
+
+ if ((s = [self imap4URLString]) == nil)
+ return nil;
self->imap4URL = [[NSURL alloc] initWithString:s];
return self->imap4URL;
ct = [[ctClass alloc] initWithName:_key inContainer:self];
return [ct autorelease];
}
+- (id)sharedMailAccountWithName:(NSString *)_key inContext:(id)_ctx {
+ static Class ctClass = Nil;
+ id ct;
+
+ if (ctClass == Nil)
+ ctClass = NSClassFromString(@"SOGoSharedMailAccount");
+ if (ctClass == Nil) {
+ [self errorWithFormat:@"missing SOGoSharedMailAccount class!"];
+ return nil;
+ }
+
+ ct = [[ctClass alloc] initWithName:_key inContainer:self];
+ return [ct autorelease];
+}
- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
id obj;
if ([self isValidMailAccountName:_key]) {
/* forbid shares for requests coming from the Internet */
+ BOOL isSharedKey;
+
+ isSharedKey = [_key rangeOfString:AgenorShareLoginMarker].length > 0;
+
if ([self isInternetRequest]) {
- if ([_key rangeOfString:AgenorShareLoginMarker].length > 0) {
+ if (isSharedKey) {
return [NSException exceptionWithHTTPStatus:403 /* Forbidden */
reason:
@"Access to shares forbidden from the Internet"];
}
}
- return [self mailAccountWithName:_key inContext:_ctx];
+ return isSharedKey
+ ? [self sharedMailAccountWithName:_key inContext:_ctx]
+ : [self mailAccountWithName:_key inContext:_ctx];
}
/* return 404 to stop acquisition */
--- /dev/null
+/*
+ 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 <SoObjects/Mailer/SOGoMailAccount.h>
+
+/*
+ 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__ */
--- /dev/null
+/*
+ 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.
+*/
+
+#include "SOGoSharedMailAccount.h"
+#include "common.h"
+
+@interface SOGoMailAccount(UsedPrivates)
+- (NSString *)imap4URLString;
+@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 *)toManyRelationshipKeys {
+ NSArray *a, *b;
+
+ a = [self additionalRootFolderNames];
+ // TODO: we also need to add the INBOX here (the 'real' INBOX is the root)
+
+ b = [[self imap4Connection] subfoldersForURL:[self imap4URL]];
+ return [b count] > 0 ? [b arrayByAddingObjectsFromArray:a] : a;
+}
+
+/* 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;
+}
+
+@end /* SOGoSharedMailAccount */
# Version file
-SUBMINOR_VERSION:=99
+SUBMINOR_VERSION:=100
# v0.9.96 requires libNGMime v4.5.223
# v0.9.91 requires libNGMime v4.5.222
"Add Folders" = "Owner";
};
};
+ SOGoSharedMailAccount = {
+ superclass = "SOGoMailAccount";
+ };
SOGoMailFolder = {
superclass = "SOGoMailBaseObject";