]> err.no Git - scalable-opengroupware.org/blob - UI/MailerUI/UIxSieveEditor.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1158 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / MailerUI / UIxSieveEditor.m
1 /*
2   Copyright (C) 2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #include <SOGoUI/UIxComponent.h>
23
24 /*
25   UIxSieveEditor
26   
27   An editor component which works on SOGoSieveScriptObject's.
28 */
29
30 @class NSArray, NSString;
31
32 @interface UIxSieveEditor : UIxComponent
33 {
34   NSString *scriptName;
35   NSString *scriptText;
36 }
37
38 @end
39
40 #include <SoObjects/Sieve/SOGoSieveScriptObject.h>
41 #include "common.h"
42
43 @implementation UIxSieveEditor
44
45 - (void)dealloc {
46   [self->scriptText release];
47   [self->scriptName release];
48   [super dealloc];
49 }
50
51 /* accessors */
52
53 - (void)setScriptName:(NSString *)_value {
54   ASSIGNCOPY(self->scriptName, _value);
55 }
56 - (NSString *)scriptName {
57   return self->scriptName ? self->scriptName : @"";
58 }
59
60 - (void)setScriptText:(NSString *)_value {
61   ASSIGNCOPY(self->scriptText, _value);
62 }
63 - (NSString *)scriptText {
64   return [self->scriptText isNotNull] ? self->scriptText : @"";
65 }
66
67 - (NSString *)panelTitle {
68   return [self labelForKey:@"Edit Mail Filter"];
69 }
70
71 /* requests */
72
73 - (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c {
74   return YES;
75 }
76
77 /* actions */
78
79 - (id)defaultAction {
80   return [self redirectToLocation:@"edit"];
81 }
82
83 - (id)editAction {
84 #if 0
85   [self logWithFormat:@"edit action, load content from: %@",
86           [self clientObject]];
87 #endif
88   
89   [self setScriptName:[[self clientObject] nameInContainer]];
90   [self setScriptText:[[self clientObject] contentAsString]];
91   
92   return self;
93 }
94
95 - (id)saveAction {
96   NSException *error;
97   NSString *text;
98   
99   text = [self scriptText];
100   if ((error = [[self clientObject] writeContent:text]) != nil)
101     return error;
102   
103   return self;
104 }
105
106 - (id)deleteAction {
107   NSException *error;
108   
109   if ((error = [[self clientObject] delete]) != nil)
110     return error;
111   
112   return nil;
113 }
114
115 @end /* UIxSieveEditor */