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 #include "SOGoSieveBaseObject.h"
23 #include <Mailer/SOGoMailManager.h>
24 #include <Mailer/SOGoMailAccount.h>
26 #include <NGImap4/NGSieveClient.h>
27 #include <NGObjWeb/SoObject+SoDAV.h>
28 #include <NGObjWeb/SoHTTPAuthenticator.h>
29 #include <NGExtensions/NSURL+misc.h>
31 @implementation SOGoSieveBaseObject
34 [self->sieveClient release];
40 - (SOGoMailAccount *)mailAccountFolder {
41 if (![[self container] respondsToSelector:_cmd]) {
42 [self logWithFormat:@"WARNING: weird container of mailfolder: %@",
47 return [[self container] mailAccountFolder];
52 - (NGImap4ConnectionManager *)mailManager {
53 return [[self mailAccountFolder] mailManager];
56 return [[self mailAccountFolder] imap4URL];
59 - (NSString *)imap4Password {
60 return [[self mailAccountFolder] imap4Password];
63 - (void)flushMailCaches {
68 - (NGSieveClient *)sieveClient {
71 if (self->sieveClient != nil)
72 return self->sieveClient;
76 res = [self container];
77 if ([res respondsToSelector:_cmd]) {
78 if ((res = [res sieveClient]) != nil) {
79 self->sieveClient = [res retain];
80 return self->sieveClient;
87 [[NGSieveClient alloc] initWithHost:[[self imap4URL] host]];
88 if (self->sieveClient == nil)
93 res = [self->sieveClient
94 login:[[self imap4URL] user]
95 password:[self imap4Password]];
97 if (![[res valueForKey:@"result"] boolValue]) {
99 @"ERROR: could not login '%@'(%@) into Sieve server: %@: %@",
100 [[self imap4URL] user], [self imap4Password],
101 self->sieveClient, res];
102 [self->sieveClient release]; self->sieveClient = nil;
106 return self->sieveClient;
111 - (NSString *)loggingPrefix {
112 /* improve perf ... */
113 return [NSString stringWithFormat:@"<0x%08X[%@]:%@>",
114 self, NSStringFromClass([self class]),
115 [self nameInContainer]];
117 @end /* SOGoSieveBaseObject */