]> err.no Git - sope/blob - sope-appserver/NGObjWeb/NGObjWeb/WOApplication.h
improved SOPE security exceptions
[sope] / sope-appserver / NGObjWeb / NGObjWeb / WOApplication.h
1 /*
2   Copyright (C) 2000-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 #ifndef __NGObjWeb_WOApplication_H__
24 #define __NGObjWeb_WOApplication_H__
25
26 #import <Foundation/NSObject.h>
27 #import <Foundation/NSLock.h>
28 #import <Foundation/NSMapTable.h>
29 #include <NGObjWeb/NGObjWebDecls.h>
30 #include <NGObjWeb/WOCoreApplication.h>
31
32 @class NSString, NSRunLoop, NSArray, NSTimer, NSException, NSNumber, NSURL;
33 @class NSMutableDictionary, NSDictionary;
34 @class WOResourceManager, WOComponent, WOContext, WOSession;
35 @class WORequest, WOResponse, WOAdaptor, WORequestHandler;
36 @class WOSessionStore, WODynamicElement, WOElement, WOStatisticsStore;
37
38 @interface WOApplication : WOCoreApplication
39 {
40 @private
41   int                 minimumActiveSessionsCount;
42   NSString            *name;
43   NSString            *path;
44   WORequestHandler    *defaultRequestHandler;
45   NSMapTable          *requestHandlerRegistry;
46   WOSessionStore      *iSessionStore;
47   WOStatisticsStore   *iStatisticsStore;
48   WOResourceManager   *resourceManager;
49   void                *_unused;
50   NSTimer             *expirationTimer;
51   NSString            *instanceNumber;
52   short               pageCacheSize;
53   short               permanentPageCacheSize;
54
55   struct {
56     BOOL doesRefuseNewSessions:1;
57     BOOL isPageRefreshOnBacktrackEnabled:1;
58     BOOL isCachingEnabled:1;
59   } appFlags;
60 }
61
62 /* accessors */
63
64 - (NSString *)name;
65 - (BOOL)monitoringEnabled;
66 - (NSString *)path;
67 - (NSString *)number;
68
69 /* request handlers */
70
71 - (void)registerRequestHandler:(WORequestHandler *)_hdl forKey:(NSString *)_key;
72 - (void)removeRequestHandlerForKey:(NSString *)_key;
73 - (void)setDefaultRequestHandler:(WORequestHandler *)_hdl;
74 - (WORequestHandler *)defaultRequestHandler;
75 - (NSArray *)registeredRequestHandlerKeys;
76
77 /* sessions */
78
79 - (id)createSessionForRequest:(WORequest *)_request;
80 - (id)restoreSessionWithID:(NSString *)_id inContext:(WOContext *)_ctx;
81 - (void)saveSessionForContext:(WOContext *)_ctx;
82
83 - (void)setSessionStore:(WOSessionStore *)_store;
84 - (WOSessionStore *)sessionStore;
85 - (NSString *)sessionStoreClassName;
86 - (void)refuseNewSessions:(BOOL)_flag;
87 - (BOOL)isRefusingNewSessions;
88 - (int)activeSessionsCount;
89
90 - (void)setMinimumActiveSessionsCount:(int)_minimum;
91 - (int)minimumActiveSessionsCount;
92
93 - (WOResponse *)handleSessionCreationErrorInContext:(WOContext *)_context;
94 - (WOResponse *)handleSessionRestorationErrorInContext:(WOContext *)_context;
95 - (WOResponse *)handlePageRestorationErrorInContext:(WOContext *)_context;
96
97 /* statistics */
98
99 - (void)setStatisticsStore:(WOStatisticsStore *)_statStore;
100 - (WOStatisticsStore *)statisticsStore;
101 - (bycopy NSDictionary *)statistics;
102
103 /* resources */
104
105 - (void)setResourceManager:(WOResourceManager *)_manager;
106 - (WOResourceManager *)resourceManager;
107 - (NSURL *)baseURL;
108 - (NSString *)pathForResourceNamed:(NSString *)_name ofType:(NSString *)_type;
109
110 /* notifications */
111
112 - (void)awake;
113 - (void)sleep;
114
115 /* responder */
116
117 - (void)takeValuesFromRequest:(WORequest *)_req  inContext:(WOContext *)_ctx;
118 - (id)invokeActionForRequest:(WORequest *)_req   inContext:(WOContext *)_ctx;
119 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx;
120
121 /* dynamic elements */
122
123 - (WOElement *)dynamicElementWithName:(NSString *)_name // element class name
124   associations:(NSDictionary *)_associations            // bindings
125   template:(WOElement *)_template                       // child elements
126   languages:(NSArray *)_languages;
127
128 /* pages */
129
130 - (void)setPageRefreshOnBacktrackEnabled:(BOOL)_flag;
131 - (BOOL)isPageRefreshOnBacktrackEnabled;
132 - (void)setCachingEnabled:(BOOL)_flag;
133 - (BOOL)isCachingEnabled;
134 - (void)setPageCacheSize:(int)_size;
135 - (int)pageCacheSize;
136 - (void)setPermanentPageCacheSize:(int)_size;
137 - (int)permanentPageCacheSize;
138
139 - (id)pageWithName:(NSString *)_name inContext:(WOContext *)_ctx;
140 - (id)pageWithName:(NSString *)_name forRequest:(WORequest *)_req;
141
142 /* exceptions */
143
144 - (WOResponse *)handleException:(NSException *)_exc
145   inContext:(WOContext *)_ctx;
146
147 @end
148
149 @interface WOApplication(DeprecatedMethodsInWO4)
150
151 - (id)session;
152 - (WOContext *)context;
153
154 - (id)createSession;
155 - (id)restoreSession;
156 - (void)saveSession:(WOSession *)_session;
157
158 - (WOResponse *)handleSessionCreationError;
159 - (WOResponse *)handleSessionRestorationError;
160 - (WOResponse *)handlePageRestorationError;
161
162 - (void)savePage:(WOComponent *)_page;
163 - (id)restorePageForContextID:(NSString *)_ctxId;
164
165 - (id)pageWithName:(NSString *)_name;
166
167 - (WOResponse *)handleException:(NSException *)_exception;
168 - (WOResponse *)handleRequest:(WORequest *)_request;
169
170 - (WOElement *)dynamicElementWithName:(NSString *)_name // element class name
171   associations:(NSDictionary *)_associations            // bindings
172   template:(WOElement *)_template;                      // child elements
173
174 - (NSString *)stringForKey:(NSString *)_key
175   inTableNamed:(NSString *)_tableName
176   withDefaultValue:(NSString *)_default;
177
178 @end
179
180 @interface WOApplication(NonWOMethods)
181
182 - (WORequestHandler *)requestHandlerForKey:(NSString *)_key;
183
184 - (NSString *)sessionIDFromRequest:(WORequest *)_request;
185 - (NSString *)createSessionIDForSession:(WOSession *)_session;
186
187 + (Class)eoEditingContextClass;
188 + (BOOL)implementsEditingContexts;
189
190 @end
191
192 @interface WOApplication(Defaults)
193
194 /* WOComponentRequestHandlerKey */
195 + (void)setComponentRequestHandlerKey:(NSString *)_key;
196 + (NSString *)componentRequestHandlerKey;
197
198 /* WODirectActionRequestHandlerKey */
199 + (void)setDirectActionRequestHandlerKey:(NSString *)_key;
200 + (NSString *)directActionRequestHandlerKey;
201
202 /* WOResourceRequestHandlerKey */
203 + (void)setResourceRequestHandlerKey:(NSString *)_key;
204 + (NSString *)resourceRequestHandlerKey;
205
206 /* WODefaultSessionTimeOut */
207 + (void)setSessionTimeOut:(NSNumber *)_timeOut;
208 + (NSNumber *)sessionTimeOut;
209
210 /* WOCachingEnabled */
211 + (BOOL)isCachingEnabled;
212
213 /* WODebuggingEnabled */
214 + (BOOL)isDebuggingEnabled;
215
216 @end
217
218 @interface WOApplication(WODebugging)
219 /* implemented in NGExtensions */
220
221 - (void)debugWithFormat:(NSString *)_format, ...;
222 - (void)logWithFormat:(NSString *)_format, ...;
223
224 @end
225
226 #endif /* __NGObjWeb_WOApplication_H__ */