Source/AICoreComponentLoader.m
author Zachary West <zacw@adium.im>
Wed Oct 28 10:44:02 2009 -0400 (2009-10-28)
changeset 2795 74a33a2e7467
parent 2389 9b5721fa5865
child 3259 a71c719e9271
permissions -rw-r--r--
Add a "Default font remover" plugin. Refs #12906 (though really fixes it).

This restores our pre-Snow Leopard behavior of sending plaintext when our defualt default font is specified. This also removes the white background Snow Leopard gives us for the attributed string, which would cause it to be sent for every message as well.

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