annotate plugins/mono/loader/mono.c @ 12358:d1af58b4a463

[gaim-migrate @ 14662] This will save us from having to parse the send color for every buddy we add to a chat. That's probably not a big savings, but every little bit helps, right? Yeah, totally untested. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 05 Dec 2005 20:34:00 +0000
parents ecd33ffb0b0a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Mono Plugin Loader
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * -- Thanks to the perl plugin loader for all the great tips ;-)
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 *
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * Eoin Coffey
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 */
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 #ifdef HAVE_CONFIG_H
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
10 # include <config.h>
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 #endif
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 #include "internal.h"
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 #include "debug.h"
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 #include "plugin.h"
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 #include "version.h"
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 #include "mono-helper.h"
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #define MONO_PLUGIN_ID "core-mono"
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
21 /******************************************************************************
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
22 * Loader Stuff
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
23 *****************************************************************************/
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 /* probes the given plugin to determine if its a plugin */
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 static gboolean probe_mono_plugin(GaimPlugin *plugin)
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 MonoAssembly *assm;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 MonoMethod *m = NULL;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 MonoMethod *info_method = NULL;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 MonoObject *plugin_info;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 gboolean found_load = FALSE, found_unload = FALSE, found_destroy = FALSE, found_info = FALSE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 gpointer iter = NULL;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
33
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 GaimPluginInfo *info;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 GaimMonoPlugin *mplug;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
36
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 char *file = plugin->path;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
38
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
39 assm = mono_domain_assembly_open(ml_get_domain(), file);
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
40
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 if (!assm) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 return FALSE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 }
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
44
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 gaim_debug(GAIM_DEBUG_INFO, "mono", "Probing plugin\n");
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
46
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
47 if (ml_is_api_dll(mono_assembly_get_image(assm))) {
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 gaim_debug(GAIM_DEBUG_INFO, "mono", "Found our GaimAPI.dll\n");
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 return FALSE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 }
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
51
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 info = g_new0(GaimPluginInfo, 1);
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 mplug = g_new0(GaimMonoPlugin, 1);
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
54
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
55 mplug->signal_data = NULL;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
56
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 mplug->assm = assm;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
58
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
59 mplug->klass = ml_find_plugin_class(mono_assembly_get_image(mplug->assm));
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 if (!mplug->klass) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 gaim_debug(GAIM_DEBUG_ERROR, "mono", "no plugin class in \'%s\'\n", file);
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 return FALSE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 }
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
64
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
65 mplug->obj = mono_object_new(ml_get_domain(), mplug->klass);
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 if (!mplug->obj) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 gaim_debug(GAIM_DEBUG_ERROR, "mono", "obj not valid\n");
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 return FALSE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 }
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
70
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 mono_runtime_object_init(mplug->obj);
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
72
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 while ((m = mono_class_get_methods(mplug->klass, &iter))) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 if (strcmp(mono_method_get_name(m), "Load") == 0) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 mplug->load = m;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 found_load = TRUE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 } else if (strcmp(mono_method_get_name(m), "Unload") == 0) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 mplug->unload = m;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 found_unload = TRUE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 } else if (strcmp(mono_method_get_name(m), "Destroy") == 0) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 mplug->destroy = m;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 found_destroy = TRUE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 } else if (strcmp(mono_method_get_name(m), "Info") == 0) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 info_method = m;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 found_info = TRUE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 }
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 }
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
88
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 if (!(found_load && found_unload && found_destroy && found_info)) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 gaim_debug(GAIM_DEBUG_ERROR, "mono", "did not find the required methods\n");
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 return FALSE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 }
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
93
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
94 plugin_info = ml_invoke(info_method, mplug->obj, NULL);
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
95
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 /* now that the methods are filled out we can populate
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 the info struct with all the needed info */
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
98
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
99 info->name = ml_get_prop_string(plugin_info, "Name");
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
100 info->version = ml_get_prop_string(plugin_info, "Version");
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
101 info->summary = ml_get_prop_string(plugin_info, "Summary");
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
102 info->description = ml_get_prop_string(plugin_info, "Description");
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
103 info->author = ml_get_prop_string(plugin_info, "Author");
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
104 info->homepage = ml_get_prop_string(plugin_info, "Homepage");
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
105
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 info->magic = GAIM_PLUGIN_MAGIC;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 info->major_version = GAIM_MAJOR_VERSION;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 info->minor_version = GAIM_MINOR_VERSION;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 info->type = GAIM_PLUGIN_STANDARD;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
110
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 /* this plugin depends on us; duh */
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 info->dependencies = g_list_append(info->dependencies, MONO_PLUGIN_ID);
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 mplug->plugin = plugin;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 plugin->info = info;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 info->extra_info = mplug;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
117
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
118 ml_add_plugin(mplug);
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
119
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 return gaim_plugin_register(plugin);
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 }
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 /* Loads a Mono Plugin by calling 'load' in the class */
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 static gboolean load_mono_plugin(GaimPlugin *plugin)
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 GaimMonoPlugin *mplug;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
127
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 gaim_debug(GAIM_DEBUG_INFO, "mono", "Loading plugin\n");
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
129
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 mplug = (GaimMonoPlugin*)plugin->info->extra_info;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
131
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
132 ml_invoke(mplug->load, mplug->obj, NULL);
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
133
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 return TRUE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 }
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 /* Unloads a Mono Plugin by calling 'unload' in the class */
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 static gboolean unload_mono_plugin(GaimPlugin *plugin)
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 GaimMonoPlugin *mplug;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
141
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 gaim_debug(GAIM_DEBUG_INFO, "mono", "Unloading plugin\n");
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
143
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 mplug = (GaimMonoPlugin*)plugin->info->extra_info;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
145
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 gaim_signals_disconnect_by_handle((gpointer)mplug->klass);
11996
ecd33ffb0b0a [gaim-migrate @ 14289]
Gary Kramlich <grim@reaperworld.com>
parents: 11980
diff changeset
147 g_list_foreach(mplug->signal_data, (GFunc)g_free, NULL);
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
148 g_list_free(mplug->signal_data);
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
149 mplug->signal_data = NULL;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
150
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
151 ml_invoke(mplug->unload, mplug->obj, NULL);
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
152
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 return TRUE;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 }
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
11679
f05542391cd2 [gaim-migrate @ 13965]
Gary Kramlich <grim@reaperworld.com>
parents: 11660
diff changeset
156 static void destroy_mono_plugin(GaimPlugin *plugin)
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 GaimMonoPlugin *mplug;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
159
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 gaim_debug(GAIM_DEBUG_INFO, "mono", "Destroying plugin\n");
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
161
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 mplug = (GaimMonoPlugin*)plugin->info->extra_info;
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
163
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
164 ml_invoke(mplug->destroy, mplug->obj, NULL);
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
165
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 if (plugin->info) {
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
167 g_free(plugin->info->name);
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
168 g_free(plugin->info->version);
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
169 g_free(plugin->info->summary);
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
170 g_free(plugin->info->description);
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
171 g_free(plugin->info->author);
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
172 g_free(plugin->info->homepage);
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 }
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
174
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 if (mplug) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 if (mplug->assm) {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 mono_assembly_close(mplug->assm);
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 }
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
179
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 g_free(mplug);
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 mplug = NULL;
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 }
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 }
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184
11786
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
185 /******************************************************************************
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
186 * Plugin Stuff
2c8216659a84 [gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents: 11679
diff changeset
187 *****************************************************************************/
11679
f05542391cd2 [gaim-migrate @ 13965]
Gary Kramlich <grim@reaperworld.com>
parents: 11660
diff changeset
188 static void plugin_destroy(GaimPlugin *plugin)
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 {
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
190 ml_uninit();
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 }
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 static GaimPluginLoaderInfo loader_info =
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 NULL,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 probe_mono_plugin,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 load_mono_plugin,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 unload_mono_plugin,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 destroy_mono_plugin
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 };
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 static GaimPluginInfo info =
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 {
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 GAIM_PLUGIN_MAGIC,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 GAIM_MAJOR_VERSION,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 GAIM_MINOR_VERSION,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 GAIM_PLUGIN_LOADER,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 NULL,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 0,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 NULL,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 GAIM_PRIORITY_DEFAULT,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 MONO_PLUGIN_ID,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 N_("Mono Plugin Loader"),
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 VERSION,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 N_("Loads .NET plugins with Mono."),
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 N_("Loads .NET plugins with Mono."),
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 "Eoin Coffey <ecoffey@simla.colostate.edu>",
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 GAIM_WEBSITE,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 NULL,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 NULL,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 plugin_destroy,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 NULL,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 &loader_info,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 NULL,
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 NULL
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 };
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 static void init_plugin(GaimPlugin *plugin)
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 {
11980
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
230 ml_init();
67fbd2ff4c4e [gaim-migrate @ 14273]
Gary Kramlich <grim@reaperworld.com>
parents: 11952
diff changeset
231
11660
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 loader_info.exts = g_list_append(loader_info.exts, "dll");
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 }
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234
a3302d271199 [gaim-migrate @ 13945]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 GAIM_INIT_PLUGIN(mono, init_plugin, info)