2 Copyright (C) 2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "SOGoSharedMailAccount.h"
25 @interface SOGoMailAccount(UsedPrivates)
27 - (NSString *)imap4URLString;
29 - (id)lookupFolder:(NSString *)_key ofClassNamed:(NSString *)_cn
34 @implementation SOGoSharedMailAccount
36 static NSString *otherUsersFolderName = @""; // TODO: add English default
39 return [super version] + 0 /* v1 */;
43 NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
45 NSAssert2([super version] == 1,
46 @"invalid superclass (%@) version %i !",
47 NSStringFromClass([self superclass]), [super version]);
49 otherUsersFolderName = [ud stringForKey:@"SOGoOtherUsersFolderName"];
50 NSLog(@"Note: using other-users-folders name: '%@'", otherUsersFolderName);
55 - (BOOL)isSharedAccount {
59 - (NSString *)sharedAccountName {
63 s = [self nameInContainer];
64 r = [s rangeOfString:@"@"];
65 if (r.length == 0) /* regular HTTP logins are never a shared mailbox */
68 s = [s substringToIndex:r.location];
69 r = [s rangeOfString:@".-."];
70 if (r.length == 0) /* no shared mailbox marker */
73 return [s substringFromIndex:(r.location + r.length)];
76 /* listing the available folders */
78 - (NSArray *)additionalRootFolderNames {
79 /* do not show Drafts folder in shared mailboxes (#1452) */
80 /* Note: this also disables the Sieve folder */
84 - (NSArray *)toManyRelationshipKeys {
88 m = [NSMutableArray arrayWithCapacity:16];
90 [m addObject:@"INBOX"]; /* special for shared, see -lookupInboxFolder:.. */
92 if ((b = [[self imap4Connection] subfoldersForURL:[self imap4URL]]) != nil)
93 [m addObjectsFromArray:b];
95 if ((b = [self additionalRootFolderNames]) != nil)
96 [m addObjectsFromArray:b];
102 - (NSString *)imap4URLString {
103 /* we jump in the hierarchy directly to the shared user folder */
106 s = [super imap4URLString];
107 s = [s stringByAppendingString:otherUsersFolderName];
108 s = [s stringByAppendingString:@"/"];
109 s = [s stringByAppendingString:[self sharedAccountName]];
115 - (id)lookupInboxFolder:(NSString *)_key inContext:(id)_ctx {
117 Note: We have a choice: Cyrus does both, it gives the user an own
118 INBOX folder, but it also provides access to the mailbox INBOX
120 However the mailbox INBOX folder is NOT returned as an "INBOX"
121 subcollection as usual, but is the primary mailbox name.
124 * LIST (\Noinferiors) "/" "INBOX"
125 * LIST (\HasChildren) "/" "Boite partag&AOk-e/alienor.a"
127 The first INBOX is auto-assigned for the user by Cyrus, the second entry
128 is actually the INBOX of the mailbox itself (alienor.a).
130 return [self lookupFolder:_key ofClassNamed:@"SOGoSharedInboxFolder"
134 - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
135 if ([_key isEqualToString:@"INBOX"])
136 return [self lookupInboxFolder:_key inContext:_ctx];
138 return [super lookupName:_key inContext:_ctx acquire:_flag];
141 @end /* SOGoSharedMailAccount */