From: helge Date: Fri, 3 Dec 2004 21:42:40 +0000 (+0000) Subject: work on Sieve client X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b41fa551bf0e75dc9d2dd0e68cd3568940c32179;p=scalable-opengroupware.org work on Sieve client git-svn-id: http://svn.opengroupware.org/SOGo/trunk@460 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/SOGo/SOGoObject.h b/SOGo/SoObjects/SOGo/SOGoObject.h index b072828f..c792d609 100644 --- a/SOGo/SoObjects/SOGo/SOGoObject.h +++ b/SOGo/SoObjects/SOGo/SOGoObject.h @@ -25,6 +25,16 @@ #import +/* + SOGoObject + + This is the abstract class used by all SOGo SoObjects. It contains the + ability to track a container as well as the key the object was invoked with. + + In addition it provides some generic methods like user or group folder + lookup. +*/ + @class NSString, NSArray, NSMutableString, NSException; @class OCSFolderManager, OCSFolder; @class SOGoUserFolder, SOGoGroupsFolder; diff --git a/SOGo/SoObjects/Sieve/ChangeLog b/SOGo/SoObjects/Sieve/ChangeLog index 97db7522..366cc880 100644 --- a/SOGo/SoObjects/Sieve/ChangeLog +++ b/SOGo/SoObjects/Sieve/ChangeLog @@ -1,12 +1,15 @@ 2004-12-03 Helge Hess - + + * SOGoSieveScriptObject.m, SOGoSieveScriptsFolder.m: added script + activation action (v0.9.4) + * 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.h b/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.h index 7f8fcf8f..8d6f2dd2 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.h +++ b/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.h @@ -37,7 +37,6 @@ { } - @end #endif /* __Sieve_SOGoSieveScriptObject_H__ */ diff --git a/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m b/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m index 07f9e70d..bb8bbbdc 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m +++ b/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m @@ -20,6 +20,7 @@ */ #include "SOGoSieveScriptObject.h" +#include "SOGoSieveScriptsFolder.h" #include "common.h" #include @@ -45,6 +46,28 @@ return [[self contentAsString] dataUsingEncoding:NSUTF8StringEncoding]; } +/* operations */ + +- (NSException *)delete { + NSDictionary *res; + NSString *r; + + res = [[self sieveClient] deleteScript:[self nameInContainer]]; + if ([[res valueForKey:@"result"] boolValue]) + return nil; + + // TODO: make it a debug log + [self logWithFormat:@"sieve delete failed: %@", res]; + + r = [@"Sieve delete failed: " stringByAppendingString:[res description]]; + return [NSException exceptionWithHTTPStatus:500 /* Server Error */ + reason:r]; +} + +- (NSException *)activate { + return [[self container] activateScript:[self nameInContainer]]; +} + /* name lookup */ - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { @@ -58,4 +81,6 @@ return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; } +/* WebDAV */ + @end /* SOGoSieveScriptObject */ diff --git a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.h b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.h index acaf78fe..c711f362 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.h +++ b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.h @@ -34,13 +34,16 @@ server. */ -@class NSDictionary; +@class NSString, NSException, NSDictionary; @interface SOGoSieveScriptsFolder : SOGoSieveBaseObject { NSDictionary *listedScripts; } +/* operations */ + +- (NSException *)activateScript:(NSString *)_name; @end diff --git a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m index 4c14d812..37f8c25a 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m +++ b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m @@ -46,6 +46,25 @@ return [[self fetchScripts] allKeys]; } +/* operations */ + +- (NSException *)activateScript:(NSString *)_name { + NSDictionary *res; + NSString *r; + + res = [[self sieveClient] setActiveScript:_name]; + if ([[res valueForKey:@"result"] boolValue]) + return nil; + + // TODO: make it a debug log + [self logWithFormat:@"sieve activate failed: %@", res]; + + r = [@"Script activation failed: " + stringByAppendingString:[res description]]; + return [NSException exceptionWithHTTPStatus:500 /* Server Error */ + reason:r]; +} + /* name lookup */ - (NSString *)lookupScript:(NSString *)_key inContext:(id)_ctx { diff --git a/SOGo/SoObjects/Sieve/Version b/SOGo/SoObjects/Sieve/Version index 9ccde977..60cc37e5 100644 --- a/SOGo/SoObjects/Sieve/Version +++ b/SOGo/SoObjects/Sieve/Version @@ -1,5 +1,5 @@ # Version file -SUBMINOR_VERSION:=3 +SUBMINOR_VERSION:=4 # v0.9.1 requires libNGMime v4.3.194 diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index eaa3de02..31195dd3 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,5 +1,9 @@ 2004-12-03 Helge Hess + * v0.9.69 + + * UIxFilterList.m: added support for script creation + * v0.9.68 * UIxFilterList.m: added ability to trigger new editor diff --git a/SOGo/UI/Mailer/UIxFilterList.m b/SOGo/UI/Mailer/UIxFilterList.m index bebe2fc1..d6d99966 100644 --- a/SOGo/UI/Mailer/UIxFilterList.m +++ b/SOGo/UI/Mailer/UIxFilterList.m @@ -69,6 +69,8 @@ return self->filters; } +/* JavaScript code */ + - (NSString *)clickedFilterJS { /* return 'false' aborts processing */ return [NSString stringWithFormat: @@ -76,16 +78,35 @@ [self filter]]; } +/* creating scripts */ + +- (NSString *)newScriptName { + NSCalendarDate *now; + + now = [NSCalendarDate date]; + return [NSString stringWithFormat:@"MyFilter-%04d%02d%02d-%02d%02d%02d", + [now yearOfCommonEra], [now monthOfYear], + [now dayOfMonth], + [now hourOfDay], [now minuteOfHour], [now secondOfMinute]]; +} + /* actions */ - (id)defaultAction { - // TODO: remove log - [self logWithFormat:@"default action ..."]; - - [self logWithFormat:@"should fetch scripts in: %@", [self clientObject]]; + [self debugWithFormat:@"fetch scripts in: %@", [self clientObject]]; self->filters = [[[self clientObject] toOneRelationshipKeys] copy]; - return self; } +- (id)createAction { + NSString *newURL; + + newURL = [[self clientObject] baseURLInContext:[self context]]; + if (![newURL hasSuffix:@"/"]) newURL = [newURL stringByAppendingString:@"/"]; + newURL = [newURL stringByAppendingString:[self newScriptName]]; + newURL = [newURL stringByAppendingString:@"/edit"]; + + return [self redirectToLocation:newURL]; +} + @end /* UIxFilterList */ diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index e1edb0f7..8bbbec8f 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,7 +1,8 @@ # version file -SUBMINOR_VERSION:=68 +SUBMINOR_VERSION:=69 +# v0.9.69 requires libNGMime v4.5.203 # v0.9.50 requires libNGMime v4.3.190 # v0.9.43 requires libNGObjWeb v4.3.73 # v0.9.42 requires libNGObjWeb v4.3.72 diff --git a/SOGo/UI/Mailer/mailer.js b/SOGo/UI/Mailer/mailer.js index bd970ce5..8b6d9e50 100644 --- a/SOGo/UI/Mailer/mailer.js +++ b/SOGo/UI/Mailer/mailer.js @@ -129,3 +129,13 @@ function clickedFilter(sender, scriptname) { "location=0,directories=0,status=0,menubar=0,copyhistory=0") return true; } + +function clickedNewFilter(sender) { + var urlstr; + + urlstr = "create"; + window.open(urlstr, "SOGo_filter", + "width=680,height=480,resizable=1,scrollbars=1,toolbar=0," + + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); + return false; /* stop following the link */ +} diff --git a/SOGo/UI/Mailer/product.plist b/SOGo/UI/Mailer/product.plist index 64e63db1..7eb6a814 100644 --- a/SOGo/UI/Mailer/product.plist +++ b/SOGo/UI/Mailer/product.plist @@ -417,7 +417,7 @@ }, { link = "#"; // "compose"; // target = "_blank"; - onclick = "clickedNewFilter(this);return false;"; + onclick = "clickedNewFilter(this); return false"; cssClass = "tbicon_compose"; label = "New Filter"; }, ), @@ -433,6 +433,11 @@ protectedBy = "View"; pageName = "UIxFilterList"; }; + create = { + protectedBy = "View"; + pageName = "UIxFilterList"; + actionName = "create"; + }; }; };