adium 2711:92fc93345e8d: When loading a plugin, check that it ha...
commits at adium.im
commits at adium.im
Tue Sep 15 03:38:16 UTC 2009
details: http://hg.adium.im/adium/rev/92fc93345e8d
revision: 2711:92fc93345e8d
author: Stephen Holt <sholt at adium.im>
date: Mon Sep 14 23:17:28 2009 -0400
When loading a plugin, check that it has an executable type compatable with the current runtime. If not, disable the plugin and alert the user.
diffs (58 lines):
diff -r 14cef01e09dc -r 92fc93345e8d Frameworks/Adium Framework/Source/AICorePluginLoader.m
--- a/Frameworks/Adium Framework/Source/AICorePluginLoader.m Sat Sep 12 15:04:44 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AICorePluginLoader.m Mon Sep 14 23:17:28 2009 -0400
@@ -46,6 +46,7 @@
@interface AICorePluginLoader ()
- (void)loadPlugins;
+ (BOOL)confirmPluginAtPath:(NSString *)pluginPath;
++ (BOOL)confirmPluginArchitectureAtPath:(NSString *)pluginPath;
+ (BOOL)confirmMinimumVersionMetForPluginAtPath:(NSString *)pluginPath;
+ (void)disablePlugin:(NSString *)pluginPath;
+ (BOOL)allDependenciesMetForPluginAtPath:(NSString *)pluginPath;
@@ -145,6 +146,19 @@
#ifdef PLUGIN_LOAD_TIMING
NSDate *start = [NSDate date];
#endif
+ // Confirm plugins can load on this arch
+ if(![self confirmPluginArchitectureAtPath:pluginPath]) {
+ NSRunInformationalAlertPanel([NSString stringWithFormat:AILocalizedString(@"Plugin %@ Will be Disabled", "%@ will be the name of a plugin. This is the title of the dialogue shown when an plugin is loaded on an unsupported architecture."),
+ [[pluginPath lastPathComponent] stringByDeletingPathExtension]],
+ AILocalizedString(@"This plugin does not support your native architecture.", nil),
+ AILocalizedString(@"Disable", nil),
+ nil,
+ nil);
+ [self disablePlugin:pluginPath];
+ return;
+ }
+
+
//Confirm the presence of external plugins with the user
if (confirmLoading &&
(![self confirmMinimumVersionMetForPluginAtPath:pluginPath] ||
@@ -238,6 +252,26 @@
return loadPlugin;
}
++ (BOOL)confirmPluginArchitectureAtPath:(NSString *)pluginPath
+{
+#ifndef CURRENT_BUNDLE_ARCH_IS_DEFINED
+ #if defined(__x86_64__)
+ #define CURRENT_BUNDLE_ARCH NSBundleExecutableArchitectureX86_64
+ #elif defined(__i386__)
+ #define CURRENT_BUNDLE_ARCH NSBundleExecutableArchitectureI386
+ #elif defined(__ppc__)
+ #define CURRENT_BUNDLE_ARCH NSBundleExecutableArchitecturePPC
+ #else
+ #error Unsupported Architecture!
+ #endif
+ #define CURRENT_BUNDLE_ARCH_IS_DEFINED 1
+#endif
+ NSBundle *pluginBundle = [NSBundle bundleWithPath:pluginPath];
+ NSArray *pluginArchs = [pluginBundle executableArchitectures];
+
+ return [pluginArchs containsObject:[NSNumber numberWithInteger:CURRENT_BUNDLE_ARCH]];
+}
+
+ (BOOL)confirmMinimumVersionMetForPluginAtPath:(NSString *)pluginPath
{
NSString *minimumVersionOfPlugin = [[[NSBundle bundleWithPath:pluginPath] infoDictionary] objectForKey:@"AIMinimumAdiumVersionRequirement"];
More information about the commits
mailing list