/*
- 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.
*/
@implementation WOApplication
+#if 1
+static NSString *defaultCompRqHandlerClassName = @"OWViewRequestHandler";
+#else
+static NSString *defaultCompRqHandlerClassName = @"WOComponentRequestHandler";
+#endif
+
+ (int)version {
return [super version] + 5 /* v6 */;
}
self->requestHandlerRegistry =
NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 8);
- rk = [WOApplication componentRequestHandlerKey];
-#if 1
- rh = [[NSClassFromString(@"OWViewRequestHandler") alloc] init];
-#else
- rh = [[NSClassFromString(@"WOComponentRequestHandler") alloc] init];
-#endif
+ if ((rk = [WOApplication componentRequestHandlerKey]) == nil) {
+ [self logWithFormat:
+ @"WARNING: no component request handler key is specified, "
+ @"this probably means that share/ngobjweb/Defaults.plist "
+ @"could not get loaded (permissions?)"];
+ }
+ rh = [[NSClassFromString(defaultCompRqHandlerClassName) alloc] init];
if ([rk length] > 0 && (rh != nil))
[self registerRequestHandler:rh forKey:rk];
[rh release]; rh = nil;
/* resources */
+- (void)_setupDefaultResourceManager {
+ NSUserDefaults *ud;
+ Class rmClass;
+ NSString *p;
+
+ ud = [NSUserDefaults standardUserDefaults];
+ p = [ud stringForKey:@"WODefaultResourceManager"];
+ rmClass = ([p length] == 0)
+ ? [WOResourceManager class]
+ : NSClassFromString(p);
+
+ if (rmClass == Nil) {
+ [self errorWithFormat:
+ @"failed to locate class of resource manager: '%@'", p];
+ return;
+ }
+
+ if ([rmClass instancesRespondToSelector:@selector(initWithPath:)])
+ self->resourceManager = [[rmClass alloc] init];
+ else {
+ self->resourceManager =
+ [(WOResourceManager *)[rmClass alloc] initWithPath:[self path]];
+ }
+}
+
- (void)setResourceManager:(WOResourceManager *)_manager {
ASSIGN(self->resourceManager, _manager);
}
- (WOResourceManager *)resourceManager {
- if (self->resourceManager == nil) {
- NSString *p;
-
-#if 0 && DEBUG
- if ([(p = [self path]) length] > 0)
- [self debugWithFormat:@"setup WOResourceManager at path '%@' ...", p];
-#else
- p = [self path];
-#endif
-
- self->resourceManager =
- [(WOResourceManager *)[WOResourceManager alloc] initWithPath:p];
- }
+ if (self->resourceManager == nil)
+ [self _setupDefaultResourceManager];
+
return self->resourceManager;
}
start = [self memoryStatistics];
#endif
- pool = [[NSAutoreleasePool alloc] init];
+ pool = [[NSAutoreleasePool alloc] init];
- languages = [_ctx hasSession]
- ? [(WOSession *)[_ctx session] languages]
- : [[_ctx request] browserLanguages];
+ languages = [_ctx resourceLookupLanguages];
if ((rm = [[_ctx component] resourceManager]) == nil)
rm = [self resourceManager];
- page = [rm pageWithName:(_name != nil ? _name : @"Main")
- languages:languages];
+ page = [rm pageWithName:(_name != nil ? _name : @"Main")
+ languages:languages];
[page ensureAwakeInContext:_ctx];
page = [page retain];