]> err.no Git - sope/blob - sope-appserver/NGObjWeb/SoObjects/SoSubContext.m
fixed various warnings
[sope] / sope-appserver / NGObjWeb / SoObjects / SoSubContext.m
1 /*
2   Copyright (C) 2002-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "SoSubContext.h"
24 #include "WOElementID.h"
25 #include "WOContext+SoObjects.h"
26 #include <NGObjWeb/WOApplication.h>
27 #include <NGObjWeb/WORequest.h>
28 #include <NGObjWeb/WOResponse.h>
29 #include "common.h"
30
31 @implementation SoSubContext
32
33 + (int)version {
34   return [super version] + 0 /* v7 */;
35 }
36 + (void)initialize {
37   NSAssert2([super version] == 7,
38             @"invalid superclass (%@) version %i !",
39             NSStringFromClass([self superclass]), [super version]);
40 }
41
42 - (id)initWithParentContext:(WOContext *)_parent {
43   if ((self = [super init])) {
44     self->parentContext = [_parent retain];
45
46     self->qpJoin = @"&";
47     
48     self->elementID = [[WOElementID alloc] init];
49     self->request   = [[_parent request]  retain];
50     self->response  = [[_parent response] retain];
51     
52     self->traversalStack = [[_parent objectTraversalStack] mutableCopy];
53     self->clientObject   = [[_parent clientObject] retain];
54     
55     self->soRequestType = @"INTERNAL";
56   }
57   return self;
58 }
59 - (id)init {
60   return [self initWithParentContext:[[WOApplication application] context]];
61 }
62
63 - (void)dealloc {
64   [self->parentContext release];
65   [super dealloc];
66 }
67
68 /* accessors */
69
70 - (WOContext *)parentContext {
71   return self->parentContext;
72 }
73 - (WOContext *)rootContext {
74   return [[self parentContext] rootContext];
75 }
76
77 /* overrides */
78
79 - (NSString *)contextID {
80   /* a subcontext currently has no ID */
81   /*
82     NOTE: a subcontext may *NOT* have the same ID as the parent-context,
83           otherwise havoc is done in component activation
84   */
85   return nil;
86 }
87
88 - (void)setSession:(WOSession *)_session {
89   [self logWithFormat:@"ignoring -setSession:%@ on sub-context", _session];
90 }
91 - (WOSession *)session {
92   return [[self parentContext] session];
93 }
94
95 - (BOOL)hasSession {
96   return [[self parentContext] hasSession];
97 }
98 - (BOOL)savePageRequired {
99   return [[self parentContext] savePageRequired];
100 }
101
102 - (void)setPage:(WOComponent *)_page {
103   [self logWithFormat:@"ignoring -setPage:%@ on sub-context", _page];
104 }
105 - (WOComponent *)page {
106   return [[self parentContext] page];
107 }
108
109 - (NSURL *)serverURL {
110   return [[self parentContext] serverURL];
111 }
112 - (NSURL *)baseURL {
113   return [[self parentContext] baseURL];
114 }
115 - (NSURL *)applicationURL {
116   return [[self parentContext] applicationURL];
117 }
118 - (NSURL *)urlForKey:(NSString *)_key {
119   return [[self parentContext] urlForKey:_key];
120 }
121
122 /* description */
123
124 - (NSString *)description {
125   return [NSString stringWithFormat:
126                      @"<0x%08X[%@]: parent=0x%08X>",
127                      (unsigned)self, NSStringFromClass([self class]),
128                      [self parentContext]];
129 }
130
131 @end /* SoSubContext */