changeset 11786:2c8216659a84

[gaim-migrate @ 14077] some cleanups.. committer: Tailor Script <tailor@pidgin.im>
author Gary Kramlich <grim@reaperworld.com>
date Mon, 24 Oct 2005 03:31:44 +0000
parents c90676803a1a
children c9188d3eb9d3
files plugins/mono/loader/mono-helper.c plugins/mono/loader/mono.c
diffstat 2 files changed, 54 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mono/loader/mono-helper.c	Mon Oct 24 02:55:27 2005 +0000
+++ b/plugins/mono/loader/mono-helper.c	Mon Oct 24 03:31:44 2005 +0000
@@ -104,7 +104,7 @@
 	return obj;
 }
 
-static MonoDomain *_domain;
+static MonoDomain *_domain = NULL;
 
 MonoDomain* mono_loader_get_domain(void)
 {
--- a/plugins/mono/loader/mono.c	Mon Oct 24 02:55:27 2005 +0000
+++ b/plugins/mono/loader/mono.c	Mon Oct 24 03:31:44 2005 +0000
@@ -7,7 +7,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #include "internal.h"
@@ -19,8 +19,11 @@
 #define MONO_PLUGIN_ID "core-mono"
 
 /* This is where our code executes */
-static MonoDomain *domain;
+static MonoDomain *domain = NULL;
 
+/******************************************************************************
+ * Loader Stuff
+ *****************************************************************************/
 /* probes the given plugin to determine if its a plugin */
 static gboolean probe_mono_plugin(GaimPlugin *plugin)
 {
@@ -30,44 +33,44 @@
 	MonoObject *plugin_info;
 	gboolean found_load = FALSE, found_unload = FALSE, found_destroy = FALSE, found_info = FALSE;
 	gpointer iter = NULL;
-	
+
 	GaimPluginInfo *info;
 	GaimMonoPlugin *mplug;
-	
+
 	char *file = plugin->path;
-	
+
 	assm = mono_domain_assembly_open(domain, file);
-	
+
 	if (!assm) {
 		return FALSE;
 	} 
-		
+
 	gaim_debug(GAIM_DEBUG_INFO, "mono", "Probing plugin\n");
-	
+
 	if (mono_loader_is_api_dll(mono_assembly_get_image(assm))) {
 		gaim_debug(GAIM_DEBUG_INFO, "mono", "Found our GaimAPI.dll\n");
 		return FALSE;
 	}
-		
+
 	info = g_new0(GaimPluginInfo, 1);
 	mplug = g_new0(GaimMonoPlugin, 1);
-		
+
 	mplug->assm = assm;
-		
+
 	mplug->klass = mono_loader_find_plugin_class(mono_assembly_get_image(mplug->assm));
 	if (!mplug->klass) {
 		gaim_debug(GAIM_DEBUG_ERROR, "mono", "no plugin class in \'%s\'\n", file);
 		return FALSE;
 	}
-	
+
 	mplug->obj = mono_object_new(domain, mplug->klass);
 	if (!mplug->obj) {
 		gaim_debug(GAIM_DEBUG_ERROR, "mono", "obj not valid\n");
 		return FALSE;
 	}
-	
+
 	mono_runtime_object_init(mplug->obj);
-	
+
 	while ((m = mono_class_get_methods(mplug->klass, &iter))) {
 		if (strcmp(mono_method_get_name(m), "Load") == 0) {
 			mplug->load = m;
@@ -83,38 +86,38 @@
 			found_info = TRUE;
 		}
 	}
-	
+
 	if (!(found_load && found_unload && found_destroy && found_info)) {
 		gaim_debug(GAIM_DEBUG_ERROR, "mono", "did not find the required methods\n");
 		return FALSE;
 	}
-	
+
 	plugin_info = mono_runtime_invoke(info_method, mplug->obj, NULL, NULL);
-	
+
 	/* now that the methods are filled out we can populate
 	   the info struct with all the needed info */
-	
+
 	info->name = mono_loader_get_prop_string(plugin_info, "Name");
 	info->version = mono_loader_get_prop_string(plugin_info, "Version");
 	info->summary = mono_loader_get_prop_string(plugin_info, "Summary");
 	info->description = mono_loader_get_prop_string(plugin_info, "Description");
 	info->author = mono_loader_get_prop_string(plugin_info, "Author");
 	info->homepage = mono_loader_get_prop_string(plugin_info, "Homepage");
-		
+
 	info->magic = GAIM_PLUGIN_MAGIC;
 	info->major_version = GAIM_MAJOR_VERSION;
 	info->minor_version = GAIM_MINOR_VERSION;
 	info->type = GAIM_PLUGIN_STANDARD;
-		
+
 	/* this plugin depends on us; duh */
 	info->dependencies = g_list_append(info->dependencies, MONO_PLUGIN_ID);
 	mplug->plugin = plugin;
 				
 	plugin->info = info;
 	info->extra_info = mplug;
-	
+
 	mono_loader_add_plugin(mplug);
-	
+
 	return gaim_plugin_register(plugin);
 }
 
@@ -122,13 +125,13 @@
 static gboolean load_mono_plugin(GaimPlugin *plugin)
 {
 	GaimMonoPlugin *mplug;
-	
+
 	gaim_debug(GAIM_DEBUG_INFO, "mono", "Loading plugin\n");
-	
+
 	mplug = (GaimMonoPlugin*)plugin->info->extra_info;
-	
+
 	mono_runtime_invoke(mplug->load, mplug->obj, NULL, NULL);
-	
+
 	return TRUE;
 }
 
@@ -136,15 +139,15 @@
 static gboolean unload_mono_plugin(GaimPlugin *plugin)
 {
 	GaimMonoPlugin *mplug;
-	
+
 	gaim_debug(GAIM_DEBUG_INFO, "mono", "Unloading plugin\n");
-	
+
 	mplug = (GaimMonoPlugin*)plugin->info->extra_info;
-	
+
 	gaim_signals_disconnect_by_handle((gpointer)mplug->klass);
-	
+
 	mono_runtime_invoke(mplug->unload, mplug->obj, NULL, NULL);
-	
+
 	return TRUE;
 }
 
@@ -153,35 +156,38 @@
 static void destroy_mono_plugin(GaimPlugin *plugin)
 {
 	GaimMonoPlugin *mplug;
-	
+
 	gaim_debug(GAIM_DEBUG_INFO, "mono", "Destroying plugin\n");
-	
+
 	mplug = (GaimMonoPlugin*)plugin->info->extra_info;
-	
+
 	mono_runtime_invoke(mplug->destroy, mplug->obj, NULL, NULL);
-	
+
 	if (plugin->info) {
-		if (plugin->info->name) g_free(plugin->info->name);
-		if (plugin->info->version) g_free(plugin->info->version);
-		if (plugin->info->summary) g_free(plugin->info->summary);
-		if (plugin->info->description) g_free(plugin->info->description);
-		if (plugin->info->author) g_free(plugin->info->author);
-		if (plugin->info->homepage) g_free(plugin->info->homepage);
+		g_free(plugin->info->name);
+		g_free(plugin->info->version);
+		g_free(plugin->info->summary);
+		g_free(plugin->info->description);
+		g_free(plugin->info->author);
+		g_free(plugin->info->homepage);
 	}
-	
+
 	if (mplug) {
 		if (mplug->assm) {
 			mono_assembly_close(mplug->assm);
 		}
-		
+
 		g_free(mplug);
 		mplug = NULL;
 	}
 }
 
+/******************************************************************************
+ * Plugin Stuff
+ *****************************************************************************/
 static void plugin_destroy(GaimPlugin *plugin)
 {
-	mono_jit_cleanup(domain);	
+	mono_jit_cleanup(domain);
 }
 
 static GaimPluginLoaderInfo loader_info =
@@ -226,11 +232,11 @@
 static void init_plugin(GaimPlugin *plugin)
 {
 	domain = mono_jit_init("gaim");
-	
+
 	mono_loader_set_domain(domain);
-	
+
 	mono_loader_init_internal_calls();
-	
+
 	loader_info.exts = g_list_append(loader_info.exts, "dll");
 }