Mon, 23 Sep 2013 22:56:17 +0530
Make sure purple_plugins_find_all() returns only purple plugins
| 7016 | 1 | /** |
| 2 | * @file ssl.c Main SSL plugin | |
| 3 | * | |
| 15884 | 4 | * purple |
| 7016 | 5 | * |
| 6 | * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 7 | * | |
| 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 | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16744
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7016 | 21 | */ |
| 22 | #include "internal.h" | |
| 23 | #include "debug.h" | |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
20288
diff
changeset
|
24 | #include "plugins.h" |
| 7016 | 25 | #include "sslconn.h" |
| 9943 | 26 | #include "version.h" |
| 7016 | 27 | |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
28 | #define SSL_PLUGIN_ID "core-ssl" |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
29 | #define SSL_PLUGIN_DOMAIN (g_quark_from_static_string(SSL_PLUGIN_ID)) |
| 7016 | 30 | |
| 15884 | 31 | static PurplePlugin *ssl_plugin = NULL; |
| 7016 | 32 | |
| 33 | static gboolean | |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
34 | probe_ssl_plugins(PurplePlugin *my_plugin, GError **error) |
| 7016 | 35 | { |
| 15884 | 36 | PurplePlugin *plugin; |
| 36655 | 37 | PurplePluginInfo *info; |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
38 | GList *plugins, *l; |
| 7016 | 39 | |
| 40 | ssl_plugin = NULL; | |
| 41 | ||
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
42 | plugins = purple_plugins_find_all(); |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
43 | |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
44 | for (l = plugins; l != NULL; l = l->next) |
| 7016 | 45 | { |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
46 | plugin = PURPLE_PLUGIN(l->data); |
| 7016 | 47 | if (plugin == my_plugin) |
| 48 | continue; | |
| 49 | ||
| 36655 | 50 | info = purple_plugin_get_info(plugin); |
| 51 | ||
| 52 | if (strncmp(purple_plugin_info_get_id(info), "ssl-", 4) == 0) | |
| 7016 | 53 | { |
|
36509
86e882c3cfdf
Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents:
36505
diff
changeset
|
54 | if (purple_plugin_load(plugin, NULL)) |
| 7016 | 55 | { |
| 56 | ssl_plugin = plugin; | |
| 57 | break; | |
| 58 | } | |
| 59 | } | |
| 60 | } | |
| 61 | ||
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
62 | g_list_free(plugins); |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
63 | |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
64 | if (ssl_plugin == NULL) { |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
65 | g_set_error(error, SSL_PLUGIN_DOMAIN, 0, |
|
36509
86e882c3cfdf
Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents:
36505
diff
changeset
|
66 | "Could not load a plugin that implements SSL."); |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
67 | return FALSE; |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
68 | } else { |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
69 | return TRUE; |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
70 | } |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
71 | } |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
72 | |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
73 | static PurplePluginInfo * |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
74 | plugin_query(GError **error) |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
75 | { |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36509
diff
changeset
|
76 | const gchar * const authors[] = { |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36509
diff
changeset
|
77 | "Christian Hammond <chipx86@gnupdate.org>", |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36509
diff
changeset
|
78 | NULL |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36509
diff
changeset
|
79 | }; |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36509
diff
changeset
|
80 | |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
81 | return purple_plugin_info_new( |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
82 | "id", SSL_PLUGIN_ID, |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
83 | "name", N_("SSL"), |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
84 | "version", DISPLAY_VERSION, |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
85 | "category", N_("SSL"), |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
86 | "summary", N_("Provides a wrapper around SSL support libraries."), |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
87 | "description", N_("Provides a wrapper around SSL support libraries."), |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36509
diff
changeset
|
88 | "authors", authors, |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
89 | "website", PURPLE_WEBSITE, |
|
36505
60c161851325
Integrated purple ABI requirement into GPlugin's "abi-version" property
Ankit Vani <a@nevitus.org>
parents:
36501
diff
changeset
|
90 | "abi-version", PURPLE_ABI_VERSION, |
|
36795
ceb47557895a
Added PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD flag to core-ssl plugin
Ankit Vani <a@nevitus.org>
parents:
36655
diff
changeset
|
91 | "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL | |
|
ceb47557895a
Added PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD flag to core-ssl plugin
Ankit Vani <a@nevitus.org>
parents:
36655
diff
changeset
|
92 | PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD, |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
93 | NULL |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
94 | ); |
| 7016 | 95 | } |
| 96 | ||
| 97 | static gboolean | |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
98 | plugin_load(PurplePlugin *plugin, GError **error) |
| 7016 | 99 | { |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
100 | return probe_ssl_plugins(plugin, error); |
| 7016 | 101 | } |
| 102 | ||
| 103 | static gboolean | |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
104 | plugin_unload(PurplePlugin *plugin, GError **error) |
| 7016 | 105 | { |
|
7040
a7560306d591
[gaim-migrate @ 7603]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
106 | if (ssl_plugin != NULL && |
| 15884 | 107 | g_list_find(purple_plugins_get_loaded(), ssl_plugin) != NULL) |
| 7016 | 108 | { |
|
36509
86e882c3cfdf
Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents:
36505
diff
changeset
|
109 | if (!purple_plugin_unload(ssl_plugin, error)) |
|
86e882c3cfdf
Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents:
36505
diff
changeset
|
110 | return FALSE; |
|
7040
a7560306d591
[gaim-migrate @ 7603]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
111 | } |
| 7016 | 112 | |
|
7040
a7560306d591
[gaim-migrate @ 7603]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
113 | ssl_plugin = NULL; |
| 7016 | 114 | |
| 115 | return TRUE; | |
| 116 | } | |
| 117 | ||
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
118 | PURPLE_PLUGIN_INIT(ssl, plugin_query, plugin_load, plugin_unload); |