2 Copyright (C) 2002-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include <NGObjWeb/WODirectAction.h>
23 #include "WOContext+SoObjects.h"
28 WODirectActionPubInvocation
30 This invocation is used if you have a direct action in the lookup path, this
31 can be configured by setting a WODirectAction subclass as a 'slot' of a
35 @interface WODirectActionPubInvocation : NSObject
38 WODirectAction *parent;
43 @implementation WODirectAction(SoObjectRequestHandler)
46 return [[(id)self context] clientObject];
49 - (id)lookupName:(NSString *)_name inContext:(id)_ctx acquire:(BOOL)_flag {
50 WODirectActionPubInvocation *inv;
54 daName = [_name stringByAppendingString:@"Action"];
55 sel = daName ? NSSelectorFromString(daName) : NULL;
57 if (![self respondsToSelector:sel])
58 return [super lookupName:_name inContext:_ctx acquire:_flag];
60 inv = [[WODirectActionPubInvocation alloc] init];
61 inv->daName = [_name copy];
62 inv->parent = [self retain];
63 return [inv autorelease];
66 @end /* WODirectAction(SoObjectRequestHandler) */
68 @implementation WODirectActionPubInvocation
71 [self->daName release];
72 [self->parent release];
83 - (id)callOnObject:(id)_object inContext:(WOContext *)_ctx {
84 return [_object ? _object : self->parent performActionNamed:self->daName];
89 - (NSString *)description {
92 ms = [NSMutableString stringWithCapacity:64];
93 [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
94 [ms appendFormat:@" action=%@", self->daName];
95 [ms appendFormat:@" class=%@", NSStringFromClass([self->parent class])];
96 [ms appendString:@">"];
100 @end /* WODirectActionPubInvocation */