|
David@0
|
1 |
/* |
|
catfish@1855
|
2 |
* Adium is the legal property of its developers, whose names are listed in the copyright file included |
|
David@0
|
3 |
* with this source distribution. |
|
David@0
|
4 |
* |
|
David@0
|
5 |
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
|
David@0
|
6 |
* General Public License as published by the Free Software Foundation; either version 2 of the License, |
|
David@0
|
7 |
* or (at your option) any later version. |
|
David@0
|
8 |
* |
|
catfish@1855
|
9 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
|
David@0
|
10 |
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|
David@0
|
11 |
* Public License for more details. |
|
David@0
|
12 |
* |
|
David@0
|
13 |
* You should have received a copy of the GNU General Public License along with this program; if not, |
|
catfish@1855
|
14 |
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
David@0
|
15 |
*/ |
|
David@0
|
16 |
|
|
David@0
|
17 |
/*! |
|
David@0
|
18 |
* @class AICoreComponentLoader |
|
David@0
|
19 |
* @brief Core - Component Loader |
|
David@0
|
20 |
* |
|
David@0
|
21 |
* Loads integrated plugins. Component classes to load are determined by CoreComponents.plist |
|
David@0
|
22 |
*/ |
|
David@0
|
23 |
|
|
David@0
|
24 |
#import "AICoreComponentLoader.h" |
|
David@0
|
25 |
|
|
David@0
|
26 |
//#define COMPONENT_LOAD_TIMING |
|
David@0
|
27 |
#ifdef COMPONENT_LOAD_TIMING |
|
David@0
|
28 |
NSTimeInterval aggregateComponentLoadingTime = 0.0; |
|
David@0
|
29 |
#endif |
|
David@0
|
30 |
|
|
David@84
|
31 |
@interface AICoreComponentLoader () |
|
David@0
|
32 |
- (void)loadComponents; |
|
David@0
|
33 |
@end |
|
David@0
|
34 |
|
|
David@0
|
35 |
@implementation AICoreComponentLoader |
|
David@0
|
36 |
|
|
David@0
|
37 |
/*! |
|
David@0
|
38 |
* @brief Init |
|
David@0
|
39 |
*/ |
|
David@0
|
40 |
- (id)init |
|
David@0
|
41 |
{ |
|
David@0
|
42 |
if ((self = [super init])) { |
|
David@0
|
43 |
components = [[NSMutableDictionary alloc] init]; |
|
David@0
|
44 |
|
|
David@0
|
45 |
[self loadComponents]; |
|
David@0
|
46 |
} |
|
David@0
|
47 |
|
|
David@0
|
48 |
return self; |
|
David@0
|
49 |
} |
|
David@0
|
50 |
|
|
David@0
|
51 |
/*! |
|
David@0
|
52 |
* @brief Deallocate |
|
David@0
|
53 |
*/ |
|
David@0
|
54 |
- (void)dealloc |
|
David@0
|
55 |
{ |
|
David@0
|
56 |
[components release]; |
|
David@0
|
57 |
[super dealloc]; |
|
David@0
|
58 |
} |
|
David@0
|
59 |
|
|
David@0
|
60 |
#pragma mark - |
|
David@0
|
61 |
|
|
David@0
|
62 |
/*! |
|
David@0
|
63 |
* @brief Load integrated components |
|
David@0
|
64 |
*/ |
|
David@0
|
65 |
- (void)loadComponents |
|
David@0
|
66 |
{ |
|
David@0
|
67 |
//Fetch the list of components to load |
|
catfish@1854
|
68 |
NSArray *componentClassNames = [NSArray arrayWithObjects: |
|
catfish@1854
|
69 |
@"AIAccountListPreferencesPlugin", |
|
catfish@1854
|
70 |
@"AIAccountMenuAccessPlugin", |
|
catfish@1854
|
71 |
@"AIAliasSupportPlugin", |
|
catfish@1854
|
72 |
@"AIAppearancePreferencesPlugin", |
|
catfish@1854
|
73 |
@"AIAutoLinkingPlugin", |
|
catfish@1854
|
74 |
@"AIAutoReplyPlugin", |
|
catfish@1854
|
75 |
@"AIChatConsolidationPlugin", |
|
catfish@1854
|
76 |
@"AIChatCyclingPlugin", |
|
catfish@1854
|
77 |
@"AIContactAwayPlugin", |
|
catfish@1854
|
78 |
@"AIContactIdlePlugin", |
|
catfish@1854
|
79 |
@"AIContactInfoWindowPlugin", |
|
catfish@1854
|
80 |
@"AIContactListEditorPlugin", |
|
catfish@1854
|
81 |
@"AIContactOnlineSincePlugin", |
|
catfish@1854
|
82 |
@"AIContactSortSelectionPlugin", |
|
catfish@1854
|
83 |
@"AIContactStatusColoringPlugin", |
|
catfish@1854
|
84 |
@"AIContactStatusDockOverlaysPlugin", |
|
catfish@1854
|
85 |
@"AIContactStatusEventsPlugin", |
|
catfish@1854
|
86 |
@"AIDockAccountStatusPlugin", |
|
catfish@1854
|
87 |
@"AIDockBehaviorPlugin", |
|
catfish@1854
|
88 |
@"AIDockUnviewedContentPlugin", |
|
catfish@1854
|
89 |
@"AIDualWindowInterfacePlugin", |
|
catfish@1854
|
90 |
@"AIEventSoundsPlugin", |
|
catfish@1854
|
91 |
@"AIExtendedStatusPlugin", |
|
catfish@1854
|
92 |
@"AILoggerPlugin", |
|
catfish@1854
|
93 |
@"AIMessageAliasPlugin", |
|
catfish@1854
|
94 |
@"AINewMessagePanelPlugin", |
|
catfish@1854
|
95 |
@"AINudgeBuzzHandlerPlugin", |
|
catfish@1854
|
96 |
@"AIContactVisibilityControlPlugin", |
|
catfish@1854
|
97 |
@"AISCLViewPlugin", |
|
catfish@1854
|
98 |
@"AIStandardToolbarItemsPlugin", |
|
catfish@1854
|
99 |
@"AIStateMenuPlugin", |
|
catfish@1854
|
100 |
@"AIStatusChangedMessagesPlugin", |
|
catfish@1854
|
101 |
@"AITabStatusIconsPlugin", |
|
catfish@1854
|
102 |
@"BGContactNotesPlugin", |
|
catfish@1854
|
103 |
@"BGEmoticonMenuPlugin", |
|
catfish@1854
|
104 |
@"CBActionSupportPlugin", |
|
catfish@1854
|
105 |
@"CBContactCountingDisplayPlugin", |
|
catfish@1854
|
106 |
@"CBContactLastSeenPlugin", |
|
catfish@1854
|
107 |
@"CBStatusMenuItemPlugin", |
|
catfish@1854
|
108 |
@"DCInviteToChatPlugin", |
|
catfish@1854
|
109 |
@"DCJoinChatPanelPlugin", |
|
catfish@1854
|
110 |
@"DCMessageContextDisplayPlugin", |
|
catfish@1854
|
111 |
@"AIAddBookmarkPlugin", |
|
catfish@1854
|
112 |
@"ESAccountEvents", |
|
catfish@1854
|
113 |
@"ESAccountNetworkConnectivityPlugin", |
|
catfish@1854
|
114 |
@"ESAnnouncerPlugin", |
|
catfish@1854
|
115 |
@"ESApplescriptContactAlertPlugin", |
|
catfish@1854
|
116 |
@"ESBlockingPlugin", |
|
catfish@1854
|
117 |
@"ESContactClientPlugin", |
|
catfish@1854
|
118 |
@"ESContactServersideDisplayName", |
|
catfish@1854
|
119 |
@"ESFileTransferMessagesPlugin", |
|
colin@2056
|
120 |
@"AIListObjectContentsPlugin", |
|
catfish@1854
|
121 |
@"ESOpenMessageWindowContactAlertPlugin", |
|
catfish@1854
|
122 |
@"ESSafariLinkToolbarItemPlugin", |
|
catfish@1854
|
123 |
@"ESSendMessageContactAlertPlugin", |
|
catfish@1854
|
124 |
@"ESUserIconHandlingPlugin", |
|
catfish@1854
|
125 |
@"ErrorMessageHandlerPlugin", |
|
catfish@1854
|
126 |
@"GBApplescriptFiltersPlugin", |
|
catfish@1854
|
127 |
@"SAContactOnlineForPlugin", |
|
catfish@1854
|
128 |
@"SHLinkManagementPlugin", |
|
catfish@1854
|
129 |
@"ESGlobalEventsPreferencesPlugin", |
|
catfish@1854
|
130 |
@"ESGeneralPreferencesPlugin", |
|
catfish@1854
|
131 |
@"NEHGrowlPlugin", |
|
catfish@1854
|
132 |
@"ESSecureMessagingPlugin", |
|
catfish@1854
|
133 |
@"ESStatusPreferencesPlugin", |
|
catfish@1854
|
134 |
@"AIAutomaticStatus", |
|
catfish@1854
|
135 |
@"ESAwayStatusWindowPlugin", |
|
catfish@1854
|
136 |
@"RAFBlockEditorPlugin", |
|
catfish@1854
|
137 |
@"SMContactListShowBehaviorPlugin", |
|
catfish@1854
|
138 |
@"ESiTunesPlugin", |
|
catfish@1854
|
139 |
@"AIDockBadger", |
|
catfish@1854
|
140 |
@"ESPersonalPreferencesPlugin", |
|
catfish@1854
|
141 |
@"AIXtrasManager", |
|
catfish@1854
|
142 |
@"OWSpellingPerContactPlugin", |
|
catfish@1854
|
143 |
@"GBQuestionHandlerPlugin", |
|
catfish@1854
|
144 |
@"AINulRemovalPlugin", |
|
zacw@2666
|
145 |
@"AIDefaultFontRemovalPlugin", |
|
catfish@1854
|
146 |
@"AIAdvancedPreferencesPlugin", |
|
catfish@1854
|
147 |
@"GBImportPlugin", |
|
catfish@1854
|
148 |
@"AIMentionEventPlugin", |
|
catfish@1854
|
149 |
@"AITwitterIMPlugin", |
|
catfish@1854
|
150 |
@"AITwitterPlugin", |
|
catfish@1854
|
151 |
@"AILaconicaPlugin", |
|
catfish@1854
|
152 |
@"AITwitterURLHandler", |
|
zacw@2277
|
153 |
@"AITwitterActionsHTMLFilter", |
|
catfish@1854
|
154 |
@"AIURLShortenerPlugin", |
|
catfish@1854
|
155 |
@"AIGroupChatStatusTooltipPlugin", |
|
catfish@1854
|
156 |
@"AIRealNameTooltip", |
|
catfish@1854
|
157 |
@"AIUserHostTooltip", |
|
catfish@1854
|
158 |
@"AIIRCChannelLinker", |
|
catfish@1854
|
159 |
@"AIURLHandlerPlugin", |
|
catfish@1854
|
160 |
@"AIJumpControlPlugin", |
|
catfish@1854
|
161 |
@"AIWebKitMessageViewPlugin", |
|
catfish@1854
|
162 |
@"AWBonjourPlugin", |
|
catfish@1854
|
163 |
@"CBPurpleServicePlugin", |
|
zacw@2344
|
164 |
@"AIImageUploaderPlugin", |
|
zacw@2389
|
165 |
@"AITwitterStatusFollowup", |
|
catfish@1854
|
166 |
nil |
|
catfish@1854
|
167 |
]; |
|
David@0
|
168 |
//Load each component |
|
catfish@1853
|
169 |
for (NSString *className in componentClassNames) { |
|
catfish@1853
|
170 |
|
|
David@0
|
171 |
#ifdef COMPONENT_LOAD_TIMING |
|
David@0
|
172 |
NSDate *start = [NSDate date]; |
|
David@0
|
173 |
#endif |
|
David@0
|
174 |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
|
David@0
|
175 |
Class class; |
|
David@0
|
176 |
|
|
David@0
|
177 |
if (className && (class = NSClassFromString(className))) { |
|
David@0
|
178 |
id <AIPlugin> object = [[class alloc] init]; |
|
David@0
|
179 |
|
|
catfish@1855
|
180 |
NSAssert1(object, @"Failed to load %@", className); |
|
David@0
|
181 |
|
|
David@0
|
182 |
[object installPlugin]; |
|
David@0
|
183 |
|
|
David@0
|
184 |
[components setObject:object forKey:className]; |
|
David@0
|
185 |
[object release]; |
|
catfish@2101
|
186 |
} else { |
|
catfish@2101
|
187 |
NSAssert1(NO, @"Failed to load %@", className); |
|
catfish@2101
|
188 |
} |
|
David@0
|
189 |
[pool release]; |
|
David@0
|
190 |
#ifdef COMPONENT_LOAD_TIMING |
|
David@0
|
191 |
NSTimeInterval t = -[start timeIntervalSinceNow]; |
|
David@0
|
192 |
aggregateComponentLoadingTime += t; |
|
catfish@1855
|
193 |
AILog(@"Loaded component: %@ in %f seconds", className, t); |
|
David@0
|
194 |
#endif |
|
David@0
|
195 |
} |
|
David@0
|
196 |
#ifdef COMPONENT_LOAD_TIMING |
|
catfish@1855
|
197 |
AILog(@"Total time spent loading components: %f", aggregateComponentLoadingTime); |
|
David@0
|
198 |
#endif |
|
David@0
|
199 |
} |
|
David@0
|
200 |
|
|
David@0
|
201 |
- (void)controllerDidLoad |
|
David@0
|
202 |
{ |
|
David@0
|
203 |
} |
|
David@0
|
204 |
|
|
David@0
|
205 |
/*! |
|
David@0
|
206 |
* @brief Close integreated components |
|
David@0
|
207 |
*/ |
|
David@0
|
208 |
- (void)controllerWillClose |
|
David@0
|
209 |
{ |
|
catfish@1873
|
210 |
for (id <AIPlugin> plugin in [components objectEnumerator]) { |
|
David@0
|
211 |
[[NSNotificationCenter defaultCenter] removeObserver:plugin]; |
|
David@0
|
212 |
[plugin uninstallPlugin]; |
|
David@0
|
213 |
} |
|
David@0
|
214 |
} |
|
David@0
|
215 |
|
|
David@0
|
216 |
#pragma mark - |
|
David@0
|
217 |
|
|
David@0
|
218 |
/*! |
|
David@0
|
219 |
* @brief Retrieve a component plugin by its class name |
|
David@0
|
220 |
*/ |
|
David@0
|
221 |
- (id <AIPlugin>)pluginWithClassName:(NSString *)className { |
|
David@0
|
222 |
return [components objectForKey:className]; |
|
David@0
|
223 |
} |
|
David@0
|
224 |
|
|
David@0
|
225 |
@end |