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. All integrated plugins require a _loadComponentClass statement below and their class name
22 * in the @class list. In situations where the load order of plugins is important, please make note.
25 #import "AICoreComponentLoader.h"
26 #import <Adium/AIPlugin.h>
28 #define VERSION_KEY @"Version"
29 #define COMPONENTS_KEY @"Components"
31 #define COMPONENT_DISABLED @"Disabled"
32 #define COMPONENT_CLASS @"Class"
33 #define COMPONENT_HEADER @"Header"
34 #define COMPONENT_LOCATION @"Location"
36 @implementation AICoreComponentLoader
40 if((self = [super init])){
41 components = [[NSMutableDictionary alloc] init];
60 * @brief Load integrated components
62 - (void)initController
64 NSString *propertyList = [[NSBundle mainBundle] pathForResource:@"CoreComponents" ofType:@"plist"];
65 NSDictionary *componentDict = [NSDictionary dictionaryWithContentsOfFile:propertyList];
66 NSArray *componentArray = [componentDict objectForKey:COMPONENTS_KEY];
72 NSEnumerator *compEnumerator = [componentArray objectEnumerator];
75 while((dict = [compEnumerator nextObject])){
76 if([[dict objectForKey:COMPONENT_DISABLED] boolValue]){
80 NSString *className = [dict objectForKey:COMPONENT_CLASS];
83 if(className && (class = NSClassFromString(className))){
84 id object = [[class alloc] init];
85 #ifdef TRACK_COMPONENTS
86 NSLog(@"%@: adding component: %@", [self class], object);
89 NSAssert1(object, @"Failed to load %@", className);
91 [components setObject:object forKey:className];
98 * @brief Give all components a chance to close
100 - (void)closeController
102 NSArray *keys = [components allKeys];
103 NSEnumerator *enumerator = [keys objectEnumerator];
106 while (className = [enumerator nextObject]) {
107 AIPlugin *plugin = [components objectForKey:className];
108 #ifdef TRACK_COMPONENTS
109 NSLog(@"%@: removing component: %@", [self class], plugin);
111 [plugin uninstallPlugin];
117 - (AIPlugin *)pluginWithClassName:(NSString *)className {
118 return [components objectForKey:className];