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
22 #include "SOGoSieveScriptsFolder.h"
23 #include <NGImap4/NGSieveClient.h>
26 @implementation SOGoSieveScriptsFolder
29 [self->listedScripts release];
35 - (NSDictionary *)fetchScripts {
36 if (self->listedScripts != nil)
37 return self->listedScripts;
39 self->listedScripts = [[[self sieveClient] listScripts] copy];
40 return self->listedScripts;
43 /* standard methods */
45 - (NSArray *)toOneRelationshipKeys {
46 return [[self fetchScripts] allKeys];
51 - (NSException *)activateScript:(NSString *)_name {
55 res = [[self sieveClient] setActiveScript:_name];
56 if ([[res valueForKey:@"result"] boolValue])
59 // TODO: make it a debug log
60 [self logWithFormat:@"sieve activate failed: %@", res];
62 r = [@"Script activation failed: "
63 stringByAppendingString:[res description]];
64 return [NSException exceptionWithHTTPStatus:500 /* Server Error */
70 - (NSString *)lookupScript:(NSString *)_key inContext:(id)_ctx {
73 clazz = NSClassFromString(@"SOGoSieveScriptObject");
74 return [[[clazz alloc] initWithName:_key inContainer:self] autorelease];
77 - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
80 /* first check attributes directly bound to the object */
81 if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]))
85 if ((obj = [self lookupScript:_key inContext:_ctx]))
88 /* return 404 to stop acquisition */
89 return [NSException exceptionWithHTTPStatus:404 /* Not Found */];
94 - (NSString *)outlookFolderClass {
98 @end /* SOGoSieveScriptsFolder */