2 Copyright (C) 2000-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/WOCoreApplication.h>
25 @implementation WOCoreApplication(Bundle)
27 + (BOOL)didLoadDaemonBundle:(NSBundle *)_bundle {
31 + (int)loadApplicationBundle:(NSString *)_bundleName
32 domainPath:(NSString *)_domain
34 // TODO: is this actually used somewhere?
38 NSMutableArray *chkPathes;
41 fm = [NSFileManager defaultManager];
43 if ([[_bundleName pathExtension] length] == 0)
44 _bundleName = [_bundleName stringByAppendingPathExtension:@"sxa"];
46 chkPathes = [NSMutableArray arrayWithCapacity:16];
48 if ([_bundleName isAbsolutePath]) {
49 [chkPathes addObject:_bundleName];
56 env = [[NSProcessInfo processInfo] environment];
58 [chkPathes addObject:@"."];
60 bp = [env objectForKey:@"HOME"];
61 bp = [bp stringByAppendingPathComponent:@"Library"];
62 bp = [bp stringByAppendingPathComponent:_domain];
63 [chkPathes addObject:bp];
65 bp = [bp stringByAppendingPathComponent:_domain];
66 [chkPathes addObject:bp];
67 bp = @"/System/Library";
68 bp = [bp stringByAppendingPathComponent:_domain];
69 [chkPathes addObject:bp];
71 if ((tmp = [env objectForKey:@"GNUSTEP_PATHPREFIX_LIST"]) == nil)
72 tmp = [env objectForKey:@"GNUSTEP_PATHLIST"];
73 tmp = [tmp componentsSeparatedByString:@":"];
74 e = [tmp objectEnumerator];
75 while ((tmp = [e nextObject])) {
76 bp = [tmp stringByAppendingPathComponent:@"Library"];
77 bp = [bp stringByAppendingPathComponent:_domain];
78 if ([chkPathes containsObject:bp]) continue;
80 [chkPathes addObject:bp];
85 e = [chkPathes objectEnumerator];
86 while ((bp = [e nextObject])) {
89 bp = [bp stringByAppendingPathComponent:_bundleName];
90 if (![fm fileExistsAtPath:bp isDirectory:&isDir]) continue;
95 if ([bp length] == 0) {
96 NSLog(@"%s: did not find the bundle '%@' in search list %@",
97 __PRETTY_FUNCTION__, _bundleName, chkPathes);
101 if ((bundle = [NGBundle bundleWithPath:bp]) == nil) {
102 NSLog(@"%s: did not find %@ at %@ ...", __PRETTY_FUNCTION__,
107 if (![bundle load]) {
108 NSLog(@"%s: could not load %@ %@ (path=%@)...", __PRETTY_FUNCTION__,
109 _bundleName, bundle, bp);
113 if (![self didLoadDaemonBundle:bundle]) {
117 NSLog(@"hosting bundle: %@", [bundle bundleName]);
122 + (int)runApplicationBundle:(NSString *)_bundleName
123 domainPath:(NSString *)_p
124 arguments:(void *)_argv count:(int)_argc
126 NSAutoreleasePool *pool = nil;
128 NSString *appClassName, *bundleName;
130 pool = [[NSAutoreleasePool alloc] init];
132 #if LIB_FOUNDATION_LIBRARY
134 extern char **environ;
135 [NSProcessInfo initializeWithArguments:_argv
137 environment:environ];
141 if ((rc = [self loadApplicationBundle:_bundleName
142 domainPath:_p]) != 0)
145 bundleName = [_bundleName lastPathComponent];
146 bundleName = [bundleName stringByDeletingPathExtension];
148 appClassName = [bundleName stringByAppendingString:@"Application"];
150 rc = WOWatchDogApplicationMain(appClassName, _argc, _argv);
152 RELEASE(pool); pool = nil;
157 + (int)runApplicationBundle:(NSString *)_bundleName
158 arguments:(void *)_args count:(int)_argc
160 return [self runApplicationBundle:_bundleName
162 arguments:_args count:_argc];
165 @end /* WOApplication */