Sat, 18 Sep 2004 23:17:38 +0000
[gaim-migrate @ 10999]
" Post all three of these to the sf patch tracker as
three separate patches and assign the buddy list
changes and oscar changes to me, and the
gaim_status_is_online() changes to Luke. And in the
one assigned to Luke, ask him if he could pretty please
with sugar on top check through it quickly and
commit it if it looks sensible?
--KingAnt
This adds gaim_status_is_online so that we can check
statuses as well as presences for online status. It
also changes gaim_presence_is_online to use the new
function." --Dave West
committer: Luke Schierer <lschiere@pidgin.im>
| 6703 | 1 | /** |
| 2 | * @file sslconn.c SSL API | |
| 3 | * @ingroup core | |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 8046 | 7 | * Gaim is the legal property of its developers, whose names are too numerous |
| 8 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 | * source distribution. | |
| 6703 | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | */ | |
| 25 | #include "internal.h" | |
| 26 | ||
| 27 | #include "debug.h" | |
| 28 | #include "sslconn.h" | |
| 29 | ||
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
30 | static gboolean _ssl_initialized = FALSE; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
31 | static GaimSslOps *_ssl_ops = NULL; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
32 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
33 | static gboolean |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
34 | ssl_init(void) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
35 | { |
|
7018
c441ecf99639
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
36 | GaimPlugin *plugin; |
|
7863
98ef7c137ea5
[gaim-migrate @ 8517]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7355
diff
changeset
|
37 | GaimSslOps *ops; |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
38 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
39 | if (_ssl_initialized) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
40 | return FALSE; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
41 | |
|
7024
45d9d705e258
[gaim-migrate @ 7587]
Christian Hammond <chipx86@chipx86.com>
parents:
7018
diff
changeset
|
42 | plugin = gaim_plugins_find_with_id("core-ssl"); |
|
7018
c441ecf99639
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
43 | |
|
c441ecf99639
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
44 | if (plugin != NULL && !gaim_plugin_is_loaded(plugin)) |
|
c441ecf99639
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
45 | gaim_plugin_load(plugin); |
|
c441ecf99639
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
46 | |
|
7863
98ef7c137ea5
[gaim-migrate @ 8517]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7355
diff
changeset
|
47 | ops = gaim_ssl_get_ops(); |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
48 | if (ops != NULL && ops->init != NULL) |
|
7863
98ef7c137ea5
[gaim-migrate @ 8517]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7355
diff
changeset
|
49 | return ops->init(); |
|
98ef7c137ea5
[gaim-migrate @ 8517]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7355
diff
changeset
|
50 | else |
|
98ef7c137ea5
[gaim-migrate @ 8517]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7355
diff
changeset
|
51 | return FALSE; |
| 6703 | 52 | } |
| 53 | ||
| 54 | gboolean | |
| 55 | gaim_ssl_is_supported(void) | |
| 56 | { | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
57 | #ifdef HAVE_SSL |
| 7355 | 58 | ssl_init(); |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
59 | return (gaim_ssl_get_ops() != NULL); |
| 6703 | 60 | #else |
| 61 | return FALSE; | |
| 62 | #endif | |
| 63 | } | |
| 64 | ||
| 65 | GaimSslConnection * | |
| 66 | gaim_ssl_connect(GaimAccount *account, const char *host, int port, | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
67 | GaimSslInputFunction func, GaimSslErrorFunction error_func, |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
68 | void *data) |
| 6703 | 69 | { |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
70 | GaimSslConnection *gsc; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
71 | GaimSslOps *ops; |
| 6703 | 72 | int i; |
| 73 | ||
| 74 | g_return_val_if_fail(host != NULL, NULL); | |
| 75 | g_return_val_if_fail(port != 0 && port != -1, NULL); | |
| 76 | g_return_val_if_fail(func != NULL, NULL); | |
| 77 | g_return_val_if_fail(gaim_ssl_is_supported(), NULL); | |
| 78 | ||
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
79 | ops = gaim_ssl_get_ops(); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
80 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
81 | g_return_val_if_fail(ops != NULL, NULL); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
82 | g_return_val_if_fail(ops->connect_cb != NULL, NULL); |
| 6703 | 83 | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
84 | if (!_ssl_initialized) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
85 | { |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
86 | if (!ssl_init()) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
87 | return NULL; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
88 | } |
| 6703 | 89 | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
90 | gsc = g_new0(GaimSslConnection, 1); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
91 | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
92 | gsc->host = g_strdup(host); |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
93 | gsc->port = port; |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
94 | gsc->connect_cb_data = data; |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
95 | gsc->connect_cb = func; |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
96 | gsc->error_cb = error_func; |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
97 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
98 | i = gaim_proxy_connect(account, host, port, ops->connect_cb, gsc); |
| 6703 | 99 | |
| 100 | if (i < 0) | |
| 101 | { | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
102 | g_free(gsc->host); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
103 | g_free(gsc); |
| 6703 | 104 | |
| 105 | return NULL; | |
| 106 | } | |
| 107 | ||
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
108 | return (GaimSslConnection *)gsc; |
| 6703 | 109 | } |
| 110 | ||
| 6764 | 111 | static void |
| 112 | recv_cb(gpointer data, gint source, GaimInputCondition cond) | |
| 113 | { | |
| 114 | GaimSslConnection *gsc = data; | |
| 115 | ||
| 116 | gsc->recv_cb(gsc->recv_cb_data, gsc, cond); | |
| 117 | } | |
| 118 | ||
| 119 | void | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
120 | gaim_ssl_input_add(GaimSslConnection *gsc, GaimSslInputFunction func, |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
121 | void *data) |
| 6764 | 122 | { |
| 123 | GaimSslOps *ops; | |
| 124 | ||
| 125 | g_return_if_fail(func != NULL); | |
| 126 | g_return_if_fail(gaim_ssl_is_supported()); | |
| 127 | ||
| 128 | ops = gaim_ssl_get_ops(); | |
| 129 | ||
| 130 | gsc->recv_cb_data = data; | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
131 | gsc->recv_cb = func; |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
132 | |
| 6764 | 133 | gsc->inpa = gaim_input_add(gsc->fd, GAIM_INPUT_READ, recv_cb, gsc); |
| 134 | } | |
| 135 | ||
|
6762
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
136 | GaimSslConnection * |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
137 | gaim_ssl_connect_fd(GaimAccount *account, int fd, |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
138 | GaimSslInputFunction func, |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
139 | GaimSslErrorFunction error_func, void *data) |
|
6762
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
140 | { |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
141 | GaimSslConnection *gsc; |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
142 | GaimSslOps *ops; |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
143 | |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
144 | g_return_val_if_fail(fd > 0, NULL); |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
145 | g_return_val_if_fail(func != NULL, NULL); |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
146 | g_return_val_if_fail(gaim_ssl_is_supported(), NULL); |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
147 | |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
148 | ops = gaim_ssl_get_ops(); |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
149 | |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
150 | g_return_val_if_fail(ops != NULL, NULL); |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
151 | g_return_val_if_fail(ops->connect_cb != NULL, NULL); |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
152 | |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
153 | if (!_ssl_initialized) |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
154 | { |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
155 | if (!ssl_init()) |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
156 | return NULL; |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
157 | } |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
158 | |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
159 | gsc = g_new0(GaimSslConnection, 1); |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
160 | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
161 | gsc->connect_cb_data = data; |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
162 | gsc->connect_cb = func; |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
163 | gsc->error_cb = error_func; |
|
6762
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
164 | |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
165 | ops->connect_cb(gsc, fd, GAIM_INPUT_READ); |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
166 | |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
167 | return (GaimSslConnection *)gsc; |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
168 | } |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
169 | |
| 6703 | 170 | void |
| 171 | gaim_ssl_close(GaimSslConnection *gsc) | |
| 172 | { | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
173 | GaimSslOps *ops; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
174 | |
| 6703 | 175 | g_return_if_fail(gsc != NULL); |
| 176 | ||
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
177 | ops = gaim_ssl_get_ops(); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
178 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
179 | if (gsc->inpa) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
180 | gaim_input_remove(gsc->inpa); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
181 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
182 | if (ops != NULL && ops->close != NULL) |
|
6745
68569c0a6865
[gaim-migrate @ 7277]
Herman Bloggs <herman@bluedigits.com>
parents:
6738
diff
changeset
|
183 | (ops->close)(gsc); |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
184 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
185 | if (gsc->fd) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
186 | close(gsc->fd); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
187 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
188 | if (gsc->host != NULL) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
189 | g_free(gsc->host); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
190 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
191 | g_free(gsc); |
| 6703 | 192 | } |
| 193 | ||
| 194 | size_t | |
| 195 | gaim_ssl_read(GaimSslConnection *gsc, void *data, size_t len) | |
| 196 | { | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
197 | GaimSslOps *ops; |
| 6703 | 198 | |
| 199 | g_return_val_if_fail(gsc != NULL, 0); | |
| 200 | g_return_val_if_fail(data != NULL, 0); | |
| 201 | g_return_val_if_fail(len > 0, 0); | |
| 202 | ||
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
203 | ops = gaim_ssl_get_ops(); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
204 | |
|
6745
68569c0a6865
[gaim-migrate @ 7277]
Herman Bloggs <herman@bluedigits.com>
parents:
6738
diff
changeset
|
205 | if (ops != NULL && (ops->read) != NULL) |
|
68569c0a6865
[gaim-migrate @ 7277]
Herman Bloggs <herman@bluedigits.com>
parents:
6738
diff
changeset
|
206 | return (ops->read)(gsc, data, len); |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
207 | |
| 6703 | 208 | return 0; |
| 209 | } | |
| 210 | ||
| 211 | size_t | |
| 212 | gaim_ssl_write(GaimSslConnection *gsc, const void *data, size_t len) | |
| 213 | { | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
214 | GaimSslOps *ops; |
| 6703 | 215 | |
| 216 | g_return_val_if_fail(gsc != NULL, 0); | |
| 217 | g_return_val_if_fail(data != NULL, 0); | |
| 218 | g_return_val_if_fail(len > 0, 0); | |
| 219 | ||
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
220 | ops = gaim_ssl_get_ops(); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
221 | |
|
6745
68569c0a6865
[gaim-migrate @ 7277]
Herman Bloggs <herman@bluedigits.com>
parents:
6738
diff
changeset
|
222 | if (ops != NULL && (ops->write) != NULL) |
|
68569c0a6865
[gaim-migrate @ 7277]
Herman Bloggs <herman@bluedigits.com>
parents:
6738
diff
changeset
|
223 | return (ops->write)(gsc, data, len); |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
224 | |
| 6703 | 225 | return 0; |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
226 | } |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
227 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
228 | void |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
229 | gaim_ssl_set_ops(GaimSslOps *ops) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
230 | { |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
231 | _ssl_ops = ops; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
232 | } |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
233 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
234 | GaimSslOps * |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
235 | gaim_ssl_get_ops(void) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
236 | { |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
237 | return _ssl_ops; |
| 6703 | 238 | } |
| 239 | ||
| 240 | void | |
| 241 | gaim_ssl_init(void) | |
| 242 | { | |
| 243 | } | |
| 244 | ||
| 245 | void | |
| 246 | gaim_ssl_uninit(void) | |
| 247 | { | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
248 | GaimSslOps *ops; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
249 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
250 | if (!_ssl_initialized) |
| 6703 | 251 | return; |
| 252 | ||
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
253 | ops = gaim_ssl_get_ops(); |
| 6703 | 254 | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
255 | if (ops != NULL && ops->uninit != NULL) |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
256 | ops->uninit(); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
257 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
258 | _ssl_initialized = FALSE; |
| 6703 | 259 | } |