Revision e0354682e04a1ce00aeab4d116fd5063020da02d

rlaager at pidgin.im rlaager at pidgin.im
Sat Mar 24 03:00:44 EDT 2007


o   -----------------------------------------------------------------
|   Revision: e0354682e04a1ce00aeab4d116fd5063020da02d
|   Ancestor: d19a97c78fa039030ad9dc5fa13d41e4d9bef9d4
|   Author: rlaager at pidgin.im
|   Date: 2007-03-24T06:24:59
|   Branch: im.pidgin.pidgin
|   
|   Renamed entries:
|           libpurple/plugins/mono/api/GaimPlugin.cs to libpurple/plugins/mono/api/PurplePlugin.cs
|   Modified files:
|           libpurple/plugin.c libpurple/plugins/mono/BooPlugin.boo
|           libpurple/plugins/mono/GetBuddyBack.cs
|           libpurple/plugins/mono/MPlugin.cs
|           libpurple/plugins/mono/api/PurplePlugin.cs
|           libpurple/plugins/mono/loader/mono-helper.c
|           libpurple/plugins/mono/loader/mono-helper.h
|           libpurple/plugins/mono/loader/mono.c
|   
|   ChangeLog: 
|   
|   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.
|   
|   ============================================================
|   --- libpurple/plugin.c	9f84f09151f44c6d86857ef6331b3b7a57d3f1ab
|   +++ libpurple/plugin.c	1b7e9f2899a3ea1e04a695b9058a393008d44e55
|   @@ -369,6 +369,20 @@ purple_plugin_probe(const char *filename
|    		return plugin;
|    	}
|    
|   +	/* 
|   + 	 * Check to make sure a plugin has defined an id.
|   + 	 * Not having this check caused purple_plugin_unload to
|   + 	 * enter an infinite loop in certain situations by passing
|   + 	 * purple_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."));
|   +		purple_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 != PURPLE_PLUGIN_MAGIC)
|    	{
|   ============================================================
|   --- libpurple/plugins/mono/BooPlugin.boo	2cd05cbe7cccf93bd02b9a85629f4633debe4eb5
|   +++ libpurple/plugins/mono/BooPlugin.boo	187836a5cb987b286f09b146d633005d55b564c7
|   @@ -1,6 +1,6 @@
|   -import Gaim
|   +import Purple
|    
|   -class BooPlugin(GaimPlugin):
|   +class BooPlugin(PurplePlugin):
|    
|    	def handle(*args as (object)):
|    		b as Buddy
|   @@ -18,5 +18,5 @@ class BooPlugin(GaimPlugin):
|    		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 PurplePluginInfo("mono-boo", "Boo Plugin", "0.1", "Test Boo Plugin", "Longer Description", "Eoin Coffey", "urled")
|    		
|   ============================================================
|   --- libpurple/plugins/mono/GetBuddyBack.cs	d124c41fa7e1a51a8754651f913ea0f677512fa5
|   +++ libpurple/plugins/mono/GetBuddyBack.cs	a01c7aea5566c539534a2d44f1a9c3878358cdbd
|   @@ -1,8 +1,8 @@
|   -using Gaim;
|   +using Purple;
|    
|    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 @@ public class GetBuddyBack : Plugin
|    		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()
|   ============================================================
|   --- libpurple/plugins/mono/MPlugin.cs	a48c40cb0a0203dfa10e694c82daf42b7b9fad35
|   +++ libpurple/plugins/mono/MPlugin.cs	63d7a55ee4927cbaa17d0447907e735b7d43e8d1
|   @@ -1,8 +1,8 @@
|   -using Gaim;
|   +using Purple;
|    
|    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)
|   ============================================================
|   --- libpurple/plugins/mono/api/GaimPlugin.cs	ec61fd34227459d37206004fe0a5aff8dab8926d
|   +++ libpurple/plugins/mono/api/PurplePlugin.cs	637efd4a0a51c70a624d6fa6667b219f4cc68709
|   @@ -1,5 +1,6 @@
|   -namespace Gaim {
|   +namespace Purple {
|    	public class PluginInfo {
|   +		private string id;
|    		private string name;
|    		private string version;
|    		private string summary;
|   @@ -7,9 +8,10 @@ namespace Gaim {
|    		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 @@ namespace Gaim {
|    			this.homepage = homepage;	
|    		}
|    
|   +		public string Id {
|   +			get { return id; }
|   +		}
|   +
|    		public string Name {
|    			get { return name; }
|    		}
|   ============================================================
|   --- libpurple/plugins/mono/loader/mono-helper.c	b7bc38794dd087e6db6b1107cd6450a52fa40043
|   +++ libpurple/plugins/mono/loader/mono-helper.c	f76ab7151f91cb1ff6e2940c31cd5d791a46d47c
|   @@ -84,10 +84,13 @@ MonoClass* ml_find_plugin_class(MonoImag
|    	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("PurplePlugin", 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 @@ gchar* ml_get_prop_string(MonoObject *ob
|    	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;
|   ============================================================
|   --- libpurple/plugins/mono/loader/mono-helper.h	5eab33e40052d5ddfc6c93aa7a3f30191d989bd4
|   +++ libpurple/plugins/mono/loader/mono-helper.h	e9e0a53f3e3a875511b9d4c0bfe6cd1acb47c5b7
|   @@ -40,6 +40,8 @@ void ml_set_prop_string(MonoObject *obj,
|    
|    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);
|   ============================================================
|   --- libpurple/plugins/mono/loader/mono.c	68fdc7bfa73ddaba708ca6fde2d12bb0faad50df
|   +++ libpurple/plugins/mono/loader/mono.c	b361561ce55d11c5dafec343109841b8cad95cfb
|   @@ -26,9 +26,8 @@ static gboolean probe_mono_plugin(Purple
|    {
|    	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;
|    
|    	PurplePluginInfo *info;
|   @@ -71,6 +70,7 @@ static gboolean probe_mono_plugin(Purple
|    	mono_runtime_object_init(mplug->obj);
|    
|    	while ((m = mono_class_get_methods(mplug->klass, &iter))) {
|   +		purple_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 @@ static gboolean probe_mono_plugin(Purple
|    		} 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)) {
|    		purple_debug(PURPLE_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");

To get the patch for this revision, please do this:
mtn log --last 1 --diffs --from e0354682e04a1ce00aeab4d116fd5063020da02d


More information about the Commits mailing list