2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * @class AICoreComponentLoader
19 * @brief Core - Component Loader
21 * Loads integrated plugins. Component classes to load are determined by CoreComponents.plist
24 #import "AICoreComponentLoader.h"
25 #import <Adium/AIObject.h>
28 @interface AICoreComponentLoader (PRIVATE)
29 - (void)loadComponents;
32 @implementation AICoreComponentLoader
39 if ((self = [super init])) {
40 components = [[NSMutableDictionary alloc] init];
42 [self loadComponents];
60 * @brief Load integrated components
62 - (void)loadComponents
64 //Fetch the list of components to load
65 NSString *propertyList = [[NSBundle mainBundle] pathForResource:@"CoreComponents" ofType:@"plist"];
66 NSArray *componentArray = [NSArray arrayWithContentsOfFile:propertyList];
67 NSParameterAssert(componentArray != nil);
70 NSEnumerator *enumerator = [componentArray objectEnumerator];
73 while ((className = [enumerator nextObject])) {
74 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
77 if (className && (class = NSClassFromString(className))) {
78 id <AIPlugin> object = [[class alloc] init];
80 NSAssert1(object, @"Failed to load %@", className);
82 [object installPlugin];
84 [components setObject:object forKey:className];
91 - (void)controllerDidLoad
96 * @brief Close integreated components
98 - (void)controllerWillClose
100 NSEnumerator *enumerator = [components objectEnumerator];
101 id <AIPlugin> plugin;
103 while ((plugin = [enumerator nextObject])) {
104 [[[AIObject sharedAdiumInstance] notificationCenter] removeObserver:plugin];
105 [[NSNotificationCenter defaultCenter] removeObserver:plugin];
106 [plugin uninstallPlugin];
113 * @brief Retrieve a component plugin by its class name
115 - (id <AIPlugin>)pluginWithClassName:(NSString *)className {
116 return [components objectForKey:className];