diff --git a/ChangeLog b/ChangeLog index c7bc949bb..b6d2dfd66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-02-18 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoProductLoader.m (-loadAllProducts): new name + for "loadProducts". Do not list product directories where no + products were loaded. + (-loadProducts:): new method accepting an array of products to + load from SOGo library directories. + * SoObjects/SOGo/SOGoBuild.m: moved from Main/build.h to here. * SoObjects/SOGo/SOGoProductLoader.m: moved from Main/ to here. diff --git a/Main/SOGo.m b/Main/SOGo.m index 7500fbf99..221a6b7e7 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -134,7 +134,7 @@ static BOOL debugLeaks; localeLUT = [[NSMutableDictionary alloc] initWithCapacity:2]; /* load products */ - [[SOGoProductLoader productLoader] loadProducts]; + [[SOGoProductLoader productLoader] loadAllProducts]; /* setup resource manager */ rm = [[WEResourceManager alloc] init]; diff --git a/SoObjects/SOGo/SOGoProductLoader.h b/SoObjects/SOGo/SOGoProductLoader.h index ea85e512d..76bac8a55 100644 --- a/SoObjects/SOGo/SOGoProductLoader.h +++ b/SoObjects/SOGo/SOGoProductLoader.h @@ -32,11 +32,12 @@ NSArray *searchPathes; } -+ (id)productLoader; ++ (id) productLoader; /* operations */ -- (void)loadProducts; +- (void) loadAllProducts; +- (void) loadProducts: (NSArray *) products; @end diff --git a/SoObjects/SOGo/SOGoProductLoader.m b/SoObjects/SOGo/SOGoProductLoader.m index f86fbb7f2..4f85a0fba 100644 --- a/SoObjects/SOGo/SOGoProductLoader.m +++ b/SoObjects/SOGo/SOGoProductLoader.m @@ -103,7 +103,52 @@ static NSString *productDirectoryName = @"SOGo"; return searchPathes; } -- (void) loadProducts +- (void) loadAllProducts +{ + SoProductRegistry *registry = nil; + NSFileManager *fm; + NSMutableArray *loadedProducts; + NSEnumerator *pathes; + NSString *lpath, *bpath; + NSEnumerator *productNames; + NSString *productName; + NSAutoreleasePool *pool; + + pool = [NSAutoreleasePool new]; + + registry = [SoProductRegistry sharedProductRegistry]; + fm = [NSFileManager defaultManager]; + + loadedProducts = [NSMutableArray array]; + + pathes = [[self productSearchPathes] objectEnumerator]; + while ((lpath = [pathes nextObject])) + { + productNames = [[fm directoryContentsAtPath: lpath] objectEnumerator]; + while ((productName = [productNames nextObject])) + { + if ([[productName pathExtension] isEqualToString: @"SOGo"]) + { + bpath = [lpath stringByAppendingPathComponent: productName]; + [registry registerProductAtPath: bpath]; + [loadedProducts addObject: productName]; + } + } + if ([loadedProducts count]) + { + [self logWithFormat: @"SOGo products loaded from '%@':", lpath]; + [self logWithFormat: @" %@", + [loadedProducts componentsJoinedByString: @", "]]; + [loadedProducts removeAllObjects]; + } + } + + if (![registry loadAllProducts]) + [self warnWithFormat: @"could not load all products !"]; + [pool release]; +} + +- (void) loadProducts: (NSArray *) products { SoProductRegistry *registry = nil; NSFileManager *fm; @@ -121,16 +166,12 @@ static NSString *productDirectoryName = @"SOGo"; pathes = [[self productSearchPathes] objectEnumerator]; while ((lpath = [pathes nextObject])) { - [self logWithFormat: @"scanning SOGo products in: %@", lpath]; - productNames = [[fm directoryContentsAtPath: lpath] objectEnumerator]; while ((productName = [productNames nextObject])) { - if ([[productName pathExtension] isEqualToString: @"SOGo"]) - { + if ([products containsObject: productName]) + { bpath = [lpath stringByAppendingPathComponent: productName]; - [self logWithFormat: @" register SOGo product: %@", - productName]; [registry registerProductAtPath: bpath]; } }