#include "SOGoICalHTTPHandler.h"
#include "common.h"
+#include <NGObjWeb/WOContext+SoObjects.h>
@implementation SOGoICalHTTPHandler
[super dealloc];
}
+/* context */
+
+- (WOContext *)context {
+ return [[WOApplication application] context];
+}
+
+/* clientObject */
+
+- (id)clientObjectInContext:(id)_ctx {
+ /*
+ The handler object is _not_ a method, its just a regular object
+ itself! (because methods are defined on it).
+ */
+ NSArray *stack;
+
+ stack = [_ctx objectTraversalStack];
+ if ([stack count] == 0) {
+ [self logWithFormat:@"ERROR: no objects in traversal stack: %@", _ctx];
+ return nil;
+ }
+ if ([stack count] < 2) {
+ [self logWithFormat:@"ERROR: not enough objects in traversal stack: %@",
+ stack];
+ return nil;
+ }
+
+ if ([stack lastObject] != self) // TODO: hm, hm, not really OK
+ return [stack lastObject];
+
+ return [stack objectAtIndex:[stack count] - 2];
+}
+
+/* fetching */
+
+- (NSArray *)storedNamesInContext:(id)_ctx {
+ /* the client object will cache the names */
+ return [[self clientObjectInContext:_ctx] toOneRelationshipKeys];
+}
+
+/* actions */
+
+- (id)assembleEventsInContext:(id)_ctx {
+ [self logWithFormat:@"assemble iCal events ..."];
+ [self logWithFormat:@" names: %@", [self storedNamesInContext:_ctx]];
+ return self;
+}
+
+- (id)updateEventsInContext:(id)_ctx {
+ [self logWithFormat:@"updates iCal events from a full collection ..."];
+ return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
+ reason:@"please use WebDAV for modifications!"];
+}
+
@end /* SOGoICalHTTPHandler */
classes = {
SOGoICalHTTPHandler = {
- superclass = "NSObject";
- protectedBy = "View";
+ superclass = "NSObject";
+ protectedBy = "View";
+ methods = {
+ GET = {
+ protectedBy = "View";
+ selector = {
+ name = "assembleEventsInContext:";
+ addContextParameter = YES;
+ };
+ };
+ PUT = {
+ protectedBy = "View";
+ selector = {
+ name = "updateEventsInContext:";
+ addContextParameter = YES;
+ };
+ };
+ };
};
};