comparison src/plugin.c @ 8749:d7b8eb1f0a18

[gaim-migrate @ 9504] Bumped up the plugin API version number, and added version numbers for loader plugins and protocol plugins. Authors will want to update their plugins, and possibly use GAIM_PLUGIN_API_VERSION, GAIM_PRPL_API_VERSION, and GAIM_LOADER_API_VERSION constants. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 22 Apr 2004 01:53:18 +0000
parents fa6395637e2c
children 184b8c3b6d09
comparison
equal deleted inserted replaced
8748:13d592f485d1 8749:d7b8eb1f0a18
228 gaim_plugin_destroy(plugin); 228 gaim_plugin_destroy(plugin);
229 229
230 return NULL; 230 return NULL;
231 } 231 }
232 232
233 if (plugin->info->api_version != GAIM_PLUGIN_API_VERSION)
234 {
235 gaim_plugin_destroy(plugin);
236
237 return NULL;
238 }
239
233 return plugin; 240 return plugin;
234 #else 241 #else
235 return NULL; 242 return NULL;
236 #endif /* !GAIM_PLUGINS */ 243 #endif /* !GAIM_PLUGINS */
237 } 244 }
458 load_queue = g_list_remove(load_queue, plugin); 465 load_queue = g_list_remove(load_queue, plugin);
459 466
460 if (plugin->info != NULL && plugin->info->dependencies != NULL) 467 if (plugin->info != NULL && plugin->info->dependencies != NULL)
461 g_list_free(plugin->info->dependencies); 468 g_list_free(plugin->info->dependencies);
462 469
463 if (plugin->native_plugin) { 470 if (plugin->native_plugin)
464 471 {
465 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) { 472 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER)
473 {
474 GaimPluginLoaderInfo *loader_info;
466 GList *exts, *l, *next_l; 475 GList *exts, *l, *next_l;
467 GaimPlugin *p2; 476 GaimPlugin *p2;
468 477
469 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; 478 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin);
470 exts != NULL; 479
471 exts = exts->next) { 480 if (loader_info != NULL && plugin->info->api_version >= 3 &&
472 481 loader_info->exts != NULL)
473 for (l = gaim_plugins_get_all(); l != NULL; l = next_l) { 482 {
474 next_l = l->next; 483 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts;
475 484 exts != NULL;
476 p2 = l->data; 485 exts = exts->next) {
477 486
478 if (p2->path != NULL && is_so_file(p2->path, exts->data)) 487 for (l = gaim_plugins_get_all(); l != NULL; l = next_l)
479 gaim_plugin_destroy(p2); 488 {
489 next_l = l->next;
490
491 p2 = l->data;
492
493 if (p2->path != NULL &&
494 is_so_file(p2->path, exts->data))
495 {
496 gaim_plugin_destroy(p2);
497 }
498 }
480 } 499 }
500
501 g_list_free(loader_info->exts);
481 } 502 }
482
483 g_list_free(GAIM_PLUGIN_LOADER_INFO(plugin)->exts);
484 503
485 plugin_loaders = g_list_remove(plugin_loaders, plugin); 504 plugin_loaders = g_list_remove(plugin_loaders, plugin);
486 } 505 }
487 506
488 if (plugin->info != NULL && plugin->info->destroy != NULL) 507 if (plugin->info != NULL && plugin->info->destroy != NULL)
489 plugin->info->destroy(plugin); 508 plugin->info->destroy(plugin);
490 509
491 if (plugin->handle != NULL) 510 if (plugin->handle != NULL)
492 g_module_close(plugin->handle); 511 g_module_close(plugin->handle);
493 } 512 }
494 else { 513 else
514 {
495 GaimPlugin *loader; 515 GaimPlugin *loader;
496 GaimPluginLoaderInfo *loader_info; 516 GaimPluginLoaderInfo *loader_info;
497 517
498 loader = find_loader_for_plugin(plugin); 518 loader = find_loader_for_plugin(plugin);
499 519
500 if (loader != NULL) { 520 if (loader != NULL)
521 {
501 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); 522 loader_info = GAIM_PLUGIN_LOADER_INFO(loader);
502 523
503 if (loader_info->destroy != NULL) 524 if (loader_info->destroy != NULL)
504 loader_info->destroy(plugin); 525 loader_info->destroy(plugin);
505 } 526 }
868 gaim_plugins_probe(exts->data); 889 gaim_plugins_probe(exts->data);
869 } 890 }
870 } 891 }
871 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) 892 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL)
872 { 893 {
873
874 /* We'll just load this right now. */ 894 /* We'll just load this right now. */
875 if (!gaim_plugin_load(plugin)) 895 if (!gaim_plugin_load(plugin))
876 { 896 {
877 gaim_plugin_destroy(plugin); 897 gaim_plugin_destroy(plugin);
878 898
910 g_return_val_if_fail(plugin != NULL, FALSE); 930 g_return_val_if_fail(plugin != NULL, FALSE);
911 931
912 if (g_list_find(plugins, plugin)) 932 if (g_list_find(plugins, plugin))
913 return TRUE; 933 return TRUE;
914 934
915 if (plugin->info->type == GAIM_PLUGIN_LOADER || 935 if (plugin->info->type == GAIM_PLUGIN_LOADER)
916 plugin->info->type == GAIM_PLUGIN_PROTOCOL) 936 {
917 { 937 GaimPluginLoaderInfo *loader_info;
918 /* Special exception for loader plugins. We want them loaded NOW! */ 938
939 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin);
940
941 if (loader_info == NULL ||
942 loader_info->api_version != GAIM_LOADER_API_VERSION)
943 {
944 return FALSE;
945 }
946
947 load_queue = g_list_append(load_queue, plugin);
948 }
949 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL)
950 {
951 GaimPluginProtocolInfo *prpl_info;
952
953 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
954
955 if (prpl_info == NULL ||
956 prpl_info->api_version != GAIM_PRPL_API_VERSION)
957 {
958 return FALSE;
959 }
960
919 load_queue = g_list_append(load_queue, plugin); 961 load_queue = g_list_append(load_queue, plugin);
920 } 962 }
921 963
922 plugins = g_list_append(plugins, plugin); 964 plugins = g_list_append(plugins, plugin);
923 965