2 Copyright (C) 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
23 #include "SOGoProductLoader.h"
26 @implementation SOGoProductLoader
29 return [[[self alloc] init] autorelease];
33 if ((self = [super init])) {
34 self->productDirectoryName = @"SOGo";
40 [self->productDirectoryName release];
46 - (NSArray *)productSearchPathes {
47 static NSArray *searchPathes = nil;
55 env = [[NSProcessInfo processInfo] environment];
56 ma = [NSMutableArray arrayWithCapacity:6];
58 #if COCOA_Foundation_LIBRARY
59 tmp = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory,
62 if ([tmp count] > 0) {
65 e = [tmp objectEnumerator];
66 while ((tmp = [e nextObject])) {
67 tmp = [tmp stringByAppendingPathComponent:self->productDirectoryName];
68 if (![ma containsObject:tmp])
73 if ((tmp = [env objectForKey:@"GNUSTEP_PATHPREFIX_LIST"]) == nil)
74 tmp = [env objectForKey:@"GNUSTEP_PATHLIST"];
76 tmp = [tmp componentsSeparatedByString:@":"];
77 if ([tmp count] > 0) {
80 e = [tmp objectEnumerator];
81 while ((tmp = [e nextObject])) {
82 tmp = [tmp stringByAppendingPathComponent:@"Library"];
83 tmp = [tmp stringByAppendingPathComponent:self->productDirectoryName];
84 if (![ma containsObject:tmp])
89 NSLog(@"%s: empty library search path !", __PRETTY_FUNCTION__);
93 searchPathes = [ma copy];
95 if ([searchPathes count] == 0)
96 NSLog(@"%s: no search pathes were found !", __PRETTY_FUNCTION__);
101 - (void)loadProducts {
102 SoProductRegistry *registry = nil;
104 NSEnumerator *pathes;
107 registry = [SoProductRegistry sharedProductRegistry];
108 fm = [NSFileManager defaultManager];
110 pathes = [[self productSearchPathes] objectEnumerator];
111 while ((lpath = [pathes nextObject])) {
112 NSEnumerator *productNames;
113 NSString *productName;
115 productNames = [[fm directoryContentsAtPath:lpath] objectEnumerator];
117 while ((productName = [productNames nextObject])) {
120 bpath = [lpath stringByAppendingPathComponent:productName];
121 [self logWithFormat:@"register SOGo product: %@",
122 [bpath lastPathComponent]];
123 [registry registerProductAtPath:bpath];
127 if (![registry loadAllProducts])
128 [self warnWithFormat:@"could not load all products !"];
131 @end /* SOGoProductLoader */