libpurple/plugins/ssl/ssl.c

Mon, 02 Sep 2013 17:20:49 +0530

author
Ankit Vani <a@nevitus.org>
date
Mon, 02 Sep 2013 17:20:49 +0530
branch
soc.2013.gobjectification.plugins
changeset 36653
4084c34c051d
parent 36642
b8ba53daa445
child 36655
c4c1e8d8918a
permissions
-rw-r--r--

Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.

7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file ssl.c Main SSL plugin
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
4 * purple
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 *
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 #include "internal.h"
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "sslconn.h"
9943
b54a762f60fa [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 8993
diff changeset
26 #include "version.h"
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
31 static PurplePlugin *ssl_plugin = NULL;
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
36 PurplePlugin *plugin;
36501
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
37 GList *plugins, *l;
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 ssl_plugin = NULL;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
36501
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
41 plugins = purple_plugins_find_all();
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
42
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
43 for (l = plugins; l != NULL; l = l->next)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 {
36501
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
45 plugin = PURPLE_PLUGIN(l->data);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 if (plugin == my_plugin)
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 continue;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49
36501
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
50 if (strncmp(purple_plugin_info_get_id(purple_plugin_get_info(plugin)),
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
51 "ssl-", 4) == 0)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 {
36509
86e882c3cfdf Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
53 if (purple_plugin_load(plugin, NULL))
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 {
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 ssl_plugin = plugin;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 break;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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,
36653
4084c34c051d Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents: 36642
diff changeset
91 "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL,
36501
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
92 NULL
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
93 );
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 static gboolean
36501
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
97 plugin_load(PurplePlugin *plugin, GError **error)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 {
36501
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
99 return probe_ssl_plugins(plugin, error);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 static gboolean
36501
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
103 plugin_unload(PurplePlugin *plugin, GError **error)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 {
7040
a7560306d591 [gaim-migrate @ 7603]
Christian Hammond <chipx86@chipx86.com>
parents: 7016
diff changeset
105 if (ssl_plugin != NULL &&
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
106 g_list_find(purple_plugins_get_loaded(), ssl_plugin) != NULL)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 {
36509
86e882c3cfdf Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
108 if (!purple_plugin_unload(ssl_plugin, error))
86e882c3cfdf Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
109 return FALSE;
7040
a7560306d591 [gaim-migrate @ 7603]
Christian Hammond <chipx86@chipx86.com>
parents: 7016
diff changeset
110 }
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111
7040
a7560306d591 [gaim-migrate @ 7603]
Christian Hammond <chipx86@chipx86.com>
parents: 7016
diff changeset
112 ssl_plugin = NULL;
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 return TRUE;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116
36501
a7a71bf77f83 Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
117 PURPLE_PLUGIN_INIT(ssl, plugin_query, plugin_load, plugin_unload);

mercurial