From 03e9a37384dfb4fbabb2a32dd0369828a1a7e528 Mon Sep 17 00:00:00 2001 From: helge Date: Fri, 3 Dec 2004 20:41:45 +0000 Subject: [PATCH] work on sieve support git-svn-id: http://svn.opengroupware.org/SOGo/trunk@459 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Sieve/ChangeLog | 9 ++ SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m | 34 ++++++ SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m | 24 ++++ SOGo/SoObjects/Sieve/Version | 2 +- SOGo/UI/Mailer/ChangeLog | 8 +- SOGo/UI/Mailer/GNUmakefile | 2 + SOGo/UI/Mailer/UIxFilterList.m | 7 ++ SOGo/UI/Mailer/UIxSieveEditor.m | 103 ++++++++++++++++++ SOGo/UI/Mailer/UIxSieveEditor.wox | 33 ++++++ SOGo/UI/Mailer/Version | 2 +- SOGo/UI/Mailer/mailer.js | 12 ++ SOGo/UI/Mailer/product.plist | 33 ++++++ 12 files changed, 266 insertions(+), 3 deletions(-) create mode 100644 SOGo/UI/Mailer/UIxSieveEditor.m create mode 100644 SOGo/UI/Mailer/UIxSieveEditor.wox diff --git a/SOGo/SoObjects/Sieve/ChangeLog b/SOGo/SoObjects/Sieve/ChangeLog index cb375fee..97db7522 100644 --- a/SOGo/SoObjects/Sieve/ChangeLog +++ b/SOGo/SoObjects/Sieve/ChangeLog @@ -1,3 +1,12 @@ +2004-12-03 Helge Hess + + * v0.9.3 + + * SOGoSieveScriptObject.m: added ability to fetch content + + * SOGoSieveScriptsFolder.m: added ability to lookup/construct + SOGoSieveScriptObject's + 2004-11-28 Helge Hess * added list capability, does not work with 'dotted' logins? (v0.9.2) diff --git a/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m b/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m index 301d79b7..07f9e70d 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m +++ b/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m @@ -21,7 +21,41 @@ #include "SOGoSieveScriptObject.h" #include "common.h" +#include @implementation SOGoSieveScriptObject +/* script */ + +- (NSString *)fetchScript { + NGSieveClient *client; + + if ((client = [self sieveClient]) == nil) + return nil; + + return [client getScript:[self nameInContainer]]; +} + +/* content */ + +- (NSString *)contentAsString { + return [self fetchScript]; +} +- (NSData *)content { + return [[self contentAsString] dataUsingEncoding:NSUTF8StringEncoding]; +} + +/* name lookup */ + +- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { + id obj; + + /* first check attributes directly bound to the object */ + if ((obj = [super lookupName:_key inContext:_ctx acquire:NO])) + return obj; + + /* return 404 to stop acquisition */ + return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; +} + @end /* SOGoSieveScriptObject */ diff --git a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m index c8287516..4c14d812 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m +++ b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m @@ -46,4 +46,28 @@ return [[self fetchScripts] allKeys]; } +/* name lookup */ + +- (NSString *)lookupScript:(NSString *)_key inContext:(id)_ctx { + Class clazz; + + clazz = NSClassFromString(@"SOGoSieveScriptObject"); + return [[[clazz alloc] initWithName:_key inContainer:self] autorelease]; +} + +- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { + id obj; + + /* first check attributes directly bound to the object */ + if ((obj = [super lookupName:_key inContext:_ctx acquire:NO])) + return obj; + + /* lookup script */ + if ((obj = [self lookupScript:_key inContext:_ctx])) + return obj; + + /* return 404 to stop acquisition */ + return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; +} + @end /* SOGoSieveScriptsFolder */ diff --git a/SOGo/SoObjects/Sieve/Version b/SOGo/SoObjects/Sieve/Version index 4ba9ab79..9ccde977 100644 --- a/SOGo/SoObjects/Sieve/Version +++ b/SOGo/SoObjects/Sieve/Version @@ -1,5 +1,5 @@ # Version file -SUBMINOR_VERSION:=2 +SUBMINOR_VERSION:=3 # v0.9.1 requires libNGMime v4.3.194 diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index a6cca0fe..eaa3de02 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,7 +1,13 @@ 2004-12-03 Helge Hess + * v0.9.68 + + * UIxFilterList.m: added ability to trigger new editor + + * started UIxSieveEditor + * UIxFilterList.wox: minor fix to table layout (v0.9.67) - + 2004-11-28 Helge Hess * UIxFilterList.m: use toOneRelationshipKeys to retrieve the filters diff --git a/SOGo/UI/Mailer/GNUmakefile b/SOGo/UI/Mailer/GNUmakefile index cbeac454..0fd99b73 100644 --- a/SOGo/UI/Mailer/GNUmakefile +++ b/SOGo/UI/Mailer/GNUmakefile @@ -42,6 +42,7 @@ MailerUI_OBJC_FILES += \ UIxMailPartAlternativeViewer.m \ \ UIxFilterList.m \ + UIxSieveEditor.m \ MailerUI_RESOURCE_FILES += \ Version \ @@ -70,6 +71,7 @@ MailerUI_RESOURCE_FILES += \ UIxMailPartAlternativeViewer.wox\ \ UIxFilterList.wox \ + UIxSieveEditor.wox \ MailerUI_RESOURCE_FILES += \ uix.css \ diff --git a/SOGo/UI/Mailer/UIxFilterList.m b/SOGo/UI/Mailer/UIxFilterList.m index 958777b8..bebe2fc1 100644 --- a/SOGo/UI/Mailer/UIxFilterList.m +++ b/SOGo/UI/Mailer/UIxFilterList.m @@ -69,6 +69,13 @@ return self->filters; } +- (NSString *)clickedFilterJS { + /* return 'false' aborts processing */ + return [NSString stringWithFormat: + @"clickedFilter(this, '%@'); return false", + [self filter]]; +} + /* actions */ - (id)defaultAction { diff --git a/SOGo/UI/Mailer/UIxSieveEditor.m b/SOGo/UI/Mailer/UIxSieveEditor.m new file mode 100644 index 00000000..7a25bded --- /dev/null +++ b/SOGo/UI/Mailer/UIxSieveEditor.m @@ -0,0 +1,103 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#include + +/* + UIxSieveEditor + + An editor component which works on SOGoSieveScriptObject's. +*/ + +@class NSArray, NSString; + +@interface UIxSieveEditor : UIxComponent +{ + NSString *scriptName; + NSString *scriptText; +} + +@end + +#include +#include "common.h" + +@implementation UIxSieveEditor + +- (void)dealloc { + [self->scriptText release]; + [self->scriptName release]; + [super dealloc]; +} + +/* accessors */ + +- (void)setScriptName:(NSString *)_value { + ASSIGNCOPY(self->scriptName, _value); +} +- (NSString *)scriptName { + return self->scriptName ? self->scriptName : @""; +} + +- (void)setScriptText:(NSString *)_value { + ASSIGNCOPY(self->scriptText, _value); +} +- (NSString *)scriptText { + return [self->scriptText isNotNull] ? self->scriptText : @""; +} + +/* requests */ + +- (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c { + return YES; +} + +/* actions */ + +- (id)defaultAction { + return [self redirectToLocation:@"edit"]; +} + +- (id)editAction { + [self logWithFormat:@"edit action, load content from: %@", + [self clientObject]]; + + [self setScriptName:[[self clientObject] nameInContainer]]; + [self setScriptText:[[self clientObject] contentAsString]]; + + return self; +} + +- (id)saveAction { + [self logWithFormat:@"TODO: should save script!"]; + return self; +} + +- (id)deleteAction { + NSException *error; + + if ((error = [[self clientObject] delete]) != nil) + return error; + + return nil; +} + +@end /* UIxSieveEditor */ diff --git a/SOGo/UI/Mailer/UIxSieveEditor.wox b/SOGo/UI/Mailer/UIxSieveEditor.wox new file mode 100644 index 00000000..34b70998 --- /dev/null +++ b/SOGo/UI/Mailer/UIxSieveEditor.wox @@ -0,0 +1,33 @@ + + +
+
+ + + + + +
+ + Scriptname: +
+
+ + +
+