Mercurial > pidgin.yaz
comparison libpurple/plugin.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Mon, 19 Mar 2007 07:01:17 +0000 |
| parents | e9c12873fae0 |
| children | 80ee585fb53c |
comparison
equal
deleted
inserted
replaced
| 15822:84b0f9b23ede | 15823:32c366eeeb99 |
|---|---|
| 1 /* | 1 /* |
| 2 * gaim | 2 * purple |
| 3 * | 3 * |
| 4 * Gaim is the legal property of its developers, whose names are too numerous | 4 * Purple is the legal property of its developers, whose names are too numerous |
| 5 * to list here. Please refer to the COPYRIGHT file distributed with this | 5 * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 * source distribution. | 6 * source distribution. |
| 7 * | 7 * |
| 8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License as published by | 9 * it under the terms of the GNU General Public License as published by |
| 36 typedef struct | 36 typedef struct |
| 37 { | 37 { |
| 38 GHashTable *commands; | 38 GHashTable *commands; |
| 39 size_t command_count; | 39 size_t command_count; |
| 40 | 40 |
| 41 } GaimPluginIpcInfo; | 41 } PurplePluginIpcInfo; |
| 42 | 42 |
| 43 typedef struct | 43 typedef struct |
| 44 { | 44 { |
| 45 GaimCallback func; | 45 PurpleCallback func; |
| 46 GaimSignalMarshalFunc marshal; | 46 PurpleSignalMarshalFunc marshal; |
| 47 | 47 |
| 48 int num_params; | 48 int num_params; |
| 49 GaimValue **params; | 49 PurpleValue **params; |
| 50 GaimValue *ret_value; | 50 PurpleValue *ret_value; |
| 51 | 51 |
| 52 } GaimPluginIpcCommand; | 52 } PurplePluginIpcCommand; |
| 53 | 53 |
| 54 static GList *search_paths = NULL; | 54 static GList *search_paths = NULL; |
| 55 static GList *plugins = NULL; | 55 static GList *plugins = NULL; |
| 56 static GList *loaded_plugins = NULL; | 56 static GList *loaded_plugins = NULL; |
| 57 static GList *protocol_plugins = NULL; | 57 static GList *protocol_plugins = NULL; |
| 58 #ifdef GAIM_PLUGINS | 58 #ifdef PURPLE_PLUGINS |
| 59 static GList *load_queue = NULL; | 59 static GList *load_queue = NULL; |
| 60 static GList *plugin_loaders = NULL; | 60 static GList *plugin_loaders = NULL; |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 /* | 63 /* |
| 65 * callback functions. Perhaps using a GList instead of a | 65 * callback functions. Perhaps using a GList instead of a |
| 66 * pointer to a single function. | 66 * pointer to a single function. |
| 67 */ | 67 */ |
| 68 static void (*probe_cb)(void *) = NULL; | 68 static void (*probe_cb)(void *) = NULL; |
| 69 static void *probe_cb_data = NULL; | 69 static void *probe_cb_data = NULL; |
| 70 static void (*load_cb)(GaimPlugin *, void *) = NULL; | 70 static void (*load_cb)(PurplePlugin *, void *) = NULL; |
| 71 static void *load_cb_data = NULL; | 71 static void *load_cb_data = NULL; |
| 72 static void (*unload_cb)(GaimPlugin *, void *) = NULL; | 72 static void (*unload_cb)(PurplePlugin *, void *) = NULL; |
| 73 static void *unload_cb_data = NULL; | 73 static void *unload_cb_data = NULL; |
| 74 | 74 |
| 75 #ifdef GAIM_PLUGINS | 75 #ifdef PURPLE_PLUGINS |
| 76 | 76 |
| 77 static gboolean | 77 static gboolean |
| 78 has_file_extension(const char *filename, const char *ext) | 78 has_file_extension(const char *filename, const char *ext) |
| 79 { | 79 { |
| 80 int len, extlen; | 80 int len, extlen; |
| 104 strcmp(last_period, ".sl") & | 104 strcmp(last_period, ".sl") & |
| 105 strcmp(last_period, ".so")); | 105 strcmp(last_period, ".so")); |
| 106 } | 106 } |
| 107 | 107 |
| 108 static char * | 108 static char * |
| 109 gaim_plugin_get_basename(const char *filename) | 109 purple_plugin_get_basename(const char *filename) |
| 110 { | 110 { |
| 111 const char *basename; | 111 const char *basename; |
| 112 const char *last_period; | 112 const char *last_period; |
| 113 | 113 |
| 114 basename = strrchr(filename, G_DIR_SEPARATOR); | 114 basename = strrchr(filename, G_DIR_SEPARATOR); |
| 123 | 123 |
| 124 return g_strdup(basename); | 124 return g_strdup(basename); |
| 125 } | 125 } |
| 126 | 126 |
| 127 static gboolean | 127 static gboolean |
| 128 loader_supports_file(GaimPlugin *loader, const char *filename) | 128 loader_supports_file(PurplePlugin *loader, const char *filename) |
| 129 { | 129 { |
| 130 GList *exts; | 130 GList *exts; |
| 131 | 131 |
| 132 for (exts = GAIM_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) { | 132 for (exts = PURPLE_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) { |
| 133 if (has_file_extension(filename, (char *)exts->data)) { | 133 if (has_file_extension(filename, (char *)exts->data)) { |
| 134 return TRUE; | 134 return TRUE; |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 return FALSE; | 138 return FALSE; |
| 139 } | 139 } |
| 140 | 140 |
| 141 static GaimPlugin * | 141 static PurplePlugin * |
| 142 find_loader_for_plugin(const GaimPlugin *plugin) | 142 find_loader_for_plugin(const PurplePlugin *plugin) |
| 143 { | 143 { |
| 144 GaimPlugin *loader; | 144 PurplePlugin *loader; |
| 145 GList *l; | 145 GList *l; |
| 146 | 146 |
| 147 if (plugin->path == NULL) | 147 if (plugin->path == NULL) |
| 148 return NULL; | 148 return NULL; |
| 149 | 149 |
| 150 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { | 150 for (l = purple_plugins_get_loaded(); l != NULL; l = l->next) { |
| 151 loader = l->data; | 151 loader = l->data; |
| 152 | 152 |
| 153 if (loader->info->type == GAIM_PLUGIN_LOADER && | 153 if (loader->info->type == PURPLE_PLUGIN_LOADER && |
| 154 loader_supports_file(loader, plugin->path)) { | 154 loader_supports_file(loader, plugin->path)) { |
| 155 | 155 |
| 156 return loader; | 156 return loader; |
| 157 } | 157 } |
| 158 | 158 |
| 160 } | 160 } |
| 161 | 161 |
| 162 return NULL; | 162 return NULL; |
| 163 } | 163 } |
| 164 | 164 |
| 165 #endif /* GAIM_PLUGINS */ | 165 #endif /* PURPLE_PLUGINS */ |
| 166 | 166 |
| 167 /** | 167 /** |
| 168 * Negative if a before b, 0 if equal, positive if a after b. | 168 * Negative if a before b, 0 if equal, positive if a after b. |
| 169 */ | 169 */ |
| 170 static gint | 170 static gint |
| 171 compare_prpl(GaimPlugin *a, GaimPlugin *b) | 171 compare_prpl(PurplePlugin *a, PurplePlugin *b) |
| 172 { | 172 { |
| 173 if(GAIM_IS_PROTOCOL_PLUGIN(a)) { | 173 if(PURPLE_IS_PROTOCOL_PLUGIN(a)) { |
| 174 if(GAIM_IS_PROTOCOL_PLUGIN(b)) | 174 if(PURPLE_IS_PROTOCOL_PLUGIN(b)) |
| 175 return strcmp(a->info->name, b->info->name); | 175 return strcmp(a->info->name, b->info->name); |
| 176 else | 176 else |
| 177 return -1; | 177 return -1; |
| 178 } else { | 178 } else { |
| 179 if(GAIM_IS_PROTOCOL_PLUGIN(b)) | 179 if(PURPLE_IS_PROTOCOL_PLUGIN(b)) |
| 180 return 1; | 180 return 1; |
| 181 else | 181 else |
| 182 return 0; | 182 return 0; |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 GaimPlugin * | 186 PurplePlugin * |
| 187 gaim_plugin_new(gboolean native, const char *path) | 187 purple_plugin_new(gboolean native, const char *path) |
| 188 { | 188 { |
| 189 GaimPlugin *plugin; | 189 PurplePlugin *plugin; |
| 190 | 190 |
| 191 plugin = g_new0(GaimPlugin, 1); | 191 plugin = g_new0(PurplePlugin, 1); |
| 192 | 192 |
| 193 plugin->native_plugin = native; | 193 plugin->native_plugin = native; |
| 194 plugin->path = g_strdup(path); | 194 plugin->path = g_strdup(path); |
| 195 | 195 |
| 196 GAIM_DBUS_REGISTER_POINTER(plugin, GaimPlugin); | 196 PURPLE_DBUS_REGISTER_POINTER(plugin, PurplePlugin); |
| 197 | 197 |
| 198 return plugin; | 198 return plugin; |
| 199 } | 199 } |
| 200 | 200 |
| 201 GaimPlugin * | 201 PurplePlugin * |
| 202 gaim_plugin_probe(const char *filename) | 202 purple_plugin_probe(const char *filename) |
| 203 { | 203 { |
| 204 #ifdef GAIM_PLUGINS | 204 #ifdef PURPLE_PLUGINS |
| 205 GaimPlugin *plugin = NULL; | 205 PurplePlugin *plugin = NULL; |
| 206 GaimPlugin *loader; | 206 PurplePlugin *loader; |
| 207 gpointer unpunned; | 207 gpointer unpunned; |
| 208 gchar *basename = NULL; | 208 gchar *basename = NULL; |
| 209 gboolean (*gaim_init_plugin)(GaimPlugin *); | 209 gboolean (*purple_init_plugin)(PurplePlugin *); |
| 210 | 210 |
| 211 gaim_debug_misc("plugins", "probing %s\n", filename); | 211 purple_debug_misc("plugins", "probing %s\n", filename); |
| 212 g_return_val_if_fail(filename != NULL, NULL); | 212 g_return_val_if_fail(filename != NULL, NULL); |
| 213 | 213 |
| 214 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) | 214 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
| 215 return NULL; | 215 return NULL; |
| 216 | 216 |
| 217 /* If this plugin has already been probed then exit */ | 217 /* If this plugin has already been probed then exit */ |
| 218 basename = gaim_plugin_get_basename(filename); | 218 basename = purple_plugin_get_basename(filename); |
| 219 plugin = gaim_plugins_find_with_basename(basename); | 219 plugin = purple_plugins_find_with_basename(basename); |
| 220 g_free(basename); | 220 g_free(basename); |
| 221 if (plugin != NULL) | 221 if (plugin != NULL) |
| 222 { | 222 { |
| 223 if (!strcmp(filename, plugin->path)) | 223 if (!strcmp(filename, plugin->path)) |
| 224 return plugin; | 224 return plugin; |
| 225 else if (!gaim_plugin_is_unloadable(plugin)) | 225 else if (!purple_plugin_is_unloadable(plugin)) |
| 226 { | 226 { |
| 227 gaim_debug_info("plugins", "Not loading %s. " | 227 purple_debug_info("plugins", "Not loading %s. " |
| 228 "Another plugin with the same name (%s) has already been loaded.\n", | 228 "Another plugin with the same name (%s) has already been loaded.\n", |
| 229 filename, plugin->path); | 229 filename, plugin->path); |
| 230 return plugin; | 230 return plugin; |
| 231 } | 231 } |
| 232 else | 232 else |
| 234 /* The old plugin was a different file and it was unloadable. | 234 /* The old plugin was a different file and it was unloadable. |
| 235 * There's no guarantee that this new file with the same name | 235 * There's no guarantee that this new file with the same name |
| 236 * will be loadable, but unless it fails in one of the silent | 236 * will be loadable, but unless it fails in one of the silent |
| 237 * ways and the first one didn't, it's not any worse. The user | 237 * ways and the first one didn't, it's not any worse. The user |
| 238 * will still see a greyed-out plugin, which is what we want. */ | 238 * will still see a greyed-out plugin, which is what we want. */ |
| 239 gaim_plugin_destroy(plugin); | 239 purple_plugin_destroy(plugin); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 plugin = gaim_plugin_new(has_file_extension(filename, G_MODULE_SUFFIX), filename); | 243 plugin = purple_plugin_new(has_file_extension(filename, G_MODULE_SUFFIX), filename); |
| 244 | 244 |
| 245 if (plugin->native_plugin) { | 245 if (plugin->native_plugin) { |
| 246 const char *error; | 246 const char *error; |
| 247 #ifdef _WIN32 | 247 #ifdef _WIN32 |
| 248 /* Suppress error popups for failing to load plugins */ | 248 /* Suppress error popups for failing to load plugins */ |
| 263 #endif | 263 #endif |
| 264 | 264 |
| 265 if (plugin->handle == NULL) | 265 if (plugin->handle == NULL) |
| 266 { | 266 { |
| 267 const char *error = g_module_error(); | 267 const char *error = g_module_error(); |
| 268 if (error != NULL && gaim_str_has_prefix(error, filename)) | 268 if (error != NULL && purple_str_has_prefix(error, filename)) |
| 269 { | 269 { |
| 270 error = error + strlen(filename); | 270 error = error + strlen(filename); |
| 271 | 271 |
| 272 /* These are just so we don't crash. If we | 272 /* These are just so we don't crash. If we |
| 273 * got this far, they should always be true. */ | 273 * got this far, they should always be true. */ |
| 278 } | 278 } |
| 279 | 279 |
| 280 if (error == NULL || !*error) | 280 if (error == NULL || !*error) |
| 281 { | 281 { |
| 282 plugin->error = g_strdup(_("Unknown error")); | 282 plugin->error = g_strdup(_("Unknown error")); |
| 283 gaim_debug_error("plugins", "%s is not loadable: Unknown error\n", | 283 purple_debug_error("plugins", "%s is not loadable: Unknown error\n", |
| 284 plugin->path); | 284 plugin->path); |
| 285 } | 285 } |
| 286 else | 286 else |
| 287 { | 287 { |
| 288 plugin->error = g_strdup(error); | 288 plugin->error = g_strdup(error); |
| 289 gaim_debug_error("plugins", "%s is not loadable: %s\n", | 289 purple_debug_error("plugins", "%s is not loadable: %s\n", |
| 290 plugin->path, plugin->error); | 290 plugin->path, plugin->error); |
| 291 } | 291 } |
| 292 #if GLIB_CHECK_VERSION(2,3,3) | 292 #if GLIB_CHECK_VERSION(2,3,3) |
| 293 plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); | 293 plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); |
| 294 #else | 294 #else |
| 299 { | 299 { |
| 300 #ifdef _WIN32 | 300 #ifdef _WIN32 |
| 301 /* Restore the original error mode */ | 301 /* Restore the original error mode */ |
| 302 SetErrorMode(old_error_mode); | 302 SetErrorMode(old_error_mode); |
| 303 #endif | 303 #endif |
| 304 gaim_plugin_destroy(plugin); | 304 purple_plugin_destroy(plugin); |
| 305 return NULL; | 305 return NULL; |
| 306 } | 306 } |
| 307 else | 307 else |
| 308 { | 308 { |
| 309 /* We were able to load the plugin with lazy symbol binding. | 309 /* We were able to load the plugin with lazy symbol binding. |
| 312 * to the user so they know to rebuild this plugin. */ | 312 * to the user so they know to rebuild this plugin. */ |
| 313 plugin->unloadable = TRUE; | 313 plugin->unloadable = TRUE; |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 | 316 |
| 317 if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | 317 if (!g_module_symbol(plugin->handle, "purple_init_plugin", |
| 318 &unpunned)) | 318 &unpunned)) |
| 319 { | 319 { |
| 320 gaim_debug_error("plugins", "%s is not usable because the " | 320 purple_debug_error("plugins", "%s is not usable because the " |
| 321 "'gaim_init_plugin' symbol could not be " | 321 "'purple_init_plugin' symbol could not be " |
| 322 "found. Does the plugin call the " | 322 "found. Does the plugin call the " |
| 323 "GAIM_INIT_PLUGIN() macro?\n", plugin->path); | 323 "PURPLE_INIT_PLUGIN() macro?\n", plugin->path); |
| 324 | 324 |
| 325 g_module_close(plugin->handle); | 325 g_module_close(plugin->handle); |
| 326 error = g_module_error(); | 326 error = g_module_error(); |
| 327 if (error != NULL) | 327 if (error != NULL) |
| 328 gaim_debug_error("plugins", "Error closing module %s: %s\n", | 328 purple_debug_error("plugins", "Error closing module %s: %s\n", |
| 329 plugin->path, error); | 329 plugin->path, error); |
| 330 plugin->handle = NULL; | 330 plugin->handle = NULL; |
| 331 | 331 |
| 332 #ifdef _WIN32 | 332 #ifdef _WIN32 |
| 333 /* Restore the original error mode */ | 333 /* Restore the original error mode */ |
| 334 SetErrorMode(old_error_mode); | 334 SetErrorMode(old_error_mode); |
| 335 #endif | 335 #endif |
| 336 gaim_plugin_destroy(plugin); | 336 purple_plugin_destroy(plugin); |
| 337 return NULL; | 337 return NULL; |
| 338 } | 338 } |
| 339 gaim_init_plugin = unpunned; | 339 purple_init_plugin = unpunned; |
| 340 | 340 |
| 341 #ifdef _WIN32 | 341 #ifdef _WIN32 |
| 342 /* Restore the original error mode */ | 342 /* Restore the original error mode */ |
| 343 SetErrorMode(old_error_mode); | 343 SetErrorMode(old_error_mode); |
| 344 #endif | 344 #endif |
| 345 } | 345 } |
| 346 else { | 346 else { |
| 347 loader = find_loader_for_plugin(plugin); | 347 loader = find_loader_for_plugin(plugin); |
| 348 | 348 |
| 349 if (loader == NULL) { | 349 if (loader == NULL) { |
| 350 gaim_plugin_destroy(plugin); | 350 purple_plugin_destroy(plugin); |
| 351 return NULL; | 351 return NULL; |
| 352 } | 352 } |
| 353 | 353 |
| 354 gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe; | 354 purple_init_plugin = PURPLE_PLUGIN_LOADER_INFO(loader)->probe; |
| 355 } | 355 } |
| 356 | 356 |
| 357 if (!gaim_init_plugin(plugin) || plugin->info == NULL) | 357 if (!purple_init_plugin(plugin) || plugin->info == NULL) |
| 358 { | 358 { |
| 359 gaim_plugin_destroy(plugin); | 359 purple_plugin_destroy(plugin); |
| 360 return NULL; | 360 return NULL; |
| 361 } | 361 } |
| 362 else if (plugin->info->ui_requirement && | 362 else if (plugin->info->ui_requirement && |
| 363 strcmp(plugin->info->ui_requirement, gaim_core_get_ui())) | 363 strcmp(plugin->info->ui_requirement, purple_core_get_ui())) |
| 364 { | 364 { |
| 365 plugin->error = g_strdup_printf(_("You are using %s, but this plugin requires %s."), | 365 plugin->error = g_strdup_printf(_("You are using %s, but this plugin requires %s."), |
| 366 gaim_core_get_ui(), plugin->info->ui_requirement); | 366 purple_core_get_ui(), plugin->info->ui_requirement); |
| 367 gaim_debug_error("plugins", "%s is not loadable: The UI requirement is not met.\n", plugin->path); | 367 purple_debug_error("plugins", "%s is not loadable: The UI requirement is not met.\n", plugin->path); |
| 368 plugin->unloadable = TRUE; | 368 plugin->unloadable = TRUE; |
| 369 return plugin; | 369 return plugin; |
| 370 } | 370 } |
| 371 | 371 |
| 372 /* Really old plugins. */ | 372 /* Really old plugins. */ |
| 373 if (plugin->info->magic != GAIM_PLUGIN_MAGIC) | 373 if (plugin->info->magic != PURPLE_PLUGIN_MAGIC) |
| 374 { | 374 { |
| 375 if (plugin->info->magic >= 2 && plugin->info->magic <= 4) | 375 if (plugin->info->magic >= 2 && plugin->info->magic <= 4) |
| 376 { | 376 { |
| 377 struct _GaimPluginInfo2 | 377 struct _PurplePluginInfo2 |
| 378 { | 378 { |
| 379 unsigned int api_version; | 379 unsigned int api_version; |
| 380 GaimPluginType type; | 380 PurplePluginType type; |
| 381 char *ui_requirement; | 381 char *ui_requirement; |
| 382 unsigned long flags; | 382 unsigned long flags; |
| 383 GList *dependencies; | 383 GList *dependencies; |
| 384 GaimPluginPriority priority; | 384 PurplePluginPriority priority; |
| 385 | 385 |
| 386 char *id; | 386 char *id; |
| 387 char *name; | 387 char *name; |
| 388 char *version; | 388 char *version; |
| 389 char *summary; | 389 char *summary; |
| 390 char *description; | 390 char *description; |
| 391 char *author; | 391 char *author; |
| 392 char *homepage; | 392 char *homepage; |
| 393 | 393 |
| 394 gboolean (*load)(GaimPlugin *plugin); | 394 gboolean (*load)(PurplePlugin *plugin); |
| 395 gboolean (*unload)(GaimPlugin *plugin); | 395 gboolean (*unload)(PurplePlugin *plugin); |
| 396 void (*destroy)(GaimPlugin *plugin); | 396 void (*destroy)(PurplePlugin *plugin); |
| 397 | 397 |
| 398 void *ui_info; | 398 void *ui_info; |
| 399 void *extra_info; | 399 void *extra_info; |
| 400 GaimPluginUiInfo *prefs_info; | 400 PurplePluginUiInfo *prefs_info; |
| 401 GList *(*actions)(GaimPlugin *plugin, gpointer context); | 401 GList *(*actions)(PurplePlugin *plugin, gpointer context); |
| 402 } *info2 = (struct _GaimPluginInfo2 *)plugin->info; | 402 } *info2 = (struct _PurplePluginInfo2 *)plugin->info; |
| 403 | 403 |
| 404 /* This leaks... but only for ancient plugins, so deal with it. */ | 404 /* This leaks... but only for ancient plugins, so deal with it. */ |
| 405 plugin->info = g_new0(GaimPluginInfo, 1); | 405 plugin->info = g_new0(PurplePluginInfo, 1); |
| 406 | 406 |
| 407 /* We don't really need all these to display the plugin info, but | 407 /* We don't really need all these to display the plugin info, but |
| 408 * I'm copying them all for good measure. */ | 408 * I'm copying them all for good measure. */ |
| 409 plugin->info->magic = info2->api_version; | 409 plugin->info->magic = info2->api_version; |
| 410 plugin->info->type = info2->type; | 410 plugin->info->type = info2->type; |
| 430 if (info2->api_version >= 4) | 430 if (info2->api_version >= 4) |
| 431 plugin->info->actions = info2->actions; | 431 plugin->info->actions = info2->actions; |
| 432 | 432 |
| 433 | 433 |
| 434 plugin->error = g_strdup_printf(_("Plugin magic mismatch %d (need %d)"), | 434 plugin->error = g_strdup_printf(_("Plugin magic mismatch %d (need %d)"), |
| 435 plugin->info->magic, GAIM_PLUGIN_MAGIC); | 435 plugin->info->magic, PURPLE_PLUGIN_MAGIC); |
| 436 gaim_debug_error("plugins", "%s is not loadable: Plugin magic mismatch %d (need %d)\n", | 436 purple_debug_error("plugins", "%s is not loadable: Plugin magic mismatch %d (need %d)\n", |
| 437 plugin->path, plugin->info->magic, GAIM_PLUGIN_MAGIC); | 437 plugin->path, plugin->info->magic, PURPLE_PLUGIN_MAGIC); |
| 438 plugin->unloadable = TRUE; | 438 plugin->unloadable = TRUE; |
| 439 return plugin; | 439 return plugin; |
| 440 } | 440 } |
| 441 | 441 |
| 442 gaim_debug_error("plugins", "%s is not loadable: Plugin magic mismatch %d (need %d)\n", | 442 purple_debug_error("plugins", "%s is not loadable: Plugin magic mismatch %d (need %d)\n", |
| 443 plugin->path, plugin->info->magic, GAIM_PLUGIN_MAGIC); | 443 plugin->path, plugin->info->magic, PURPLE_PLUGIN_MAGIC); |
| 444 gaim_plugin_destroy(plugin); | 444 purple_plugin_destroy(plugin); |
| 445 return NULL; | 445 return NULL; |
| 446 } | 446 } |
| 447 | 447 |
| 448 if (plugin->info->major_version != GAIM_MAJOR_VERSION || | 448 if (plugin->info->major_version != PURPLE_MAJOR_VERSION || |
| 449 plugin->info->minor_version > GAIM_MINOR_VERSION) | 449 plugin->info->minor_version > PURPLE_MINOR_VERSION) |
| 450 { | 450 { |
| 451 plugin->error = g_strdup_printf(_("ABI version mismatch %d.%d.x (need %d.%d.x)"), | 451 plugin->error = g_strdup_printf(_("ABI version mismatch %d.%d.x (need %d.%d.x)"), |
| 452 plugin->info->major_version, plugin->info->minor_version, | 452 plugin->info->major_version, plugin->info->minor_version, |
| 453 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION); | 453 PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION); |
| 454 gaim_debug_error("plugins", "%s is not loadable: ABI version mismatch %d.%d.x (need %d.%d.x)\n", | 454 purple_debug_error("plugins", "%s is not loadable: ABI version mismatch %d.%d.x (need %d.%d.x)\n", |
| 455 plugin->path, plugin->info->major_version, plugin->info->minor_version, | 455 plugin->path, plugin->info->major_version, plugin->info->minor_version, |
| 456 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION); | 456 PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION); |
| 457 plugin->unloadable = TRUE; | 457 plugin->unloadable = TRUE; |
| 458 return plugin; | 458 return plugin; |
| 459 } | 459 } |
| 460 | 460 |
| 461 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) | 461 if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) |
| 462 { | 462 { |
| 463 /* If plugin is a PRPL, make sure it implements the required functions */ | 463 /* If plugin is a PRPL, make sure it implements the required functions */ |
| 464 if ((GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon == NULL) || | 464 if ((PURPLE_PLUGIN_PROTOCOL_INFO(plugin)->list_icon == NULL) || |
| 465 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->login == NULL) || | 465 (PURPLE_PLUGIN_PROTOCOL_INFO(plugin)->login == NULL) || |
| 466 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->close == NULL)) | 466 (PURPLE_PLUGIN_PROTOCOL_INFO(plugin)->close == NULL)) |
| 467 { | 467 { |
| 468 plugin->error = g_strdup(_("Plugin does not implement all required functions")); | 468 plugin->error = g_strdup(_("Plugin does not implement all required functions")); |
| 469 gaim_debug_error("plugins", "%s is not loadable: Plugin does not implement all required functions\n", | 469 purple_debug_error("plugins", "%s is not loadable: Plugin does not implement all required functions\n", |
| 470 plugin->path); | 470 plugin->path); |
| 471 plugin->unloadable = TRUE; | 471 plugin->unloadable = TRUE; |
| 472 return plugin; | 472 return plugin; |
| 473 } | 473 } |
| 474 | 474 |
| 475 /* For debugging, let's warn about prpl prefs. */ | 475 /* For debugging, let's warn about prpl prefs. */ |
| 476 if (plugin->info->prefs_info != NULL) | 476 if (plugin->info->prefs_info != NULL) |
| 477 { | 477 { |
| 478 gaim_debug_error("plugins", "%s has a prefs_info, but is a prpl. This is no longer supported.\n", | 478 purple_debug_error("plugins", "%s has a prefs_info, but is a prpl. This is no longer supported.\n", |
| 479 plugin->path); | 479 plugin->path); |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 return plugin; | 483 return plugin; |
| 484 #else | 484 #else |
| 485 return NULL; | 485 return NULL; |
| 486 #endif /* !GAIM_PLUGINS */ | 486 #endif /* !PURPLE_PLUGINS */ |
| 487 } | 487 } |
| 488 | 488 |
| 489 #ifdef GAIM_PLUGINS | 489 #ifdef PURPLE_PLUGINS |
| 490 static gint | 490 static gint |
| 491 compare_plugins(gconstpointer a, gconstpointer b) | 491 compare_plugins(gconstpointer a, gconstpointer b) |
| 492 { | 492 { |
| 493 const GaimPlugin *plugina = a; | 493 const PurplePlugin *plugina = a; |
| 494 const GaimPlugin *pluginb = b; | 494 const PurplePlugin *pluginb = b; |
| 495 | 495 |
| 496 return strcmp(plugina->info->name, pluginb->info->name); | 496 return strcmp(plugina->info->name, pluginb->info->name); |
| 497 } | 497 } |
| 498 #endif /* GAIM_PLUGINS */ | 498 #endif /* PURPLE_PLUGINS */ |
| 499 | 499 |
| 500 gboolean | 500 gboolean |
| 501 gaim_plugin_load(GaimPlugin *plugin) | 501 purple_plugin_load(PurplePlugin *plugin) |
| 502 { | 502 { |
| 503 #ifdef GAIM_PLUGINS | 503 #ifdef PURPLE_PLUGINS |
| 504 GList *dep_list = NULL; | 504 GList *dep_list = NULL; |
| 505 GList *l; | 505 GList *l; |
| 506 | 506 |
| 507 g_return_val_if_fail(plugin != NULL, FALSE); | 507 g_return_val_if_fail(plugin != NULL, FALSE); |
| 508 | 508 |
| 509 if (gaim_plugin_is_loaded(plugin)) | 509 if (purple_plugin_is_loaded(plugin)) |
| 510 return TRUE; | 510 return TRUE; |
| 511 | 511 |
| 512 if (gaim_plugin_is_unloadable(plugin)) | 512 if (purple_plugin_is_unloadable(plugin)) |
| 513 return FALSE; | 513 return FALSE; |
| 514 | 514 |
| 515 g_return_val_if_fail(plugin->error == NULL, FALSE); | 515 g_return_val_if_fail(plugin->error == NULL, FALSE); |
| 516 | 516 |
| 517 /* | 517 /* |
| 520 * First pass: Make sure all the plugins needed are probed. | 520 * First pass: Make sure all the plugins needed are probed. |
| 521 */ | 521 */ |
| 522 for (l = plugin->info->dependencies; l != NULL; l = l->next) | 522 for (l = plugin->info->dependencies; l != NULL; l = l->next) |
| 523 { | 523 { |
| 524 const char *dep_name = (const char *)l->data; | 524 const char *dep_name = (const char *)l->data; |
| 525 GaimPlugin *dep_plugin; | 525 PurplePlugin *dep_plugin; |
| 526 | 526 |
| 527 dep_plugin = gaim_plugins_find_with_id(dep_name); | 527 dep_plugin = purple_plugins_find_with_id(dep_name); |
| 528 | 528 |
| 529 if (dep_plugin == NULL) | 529 if (dep_plugin == NULL) |
| 530 { | 530 { |
| 531 char *tmp; | 531 char *tmp; |
| 532 | 532 |
| 533 tmp = g_strdup_printf(_("The required plugin %s was not found. " | 533 tmp = g_strdup_printf(_("The required plugin %s was not found. " |
| 534 "Please install this plugin and try again."), | 534 "Please install this plugin and try again."), |
| 535 dep_name); | 535 dep_name); |
| 536 | 536 |
| 537 gaim_notify_error(NULL, NULL, | 537 purple_notify_error(NULL, NULL, |
| 538 _("Unable to load the plugin"), tmp); | 538 _("Unable to load the plugin"), tmp); |
| 539 g_free(tmp); | 539 g_free(tmp); |
| 540 | 540 |
| 541 g_list_free(dep_list); | 541 g_list_free(dep_list); |
| 542 | 542 |
| 547 } | 547 } |
| 548 | 548 |
| 549 /* Second pass: load all the required plugins. */ | 549 /* Second pass: load all the required plugins. */ |
| 550 for (l = dep_list; l != NULL; l = l->next) | 550 for (l = dep_list; l != NULL; l = l->next) |
| 551 { | 551 { |
| 552 GaimPlugin *dep_plugin = (GaimPlugin *)l->data; | 552 PurplePlugin *dep_plugin = (PurplePlugin *)l->data; |
| 553 | 553 |
| 554 if (!gaim_plugin_is_loaded(dep_plugin)) | 554 if (!purple_plugin_is_loaded(dep_plugin)) |
| 555 { | 555 { |
| 556 if (!gaim_plugin_load(dep_plugin)) | 556 if (!purple_plugin_load(dep_plugin)) |
| 557 { | 557 { |
| 558 char *tmp; | 558 char *tmp; |
| 559 | 559 |
| 560 tmp = g_strdup_printf(_("The required plugin %s was unable to load."), | 560 tmp = g_strdup_printf(_("The required plugin %s was unable to load."), |
| 561 plugin->info->name); | 561 plugin->info->name); |
| 562 | 562 |
| 563 gaim_notify_error(NULL, NULL, | 563 purple_notify_error(NULL, NULL, |
| 564 _("Unable to load your plugin."), tmp); | 564 _("Unable to load your plugin."), tmp); |
| 565 g_free(tmp); | 565 g_free(tmp); |
| 566 | 566 |
| 567 g_list_free(dep_list); | 567 g_list_free(dep_list); |
| 568 | 568 |
| 573 | 573 |
| 574 /* Third pass: note that other plugins are dependencies of this plugin. | 574 /* Third pass: note that other plugins are dependencies of this plugin. |
| 575 * This is done separately in case we had to bail out earlier. */ | 575 * This is done separately in case we had to bail out earlier. */ |
| 576 for (l = dep_list; l != NULL; l = l->next) | 576 for (l = dep_list; l != NULL; l = l->next) |
| 577 { | 577 { |
| 578 GaimPlugin *dep_plugin = (GaimPlugin *)l->data; | 578 PurplePlugin *dep_plugin = (PurplePlugin *)l->data; |
| 579 dep_plugin->dependent_plugins = g_list_prepend(dep_plugin->dependent_plugins, plugin->info->id); | 579 dep_plugin->dependent_plugins = g_list_prepend(dep_plugin->dependent_plugins, plugin->info->id); |
| 580 } | 580 } |
| 581 | 581 |
| 582 g_list_free(dep_list); | 582 g_list_free(dep_list); |
| 583 | 583 |
| 588 if (!plugin->info->load(plugin)) | 588 if (!plugin->info->load(plugin)) |
| 589 return FALSE; | 589 return FALSE; |
| 590 } | 590 } |
| 591 } | 591 } |
| 592 else { | 592 else { |
| 593 GaimPlugin *loader; | 593 PurplePlugin *loader; |
| 594 GaimPluginLoaderInfo *loader_info; | 594 PurplePluginLoaderInfo *loader_info; |
| 595 | 595 |
| 596 loader = find_loader_for_plugin(plugin); | 596 loader = find_loader_for_plugin(plugin); |
| 597 | 597 |
| 598 if (loader == NULL) | 598 if (loader == NULL) |
| 599 return FALSE; | 599 return FALSE; |
| 600 | 600 |
| 601 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | 601 loader_info = PURPLE_PLUGIN_LOADER_INFO(loader); |
| 602 | 602 |
| 603 if (loader_info->load != NULL) | 603 if (loader_info->load != NULL) |
| 604 { | 604 { |
| 605 if (!loader_info->load(plugin)) | 605 if (!loader_info->load(plugin)) |
| 606 return FALSE; | 606 return FALSE; |
| 613 | 613 |
| 614 /* TODO */ | 614 /* TODO */ |
| 615 if (load_cb != NULL) | 615 if (load_cb != NULL) |
| 616 load_cb(plugin, load_cb_data); | 616 load_cb(plugin, load_cb_data); |
| 617 | 617 |
| 618 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-load", plugin); | 618 purple_signal_emit(purple_plugins_get_handle(), "plugin-load", plugin); |
| 619 | 619 |
| 620 return TRUE; | 620 return TRUE; |
| 621 | 621 |
| 622 #else | 622 #else |
| 623 return TRUE; | 623 return TRUE; |
| 624 #endif /* !GAIM_PLUGINS */ | 624 #endif /* !PURPLE_PLUGINS */ |
| 625 } | 625 } |
| 626 | 626 |
| 627 gboolean | 627 gboolean |
| 628 gaim_plugin_unload(GaimPlugin *plugin) | 628 purple_plugin_unload(PurplePlugin *plugin) |
| 629 { | 629 { |
| 630 #ifdef GAIM_PLUGINS | 630 #ifdef PURPLE_PLUGINS |
| 631 GList *l; | 631 GList *l; |
| 632 | 632 |
| 633 g_return_val_if_fail(plugin != NULL, FALSE); | 633 g_return_val_if_fail(plugin != NULL, FALSE); |
| 634 | 634 |
| 635 loaded_plugins = g_list_remove(loaded_plugins, plugin); | 635 loaded_plugins = g_list_remove(loaded_plugins, plugin); |
| 636 if ((plugin->info != NULL) && GAIM_IS_PROTOCOL_PLUGIN(plugin)) | 636 if ((plugin->info != NULL) && PURPLE_IS_PROTOCOL_PLUGIN(plugin)) |
| 637 protocol_plugins = g_list_remove(protocol_plugins, plugin); | 637 protocol_plugins = g_list_remove(protocol_plugins, plugin); |
| 638 | 638 |
| 639 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | 639 g_return_val_if_fail(purple_plugin_is_loaded(plugin), FALSE); |
| 640 | 640 |
| 641 gaim_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name); | 641 purple_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name); |
| 642 | 642 |
| 643 /* cancel any pending dialogs the plugin has */ | 643 /* cancel any pending dialogs the plugin has */ |
| 644 gaim_request_close_with_handle(plugin); | 644 purple_request_close_with_handle(plugin); |
| 645 gaim_notify_close_with_handle(plugin); | 645 purple_notify_close_with_handle(plugin); |
| 646 | 646 |
| 647 plugin->loaded = FALSE; | 647 plugin->loaded = FALSE; |
| 648 | 648 |
| 649 /* Unload all plugins that depend on this plugin. */ | 649 /* Unload all plugins that depend on this plugin. */ |
| 650 while ((l = plugin->dependent_plugins) != NULL) | 650 while ((l = plugin->dependent_plugins) != NULL) |
| 651 { | 651 { |
| 652 const char * dep_name = (const char *)l->data; | 652 const char * dep_name = (const char *)l->data; |
| 653 GaimPlugin *dep_plugin; | 653 PurplePlugin *dep_plugin; |
| 654 | 654 |
| 655 dep_plugin = gaim_plugins_find_with_id(dep_name); | 655 dep_plugin = purple_plugins_find_with_id(dep_name); |
| 656 | 656 |
| 657 if (dep_plugin != NULL && gaim_plugin_is_loaded(dep_plugin)) | 657 if (dep_plugin != NULL && purple_plugin_is_loaded(dep_plugin)) |
| 658 { | 658 { |
| 659 if (!gaim_plugin_unload(dep_plugin)) | 659 if (!purple_plugin_unload(dep_plugin)) |
| 660 { | 660 { |
| 661 char *translated_name = g_strdup(_(dep_plugin->info->name)); | 661 char *translated_name = g_strdup(_(dep_plugin->info->name)); |
| 662 char *tmp; | 662 char *tmp; |
| 663 | 663 |
| 664 tmp = g_strdup_printf(_("The dependent plugin %s failed to unload."), | 664 tmp = g_strdup_printf(_("The dependent plugin %s failed to unload."), |
| 665 translated_name); | 665 translated_name); |
| 666 g_free(translated_name); | 666 g_free(translated_name); |
| 667 | 667 |
| 668 gaim_notify_error(NULL, NULL, | 668 purple_notify_error(NULL, NULL, |
| 669 _("There were errors unloading the plugin."), tmp); | 669 _("There were errors unloading the plugin."), tmp); |
| 670 g_free(tmp); | 670 g_free(tmp); |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 } | 673 } |
| 674 | 674 |
| 675 /* Remove this plugin from each dependency's dependent_plugins list. */ | 675 /* Remove this plugin from each dependency's dependent_plugins list. */ |
| 676 for (l = plugin->info->dependencies; l != NULL; l = l->next) | 676 for (l = plugin->info->dependencies; l != NULL; l = l->next) |
| 677 { | 677 { |
| 678 const char *dep_name = (const char *)l->data; | 678 const char *dep_name = (const char *)l->data; |
| 679 GaimPlugin *dependency; | 679 PurplePlugin *dependency; |
| 680 | 680 |
| 681 dependency = gaim_plugins_find_with_id(dep_name); | 681 dependency = purple_plugins_find_with_id(dep_name); |
| 682 | 682 |
| 683 dependency->dependent_plugins = g_list_remove(dependency->dependent_plugins, plugin->info->id); | 683 dependency->dependent_plugins = g_list_remove(dependency->dependent_plugins, plugin->info->id); |
| 684 } | 684 } |
| 685 | 685 |
| 686 if (plugin->native_plugin) { | 686 if (plugin->native_plugin) { |
| 687 if (plugin->info->unload != NULL) | 687 if (plugin->info->unload != NULL) |
| 688 plugin->info->unload(plugin); | 688 plugin->info->unload(plugin); |
| 689 | 689 |
| 690 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | 690 if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) { |
| 691 GaimPluginProtocolInfo *prpl_info; | 691 PurplePluginProtocolInfo *prpl_info; |
| 692 GList *l; | 692 GList *l; |
| 693 | 693 |
| 694 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | 694 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
| 695 | 695 |
| 696 for (l = prpl_info->user_splits; l != NULL; l = l->next) | 696 for (l = prpl_info->user_splits; l != NULL; l = l->next) |
| 697 gaim_account_user_split_destroy(l->data); | 697 purple_account_user_split_destroy(l->data); |
| 698 | 698 |
| 699 for (l = prpl_info->protocol_options; l != NULL; l = l->next) | 699 for (l = prpl_info->protocol_options; l != NULL; l = l->next) |
| 700 gaim_account_option_destroy(l->data); | 700 purple_account_option_destroy(l->data); |
| 701 | 701 |
| 702 if (prpl_info->user_splits != NULL) { | 702 if (prpl_info->user_splits != NULL) { |
| 703 g_list_free(prpl_info->user_splits); | 703 g_list_free(prpl_info->user_splits); |
| 704 prpl_info->user_splits = NULL; | 704 prpl_info->user_splits = NULL; |
| 705 } | 705 } |
| 709 prpl_info->protocol_options = NULL; | 709 prpl_info->protocol_options = NULL; |
| 710 } | 710 } |
| 711 } | 711 } |
| 712 } | 712 } |
| 713 else { | 713 else { |
| 714 GaimPlugin *loader; | 714 PurplePlugin *loader; |
| 715 GaimPluginLoaderInfo *loader_info; | 715 PurplePluginLoaderInfo *loader_info; |
| 716 | 716 |
| 717 loader = find_loader_for_plugin(plugin); | 717 loader = find_loader_for_plugin(plugin); |
| 718 | 718 |
| 719 if (loader == NULL) | 719 if (loader == NULL) |
| 720 return FALSE; | 720 return FALSE; |
| 721 | 721 |
| 722 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | 722 loader_info = PURPLE_PLUGIN_LOADER_INFO(loader); |
| 723 | 723 |
| 724 if (loader_info->unload != NULL) | 724 if (loader_info->unload != NULL) |
| 725 loader_info->unload(plugin); | 725 loader_info->unload(plugin); |
| 726 } | 726 } |
| 727 | 727 |
| 728 gaim_signals_disconnect_by_handle(plugin); | 728 purple_signals_disconnect_by_handle(plugin); |
| 729 gaim_plugin_ipc_unregister_all(plugin); | 729 purple_plugin_ipc_unregister_all(plugin); |
| 730 | 730 |
| 731 /* TODO */ | 731 /* TODO */ |
| 732 if (unload_cb != NULL) | 732 if (unload_cb != NULL) |
| 733 unload_cb(plugin, unload_cb_data); | 733 unload_cb(plugin, unload_cb_data); |
| 734 | 734 |
| 735 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-unload", plugin); | 735 purple_signal_emit(purple_plugins_get_handle(), "plugin-unload", plugin); |
| 736 | 736 |
| 737 gaim_prefs_disconnect_by_handle(plugin); | 737 purple_prefs_disconnect_by_handle(plugin); |
| 738 | 738 |
| 739 return TRUE; | 739 return TRUE; |
| 740 #else | 740 #else |
| 741 return TRUE; | 741 return TRUE; |
| 742 #endif /* GAIM_PLUGINS */ | 742 #endif /* PURPLE_PLUGINS */ |
| 743 } | 743 } |
| 744 | 744 |
| 745 gboolean | 745 gboolean |
| 746 gaim_plugin_reload(GaimPlugin *plugin) | 746 purple_plugin_reload(PurplePlugin *plugin) |
| 747 { | 747 { |
| 748 #ifdef GAIM_PLUGINS | 748 #ifdef PURPLE_PLUGINS |
| 749 g_return_val_if_fail(plugin != NULL, FALSE); | 749 g_return_val_if_fail(plugin != NULL, FALSE); |
| 750 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | 750 g_return_val_if_fail(purple_plugin_is_loaded(plugin), FALSE); |
| 751 | 751 |
| 752 if (!gaim_plugin_unload(plugin)) | 752 if (!purple_plugin_unload(plugin)) |
| 753 return FALSE; | 753 return FALSE; |
| 754 | 754 |
| 755 if (!gaim_plugin_load(plugin)) | 755 if (!purple_plugin_load(plugin)) |
| 756 return FALSE; | 756 return FALSE; |
| 757 | 757 |
| 758 return TRUE; | 758 return TRUE; |
| 759 #else | 759 #else |
| 760 return TRUE; | 760 return TRUE; |
| 761 #endif /* !GAIM_PLUGINS */ | 761 #endif /* !PURPLE_PLUGINS */ |
| 762 } | 762 } |
| 763 | 763 |
| 764 void | 764 void |
| 765 gaim_plugin_destroy(GaimPlugin *plugin) | 765 purple_plugin_destroy(PurplePlugin *plugin) |
| 766 { | 766 { |
| 767 #ifdef GAIM_PLUGINS | 767 #ifdef PURPLE_PLUGINS |
| 768 g_return_if_fail(plugin != NULL); | 768 g_return_if_fail(plugin != NULL); |
| 769 | 769 |
| 770 if (gaim_plugin_is_loaded(plugin)) | 770 if (purple_plugin_is_loaded(plugin)) |
| 771 gaim_plugin_unload(plugin); | 771 purple_plugin_unload(plugin); |
| 772 | 772 |
| 773 plugins = g_list_remove(plugins, plugin); | 773 plugins = g_list_remove(plugins, plugin); |
| 774 | 774 |
| 775 if (load_queue != NULL) | 775 if (load_queue != NULL) |
| 776 load_queue = g_list_remove(load_queue, plugin); | 776 load_queue = g_list_remove(load_queue, plugin); |
| 777 | 777 |
| 778 /* true, this may leak a little memory if there is a major version | 778 /* true, this may leak a little memory if there is a major version |
| 779 * mismatch, but it's a lot better than trying to free something | 779 * mismatch, but it's a lot better than trying to free something |
| 780 * we shouldn't, and crashing while trying to load an old plugin */ | 780 * we shouldn't, and crashing while trying to load an old plugin */ |
| 781 if(plugin->info == NULL || plugin->info->magic != GAIM_PLUGIN_MAGIC || | 781 if(plugin->info == NULL || plugin->info->magic != PURPLE_PLUGIN_MAGIC || |
| 782 plugin->info->major_version != GAIM_MAJOR_VERSION) | 782 plugin->info->major_version != PURPLE_MAJOR_VERSION) |
| 783 { | 783 { |
| 784 if(plugin->handle) | 784 if(plugin->handle) |
| 785 g_module_close(plugin->handle); | 785 g_module_close(plugin->handle); |
| 786 | 786 |
| 787 g_free(plugin->path); | 787 g_free(plugin->path); |
| 788 g_free(plugin->error); | 788 g_free(plugin->error); |
| 789 | 789 |
| 790 GAIM_DBUS_UNREGISTER_POINTER(plugin); | 790 PURPLE_DBUS_UNREGISTER_POINTER(plugin); |
| 791 | 791 |
| 792 g_free(plugin); | 792 g_free(plugin); |
| 793 return; | 793 return; |
| 794 } | 794 } |
| 795 | 795 |
| 796 if (plugin->info != NULL) | 796 if (plugin->info != NULL) |
| 797 g_list_free(plugin->info->dependencies); | 797 g_list_free(plugin->info->dependencies); |
| 798 | 798 |
| 799 if (plugin->native_plugin) | 799 if (plugin->native_plugin) |
| 800 { | 800 { |
| 801 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) | 801 if (plugin->info != NULL && plugin->info->type == PURPLE_PLUGIN_LOADER) |
| 802 { | 802 { |
| 803 GaimPluginLoaderInfo *loader_info; | 803 PurplePluginLoaderInfo *loader_info; |
| 804 GList *exts, *l, *next_l; | 804 GList *exts, *l, *next_l; |
| 805 GaimPlugin *p2; | 805 PurplePlugin *p2; |
| 806 | 806 |
| 807 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); | 807 loader_info = PURPLE_PLUGIN_LOADER_INFO(plugin); |
| 808 | 808 |
| 809 if (loader_info != NULL && loader_info->exts != NULL) | 809 if (loader_info != NULL && loader_info->exts != NULL) |
| 810 { | 810 { |
| 811 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; | 811 for (exts = PURPLE_PLUGIN_LOADER_INFO(plugin)->exts; |
| 812 exts != NULL; | 812 exts != NULL; |
| 813 exts = exts->next) { | 813 exts = exts->next) { |
| 814 | 814 |
| 815 for (l = gaim_plugins_get_all(); l != NULL; l = next_l) | 815 for (l = purple_plugins_get_all(); l != NULL; l = next_l) |
| 816 { | 816 { |
| 817 next_l = l->next; | 817 next_l = l->next; |
| 818 | 818 |
| 819 p2 = l->data; | 819 p2 = l->data; |
| 820 | 820 |
| 821 if (p2->path != NULL && | 821 if (p2->path != NULL && |
| 822 has_file_extension(p2->path, exts->data)) | 822 has_file_extension(p2->path, exts->data)) |
| 823 { | 823 { |
| 824 gaim_plugin_destroy(p2); | 824 purple_plugin_destroy(p2); |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 } | 827 } |
| 828 | 828 |
| 829 g_list_free(loader_info->exts); | 829 g_list_free(loader_info->exts); |
| 838 if (plugin->handle != NULL) | 838 if (plugin->handle != NULL) |
| 839 g_module_close(plugin->handle); | 839 g_module_close(plugin->handle); |
| 840 } | 840 } |
| 841 else | 841 else |
| 842 { | 842 { |
| 843 GaimPlugin *loader; | 843 PurplePlugin *loader; |
| 844 GaimPluginLoaderInfo *loader_info; | 844 PurplePluginLoaderInfo *loader_info; |
| 845 | 845 |
| 846 loader = find_loader_for_plugin(plugin); | 846 loader = find_loader_for_plugin(plugin); |
| 847 | 847 |
| 848 if (loader != NULL) | 848 if (loader != NULL) |
| 849 { | 849 { |
| 850 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | 850 loader_info = PURPLE_PLUGIN_LOADER_INFO(loader); |
| 851 | 851 |
| 852 if (loader_info->destroy != NULL) | 852 if (loader_info->destroy != NULL) |
| 853 loader_info->destroy(plugin); | 853 loader_info->destroy(plugin); |
| 854 } | 854 } |
| 855 } | 855 } |
| 856 | 856 |
| 857 g_free(plugin->path); | 857 g_free(plugin->path); |
| 858 g_free(plugin->error); | 858 g_free(plugin->error); |
| 859 | 859 |
| 860 GAIM_DBUS_UNREGISTER_POINTER(plugin); | 860 PURPLE_DBUS_UNREGISTER_POINTER(plugin); |
| 861 | 861 |
| 862 g_free(plugin); | 862 g_free(plugin); |
| 863 #endif /* !GAIM_PLUGINS */ | 863 #endif /* !PURPLE_PLUGINS */ |
| 864 } | 864 } |
| 865 | 865 |
| 866 gboolean | 866 gboolean |
| 867 gaim_plugin_is_loaded(const GaimPlugin *plugin) | 867 purple_plugin_is_loaded(const PurplePlugin *plugin) |
| 868 { | 868 { |
| 869 g_return_val_if_fail(plugin != NULL, FALSE); | 869 g_return_val_if_fail(plugin != NULL, FALSE); |
| 870 | 870 |
| 871 return plugin->loaded; | 871 return plugin->loaded; |
| 872 } | 872 } |
| 873 | 873 |
| 874 gboolean | 874 gboolean |
| 875 gaim_plugin_is_unloadable(const GaimPlugin *plugin) | 875 purple_plugin_is_unloadable(const PurplePlugin *plugin) |
| 876 { | 876 { |
| 877 g_return_val_if_fail(plugin != NULL, FALSE); | 877 g_return_val_if_fail(plugin != NULL, FALSE); |
| 878 | 878 |
| 879 return plugin->unloadable; | 879 return plugin->unloadable; |
| 880 } | 880 } |
| 881 | 881 |
| 882 const gchar * | 882 const gchar * |
| 883 gaim_plugin_get_id(const GaimPlugin *plugin) { | 883 purple_plugin_get_id(const PurplePlugin *plugin) { |
| 884 g_return_val_if_fail(plugin, NULL); | 884 g_return_val_if_fail(plugin, NULL); |
| 885 g_return_val_if_fail(plugin->info, NULL); | 885 g_return_val_if_fail(plugin->info, NULL); |
| 886 | 886 |
| 887 return plugin->info->id; | 887 return plugin->info->id; |
| 888 } | 888 } |
| 889 | 889 |
| 890 const gchar * | 890 const gchar * |
| 891 gaim_plugin_get_name(const GaimPlugin *plugin) { | 891 purple_plugin_get_name(const PurplePlugin *plugin) { |
| 892 g_return_val_if_fail(plugin, NULL); | 892 g_return_val_if_fail(plugin, NULL); |
| 893 g_return_val_if_fail(plugin->info, NULL); | 893 g_return_val_if_fail(plugin->info, NULL); |
| 894 | 894 |
| 895 return plugin->info->name; | 895 return plugin->info->name; |
| 896 } | 896 } |
| 897 | 897 |
| 898 const gchar * | 898 const gchar * |
| 899 gaim_plugin_get_version(const GaimPlugin *plugin) { | 899 purple_plugin_get_version(const PurplePlugin *plugin) { |
| 900 g_return_val_if_fail(plugin, NULL); | 900 g_return_val_if_fail(plugin, NULL); |
| 901 g_return_val_if_fail(plugin->info, NULL); | 901 g_return_val_if_fail(plugin->info, NULL); |
| 902 | 902 |
| 903 return plugin->info->version; | 903 return plugin->info->version; |
| 904 } | 904 } |
| 905 | 905 |
| 906 const gchar * | 906 const gchar * |
| 907 gaim_plugin_get_summary(const GaimPlugin *plugin) { | 907 purple_plugin_get_summary(const PurplePlugin *plugin) { |
| 908 g_return_val_if_fail(plugin, NULL); | 908 g_return_val_if_fail(plugin, NULL); |
| 909 g_return_val_if_fail(plugin->info, NULL); | 909 g_return_val_if_fail(plugin->info, NULL); |
| 910 | 910 |
| 911 return plugin->info->summary; | 911 return plugin->info->summary; |
| 912 } | 912 } |
| 913 | 913 |
| 914 const gchar * | 914 const gchar * |
| 915 gaim_plugin_get_description(const GaimPlugin *plugin) { | 915 purple_plugin_get_description(const PurplePlugin *plugin) { |
| 916 g_return_val_if_fail(plugin, NULL); | 916 g_return_val_if_fail(plugin, NULL); |
| 917 g_return_val_if_fail(plugin->info, NULL); | 917 g_return_val_if_fail(plugin->info, NULL); |
| 918 | 918 |
| 919 return plugin->info->description; | 919 return plugin->info->description; |
| 920 } | 920 } |
| 921 | 921 |
| 922 const gchar * | 922 const gchar * |
| 923 gaim_plugin_get_author(const GaimPlugin *plugin) { | 923 purple_plugin_get_author(const PurplePlugin *plugin) { |
| 924 g_return_val_if_fail(plugin, NULL); | 924 g_return_val_if_fail(plugin, NULL); |
| 925 g_return_val_if_fail(plugin->info, NULL); | 925 g_return_val_if_fail(plugin->info, NULL); |
| 926 | 926 |
| 927 return plugin->info->author; | 927 return plugin->info->author; |
| 928 } | 928 } |
| 929 | 929 |
| 930 const gchar * | 930 const gchar * |
| 931 gaim_plugin_get_homepage(const GaimPlugin *plugin) { | 931 purple_plugin_get_homepage(const PurplePlugin *plugin) { |
| 932 g_return_val_if_fail(plugin, NULL); | 932 g_return_val_if_fail(plugin, NULL); |
| 933 g_return_val_if_fail(plugin->info, NULL); | 933 g_return_val_if_fail(plugin->info, NULL); |
| 934 | 934 |
| 935 return plugin->info->homepage; | 935 return plugin->info->homepage; |
| 936 } | 936 } |
| 939 * Plugin IPC | 939 * Plugin IPC |
| 940 **************************************************************************/ | 940 **************************************************************************/ |
| 941 static void | 941 static void |
| 942 destroy_ipc_info(void *data) | 942 destroy_ipc_info(void *data) |
| 943 { | 943 { |
| 944 GaimPluginIpcCommand *ipc_command = (GaimPluginIpcCommand *)data; | 944 PurplePluginIpcCommand *ipc_command = (PurplePluginIpcCommand *)data; |
| 945 int i; | 945 int i; |
| 946 | 946 |
| 947 if (ipc_command->params != NULL) | 947 if (ipc_command->params != NULL) |
| 948 { | 948 { |
| 949 for (i = 0; i < ipc_command->num_params; i++) | 949 for (i = 0; i < ipc_command->num_params; i++) |
| 950 gaim_value_destroy(ipc_command->params[i]); | 950 purple_value_destroy(ipc_command->params[i]); |
| 951 | 951 |
| 952 g_free(ipc_command->params); | 952 g_free(ipc_command->params); |
| 953 } | 953 } |
| 954 | 954 |
| 955 if (ipc_command->ret_value != NULL) | 955 if (ipc_command->ret_value != NULL) |
| 956 gaim_value_destroy(ipc_command->ret_value); | 956 purple_value_destroy(ipc_command->ret_value); |
| 957 | 957 |
| 958 g_free(ipc_command); | 958 g_free(ipc_command); |
| 959 } | 959 } |
| 960 | 960 |
| 961 gboolean | 961 gboolean |
| 962 gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command, | 962 purple_plugin_ipc_register(PurplePlugin *plugin, const char *command, |
| 963 GaimCallback func, GaimSignalMarshalFunc marshal, | 963 PurpleCallback func, PurpleSignalMarshalFunc marshal, |
| 964 GaimValue *ret_value, int num_params, ...) | 964 PurpleValue *ret_value, int num_params, ...) |
| 965 { | 965 { |
| 966 GaimPluginIpcInfo *ipc_info; | 966 PurplePluginIpcInfo *ipc_info; |
| 967 GaimPluginIpcCommand *ipc_command; | 967 PurplePluginIpcCommand *ipc_command; |
| 968 | 968 |
| 969 g_return_val_if_fail(plugin != NULL, FALSE); | 969 g_return_val_if_fail(plugin != NULL, FALSE); |
| 970 g_return_val_if_fail(command != NULL, FALSE); | 970 g_return_val_if_fail(command != NULL, FALSE); |
| 971 g_return_val_if_fail(func != NULL, FALSE); | 971 g_return_val_if_fail(func != NULL, FALSE); |
| 972 g_return_val_if_fail(marshal != NULL, FALSE); | 972 g_return_val_if_fail(marshal != NULL, FALSE); |
| 973 | 973 |
| 974 if (plugin->ipc_data == NULL) | 974 if (plugin->ipc_data == NULL) |
| 975 { | 975 { |
| 976 ipc_info = plugin->ipc_data = g_new0(GaimPluginIpcInfo, 1); | 976 ipc_info = plugin->ipc_data = g_new0(PurplePluginIpcInfo, 1); |
| 977 ipc_info->commands = g_hash_table_new_full(g_str_hash, g_str_equal, | 977 ipc_info->commands = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 978 g_free, destroy_ipc_info); | 978 g_free, destroy_ipc_info); |
| 979 } | 979 } |
| 980 else | 980 else |
| 981 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; | 981 ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
| 982 | 982 |
| 983 ipc_command = g_new0(GaimPluginIpcCommand, 1); | 983 ipc_command = g_new0(PurplePluginIpcCommand, 1); |
| 984 ipc_command->func = func; | 984 ipc_command->func = func; |
| 985 ipc_command->marshal = marshal; | 985 ipc_command->marshal = marshal; |
| 986 ipc_command->num_params = num_params; | 986 ipc_command->num_params = num_params; |
| 987 ipc_command->ret_value = ret_value; | 987 ipc_command->ret_value = ret_value; |
| 988 | 988 |
| 989 if (num_params > 0) | 989 if (num_params > 0) |
| 990 { | 990 { |
| 991 va_list args; | 991 va_list args; |
| 992 int i; | 992 int i; |
| 993 | 993 |
| 994 ipc_command->params = g_new0(GaimValue *, num_params); | 994 ipc_command->params = g_new0(PurpleValue *, num_params); |
| 995 | 995 |
| 996 va_start(args, num_params); | 996 va_start(args, num_params); |
| 997 | 997 |
| 998 for (i = 0; i < num_params; i++) | 998 for (i = 0; i < num_params; i++) |
| 999 ipc_command->params[i] = va_arg(args, GaimValue *); | 999 ipc_command->params[i] = va_arg(args, PurpleValue *); |
| 1000 | 1000 |
| 1001 va_end(args); | 1001 va_end(args); |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 g_hash_table_replace(ipc_info->commands, g_strdup(command), ipc_command); | 1004 g_hash_table_replace(ipc_info->commands, g_strdup(command), ipc_command); |
| 1007 | 1007 |
| 1008 return TRUE; | 1008 return TRUE; |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 void | 1011 void |
| 1012 gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command) | 1012 purple_plugin_ipc_unregister(PurplePlugin *plugin, const char *command) |
| 1013 { | 1013 { |
| 1014 GaimPluginIpcInfo *ipc_info; | 1014 PurplePluginIpcInfo *ipc_info; |
| 1015 | 1015 |
| 1016 g_return_if_fail(plugin != NULL); | 1016 g_return_if_fail(plugin != NULL); |
| 1017 g_return_if_fail(command != NULL); | 1017 g_return_if_fail(command != NULL); |
| 1018 | 1018 |
| 1019 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; | 1019 ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
| 1020 | 1020 |
| 1021 if (ipc_info == NULL || | 1021 if (ipc_info == NULL || |
| 1022 g_hash_table_lookup(ipc_info->commands, command) == NULL) | 1022 g_hash_table_lookup(ipc_info->commands, command) == NULL) |
| 1023 { | 1023 { |
| 1024 gaim_debug_error("plugins", | 1024 purple_debug_error("plugins", |
| 1025 "IPC command '%s' was not registered for plugin %s\n", | 1025 "IPC command '%s' was not registered for plugin %s\n", |
| 1026 command, plugin->info->name); | 1026 command, plugin->info->name); |
| 1027 return; | 1027 return; |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1039 plugin->ipc_data = NULL; | 1039 plugin->ipc_data = NULL; |
| 1040 } | 1040 } |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 void | 1043 void |
| 1044 gaim_plugin_ipc_unregister_all(GaimPlugin *plugin) | 1044 purple_plugin_ipc_unregister_all(PurplePlugin *plugin) |
| 1045 { | 1045 { |
| 1046 GaimPluginIpcInfo *ipc_info; | 1046 PurplePluginIpcInfo *ipc_info; |
| 1047 | 1047 |
| 1048 g_return_if_fail(plugin != NULL); | 1048 g_return_if_fail(plugin != NULL); |
| 1049 | 1049 |
| 1050 if (plugin->ipc_data == NULL) | 1050 if (plugin->ipc_data == NULL) |
| 1051 return; /* Silently ignore it. */ | 1051 return; /* Silently ignore it. */ |
| 1052 | 1052 |
| 1053 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; | 1053 ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
| 1054 | 1054 |
| 1055 g_hash_table_destroy(ipc_info->commands); | 1055 g_hash_table_destroy(ipc_info->commands); |
| 1056 g_free(ipc_info); | 1056 g_free(ipc_info); |
| 1057 | 1057 |
| 1058 plugin->ipc_data = NULL; | 1058 plugin->ipc_data = NULL; |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 gboolean | 1061 gboolean |
| 1062 gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command, | 1062 purple_plugin_ipc_get_params(PurplePlugin *plugin, const char *command, |
| 1063 GaimValue **ret_value, int *num_params, | 1063 PurpleValue **ret_value, int *num_params, |
| 1064 GaimValue ***params) | 1064 PurpleValue ***params) |
| 1065 { | 1065 { |
| 1066 GaimPluginIpcInfo *ipc_info; | 1066 PurplePluginIpcInfo *ipc_info; |
| 1067 GaimPluginIpcCommand *ipc_command; | 1067 PurplePluginIpcCommand *ipc_command; |
| 1068 | 1068 |
| 1069 g_return_val_if_fail(plugin != NULL, FALSE); | 1069 g_return_val_if_fail(plugin != NULL, FALSE); |
| 1070 g_return_val_if_fail(command != NULL, FALSE); | 1070 g_return_val_if_fail(command != NULL, FALSE); |
| 1071 | 1071 |
| 1072 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; | 1072 ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
| 1073 | 1073 |
| 1074 if (ipc_info == NULL || | 1074 if (ipc_info == NULL || |
| 1075 (ipc_command = g_hash_table_lookup(ipc_info->commands, | 1075 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
| 1076 command)) == NULL) | 1076 command)) == NULL) |
| 1077 { | 1077 { |
| 1078 gaim_debug_error("plugins", | 1078 purple_debug_error("plugins", |
| 1079 "IPC command '%s' was not registered for plugin %s\n", | 1079 "IPC command '%s' was not registered for plugin %s\n", |
| 1080 command, plugin->info->name); | 1080 command, plugin->info->name); |
| 1081 | 1081 |
| 1082 return FALSE; | 1082 return FALSE; |
| 1083 } | 1083 } |
| 1093 | 1093 |
| 1094 return TRUE; | 1094 return TRUE; |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 void * | 1097 void * |
| 1098 gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command, | 1098 purple_plugin_ipc_call(PurplePlugin *plugin, const char *command, |
| 1099 gboolean *ok, ...) | 1099 gboolean *ok, ...) |
| 1100 { | 1100 { |
| 1101 GaimPluginIpcInfo *ipc_info; | 1101 PurplePluginIpcInfo *ipc_info; |
| 1102 GaimPluginIpcCommand *ipc_command; | 1102 PurplePluginIpcCommand *ipc_command; |
| 1103 va_list args; | 1103 va_list args; |
| 1104 void *ret_value; | 1104 void *ret_value; |
| 1105 | 1105 |
| 1106 if (ok != NULL) | 1106 if (ok != NULL) |
| 1107 *ok = FALSE; | 1107 *ok = FALSE; |
| 1108 | 1108 |
| 1109 g_return_val_if_fail(plugin != NULL, NULL); | 1109 g_return_val_if_fail(plugin != NULL, NULL); |
| 1110 g_return_val_if_fail(command != NULL, NULL); | 1110 g_return_val_if_fail(command != NULL, NULL); |
| 1111 | 1111 |
| 1112 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; | 1112 ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
| 1113 | 1113 |
| 1114 if (ipc_info == NULL || | 1114 if (ipc_info == NULL || |
| 1115 (ipc_command = g_hash_table_lookup(ipc_info->commands, | 1115 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
| 1116 command)) == NULL) | 1116 command)) == NULL) |
| 1117 { | 1117 { |
| 1118 gaim_debug_error("plugins", | 1118 purple_debug_error("plugins", |
| 1119 "IPC command '%s' was not registered for plugin %s\n", | 1119 "IPC command '%s' was not registered for plugin %s\n", |
| 1120 command, plugin->info->name); | 1120 command, plugin->info->name); |
| 1121 | 1121 |
| 1122 return NULL; | 1122 return NULL; |
| 1123 } | 1123 } |
| 1134 | 1134 |
| 1135 /************************************************************************** | 1135 /************************************************************************** |
| 1136 * Plugins subsystem | 1136 * Plugins subsystem |
| 1137 **************************************************************************/ | 1137 **************************************************************************/ |
| 1138 void * | 1138 void * |
| 1139 gaim_plugins_get_handle(void) { | 1139 purple_plugins_get_handle(void) { |
| 1140 static int handle; | 1140 static int handle; |
| 1141 | 1141 |
| 1142 return &handle; | 1142 return &handle; |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 void | 1145 void |
| 1146 gaim_plugins_init(void) { | 1146 purple_plugins_init(void) { |
| 1147 void *handle = gaim_plugins_get_handle(); | 1147 void *handle = purple_plugins_get_handle(); |
| 1148 | 1148 |
| 1149 gaim_plugins_add_search_path(LIBDIR); | 1149 purple_plugins_add_search_path(LIBDIR); |
| 1150 | 1150 |
| 1151 gaim_signal_register(handle, "plugin-load", | 1151 purple_signal_register(handle, "plugin-load", |
| 1152 gaim_marshal_VOID__POINTER, | 1152 purple_marshal_VOID__POINTER, |
| 1153 NULL, 1, | 1153 NULL, 1, |
| 1154 gaim_value_new(GAIM_TYPE_SUBTYPE, | 1154 purple_value_new(PURPLE_TYPE_SUBTYPE, |
| 1155 GAIM_SUBTYPE_PLUGIN)); | 1155 PURPLE_SUBTYPE_PLUGIN)); |
| 1156 gaim_signal_register(handle, "plugin-unload", | 1156 purple_signal_register(handle, "plugin-unload", |
| 1157 gaim_marshal_VOID__POINTER, | 1157 purple_marshal_VOID__POINTER, |
| 1158 NULL, 1, | 1158 NULL, 1, |
| 1159 gaim_value_new(GAIM_TYPE_SUBTYPE, | 1159 purple_value_new(PURPLE_TYPE_SUBTYPE, |
| 1160 GAIM_SUBTYPE_PLUGIN)); | 1160 PURPLE_SUBTYPE_PLUGIN)); |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 void | 1163 void |
| 1164 gaim_plugins_uninit(void) { | 1164 purple_plugins_uninit(void) { |
| 1165 gaim_signals_disconnect_by_handle(gaim_plugins_get_handle()); | 1165 purple_signals_disconnect_by_handle(purple_plugins_get_handle()); |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 /************************************************************************** | 1168 /************************************************************************** |
| 1169 * Plugins API | 1169 * Plugins API |
| 1170 **************************************************************************/ | 1170 **************************************************************************/ |
| 1171 void | 1171 void |
| 1172 gaim_plugins_add_search_path(const char *path) | 1172 purple_plugins_add_search_path(const char *path) |
| 1173 { | 1173 { |
| 1174 g_return_if_fail(path != NULL); | 1174 g_return_if_fail(path != NULL); |
| 1175 | 1175 |
| 1176 if (g_list_find_custom(search_paths, path, (GCompareFunc)strcmp)) | 1176 if (g_list_find_custom(search_paths, path, (GCompareFunc)strcmp)) |
| 1177 return; | 1177 return; |
| 1178 | 1178 |
| 1179 search_paths = g_list_append(search_paths, strdup(path)); | 1179 search_paths = g_list_append(search_paths, strdup(path)); |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 void | 1182 void |
| 1183 gaim_plugins_unload_all(void) | 1183 purple_plugins_unload_all(void) |
| 1184 { | 1184 { |
| 1185 #ifdef GAIM_PLUGINS | 1185 #ifdef PURPLE_PLUGINS |
| 1186 | 1186 |
| 1187 while (loaded_plugins != NULL) | 1187 while (loaded_plugins != NULL) |
| 1188 gaim_plugin_unload(loaded_plugins->data); | 1188 purple_plugin_unload(loaded_plugins->data); |
| 1189 | 1189 |
| 1190 #endif /* GAIM_PLUGINS */ | 1190 #endif /* PURPLE_PLUGINS */ |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 void | 1193 void |
| 1194 gaim_plugins_destroy_all(void) | 1194 purple_plugins_destroy_all(void) |
| 1195 { | 1195 { |
| 1196 #ifdef GAIM_PLUGINS | 1196 #ifdef PURPLE_PLUGINS |
| 1197 | 1197 |
| 1198 while (plugins != NULL) | 1198 while (plugins != NULL) |
| 1199 gaim_plugin_destroy(plugins->data); | 1199 purple_plugin_destroy(plugins->data); |
| 1200 | 1200 |
| 1201 #endif /* GAIM_PLUGINS */ | 1201 #endif /* PURPLE_PLUGINS */ |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 void | 1204 void |
| 1205 gaim_plugins_save_loaded(const char *key) | 1205 purple_plugins_save_loaded(const char *key) |
| 1206 { | 1206 { |
| 1207 #ifdef GAIM_PLUGINS | 1207 #ifdef PURPLE_PLUGINS |
| 1208 GList *pl; | 1208 GList *pl; |
| 1209 GList *files = NULL; | 1209 GList *files = NULL; |
| 1210 GaimPlugin *p; | 1210 PurplePlugin *p; |
| 1211 | 1211 |
| 1212 for (pl = gaim_plugins_get_loaded(); pl != NULL; pl = pl->next) { | 1212 for (pl = purple_plugins_get_loaded(); pl != NULL; pl = pl->next) { |
| 1213 p = pl->data; | 1213 p = pl->data; |
| 1214 | 1214 |
| 1215 if (p->info->type != GAIM_PLUGIN_PROTOCOL && | 1215 if (p->info->type != PURPLE_PLUGIN_PROTOCOL && |
| 1216 p->info->type != GAIM_PLUGIN_LOADER) { | 1216 p->info->type != PURPLE_PLUGIN_LOADER) { |
| 1217 files = g_list_append(files, p->path); | 1217 files = g_list_append(files, p->path); |
| 1218 } | 1218 } |
| 1219 } | 1219 } |
| 1220 | 1220 |
| 1221 gaim_prefs_set_path_list(key, files); | 1221 purple_prefs_set_path_list(key, files); |
| 1222 g_list_free(files); | 1222 g_list_free(files); |
| 1223 #endif | 1223 #endif |
| 1224 } | 1224 } |
| 1225 | 1225 |
| 1226 void | 1226 void |
| 1227 gaim_plugins_load_saved(const char *key) | 1227 purple_plugins_load_saved(const char *key) |
| 1228 { | 1228 { |
| 1229 #ifdef GAIM_PLUGINS | 1229 #ifdef PURPLE_PLUGINS |
| 1230 GList *f, *files; | 1230 GList *f, *files; |
| 1231 | 1231 |
| 1232 g_return_if_fail(key != NULL); | 1232 g_return_if_fail(key != NULL); |
| 1233 | 1233 |
| 1234 files = gaim_prefs_get_path_list(key); | 1234 files = purple_prefs_get_path_list(key); |
| 1235 | 1235 |
| 1236 for (f = files; f; f = f->next) | 1236 for (f = files; f; f = f->next) |
| 1237 { | 1237 { |
| 1238 char *filename; | 1238 char *filename; |
| 1239 char *basename; | 1239 char *basename; |
| 1240 GaimPlugin *plugin; | 1240 PurplePlugin *plugin; |
| 1241 | 1241 |
| 1242 if (f->data == NULL) | 1242 if (f->data == NULL) |
| 1243 continue; | 1243 continue; |
| 1244 | 1244 |
| 1245 filename = f->data; | 1245 filename = f->data; |
| 1256 if (basename != NULL) | 1256 if (basename != NULL) |
| 1257 basename++; | 1257 basename++; |
| 1258 | 1258 |
| 1259 /* Strip the extension */ | 1259 /* Strip the extension */ |
| 1260 if (basename) | 1260 if (basename) |
| 1261 basename = gaim_plugin_get_basename(filename); | 1261 basename = purple_plugin_get_basename(filename); |
| 1262 | 1262 |
| 1263 if ((plugin = gaim_plugins_find_with_filename(filename)) != NULL) | 1263 if ((plugin = purple_plugins_find_with_filename(filename)) != NULL) |
| 1264 { | 1264 { |
| 1265 gaim_debug_info("plugins", "Loading saved plugin %s\n", | 1265 purple_debug_info("plugins", "Loading saved plugin %s\n", |
| 1266 plugin->path); | 1266 plugin->path); |
| 1267 gaim_plugin_load(plugin); | 1267 purple_plugin_load(plugin); |
| 1268 } | 1268 } |
| 1269 else if (basename && (plugin = gaim_plugins_find_with_basename(basename)) != NULL) | 1269 else if (basename && (plugin = purple_plugins_find_with_basename(basename)) != NULL) |
| 1270 { | 1270 { |
| 1271 gaim_debug_info("plugins", "Loading saved plugin %s\n", | 1271 purple_debug_info("plugins", "Loading saved plugin %s\n", |
| 1272 plugin->path); | 1272 plugin->path); |
| 1273 gaim_plugin_load(plugin); | 1273 purple_plugin_load(plugin); |
| 1274 } | 1274 } |
| 1275 else | 1275 else |
| 1276 { | 1276 { |
| 1277 gaim_debug_error("plugins", "Unable to find saved plugin %s\n", | 1277 purple_debug_error("plugins", "Unable to find saved plugin %s\n", |
| 1278 filename); | 1278 filename); |
| 1279 } | 1279 } |
| 1280 | 1280 |
| 1281 g_free(basename); | 1281 g_free(basename); |
| 1282 | 1282 |
| 1283 g_free(f->data); | 1283 g_free(f->data); |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 g_list_free(files); | 1286 g_list_free(files); |
| 1287 #endif /* GAIM_PLUGINS */ | 1287 #endif /* PURPLE_PLUGINS */ |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 | 1290 |
| 1291 void | 1291 void |
| 1292 gaim_plugins_probe(const char *ext) | 1292 purple_plugins_probe(const char *ext) |
| 1293 { | 1293 { |
| 1294 #ifdef GAIM_PLUGINS | 1294 #ifdef PURPLE_PLUGINS |
| 1295 GDir *dir; | 1295 GDir *dir; |
| 1296 const gchar *file; | 1296 const gchar *file; |
| 1297 gchar *path; | 1297 gchar *path; |
| 1298 GaimPlugin *plugin; | 1298 PurplePlugin *plugin; |
| 1299 GList *cur; | 1299 GList *cur; |
| 1300 const char *search_path; | 1300 const char *search_path; |
| 1301 | 1301 |
| 1302 if (!g_module_supported()) | 1302 if (!g_module_supported()) |
| 1303 return; | 1303 return; |
| 1314 while ((file = g_dir_read_name(dir)) != NULL) | 1314 while ((file = g_dir_read_name(dir)) != NULL) |
| 1315 { | 1315 { |
| 1316 path = g_build_filename(search_path, file, NULL); | 1316 path = g_build_filename(search_path, file, NULL); |
| 1317 | 1317 |
| 1318 if (ext == NULL || has_file_extension(file, ext)) | 1318 if (ext == NULL || has_file_extension(file, ext)) |
| 1319 plugin = gaim_plugin_probe(path); | 1319 plugin = purple_plugin_probe(path); |
| 1320 | 1320 |
| 1321 g_free(path); | 1321 g_free(path); |
| 1322 } | 1322 } |
| 1323 | 1323 |
| 1324 g_dir_close(dir); | 1324 g_dir_close(dir); |
| 1326 } | 1326 } |
| 1327 | 1327 |
| 1328 /* See if we have any plugins waiting to load */ | 1328 /* See if we have any plugins waiting to load */ |
| 1329 while (load_queue != NULL) | 1329 while (load_queue != NULL) |
| 1330 { | 1330 { |
| 1331 plugin = (GaimPlugin *)load_queue->data; | 1331 plugin = (PurplePlugin *)load_queue->data; |
| 1332 | 1332 |
| 1333 load_queue = g_list_remove(load_queue, plugin); | 1333 load_queue = g_list_remove(load_queue, plugin); |
| 1334 | 1334 |
| 1335 if (plugin == NULL || plugin->info == NULL) | 1335 if (plugin == NULL || plugin->info == NULL) |
| 1336 continue; | 1336 continue; |
| 1337 | 1337 |
| 1338 if (plugin->info->type == GAIM_PLUGIN_LOADER) | 1338 if (plugin->info->type == PURPLE_PLUGIN_LOADER) |
| 1339 { | 1339 { |
| 1340 /* We'll just load this right now. */ | 1340 /* We'll just load this right now. */ |
| 1341 if (!gaim_plugin_load(plugin)) | 1341 if (!purple_plugin_load(plugin)) |
| 1342 { | 1342 { |
| 1343 gaim_plugin_destroy(plugin); | 1343 purple_plugin_destroy(plugin); |
| 1344 | 1344 |
| 1345 continue; | 1345 continue; |
| 1346 } | 1346 } |
| 1347 | 1347 |
| 1348 plugin_loaders = g_list_append(plugin_loaders, plugin); | 1348 plugin_loaders = g_list_append(plugin_loaders, plugin); |
| 1349 | 1349 |
| 1350 for (cur = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; | 1350 for (cur = PURPLE_PLUGIN_LOADER_INFO(plugin)->exts; |
| 1351 cur != NULL; | 1351 cur != NULL; |
| 1352 cur = cur->next) | 1352 cur = cur->next) |
| 1353 { | 1353 { |
| 1354 gaim_plugins_probe(cur->data); | 1354 purple_plugins_probe(cur->data); |
| 1355 } | 1355 } |
| 1356 } | 1356 } |
| 1357 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) | 1357 else if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) |
| 1358 { | 1358 { |
| 1359 /* We'll just load this right now. */ | 1359 /* We'll just load this right now. */ |
| 1360 if (!gaim_plugin_load(plugin)) | 1360 if (!purple_plugin_load(plugin)) |
| 1361 { | 1361 { |
| 1362 gaim_plugin_destroy(plugin); | 1362 purple_plugin_destroy(plugin); |
| 1363 | 1363 |
| 1364 continue; | 1364 continue; |
| 1365 } | 1365 } |
| 1366 | 1366 |
| 1367 /* Make sure we don't load two PRPLs with the same name? */ | 1367 /* Make sure we don't load two PRPLs with the same name? */ |
| 1368 if (gaim_find_prpl(plugin->info->id)) | 1368 if (purple_find_prpl(plugin->info->id)) |
| 1369 { | 1369 { |
| 1370 /* Nothing to see here--move along, move along */ | 1370 /* Nothing to see here--move along, move along */ |
| 1371 gaim_plugin_destroy(plugin); | 1371 purple_plugin_destroy(plugin); |
| 1372 | 1372 |
| 1373 continue; | 1373 continue; |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, | 1376 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
| 1378 } | 1378 } |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 if (probe_cb != NULL) | 1381 if (probe_cb != NULL) |
| 1382 probe_cb(probe_cb_data); | 1382 probe_cb(probe_cb_data); |
| 1383 #endif /* GAIM_PLUGINS */ | 1383 #endif /* PURPLE_PLUGINS */ |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 gboolean | 1386 gboolean |
| 1387 gaim_plugin_register(GaimPlugin *plugin) | 1387 purple_plugin_register(PurplePlugin *plugin) |
| 1388 { | 1388 { |
| 1389 g_return_val_if_fail(plugin != NULL, FALSE); | 1389 g_return_val_if_fail(plugin != NULL, FALSE); |
| 1390 | 1390 |
| 1391 /* If this plugin has been registered already then exit */ | 1391 /* If this plugin has been registered already then exit */ |
| 1392 if (g_list_find(plugins, plugin)) | 1392 if (g_list_find(plugins, plugin)) |
| 1393 return TRUE; | 1393 return TRUE; |
| 1394 | 1394 |
| 1395 /* Ensure the plugin has the requisite information */ | 1395 /* Ensure the plugin has the requisite information */ |
| 1396 if (plugin->info->type == GAIM_PLUGIN_LOADER) | 1396 if (plugin->info->type == PURPLE_PLUGIN_LOADER) |
| 1397 { | 1397 { |
| 1398 GaimPluginLoaderInfo *loader_info; | 1398 PurplePluginLoaderInfo *loader_info; |
| 1399 | 1399 |
| 1400 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); | 1400 loader_info = PURPLE_PLUGIN_LOADER_INFO(plugin); |
| 1401 | 1401 |
| 1402 if (loader_info == NULL) | 1402 if (loader_info == NULL) |
| 1403 { | 1403 { |
| 1404 gaim_debug_error("plugins", "%s is not loadable, loader plugin missing loader_info\n", | 1404 purple_debug_error("plugins", "%s is not loadable, loader plugin missing loader_info\n", |
| 1405 plugin->path); | 1405 plugin->path); |
| 1406 return FALSE; | 1406 return FALSE; |
| 1407 } | 1407 } |
| 1408 } | 1408 } |
| 1409 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) | 1409 else if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) |
| 1410 { | 1410 { |
| 1411 GaimPluginProtocolInfo *prpl_info; | 1411 PurplePluginProtocolInfo *prpl_info; |
| 1412 | 1412 |
| 1413 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | 1413 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
| 1414 | 1414 |
| 1415 if (prpl_info == NULL) | 1415 if (prpl_info == NULL) |
| 1416 { | 1416 { |
| 1417 gaim_debug_error("plugins", "%s is not loadable, protocol plugin missing prpl_info\n", | 1417 purple_debug_error("plugins", "%s is not loadable, protocol plugin missing prpl_info\n", |
| 1418 plugin->path); | 1418 plugin->path); |
| 1419 return FALSE; | 1419 return FALSE; |
| 1420 } | 1420 } |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 #ifdef GAIM_PLUGINS | 1423 #ifdef PURPLE_PLUGINS |
| 1424 /* This plugin should be probed and maybe loaded--add it to the queue */ | 1424 /* This plugin should be probed and maybe loaded--add it to the queue */ |
| 1425 load_queue = g_list_append(load_queue, plugin); | 1425 load_queue = g_list_append(load_queue, plugin); |
| 1426 #else | 1426 #else |
| 1427 if (plugin->info != NULL) | 1427 if (plugin->info != NULL) |
| 1428 { | 1428 { |
| 1429 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) | 1429 if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) |
| 1430 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, | 1430 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
| 1431 (GCompareFunc)compare_prpl); | 1431 (GCompareFunc)compare_prpl); |
| 1432 if (plugin->info->load != NULL) | 1432 if (plugin->info->load != NULL) |
| 1433 if (!plugin->info->load(plugin)) | 1433 if (!plugin->info->load(plugin)) |
| 1434 return FALSE; | 1434 return FALSE; |
| 1439 | 1439 |
| 1440 return TRUE; | 1440 return TRUE; |
| 1441 } | 1441 } |
| 1442 | 1442 |
| 1443 gboolean | 1443 gboolean |
| 1444 gaim_plugins_enabled(void) | 1444 purple_plugins_enabled(void) |
| 1445 { | 1445 { |
| 1446 #ifdef GAIM_PLUGINS | 1446 #ifdef PURPLE_PLUGINS |
| 1447 return TRUE; | 1447 return TRUE; |
| 1448 #else | 1448 #else |
| 1449 return FALSE; | 1449 return FALSE; |
| 1450 #endif | 1450 #endif |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 void | 1453 void |
| 1454 gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data) | 1454 purple_plugins_register_probe_notify_cb(void (*func)(void *), void *data) |
| 1455 { | 1455 { |
| 1456 /* TODO */ | 1456 /* TODO */ |
| 1457 probe_cb = func; | 1457 probe_cb = func; |
| 1458 probe_cb_data = data; | 1458 probe_cb_data = data; |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 void | 1461 void |
| 1462 gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)) | 1462 purple_plugins_unregister_probe_notify_cb(void (*func)(void *)) |
| 1463 { | 1463 { |
| 1464 /* TODO */ | 1464 /* TODO */ |
| 1465 probe_cb = NULL; | 1465 probe_cb = NULL; |
| 1466 probe_cb_data = NULL; | 1466 probe_cb_data = NULL; |
| 1467 } | 1467 } |
| 1468 | 1468 |
| 1469 void | 1469 void |
| 1470 gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | 1470 purple_plugins_register_load_notify_cb(void (*func)(PurplePlugin *, void *), |
| 1471 void *data) | 1471 void *data) |
| 1472 { | 1472 { |
| 1473 /* TODO */ | 1473 /* TODO */ |
| 1474 load_cb = func; | 1474 load_cb = func; |
| 1475 load_cb_data = data; | 1475 load_cb_data = data; |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 void | 1478 void |
| 1479 gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)) | 1479 purple_plugins_unregister_load_notify_cb(void (*func)(PurplePlugin *, void *)) |
| 1480 { | 1480 { |
| 1481 /* TODO */ | 1481 /* TODO */ |
| 1482 load_cb = NULL; | 1482 load_cb = NULL; |
| 1483 load_cb_data = NULL; | 1483 load_cb_data = NULL; |
| 1484 } | 1484 } |
| 1485 | 1485 |
| 1486 void | 1486 void |
| 1487 gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | 1487 purple_plugins_register_unload_notify_cb(void (*func)(PurplePlugin *, void *), |
| 1488 void *data) | 1488 void *data) |
| 1489 { | 1489 { |
| 1490 /* TODO */ | 1490 /* TODO */ |
| 1491 unload_cb = func; | 1491 unload_cb = func; |
| 1492 unload_cb_data = data; | 1492 unload_cb_data = data; |
| 1493 } | 1493 } |
| 1494 | 1494 |
| 1495 void | 1495 void |
| 1496 gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *)) | 1496 purple_plugins_unregister_unload_notify_cb(void (*func)(PurplePlugin *, void *)) |
| 1497 { | 1497 { |
| 1498 /* TODO */ | 1498 /* TODO */ |
| 1499 unload_cb = NULL; | 1499 unload_cb = NULL; |
| 1500 unload_cb_data = NULL; | 1500 unload_cb_data = NULL; |
| 1501 } | 1501 } |
| 1502 | 1502 |
| 1503 GaimPlugin * | 1503 PurplePlugin * |
| 1504 gaim_plugins_find_with_name(const char *name) | 1504 purple_plugins_find_with_name(const char *name) |
| 1505 { | 1505 { |
| 1506 GaimPlugin *plugin; | 1506 PurplePlugin *plugin; |
| 1507 GList *l; | 1507 GList *l; |
| 1508 | 1508 |
| 1509 for (l = plugins; l != NULL; l = l->next) { | 1509 for (l = plugins; l != NULL; l = l->next) { |
| 1510 plugin = l->data; | 1510 plugin = l->data; |
| 1511 | 1511 |
| 1514 } | 1514 } |
| 1515 | 1515 |
| 1516 return NULL; | 1516 return NULL; |
| 1517 } | 1517 } |
| 1518 | 1518 |
| 1519 GaimPlugin * | 1519 PurplePlugin * |
| 1520 gaim_plugins_find_with_filename(const char *filename) | 1520 purple_plugins_find_with_filename(const char *filename) |
| 1521 { | 1521 { |
| 1522 GaimPlugin *plugin; | 1522 PurplePlugin *plugin; |
| 1523 GList *l; | 1523 GList *l; |
| 1524 | 1524 |
| 1525 for (l = plugins; l != NULL; l = l->next) { | 1525 for (l = plugins; l != NULL; l = l->next) { |
| 1526 plugin = l->data; | 1526 plugin = l->data; |
| 1527 | 1527 |
| 1530 } | 1530 } |
| 1531 | 1531 |
| 1532 return NULL; | 1532 return NULL; |
| 1533 } | 1533 } |
| 1534 | 1534 |
| 1535 GaimPlugin * | 1535 PurplePlugin * |
| 1536 gaim_plugins_find_with_basename(const char *basename) | 1536 purple_plugins_find_with_basename(const char *basename) |
| 1537 { | 1537 { |
| 1538 #ifdef GAIM_PLUGINS | 1538 #ifdef PURPLE_PLUGINS |
| 1539 GaimPlugin *plugin; | 1539 PurplePlugin *plugin; |
| 1540 GList *l; | 1540 GList *l; |
| 1541 char *tmp; | 1541 char *tmp; |
| 1542 | 1542 |
| 1543 g_return_val_if_fail(basename != NULL, NULL); | 1543 g_return_val_if_fail(basename != NULL, NULL); |
| 1544 | 1544 |
| 1545 for (l = plugins; l != NULL; l = l->next) | 1545 for (l = plugins; l != NULL; l = l->next) |
| 1546 { | 1546 { |
| 1547 plugin = (GaimPlugin *)l->data; | 1547 plugin = (PurplePlugin *)l->data; |
| 1548 | 1548 |
| 1549 if (plugin->path != NULL) { | 1549 if (plugin->path != NULL) { |
| 1550 tmp = gaim_plugin_get_basename(plugin->path); | 1550 tmp = purple_plugin_get_basename(plugin->path); |
| 1551 if (!strcmp(tmp, basename)) | 1551 if (!strcmp(tmp, basename)) |
| 1552 { | 1552 { |
| 1553 g_free(tmp); | 1553 g_free(tmp); |
| 1554 return plugin; | 1554 return plugin; |
| 1555 } | 1555 } |
| 1556 g_free(tmp); | 1556 g_free(tmp); |
| 1557 } | 1557 } |
| 1558 } | 1558 } |
| 1559 | 1559 |
| 1560 #endif /* GAIM_PLUGINS */ | 1560 #endif /* PURPLE_PLUGINS */ |
| 1561 | 1561 |
| 1562 return NULL; | 1562 return NULL; |
| 1563 } | 1563 } |
| 1564 | 1564 |
| 1565 GaimPlugin * | 1565 PurplePlugin * |
| 1566 gaim_plugins_find_with_id(const char *id) | 1566 purple_plugins_find_with_id(const char *id) |
| 1567 { | 1567 { |
| 1568 GaimPlugin *plugin; | 1568 PurplePlugin *plugin; |
| 1569 GList *l; | 1569 GList *l; |
| 1570 | 1570 |
| 1571 g_return_val_if_fail(id != NULL, NULL); | 1571 g_return_val_if_fail(id != NULL, NULL); |
| 1572 | 1572 |
| 1573 for (l = plugins; l != NULL; l = l->next) | 1573 for (l = plugins; l != NULL; l = l->next) |
| 1580 | 1580 |
| 1581 return NULL; | 1581 return NULL; |
| 1582 } | 1582 } |
| 1583 | 1583 |
| 1584 GList * | 1584 GList * |
| 1585 gaim_plugins_get_loaded(void) | 1585 purple_plugins_get_loaded(void) |
| 1586 { | 1586 { |
| 1587 return loaded_plugins; | 1587 return loaded_plugins; |
| 1588 } | 1588 } |
| 1589 | 1589 |
| 1590 GList * | 1590 GList * |
| 1591 gaim_plugins_get_protocols(void) | 1591 purple_plugins_get_protocols(void) |
| 1592 { | 1592 { |
| 1593 return protocol_plugins; | 1593 return protocol_plugins; |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 GList * | 1596 GList * |
| 1597 gaim_plugins_get_all(void) | 1597 purple_plugins_get_all(void) |
| 1598 { | 1598 { |
| 1599 return plugins; | 1599 return plugins; |
| 1600 } | 1600 } |
| 1601 | 1601 |
| 1602 | 1602 |
| 1603 GaimPluginAction * | 1603 PurplePluginAction * |
| 1604 gaim_plugin_action_new(const char* label, void (*callback)(GaimPluginAction *)) | 1604 purple_plugin_action_new(const char* label, void (*callback)(PurplePluginAction *)) |
| 1605 { | 1605 { |
| 1606 GaimPluginAction *act = g_new0(GaimPluginAction, 1); | 1606 PurplePluginAction *act = g_new0(PurplePluginAction, 1); |
| 1607 | 1607 |
| 1608 act->label = g_strdup(label); | 1608 act->label = g_strdup(label); |
| 1609 act->callback = callback; | 1609 act->callback = callback; |
| 1610 | 1610 |
| 1611 return act; | 1611 return act; |
| 1612 } | 1612 } |
| 1613 | 1613 |
| 1614 void | 1614 void |
| 1615 gaim_plugin_action_free(GaimPluginAction *action) | 1615 purple_plugin_action_free(PurplePluginAction *action) |
| 1616 { | 1616 { |
| 1617 g_return_if_fail(action != NULL); | 1617 g_return_if_fail(action != NULL); |
| 1618 | 1618 |
| 1619 g_free(action->label); | 1619 g_free(action->label); |
| 1620 g_free(action); | 1620 g_free(action); |
