From: <rl...@us...> - 2007-03-24 05:35:19
|
Revision: 18216 http://svn.sourceforge.net/gaim/?rev=18216&view=rev Author: rlaager Date: 2007-03-23 22:34:01 -0700 (Fri, 23 Mar 2007) Log Message: ----------- SF Patch #1686400 from Eoin Coffey ("ecoffey") ecoffey described the changes: 1) Small tweaks to the loader to bring it up to speed with new mono versions and API wrapper changes that grim had made. (was in original patch, just forgot about it :-P) 2) .NET Plugins are now required to define an Id as part of their info. 3) Modified gaim_probe_plugin to check for existence of info->id and to make sure it's not empty; Prints an error, stores an error in the plugin and sets plugin->unloadable = TRUE. Modified Paths: -------------- trunk/libgaim/plugin.c trunk/libgaim/plugins/mono/BooPlugin.boo trunk/libgaim/plugins/mono/GetBuddyBack.cs trunk/libgaim/plugins/mono/MPlugin.cs trunk/libgaim/plugins/mono/api/GaimPlugin.cs trunk/libgaim/plugins/mono/loader/mono-helper.c trunk/libgaim/plugins/mono/loader/mono-helper.h trunk/libgaim/plugins/mono/loader/mono.c Modified: trunk/libgaim/plugin.c =================================================================== --- trunk/libgaim/plugin.c 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugin.c 2007-03-24 05:34:01 UTC (rev 18216) @@ -369,6 +369,20 @@ return plugin; } + /* + * Check to make sure a plugin has defined an id. + * Not having this check caused gaim_plugin_unload to + * enter an infinite loop in certain situations by passing + * gaim_find_plugin_by_id a NULL value. -- ecoffey + */ + if (!plugin->info->id || !strcmp(plugin->info->id, "")) + { + plugin->error = g_strdup_printf(_("This plugin has not defined an ID.")); + gaim_debug_error("plugins", "%s is not loadable: info->id is not defined.\n", plugin->path); + plugin->unloadable = TRUE; + return plugin; + } + /* Really old plugins. */ if (plugin->info->magic != GAIM_PLUGIN_MAGIC) { Modified: trunk/libgaim/plugins/mono/BooPlugin.boo =================================================================== --- trunk/libgaim/plugins/mono/BooPlugin.boo 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/BooPlugin.boo 2007-03-24 05:34:01 UTC (rev 18216) @@ -18,5 +18,5 @@ Debug.debug(Debug.INFO, "booplugin", "destroying...\n") override def Info(): - return GaimPluginInfo("Boo Plugin", "0.1", "Test Boo Plugin", "Longer Description", "Eoin Coffey", "urled") + return GaimPluginInfo("mono-boo", "Boo Plugin", "0.1", "Test Boo Plugin", "Longer Description", "Eoin Coffey", "urled") Modified: trunk/libgaim/plugins/mono/GetBuddyBack.cs =================================================================== --- trunk/libgaim/plugins/mono/GetBuddyBack.cs 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/GetBuddyBack.cs 2007-03-24 05:34:01 UTC (rev 18216) @@ -2,7 +2,7 @@ public class GetBuddyBack : Plugin { - private static PluginInfo info = new PluginInfo("C# Get Buddy Back", "0.1", "Prints when a Buddy returns", "Longer Description", "Eoin Coffey", "urled"); + private static PluginInfo info = new PluginInfo("mono-buddyback", "C# Get Buddy Back", "0.1", "Prints when a Buddy returns", "Longer Description", "Eoin Coffey", "urled"); public GetBuddyBack() : base (info) @@ -21,7 +21,7 @@ Debug.debug(Debug.INFO, "buddyback", "loading...\n"); /*Signal.connect(BuddyList.GetHandle(), this, "buddy-back", new Signal.Handler(HandleSig));*/ - /*BuddyList.OnBuddyBack.connect(this, new Signal.Handler(HandleSig));*/ + BuddyList.OnBuddyStatusChanged.connect(this, new Signal.Handler(HandleSig)); } public override void Unload() Modified: trunk/libgaim/plugins/mono/MPlugin.cs =================================================================== --- trunk/libgaim/plugins/mono/MPlugin.cs 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/MPlugin.cs 2007-03-24 05:34:01 UTC (rev 18216) @@ -2,7 +2,7 @@ public class MPlugin : Plugin { - private static PluginInfo info = new PluginInfo("C# Plugin", "0.1", "Test C# Plugin", "Longer Description", "Eoin Coffey", "urled"); + private static PluginInfo info = new PluginInfo("mono-mplugin", "C# Plugin", "0.1", "Test C# Plugin", "Longer Description", "Eoin Coffey", "urled"); public MPlugin() : base(info) Modified: trunk/libgaim/plugins/mono/api/GaimPlugin.cs =================================================================== --- trunk/libgaim/plugins/mono/api/GaimPlugin.cs 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/api/GaimPlugin.cs 2007-03-24 05:34:01 UTC (rev 18216) @@ -1,5 +1,6 @@ namespace Gaim { public class PluginInfo { + private string id; private string name; private string version; private string summary; @@ -7,9 +8,10 @@ private string author; private string homepage; - public PluginInfo(string name, string version, string summary, + public PluginInfo(string id, string name, string version, string summary, string description, string author, string homepage) { + this.id = id; this.name = name; this.version = version; this.summary = summary; @@ -18,6 +20,10 @@ this.homepage = homepage; } + public string Id { + get { return id; } + } + public string Name { get { return name; } } Modified: trunk/libgaim/plugins/mono/loader/mono-helper.c =================================================================== --- trunk/libgaim/plugins/mono/loader/mono-helper.c 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/loader/mono-helper.c 2007-03-24 05:34:01 UTC (rev 18216) @@ -84,10 +84,13 @@ total = mono_image_get_table_rows (image, MONO_TABLE_TYPEDEF); for (i = 1; i <= total; ++i) { klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | i); + pklass = mono_class_get_parent(klass); - if (pklass) - if (strcmp("GaimPlugin", mono_class_get_name(pklass)) == 0) + if (pklass) { + + if (strcmp("Plugin", mono_class_get_name(pklass)) == 0) return klass; + } } return NULL; @@ -126,6 +129,18 @@ return mono_string_to_utf8(str); } +MonoObject* ml_get_info_prop(MonoObject *obj) +{ + MonoClass *klass; + MonoProperty *prop; + + klass = mono_class_get_parent(mono_object_get_class(obj)); + + prop = mono_class_get_property_from_name(klass, "Info"); + + return mono_property_get_value(prop, obj, NULL, NULL); +} + gboolean ml_is_api_dll(MonoImage *image) { MonoClass *klass; Modified: trunk/libgaim/plugins/mono/loader/mono-helper.h =================================================================== --- trunk/libgaim/plugins/mono/loader/mono-helper.h 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/loader/mono-helper.h 2007-03-24 05:34:01 UTC (rev 18216) @@ -40,6 +40,8 @@ void ml_set_prop_string(MonoObject *obj, char *field, char *data); +MonoObject* ml_get_info_prop(MonoObject *obj); + gboolean ml_is_api_dll(MonoImage *image); MonoDomain* ml_get_domain(void); Modified: trunk/libgaim/plugins/mono/loader/mono.c =================================================================== --- trunk/libgaim/plugins/mono/loader/mono.c 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/loader/mono.c 2007-03-24 05:34:01 UTC (rev 18216) @@ -26,9 +26,8 @@ { MonoAssembly *assm; MonoMethod *m = NULL; - MonoMethod *info_method = NULL; MonoObject *plugin_info; - gboolean found_load = FALSE, found_unload = FALSE, found_destroy = FALSE, found_info = FALSE; + gboolean found_load = FALSE, found_unload = FALSE, found_destroy = FALSE; gpointer iter = NULL; GaimPluginInfo *info; @@ -71,6 +70,7 @@ mono_runtime_object_init(mplug->obj); while ((m = mono_class_get_methods(mplug->klass, &iter))) { + gaim_debug(GAIM_DEBUG_INFO, "mono", "plugin method: %s\n", mono_method_get_name(m)); if (strcmp(mono_method_get_name(m), "Load") == 0) { mplug->load = m; found_load = TRUE; @@ -80,22 +80,20 @@ } else if (strcmp(mono_method_get_name(m), "Destroy") == 0) { mplug->destroy = m; found_destroy = TRUE; - } else if (strcmp(mono_method_get_name(m), "Info") == 0) { - info_method = m; - found_info = TRUE; } } - if (!(found_load && found_unload && found_destroy && found_info)) { + if (!(found_load && found_unload && found_destroy)) { gaim_debug(GAIM_DEBUG_ERROR, "mono", "did not find the required methods\n"); return FALSE; } + + plugin_info = ml_get_info_prop(mplug->obj); - plugin_info = ml_invoke(info_method, mplug->obj, NULL); - /* now that the methods are filled out we can populate the info struct with all the needed info */ + info->id = ml_get_prop_string(plugin_info, "Id"); info->name = ml_get_prop_string(plugin_info, "Name"); info->version = ml_get_prop_string(plugin_info, "Version"); info->summary = ml_get_prop_string(plugin_info, "Summary"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |