Mercurial > pidgin
comparison libpurple/plugins/mono/loader/mono.c @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | 80ee585fb53c |
comparison
equal
deleted
inserted
replaced
15821:84b0f9b23ede | 15822:32c366eeeb99 |
---|---|
20 | 20 |
21 /****************************************************************************** | 21 /****************************************************************************** |
22 * Loader Stuff | 22 * Loader Stuff |
23 *****************************************************************************/ | 23 *****************************************************************************/ |
24 /* probes the given plugin to determine if its a plugin */ | 24 /* probes the given plugin to determine if its a plugin */ |
25 static gboolean probe_mono_plugin(GaimPlugin *plugin) | 25 static gboolean probe_mono_plugin(PurplePlugin *plugin) |
26 { | 26 { |
27 MonoAssembly *assm; | 27 MonoAssembly *assm; |
28 MonoMethod *m = NULL; | 28 MonoMethod *m = NULL; |
29 MonoMethod *info_method = NULL; | 29 MonoMethod *info_method = NULL; |
30 MonoObject *plugin_info; | 30 MonoObject *plugin_info; |
31 gboolean found_load = FALSE, found_unload = FALSE, found_destroy = FALSE, found_info = FALSE; | 31 gboolean found_load = FALSE, found_unload = FALSE, found_destroy = FALSE, found_info = FALSE; |
32 gpointer iter = NULL; | 32 gpointer iter = NULL; |
33 | 33 |
34 GaimPluginInfo *info; | 34 PurplePluginInfo *info; |
35 GaimMonoPlugin *mplug; | 35 PurpleMonoPlugin *mplug; |
36 | 36 |
37 char *file = plugin->path; | 37 char *file = plugin->path; |
38 | 38 |
39 assm = mono_domain_assembly_open(ml_get_domain(), file); | 39 assm = mono_domain_assembly_open(ml_get_domain(), file); |
40 | 40 |
41 if (!assm) { | 41 if (!assm) { |
42 return FALSE; | 42 return FALSE; |
43 } | 43 } |
44 | 44 |
45 gaim_debug(GAIM_DEBUG_INFO, "mono", "Probing plugin\n"); | 45 purple_debug(PURPLE_DEBUG_INFO, "mono", "Probing plugin\n"); |
46 | 46 |
47 if (ml_is_api_dll(mono_assembly_get_image(assm))) { | 47 if (ml_is_api_dll(mono_assembly_get_image(assm))) { |
48 gaim_debug(GAIM_DEBUG_INFO, "mono", "Found our GaimAPI.dll\n"); | 48 purple_debug(PURPLE_DEBUG_INFO, "mono", "Found our PurpleAPI.dll\n"); |
49 return FALSE; | 49 return FALSE; |
50 } | 50 } |
51 | 51 |
52 info = g_new0(GaimPluginInfo, 1); | 52 info = g_new0(PurplePluginInfo, 1); |
53 mplug = g_new0(GaimMonoPlugin, 1); | 53 mplug = g_new0(PurpleMonoPlugin, 1); |
54 | 54 |
55 mplug->signal_data = NULL; | 55 mplug->signal_data = NULL; |
56 | 56 |
57 mplug->assm = assm; | 57 mplug->assm = assm; |
58 | 58 |
59 mplug->klass = ml_find_plugin_class(mono_assembly_get_image(mplug->assm)); | 59 mplug->klass = ml_find_plugin_class(mono_assembly_get_image(mplug->assm)); |
60 if (!mplug->klass) { | 60 if (!mplug->klass) { |
61 gaim_debug(GAIM_DEBUG_ERROR, "mono", "no plugin class in \'%s\'\n", file); | 61 purple_debug(PURPLE_DEBUG_ERROR, "mono", "no plugin class in \'%s\'\n", file); |
62 return FALSE; | 62 return FALSE; |
63 } | 63 } |
64 | 64 |
65 mplug->obj = mono_object_new(ml_get_domain(), mplug->klass); | 65 mplug->obj = mono_object_new(ml_get_domain(), mplug->klass); |
66 if (!mplug->obj) { | 66 if (!mplug->obj) { |
67 gaim_debug(GAIM_DEBUG_ERROR, "mono", "obj not valid\n"); | 67 purple_debug(PURPLE_DEBUG_ERROR, "mono", "obj not valid\n"); |
68 return FALSE; | 68 return FALSE; |
69 } | 69 } |
70 | 70 |
71 mono_runtime_object_init(mplug->obj); | 71 mono_runtime_object_init(mplug->obj); |
72 | 72 |
85 found_info = TRUE; | 85 found_info = TRUE; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 if (!(found_load && found_unload && found_destroy && found_info)) { | 89 if (!(found_load && found_unload && found_destroy && found_info)) { |
90 gaim_debug(GAIM_DEBUG_ERROR, "mono", "did not find the required methods\n"); | 90 purple_debug(PURPLE_DEBUG_ERROR, "mono", "did not find the required methods\n"); |
91 return FALSE; | 91 return FALSE; |
92 } | 92 } |
93 | 93 |
94 plugin_info = ml_invoke(info_method, mplug->obj, NULL); | 94 plugin_info = ml_invoke(info_method, mplug->obj, NULL); |
95 | 95 |
101 info->summary = ml_get_prop_string(plugin_info, "Summary"); | 101 info->summary = ml_get_prop_string(plugin_info, "Summary"); |
102 info->description = ml_get_prop_string(plugin_info, "Description"); | 102 info->description = ml_get_prop_string(plugin_info, "Description"); |
103 info->author = ml_get_prop_string(plugin_info, "Author"); | 103 info->author = ml_get_prop_string(plugin_info, "Author"); |
104 info->homepage = ml_get_prop_string(plugin_info, "Homepage"); | 104 info->homepage = ml_get_prop_string(plugin_info, "Homepage"); |
105 | 105 |
106 info->magic = GAIM_PLUGIN_MAGIC; | 106 info->magic = PURPLE_PLUGIN_MAGIC; |
107 info->major_version = GAIM_MAJOR_VERSION; | 107 info->major_version = PURPLE_MAJOR_VERSION; |
108 info->minor_version = GAIM_MINOR_VERSION; | 108 info->minor_version = PURPLE_MINOR_VERSION; |
109 info->type = GAIM_PLUGIN_STANDARD; | 109 info->type = PURPLE_PLUGIN_STANDARD; |
110 | 110 |
111 /* this plugin depends on us; duh */ | 111 /* this plugin depends on us; duh */ |
112 info->dependencies = g_list_append(info->dependencies, MONO_PLUGIN_ID); | 112 info->dependencies = g_list_append(info->dependencies, MONO_PLUGIN_ID); |
113 mplug->plugin = plugin; | 113 mplug->plugin = plugin; |
114 | 114 |
115 plugin->info = info; | 115 plugin->info = info; |
116 info->extra_info = mplug; | 116 info->extra_info = mplug; |
117 | 117 |
118 ml_add_plugin(mplug); | 118 ml_add_plugin(mplug); |
119 | 119 |
120 return gaim_plugin_register(plugin); | 120 return purple_plugin_register(plugin); |
121 } | 121 } |
122 | 122 |
123 /* Loads a Mono Plugin by calling 'load' in the class */ | 123 /* Loads a Mono Plugin by calling 'load' in the class */ |
124 static gboolean load_mono_plugin(GaimPlugin *plugin) | 124 static gboolean load_mono_plugin(PurplePlugin *plugin) |
125 { | 125 { |
126 GaimMonoPlugin *mplug; | 126 PurpleMonoPlugin *mplug; |
127 | 127 |
128 gaim_debug(GAIM_DEBUG_INFO, "mono", "Loading plugin\n"); | 128 purple_debug(PURPLE_DEBUG_INFO, "mono", "Loading plugin\n"); |
129 | 129 |
130 mplug = (GaimMonoPlugin*)plugin->info->extra_info; | 130 mplug = (PurpleMonoPlugin*)plugin->info->extra_info; |
131 | 131 |
132 ml_invoke(mplug->load, mplug->obj, NULL); | 132 ml_invoke(mplug->load, mplug->obj, NULL); |
133 | 133 |
134 return TRUE; | 134 return TRUE; |
135 } | 135 } |
136 | 136 |
137 /* Unloads a Mono Plugin by calling 'unload' in the class */ | 137 /* Unloads a Mono Plugin by calling 'unload' in the class */ |
138 static gboolean unload_mono_plugin(GaimPlugin *plugin) | 138 static gboolean unload_mono_plugin(PurplePlugin *plugin) |
139 { | 139 { |
140 GaimMonoPlugin *mplug; | 140 PurpleMonoPlugin *mplug; |
141 | 141 |
142 gaim_debug(GAIM_DEBUG_INFO, "mono", "Unloading plugin\n"); | 142 purple_debug(PURPLE_DEBUG_INFO, "mono", "Unloading plugin\n"); |
143 | 143 |
144 mplug = (GaimMonoPlugin*)plugin->info->extra_info; | 144 mplug = (PurpleMonoPlugin*)plugin->info->extra_info; |
145 | 145 |
146 gaim_signals_disconnect_by_handle((gpointer)mplug->klass); | 146 purple_signals_disconnect_by_handle((gpointer)mplug->klass); |
147 g_list_foreach(mplug->signal_data, (GFunc)g_free, NULL); | 147 g_list_foreach(mplug->signal_data, (GFunc)g_free, NULL); |
148 g_list_free(mplug->signal_data); | 148 g_list_free(mplug->signal_data); |
149 mplug->signal_data = NULL; | 149 mplug->signal_data = NULL; |
150 | 150 |
151 ml_invoke(mplug->unload, mplug->obj, NULL); | 151 ml_invoke(mplug->unload, mplug->obj, NULL); |
152 | 152 |
153 return TRUE; | 153 return TRUE; |
154 } | 154 } |
155 | 155 |
156 static void destroy_mono_plugin(GaimPlugin *plugin) | 156 static void destroy_mono_plugin(PurplePlugin *plugin) |
157 { | 157 { |
158 GaimMonoPlugin *mplug; | 158 PurpleMonoPlugin *mplug; |
159 | 159 |
160 gaim_debug(GAIM_DEBUG_INFO, "mono", "Destroying plugin\n"); | 160 purple_debug(PURPLE_DEBUG_INFO, "mono", "Destroying plugin\n"); |
161 | 161 |
162 mplug = (GaimMonoPlugin*)plugin->info->extra_info; | 162 mplug = (PurpleMonoPlugin*)plugin->info->extra_info; |
163 | 163 |
164 ml_invoke(mplug->destroy, mplug->obj, NULL); | 164 ml_invoke(mplug->destroy, mplug->obj, NULL); |
165 | 165 |
166 if (plugin->info) { | 166 if (plugin->info) { |
167 g_free(plugin->info->name); | 167 g_free(plugin->info->name); |
183 } | 183 } |
184 | 184 |
185 /****************************************************************************** | 185 /****************************************************************************** |
186 * Plugin Stuff | 186 * Plugin Stuff |
187 *****************************************************************************/ | 187 *****************************************************************************/ |
188 static void plugin_destroy(GaimPlugin *plugin) | 188 static void plugin_destroy(PurplePlugin *plugin) |
189 { | 189 { |
190 ml_uninit(); | 190 ml_uninit(); |
191 } | 191 } |
192 | 192 |
193 static GaimPluginLoaderInfo loader_info = | 193 static PurplePluginLoaderInfo loader_info = |
194 { | 194 { |
195 NULL, | 195 NULL, |
196 probe_mono_plugin, | 196 probe_mono_plugin, |
197 load_mono_plugin, | 197 load_mono_plugin, |
198 unload_mono_plugin, | 198 unload_mono_plugin, |
199 destroy_mono_plugin | 199 destroy_mono_plugin |
200 }; | 200 }; |
201 | 201 |
202 static GaimPluginInfo info = | 202 static PurplePluginInfo info = |
203 { | 203 { |
204 GAIM_PLUGIN_MAGIC, | 204 PURPLE_PLUGIN_MAGIC, |
205 GAIM_MAJOR_VERSION, | 205 PURPLE_MAJOR_VERSION, |
206 GAIM_MINOR_VERSION, | 206 PURPLE_MINOR_VERSION, |
207 GAIM_PLUGIN_LOADER, | 207 PURPLE_PLUGIN_LOADER, |
208 NULL, | 208 NULL, |
209 0, | 209 0, |
210 NULL, | 210 NULL, |
211 GAIM_PRIORITY_DEFAULT, | 211 PURPLE_PRIORITY_DEFAULT, |
212 MONO_PLUGIN_ID, | 212 MONO_PLUGIN_ID, |
213 N_("Mono Plugin Loader"), | 213 N_("Mono Plugin Loader"), |
214 VERSION, | 214 VERSION, |
215 N_("Loads .NET plugins with Mono."), | 215 N_("Loads .NET plugins with Mono."), |
216 N_("Loads .NET plugins with Mono."), | 216 N_("Loads .NET plugins with Mono."), |
217 "Eoin Coffey <ecoffey@simla.colostate.edu>", | 217 "Eoin Coffey <ecoffey@simla.colostate.edu>", |
218 GAIM_WEBSITE, | 218 PURPLE_WEBSITE, |
219 NULL, | 219 NULL, |
220 NULL, | 220 NULL, |
221 plugin_destroy, | 221 plugin_destroy, |
222 NULL, | 222 NULL, |
223 &loader_info, | 223 &loader_info, |
224 NULL, | 224 NULL, |
225 NULL | 225 NULL |
226 }; | 226 }; |
227 | 227 |
228 static void init_plugin(GaimPlugin *plugin) | 228 static void init_plugin(PurplePlugin *plugin) |
229 { | 229 { |
230 ml_init(); | 230 ml_init(); |
231 | 231 |
232 loader_info.exts = g_list_append(loader_info.exts, "dll"); | 232 loader_info.exts = g_list_append(loader_info.exts, "dll"); |
233 } | 233 } |
234 | 234 |
235 GAIM_INIT_PLUGIN(mono, init_plugin, info) | 235 PURPLE_INIT_PLUGIN(mono, init_plugin, info) |