comparison src/sslconn.c @ 7274:448e39ace278

[gaim-migrate @ 7851] Added a parameter to gaim_ssl_connect() to specify an optional error callback. MSN takes advantage of it, but since I can't reproduce the errors here, I'm not positive it works. It should though! Famous last words. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 15 Oct 2003 06:32:13 +0000
parents 001d11a7e345
children ef0684dfdf74
comparison
equal deleted inserted replaced
7273:d152ea377e4a 7274:448e39ace278
61 #endif 61 #endif
62 } 62 }
63 63
64 GaimSslConnection * 64 GaimSslConnection *
65 gaim_ssl_connect(GaimAccount *account, const char *host, int port, 65 gaim_ssl_connect(GaimAccount *account, const char *host, int port,
66 GaimSslInputFunction func, void *data) 66 GaimSslInputFunction func, GaimSslErrorFunction error_func,
67 void *data)
67 { 68 {
68 GaimSslConnection *gsc; 69 GaimSslConnection *gsc;
69 GaimSslOps *ops; 70 GaimSslOps *ops;
70 int i; 71 int i;
71 72
85 return NULL; 86 return NULL;
86 } 87 }
87 88
88 gsc = g_new0(GaimSslConnection, 1); 89 gsc = g_new0(GaimSslConnection, 1);
89 90
90 gsc->host = g_strdup(host); 91 gsc->host = g_strdup(host);
91 gsc->port = port; 92 gsc->port = port;
92 gsc->connect_cb_data = data; 93 gsc->connect_cb_data = data;
93 gsc->connect_cb = func; 94 gsc->connect_cb = func;
95 gsc->error_cb = error_func;
94 96
95 i = gaim_proxy_connect(account, host, port, ops->connect_cb, gsc); 97 i = gaim_proxy_connect(account, host, port, ops->connect_cb, gsc);
96 98
97 if (i < 0) 99 if (i < 0)
98 { 100 {
112 114
113 gsc->recv_cb(gsc->recv_cb_data, gsc, cond); 115 gsc->recv_cb(gsc->recv_cb_data, gsc, cond);
114 } 116 }
115 117
116 void 118 void
117 gaim_ssl_input_add(GaimSslConnection *gsc, GaimSslInputFunction func, void *data) 119 gaim_ssl_input_add(GaimSslConnection *gsc, GaimSslInputFunction func,
120 void *data)
118 { 121 {
119 GaimSslOps *ops; 122 GaimSslOps *ops;
120 123
121 g_return_if_fail(func != NULL); 124 g_return_if_fail(func != NULL);
122 g_return_if_fail(gaim_ssl_is_supported()); 125 g_return_if_fail(gaim_ssl_is_supported());
123 126
124 ops = gaim_ssl_get_ops(); 127 ops = gaim_ssl_get_ops();
125 128
126 gsc->recv_cb_data = data; 129 gsc->recv_cb_data = data;
127 gsc->recv_cb = func; 130 gsc->recv_cb = func;
131
128 gsc->inpa = gaim_input_add(gsc->fd, GAIM_INPUT_READ, recv_cb, gsc); 132 gsc->inpa = gaim_input_add(gsc->fd, GAIM_INPUT_READ, recv_cb, gsc);
129 } 133 }
130 134
131 GaimSslConnection * 135 GaimSslConnection *
132 gaim_ssl_connect_fd(GaimAccount *account, int fd, 136 gaim_ssl_connect_fd(GaimAccount *account, int fd,
133 GaimSslInputFunction func, void *data) 137 GaimSslInputFunction func,
138 GaimSslErrorFunction error_func, void *data)
134 { 139 {
135 GaimSslConnection *gsc; 140 GaimSslConnection *gsc;
136 GaimSslOps *ops; 141 GaimSslOps *ops;
137 142
138 g_return_val_if_fail(fd > 0, NULL); 143 g_return_val_if_fail(fd > 0, NULL);
150 return NULL; 155 return NULL;
151 } 156 }
152 157
153 gsc = g_new0(GaimSslConnection, 1); 158 gsc = g_new0(GaimSslConnection, 1);
154 159
155 gsc->connect_cb_data = data; 160 gsc->connect_cb_data = data;
156 gsc->connect_cb = func; 161 gsc->connect_cb = func;
162 gsc->error_cb = error_func;
157 163
158 ops->connect_cb(gsc, fd, GAIM_INPUT_READ); 164 ops->connect_cb(gsc, fd, GAIM_INPUT_READ);
159 165
160 return (GaimSslConnection *)gsc; 166 return (GaimSslConnection *)gsc;
161 } 167 }