/*
- Copyright (C) 2000-2004 SKYRIX Software AG
+ Copyright (C) 2000-2005 SKYRIX Software AG
- This file is part of OpenGroupware.org.
+ This file is part of SOPE.
- OGo is free software; you can redistribute it and/or modify it under
+ SOPE 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
+ SOPE 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
+ License along with SOPE; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
# include <objc/objc-class.h>
#endif
+static BOOL usePool = NO;
static BOOL perflog = NO;
+static BOOL debugOn = NO;
static Class NSDateClass = Nil;
-//#define USE_POOLS 1
-
@implementation WODirectActionRequestHandler
+ (int)version {
return [super version] + 0 /* 2 */;
}
+ (void)initialize {
+ NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+
NSAssert2([super version] == 2,
@"invalid superclass (%@) version %i !",
NSStringFromClass([self superclass]), [super version]);
NSDateClass = [NSDate class];
- perflog = [[NSUserDefaults standardUserDefaults]
- boolForKey:@"WOProfileDirectActionRequestHandler"];
+ perflog = [ud boolForKey:@"WOProfileDirectActionRequestHandler"];
}
- (NSString *)loggingPrefix {
/*
The request handler part of a direct action URI looks like this:
-
+
[actionClass/]actionName[?key=value&key=value&...]
*/
- (BOOL)isComponentClass:(Class)_clazz {
if (_clazz == Nil)
return NO;
- while ((_clazz = _clazz->super_class)) {
+ while ((_clazz = _clazz->super_class) != Nil) {
if (_clazz == [WOComponent class]) return YES;
if (_clazz == [WODirectAction class]) return NO;
if (_clazz == [NSObject class]) return NO;
if (actionClass == Nil)
return nil;
+
if (![self isComponentClass:actionClass]) {
/* create direct action object */
id actionObject;
session:(WOSession *)session
application:(WOApplication *)app
{
-#if USE_POOLS
- NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init];
-#endif
- NSString *actionClassName;
- NSString *actionName;
- WOResponse *response;
- NSArray *handlerPath;
- Class actionClass = Nil;
+ NSAutoreleasePool *pool2;
+ NSString *actionClassName;
+ NSString *actionName;
+ WOResponse *response;
+ NSArray *handlerPath;
+ Class actionClass = Nil;
WODirectAction *actionObject = nil;
id<WOActionResults> result = nil;
+
+ pool2 = usePool ? [[NSAutoreleasePool alloc] init] : nil;
*(&result) = nil;
*(&response) = nil;
handlerPath = [_request requestHandlerPathArray];
-#if DEBUG_DIRECT_ACTION
- [self debugWithFormat:@"path=%@ array=%@",
+ if (debugOn) {
+ [self debugWithFormat:@"path=%@ array=%@",
[_request requestHandlerPath], handlerPath];
-#endif
-
+ }
+
+ // TODO: fix OGo bug #1028
switch ([handlerPath count]) {
case 0:
actionClassName = @"DirectAction";
default:
actionClassName = [handlerPath objectAtIndex:0];
actionName = [handlerPath objectAtIndex:1];
-#if 0
- NSLog(@"invalid direction action URL: %@",
- [_request requestHandlerPath]);
-#endif
+ // TODO: set path info in ctx?
+ if (debugOn) {
+ [self logWithFormat:@"invalid direction action URL: %@",
+ [_request requestHandlerPath]];
+ }
break;
}
actionClass = [WODirectAction class];
}
-#if DEBUG_DIRECT_ACTION
- [self debugWithFormat:
- @"[direct action request handler] class=%@ action=%@ ..",
- actionClassName, actionName];
-#endif
+ if (debugOn) {
+ [self debugWithFormat:
+ @"[direct action request handler] class=%@ action=%@ ..",
+ actionClassName, actionName];
+ }
/* process request */
[session lock];
}
-#if USE_POOLS
- session = [session retain];
- [pool2 release]; pool2 = nil;
- session = [session autorelease];
-#endif
+ if (usePool) {
+ session = [session retain];
+ [pool2 release]; pool2 = nil;
+ session = [session autorelease];
+ }
response = [response autorelease];
}