Monotone-Parent: 1d531bb1705a798641ec3085cc160512248523f8
Monotone-Revision: 35e3135027040fead1c91041394159c3adecf931 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-02-07T20:21:13 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
90b089f23c
commit
db9ca6854a
|
@ -28,19 +28,18 @@
|
||||||
|
|
||||||
#import "../SOGo/NSArray+Utilities.h"
|
#import "../SOGo/NSArray+Utilities.h"
|
||||||
#import "../SOGo/SOGoUser.h"
|
#import "../SOGo/SOGoUser.h"
|
||||||
|
#import "SOGoMailAccount.h"
|
||||||
|
|
||||||
#import "SOGoMailAccounts.h"
|
#import "SOGoMailAccounts.h"
|
||||||
|
|
||||||
@implementation SOGoMailAccounts
|
@implementation SOGoMailAccounts
|
||||||
|
|
||||||
static NSString *AgenorShareLoginMarker = @".-.";
|
|
||||||
|
|
||||||
/* listing the available mailboxes */
|
/* listing the available mailboxes */
|
||||||
|
|
||||||
- (BOOL) isInHomeFolderBranchOfLoggedInAccount: (NSString *) userLogin
|
// - (BOOL) isInHomeFolderBranchOfLoggedInAccount: (NSString *) userLogin
|
||||||
{
|
// {
|
||||||
return [[container nameInContainer] isEqualToString: userLogin];
|
// return [[container nameInContainer] isEqualToString: userLogin];
|
||||||
}
|
// }
|
||||||
|
|
||||||
- (NSArray *) toManyRelationshipKeys
|
- (NSArray *) toManyRelationshipKeys
|
||||||
{
|
{
|
||||||
|
@ -62,70 +61,53 @@ static NSString *AgenorShareLoginMarker = @".-.";
|
||||||
return [[accounts objectsForKey: @"name"] containsObject: _key];
|
return [[accounts objectsForKey: @"name"] containsObject: _key];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) mailAccountWithName: (NSString *) _key
|
// - (id) mailAccountWithName: (NSString *) _key
|
||||||
inContext: (id) _ctx
|
// inContext: (id) _ctx
|
||||||
{
|
// {
|
||||||
static Class ctClass = Nil;
|
// static Class ctClass = Nil;
|
||||||
id ct;
|
// id ct;
|
||||||
|
|
||||||
if (ctClass == Nil)
|
// if (ctClass == Nil)
|
||||||
ctClass = NSClassFromString(@"SOGoMailAccount");
|
// ctClass = NSClassFromString(@"SOGoMailAccount");
|
||||||
if (ctClass == Nil) {
|
// if (ctClass == Nil) {
|
||||||
[self errorWithFormat:@"missing SOGoMailAccount class!"];
|
// [self errorWithFormat:@"missing SOGoMailAccount class!"];
|
||||||
return nil;
|
// return nil;
|
||||||
}
|
// }
|
||||||
|
|
||||||
ct = [[ctClass alloc] initWithName:_key inContainer:self];
|
// ct = [[ctClass alloc] initWithName:_key inContainer:self];
|
||||||
|
|
||||||
return [ct autorelease];
|
// 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];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) lookupName: (NSString *) _key
|
- (id) lookupName: (NSString *) _key
|
||||||
inContext: (id) _ctx
|
inContext: (id) _ctx
|
||||||
acquire: (BOOL) _flag
|
acquire: (BOOL) _flag
|
||||||
{
|
{
|
||||||
id obj;
|
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 */
|
/* first check attributes directly bound to the application */
|
||||||
if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]))
|
obj = [super lookupName:_key inContext:_ctx acquire:NO];
|
||||||
return obj;
|
if (!obj)
|
||||||
|
{
|
||||||
|
if ([self isValidMailAccountName: _key])
|
||||||
|
obj = [SOGoMailAccount objectWithName: _key inContainer: self];
|
||||||
|
else
|
||||||
|
obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
|
||||||
|
}
|
||||||
|
|
||||||
if (![self isInHomeFolderBranchOfLoggedInAccount: userLogin]) {
|
return obj;
|
||||||
[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 */];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end /* SOGoMailAccounts */
|
@end /* SOGoMailAccounts */
|
||||||
|
|
|
@ -132,7 +132,7 @@ static BOOL debugOn = YES;
|
||||||
{
|
{
|
||||||
NSURL *url;
|
NSURL *url;
|
||||||
|
|
||||||
if ([container respondsToSelector:@selector(imap4URL)])
|
if ([container respondsToSelector: @selector(imap4URL)])
|
||||||
url = [container imap4URL];
|
url = [container imap4URL];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 <SoObjects/Mailer/SOGoMailFolder.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
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__ */
|
|
|
@ -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 */
|
|
|
@ -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 <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__ */
|
|
|
@ -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 <Foundation/NSArray.h>
|
|
||||||
#import <Foundation/NSString.h>
|
|
||||||
#import <Foundation/NSUserDefaults.h>
|
|
||||||
|
|
||||||
#import <NGImap4/NGImap4Connection.h>
|
|
||||||
|
|
||||||
#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 */
|
|
|
@ -31,9 +31,9 @@
|
||||||
"WebDAV Access" = ( "Owner", "AuthorizedSubscriber" );
|
"WebDAV Access" = ( "Owner", "AuthorizedSubscriber" );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
SOGoSharedMailAccount = {
|
/* SOGoSharedMailAccount = {
|
||||||
superclass = "SOGoMailAccount";
|
superclass = "SOGoMailAccount";
|
||||||
};
|
}; */
|
||||||
SOGoMailFolder = {
|
SOGoMailFolder = {
|
||||||
superclass = "SOGoMailBaseObject";
|
superclass = "SOGoMailBaseObject";
|
||||||
defaultRoles = {
|
defaultRoles = {
|
||||||
|
@ -46,9 +46,9 @@
|
||||||
"SaveAcls" = ( "Owner", "MailAdministrator" );
|
"SaveAcls" = ( "Owner", "MailAdministrator" );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
SOGoSharedInboxFolder = {
|
/* SOGoSharedInboxFolder = {
|
||||||
superclass = "SOGoMailFolder";
|
superclass = "SOGoMailFolder";
|
||||||
};
|
}; */
|
||||||
SOGoTrashFolder = {
|
SOGoTrashFolder = {
|
||||||
superclass = "SOGoMailFolder";
|
superclass = "SOGoMailFolder";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue