2 Copyright (C) 2004-2005 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 "SOGoProductLoader.h"
25 @implementation SOGoProductLoader
28 return [[[self alloc] init] autorelease];
32 if ((self = [super init])) {
33 self->productDirectoryName = @"SOGo";
39 [self->productDirectoryName release];
45 - (NSArray *)productSearchPathes {
46 static NSArray *searchPathes = nil;
54 env = [[NSProcessInfo processInfo] environment];
55 ma = [NSMutableArray arrayWithCapacity:6];
57 #if COCOA_Foundation_LIBRARY
58 tmp = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory,
61 if ([tmp count] > 0) {
64 e = [tmp objectEnumerator];
65 while ((tmp = [e nextObject])) {
66 tmp = [tmp stringByAppendingPathComponent:self->productDirectoryName];
67 if (![ma containsObject:tmp])
72 if ((tmp = [env objectForKey:@"GNUSTEP_PATHPREFIX_LIST"]) == nil)
73 tmp = [env objectForKey:@"GNUSTEP_PATHLIST"];
75 tmp = [tmp componentsSeparatedByString:@":"];
76 if ([tmp count] > 0) {
79 e = [tmp objectEnumerator];
80 while ((tmp = [e nextObject])) {
81 tmp = [tmp stringByAppendingPathComponent:@"Library"];
82 tmp = [tmp stringByAppendingPathComponent:self->productDirectoryName];
83 if (![ma containsObject:tmp])
88 NSLog(@"%s: empty library search path !", __PRETTY_FUNCTION__);
92 searchPathes = [ma copy];
94 if ([searchPathes count] == 0)
95 NSLog(@"%s: no search pathes were found !", __PRETTY_FUNCTION__);
100 - (void)loadProducts {
101 SoProductRegistry *registry = nil;
103 NSEnumerator *pathes;
106 registry = [SoProductRegistry sharedProductRegistry];
107 fm = [NSFileManager defaultManager];
109 pathes = [[self productSearchPathes] objectEnumerator];
110 while ((lpath = [pathes nextObject]) != nil) {
111 NSEnumerator *productNames;
112 NSString *productName;
114 productNames = [[fm directoryContentsAtPath:lpath] objectEnumerator];
116 while ((productName = [productNames nextObject]) != nil) {
119 bpath = [lpath stringByAppendingPathComponent:productName];
120 [self logWithFormat:@"register SOGo product: %@",
121 [bpath lastPathComponent]];
122 [registry registerProductAtPath:bpath];
126 if (![registry loadAllProducts])
127 [self warnWithFormat:@"could not load all products !"];
130 @end /* SOGoProductLoader */