Mercurial > pidgin
comparison src/plugin.c @ 11950:2b9ca8861ca5
[gaim-migrate @ 14241]
sf patch #1343759, from Evan Schoenberg
Compilation error: A function depending on GAIM_PLUGINS-only
functions wasn't properly guarded with #ifdef GAIM_PLUGINS /
#endif
And some other changes to make things better when using static PRPLs
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 02 Nov 2005 04:41:40 +0000 |
parents | d1d5f27de95d |
children | d8787960e398 |
comparison
equal
deleted
inserted
replaced
11949:47e1723a89d7 | 11950:2b9ca8861ca5 |
---|---|
48 | 48 |
49 } GaimPluginIpcCommand; | 49 } GaimPluginIpcCommand; |
50 | 50 |
51 static GList *search_paths = NULL; | 51 static GList *search_paths = NULL; |
52 static GList *plugins = NULL; | 52 static GList *plugins = NULL; |
53 static GList *loaded_plugins = NULL; | |
54 static GList *protocol_plugins = NULL; | |
55 #ifdef GAIM_PLUGINS | |
53 static GList *load_queue = NULL; | 56 static GList *load_queue = NULL; |
54 static GList *loaded_plugins = NULL; | |
55 static GList *plugin_loaders = NULL; | 57 static GList *plugin_loaders = NULL; |
56 static GList *protocol_plugins = NULL; | 58 #endif |
57 | 59 |
58 static void (*probe_cb)(void *) = NULL; | 60 static void (*probe_cb)(void *) = NULL; |
59 static void *probe_cb_data = NULL; | 61 static void *probe_cb_data = NULL; |
60 static void (*load_cb)(GaimPlugin *, void *) = NULL; | 62 static void (*load_cb)(GaimPlugin *, void *) = NULL; |
61 static void *load_cb_data = NULL; | 63 static void *load_cb_data = NULL; |
62 static void (*unload_cb)(GaimPlugin *, void *) = NULL; | 64 static void (*unload_cb)(GaimPlugin *, void *) = NULL; |
63 static void *unload_cb_data = NULL; | 65 static void *unload_cb_data = NULL; |
64 | 66 |
65 #ifdef GAIM_PLUGINS | 67 #ifdef GAIM_PLUGINS |
68 | |
66 static gboolean | 69 static gboolean |
67 has_file_extension(const char *filename, const char *ext) | 70 has_file_extension(const char *filename, const char *ext) |
68 { | 71 { |
69 int len, extlen; | 72 int len, extlen; |
70 | 73 |
212 /* | 215 /* |
213 * We pass G_MODULE_BIND_LOCAL here to prevent symbols from | 216 * We pass G_MODULE_BIND_LOCAL here to prevent symbols from |
214 * plugins being added to the global name space. | 217 * plugins being added to the global name space. |
215 * | 218 * |
216 * G_MODULE_BIND_LOCAL was added in glib 2.3.3. | 219 * G_MODULE_BIND_LOCAL was added in glib 2.3.3. |
217 * TODO: What are we going to do about that? | 220 * TODO: I guess there's nothing we can do about that? |
218 */ | 221 */ |
219 #if GLIB_CHECK_VERSION(2,3,3) | 222 #if GLIB_CHECK_VERSION(2,3,3) |
220 plugin->handle = g_module_open(filename, G_MODULE_BIND_LOCAL); | 223 plugin->handle = g_module_open(filename, G_MODULE_BIND_LOCAL); |
221 #else | 224 #else |
222 plugin->handle = g_module_open(filename, 0); | 225 plugin->handle = g_module_open(filename, 0); |
234 } | 237 } |
235 | 238 |
236 if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | 239 if (!g_module_symbol(plugin->handle, "gaim_init_plugin", |
237 &unpunned)) | 240 &unpunned)) |
238 { | 241 { |
242 gaim_debug_error("plugins", "%s is not usable because the " | |
243 "'gaim_init_plugin' symbol could not be " | |
244 "found. Does the plugin call the " | |
245 "GAIM_INIT_PLUGIN() macro?\n", plugin->path); | |
246 | |
239 g_module_close(plugin->handle); | 247 g_module_close(plugin->handle); |
248 error = g_module_error(); | |
249 if (error != NULL) | |
250 gaim_debug_error("plugins", "Error closing module %s: %s\n", | |
251 plugin->path, error); | |
240 plugin->handle = NULL; | 252 plugin->handle = NULL; |
241 | |
242 error = g_module_error(); | |
243 gaim_debug_error("plugins", "%s is unloadable: %s\n", | |
244 plugin->path, error ? error : "Unknown error."); | |
245 | 253 |
246 gaim_plugin_destroy(plugin); | 254 gaim_plugin_destroy(plugin); |
247 | 255 |
248 return NULL; | 256 return NULL; |
249 } | 257 } |
423 { | 431 { |
424 #ifdef GAIM_PLUGINS | 432 #ifdef GAIM_PLUGINS |
425 g_return_val_if_fail(plugin != NULL, FALSE); | 433 g_return_val_if_fail(plugin != NULL, FALSE); |
426 | 434 |
427 loaded_plugins = g_list_remove(loaded_plugins, plugin); | 435 loaded_plugins = g_list_remove(loaded_plugins, plugin); |
436 if ((plugin->info != NULL) && GAIM_IS_PROTOCOL_PLUGIN(plugin)) | |
437 protocol_plugins = g_list_remove(protocol_plugins, plugin); | |
428 | 438 |
429 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | 439 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); |
430 | 440 |
431 gaim_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name); | 441 gaim_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name); |
432 | 442 |
1063 gaim_plugin_destroy(plugin); | 1073 gaim_plugin_destroy(plugin); |
1064 | 1074 |
1065 continue; | 1075 continue; |
1066 } | 1076 } |
1067 | 1077 |
1078 /* Make sure we don't load two PRPLs with the same name? */ | |
1068 if (gaim_find_prpl(plugin->info->id)) | 1079 if (gaim_find_prpl(plugin->info->id)) |
1069 { | 1080 { |
1070 /* Nothing to see here--move along, move along */ | 1081 /* Nothing to see here--move along, move along */ |
1071 gaim_plugin_destroy(plugin); | 1082 gaim_plugin_destroy(plugin); |
1072 | 1083 |
1078 } | 1089 } |
1079 } | 1090 } |
1080 | 1091 |
1081 if (probe_cb != NULL) | 1092 if (probe_cb != NULL) |
1082 probe_cb(probe_cb_data); | 1093 probe_cb(probe_cb_data); |
1083 | |
1084 #else /* GAIM_PLUGINS */ | |
1085 /* We just need to populate the protocol_plugins list with all the PRPLs */ | |
1086 GList *cur; | |
1087 GaimPlugin *plugin; | |
1088 | |
1089 for (cur = plugins; cur != NULL; cur = cur->next) | |
1090 { | |
1091 plugin = cur->data; | |
1092 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) | |
1093 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, | |
1094 (GCompareFunc)compare_prpl); | |
1095 } | |
1096 | |
1097 #endif /* GAIM_PLUGINS */ | 1094 #endif /* GAIM_PLUGINS */ |
1098 } | 1095 } |
1099 | 1096 |
1100 gboolean | 1097 gboolean |
1101 gaim_plugin_register(GaimPlugin *plugin) | 1098 gaim_plugin_register(GaimPlugin *plugin) |
1132 plugin->path); | 1129 plugin->path); |
1133 return FALSE; | 1130 return FALSE; |
1134 } | 1131 } |
1135 } | 1132 } |
1136 | 1133 |
1134 #ifdef GAIM_PLUGINS | |
1137 /* This plugin should be probed and maybe loaded--add it to the queue */ | 1135 /* This plugin should be probed and maybe loaded--add it to the queue */ |
1138 load_queue = g_list_append(load_queue, plugin); | 1136 load_queue = g_list_append(load_queue, plugin); |
1137 #else | |
1138 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) | |
1139 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, | |
1140 (GCompareFunc)compare_prpl); | |
1141 #endif | |
1139 | 1142 |
1140 plugins = g_list_append(plugins, plugin); | 1143 plugins = g_list_append(plugins, plugin); |
1141 | 1144 |
1142 return TRUE; | 1145 return TRUE; |
1143 } | 1146 } |
1235 } | 1238 } |
1236 | 1239 |
1237 GaimPlugin * | 1240 GaimPlugin * |
1238 gaim_plugins_find_with_basename(const char *basename) | 1241 gaim_plugins_find_with_basename(const char *basename) |
1239 { | 1242 { |
1243 #ifdef GAIM_PLUGINS | |
1240 GaimPlugin *plugin; | 1244 GaimPlugin *plugin; |
1241 GList *l; | 1245 GList *l; |
1242 char *basename_no_ext; | 1246 char *basename_no_ext; |
1243 char *tmp; | 1247 char *tmp; |
1244 | 1248 |
1261 g_free(tmp); | 1265 g_free(tmp); |
1262 } | 1266 } |
1263 } | 1267 } |
1264 | 1268 |
1265 g_free(basename_no_ext); | 1269 g_free(basename_no_ext); |
1270 #endif /* GAIM_PLUGINS */ | |
1266 | 1271 |
1267 return NULL; | 1272 return NULL; |
1268 } | 1273 } |
1269 | 1274 |
1270 GaimPlugin * | 1275 GaimPlugin * |