2 Copyright (C) 2004 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
21 // $Id: SOGoMailAccount.m 274 2004-08-26 13:10:49Z znek $
23 #include "SOGoMailAccount.h"
24 #include "SOGoMailFolder.h"
27 @implementation SOGoMailAccount
29 /* listing the available folders */
31 - (NSArray *)toManyRelationshipKeys {
32 // TODO: hardcoded, if we want to support shared folders, need to change */
33 return [NSArray arrayWithObjects:@"INBOX", nil];
38 - (SOGoMailAccount *)mailAccountFolder {
49 /* imap://agenortest@mail.opengroupware.org/INBOX/withsubdirs/subdir1 */
53 if (self->imap4URL != nil)
54 return self->imap4URL;
56 s = [self nameInContainer];
57 r = [s rangeOfString:@"@"];
59 [self logWithFormat:@"ERROR: missing login in account folder name: %@", s];
63 s = [([self useSSL] ? @"imaps://" : @"imap://") stringByAppendingString:s];
64 s = [s stringByAppendingString:@"/"];
66 self->imap4URL = [[NSURL alloc] initWithString:s];
67 return self->imap4URL;
72 - (id)lookupImap4Folder:(NSString *)_key inContext:(id)_ctx {
73 return [[[SOGoMailFolder alloc] initWithName:_key
74 inContainer:self] autorelease];
77 - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
80 /* first check attributes directly bound to the application */
81 if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]) != nil)
84 if ((obj = [self lookupImap4Folder:_key inContext:_ctx]) != nil)
87 /* return 404 to stop acquisition */
88 return [NSException exceptionWithHTTPStatus:404 /* Not Found */];
93 - (NSString *)shortTitle {
94 NSString *s, *login, *host;
97 s = [self nameInContainer];
99 r = [s rangeOfString:@"@"];
101 login = [s substringToIndex:r.location];
102 host = [s substringFromIndex:(r.location + r.length)];
109 r = [host rangeOfString:@"."];
111 host = [host substringToIndex:r.location];
113 if ([login length] == 0)
116 return [NSString stringWithFormat:@"%@ (%@)", host, login];
119 - (NSString *)davDisplayName {
120 return [self shortTitle];
123 @end /* SOGoMailAccount */