2 Copyright (C) 2004-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 #import <NGObjWeb/SoObject+SoDAV.h>
23 #import <NGObjWeb/SoHTTPAuthenticator.h>
24 #import <NGExtensions/NSNull+misc.h>
25 #import <NGExtensions/NSObject+Logs.h>
26 #import <NGExtensions/NSString+misc.h>
27 #import <NGExtensions/NSURL+misc.h>
29 #import <SoObjects/SOGo/SOGoAuthenticator.h>
31 #import "SOGoMailManager.h"
33 #import "SOGoMailBaseObject.h"
35 @implementation SOGoMailBaseObject
38 static BOOL debugOn = YES;
41 - (id) initWithImap4URL: (NSURL *) _url
42 inContainer: (id) _container
46 n = [[_url path] lastPathComponent];
47 if ((self = [self initWithName: n inContainer:_container]))
49 imap4URL = [_url retain];
63 - (SOGoMailAccount *) mailAccountFolder
65 SOGoMailAccount *folder;
67 if ([container respondsToSelector:_cmd])
68 folder = [container mailAccountFolder];
71 [self warnWithFormat: @"weird container of mailfolder: %@",
79 - (SOGoMailAccounts *) mailAccountsFolder
82 SOGoMailAccounts *folder;
87 folderClass = NSClassFromString (@"SOGoMailAccounts");
89 while (!folder && [o isNotNull])
90 if ([o isKindOfClass: folderClass])
100 - (NGImap4ConnectionManager *) mailManager
102 return [NGImap4ConnectionManager defaultConnectionManager];
105 - (NGImap4Connection *) imap4Connection
109 imap4 = [[self mailManager] connectionForURL: [self imap4URL]
110 password: [self imap4Password]];
114 [self errorWithFormat:@"Could not connect IMAP4."];
120 - (NSString *) relativeImap4Name
122 [self subclassResponsibility: _cmd];
127 - (NSURL *) baseImap4URL
131 if ([container respondsToSelector:@selector(imap4URL)])
132 url = [container imap4URL];
135 [self warnWithFormat:@"container does not implement -imap4URL!"];
142 - (NSMutableString *) imap4URLString
144 NSMutableString *urlString;
146 urlString = [container imap4URLString];
147 [urlString appendFormat: @"%@/", [nameInContainer stringByEscapingURL]];
154 /* this could probably be handled better from NSURL but it's buggy in
158 imap4URL = [[NSURL alloc] initWithString: [self imap4URLString]];
164 - (NSString *) imap4Login
166 if (![container respondsToSelector:_cmd])
169 return [container imap4Login];
172 - (NSString *) imap4Password
175 Extract password from basic authentication.
177 TODO: we might want to
178 a) move the primary code to SOGoMailAccount
179 b) cache the password
182 return [[self authenticatorInContext: context] passwordInContext: context];
185 - (void)flushMailCaches {
186 [[self mailManager] flushCachesForURL:[self imap4URL]];
191 - (BOOL)isBodyPartKey:(NSString *)_key inContext:(id)_ctx {
193 Every key starting with a digit is consider an IMAP4 mime part key, used in
194 SOGoMailObject and SOGoMailBodyPart.
196 if ([_key length] == 0)
199 if (isdigit([_key characterAtIndex:0]))
205 - (NSArray *) aclsForUser: (NSString *) uid
210 @end /* SOGoMailBaseObject */