#import <Foundation/NSObject.h>
+/*
+ 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;
2004-12-03 Helge Hess <helge.hess@skyrix.com>
-
+
+ * 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 <helge.hess@skyrix.com>
* added list capability, does not work with 'dotted' logins? (v0.9.2)
{
}
-
@end
#endif /* __Sieve_SOGoSieveScriptObject_H__ */
*/
#include "SOGoSieveScriptObject.h"
+#include "SOGoSieveScriptsFolder.h"
#include "common.h"
#include <NGImap4/NGSieveClient.h>
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 {
return [NSException exceptionWithHTTPStatus:404 /* Not Found */];
}
+/* WebDAV */
+
@end /* SOGoSieveScriptObject */
server.
*/
-@class NSDictionary;
+@class NSString, NSException, NSDictionary;
@interface SOGoSieveScriptsFolder : SOGoSieveBaseObject
{
NSDictionary *listedScripts;
}
+/* operations */
+
+- (NSException *)activateScript:(NSString *)_name;
@end
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 {
# Version file
-SUBMINOR_VERSION:=3
+SUBMINOR_VERSION:=4
# v0.9.1 requires libNGMime v4.3.194
2004-12-03 Helge Hess <helge.hess@skyrix.com>
+ * v0.9.69
+
+ * UIxFilterList.m: added support for script creation
+
* v0.9.68
* UIxFilterList.m: added ability to trigger new editor
return self->filters;
}
+/* JavaScript code */
+
- (NSString *)clickedFilterJS {
/* return 'false' aborts processing */
return [NSString stringWithFormat:
[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 */
# 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
"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 */
+}
},
{
link = "#"; // "compose"; // target = "_blank";
- onclick = "clickedNewFilter(this);return false;";
+ onclick = "clickedNewFilter(this); return false";
cssClass = "tbicon_compose"; label = "New Filter";
},
),
protectedBy = "View";
pageName = "UIxFilterList";
};
+ create = {
+ protectedBy = "View";
+ pageName = "UIxFilterList";
+ actionName = "create";
+ };
};
};