comparison libpurple/connection.c @ 15853:c5487dd19e61

merge of '31ed92ba1b530f050510b4958686e3013ba4176c' and '41f65a78d919384ad599d73c656a367d92292a41'
author Evan Schoenberg <evan.s@dreskin.net>
date Tue, 20 Mar 2007 14:37:22 +0000
parents 5198bd455160 2edbd4fede72
children
comparison
equal deleted inserted replaced
15852:5198bd455160 15853:c5487dd19e61
1 /** 1 /**
2 * @file connection.c Connection API 2 * @file connection.c Connection API
3 * @ingroup core 3 * @ingroup core
4 * 4 *
5 * gaim 5 * purple
6 * 6 *
7 * Gaim is the legal property of its developers, whose names are too numerous 7 * Purple 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 8 * to list here. Please refer to the COPYRIGHT file distributed with this
9 * source distribution. 9 * source distribution.
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 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 12 * it under the terms of the GNU General Public License as published by
37 #include "signals.h" 37 #include "signals.h"
38 #include "util.h" 38 #include "util.h"
39 39
40 static GList *connections = NULL; 40 static GList *connections = NULL;
41 static GList *connections_connecting = NULL; 41 static GList *connections_connecting = NULL;
42 static GaimConnectionUiOps *connection_ui_ops = NULL; 42 static PurpleConnectionUiOps *connection_ui_ops = NULL;
43 43
44 static int connections_handle; 44 static int connections_handle;
45 45
46 static gboolean 46 static gboolean
47 send_keepalive(gpointer data) 47 send_keepalive(gpointer data)
48 { 48 {
49 GaimConnection *gc = data; 49 PurpleConnection *gc = data;
50 GaimPluginProtocolInfo *prpl_info = NULL; 50 PurplePluginProtocolInfo *prpl_info = NULL;
51 51
52 if (gc != NULL && gc->prpl != NULL) 52 if (gc != NULL && gc->prpl != NULL)
53 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 53 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
54 54
55 if (prpl_info && prpl_info->keepalive) 55 if (prpl_info && prpl_info->keepalive)
56 prpl_info->keepalive(gc); 56 prpl_info->keepalive(gc);
57 57
58 return TRUE; 58 return TRUE;
59 } 59 }
60 60
61 static void 61 static void
62 update_keepalive(GaimConnection *gc, gboolean on) 62 update_keepalive(PurpleConnection *gc, gboolean on)
63 { 63 {
64 GaimPluginProtocolInfo *prpl_info = NULL; 64 PurplePluginProtocolInfo *prpl_info = NULL;
65 65
66 if (gc != NULL && gc->prpl != NULL) 66 if (gc != NULL && gc->prpl != NULL)
67 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 67 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
68 68
69 if (!prpl_info || !prpl_info->keepalive) 69 if (!prpl_info || !prpl_info->keepalive)
70 return; 70 return;
71 71
72 if (on && !gc->keepalive) 72 if (on && !gc->keepalive)
73 { 73 {
74 gaim_debug_info("connection", "Activating keepalive.\n"); 74 purple_debug_info("connection", "Activating keepalive.\n");
75 gc->keepalive = gaim_timeout_add(30000, send_keepalive, gc); 75 gc->keepalive = purple_timeout_add(30000, send_keepalive, gc);
76 } 76 }
77 else if (!on && gc->keepalive > 0) 77 else if (!on && gc->keepalive > 0)
78 { 78 {
79 gaim_debug_info("connection", "Deactivating keepalive.\n"); 79 purple_debug_info("connection", "Deactivating keepalive.\n");
80 gaim_timeout_remove(gc->keepalive); 80 purple_timeout_remove(gc->keepalive);
81 gc->keepalive = 0; 81 gc->keepalive = 0;
82 } 82 }
83 } 83 }
84 84
85 void 85 void
86 gaim_connection_new(GaimAccount *account, gboolean regist, const char *password) 86 purple_connection_new(PurpleAccount *account, gboolean regist, const char *password)
87 { 87 {
88 GaimConnection *gc; 88 PurpleConnection *gc;
89 GaimPlugin *prpl; 89 PurplePlugin *prpl;
90 GaimPluginProtocolInfo *prpl_info; 90 PurplePluginProtocolInfo *prpl_info;
91 91
92 g_return_if_fail(account != NULL); 92 g_return_if_fail(account != NULL);
93 93
94 if (!gaim_account_is_disconnected(account)) 94 if (!purple_account_is_disconnected(account))
95 return; 95 return;
96 96
97 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); 97 prpl = purple_find_prpl(purple_account_get_protocol_id(account));
98 98
99 if (prpl != NULL) 99 if (prpl != NULL)
100 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); 100 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
101 else { 101 else {
102 gchar *message; 102 gchar *message;
103 103
104 message = g_strdup_printf(_("Missing protocol plugin for %s"), 104 message = g_strdup_printf(_("Missing protocol plugin for %s"),
105 gaim_account_get_username(account)); 105 purple_account_get_username(account));
106 gaim_notify_error(NULL, regist ? _("Registration Error") : 106 purple_notify_error(NULL, regist ? _("Registration Error") :
107 _("Connection Error"), message, NULL); 107 _("Connection Error"), message, NULL);
108 g_free(message); 108 g_free(message);
109 return; 109 return;
110 } 110 }
111 111
118 { 118 {
119 if (((password == NULL) || (*password == '\0')) && 119 if (((password == NULL) || (*password == '\0')) &&
120 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && 120 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
121 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) 121 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
122 { 122 {
123 gaim_debug_error("connection", "Can not connect to account %s without " 123 purple_debug_error("connection", "Can not connect to account %s without "
124 "a password.\n", gaim_account_get_username(account)); 124 "a password.\n", purple_account_get_username(account));
125 return; 125 return;
126 } 126 }
127 } 127 }
128 128
129 gc = g_new0(GaimConnection, 1); 129 gc = g_new0(PurpleConnection, 1);
130 GAIM_DBUS_REGISTER_POINTER(gc, GaimConnection); 130 PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection);
131 131
132 gc->prpl = prpl; 132 gc->prpl = prpl;
133 if ((password != NULL) && (*password != '\0')) 133 if ((password != NULL) && (*password != '\0'))
134 gc->password = g_strdup(password); 134 gc->password = g_strdup(password);
135 gaim_connection_set_account(gc, account); 135 purple_connection_set_account(gc, account);
136 gaim_connection_set_state(gc, GAIM_CONNECTING); 136 purple_connection_set_state(gc, PURPLE_CONNECTING);
137 connections = g_list_append(connections, gc); 137 connections = g_list_append(connections, gc);
138 gaim_account_set_connection(account, gc); 138 purple_account_set_connection(account, gc);
139 139
140 gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc); 140 purple_signal_emit(purple_connections_get_handle(), "signing-on", gc);
141 141
142 if (regist) 142 if (regist)
143 { 143 {
144 gaim_debug_info("connection", "Registering. gc = %p\n", gc); 144 purple_debug_info("connection", "Registering. gc = %p\n", gc);
145 145
146 /* set this so we don't auto-reconnect after registering */ 146 /* set this so we don't auto-reconnect after registering */
147 gc->wants_to_die = TRUE; 147 gc->wants_to_die = TRUE;
148 148
149 prpl_info->register_user(account); 149 prpl_info->register_user(account);
150 } 150 }
151 else 151 else
152 { 152 {
153 gaim_debug_info("connection", "Connecting. gc = %p\n", gc); 153 purple_debug_info("connection", "Connecting. gc = %p\n", gc);
154 154
155 gaim_signal_emit(gaim_accounts_get_handle(), "account-connecting", account); 155 purple_signal_emit(purple_accounts_get_handle(), "account-connecting", account);
156 prpl_info->login(account); 156 prpl_info->login(account);
157 } 157 }
158 } 158 }
159 159
160 void 160 void
161 gaim_connection_destroy(GaimConnection *gc) 161 purple_connection_destroy(PurpleConnection *gc)
162 { 162 {
163 GaimAccount *account; 163 PurpleAccount *account;
164 GSList *buddies, *tmp; 164 GSList *buddies, *tmp;
165 #if 0 165 #if 0
166 GList *wins; 166 GList *wins;
167 #endif 167 #endif
168 GaimPluginProtocolInfo *prpl_info = NULL; 168 PurplePluginProtocolInfo *prpl_info = NULL;
169 gboolean remove = FALSE; 169 gboolean remove = FALSE;
170 170
171 g_return_if_fail(gc != NULL); 171 g_return_if_fail(gc != NULL);
172 172
173 account = gaim_connection_get_account(gc); 173 account = purple_connection_get_account(gc);
174 174
175 gaim_debug_info("connection", "Disconnecting connection %p\n", gc); 175 purple_debug_info("connection", "Disconnecting connection %p\n", gc);
176 176
177 if (gaim_connection_get_state(gc) != GAIM_CONNECTING) 177 if (purple_connection_get_state(gc) != PURPLE_CONNECTING)
178 remove = TRUE; 178 remove = TRUE;
179 179
180 gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc); 180 purple_signal_emit(purple_connections_get_handle(), "signing-off", gc);
181 181
182 while (gc->buddy_chats) 182 while (gc->buddy_chats)
183 { 183 {
184 GaimConversation *b = gc->buddy_chats->data; 184 PurpleConversation *b = gc->buddy_chats->data;
185 185
186 gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); 186 gc->buddy_chats = g_slist_remove(gc->buddy_chats, b);
187 gaim_conv_chat_left(GAIM_CONV_CHAT(b)); 187 purple_conv_chat_left(PURPLE_CONV_CHAT(b));
188 } 188 }
189 189
190 update_keepalive(gc, FALSE); 190 update_keepalive(gc, FALSE);
191 191
192 gaim_proxy_connect_cancel_with_handle(gc); 192 purple_proxy_connect_cancel_with_handle(gc);
193 193
194 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 194 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
195 if (prpl_info->close) 195 if (prpl_info->close)
196 (prpl_info->close)(gc); 196 (prpl_info->close)(gc);
197 197
198 /* Clear out the proto data that was freed in the prpl close method*/ 198 /* Clear out the proto data that was freed in the prpl close method*/
199 buddies = gaim_find_buddies(account, NULL); 199 buddies = purple_find_buddies(account, NULL);
200 for (tmp = buddies; tmp; tmp = tmp->next) { 200 for (tmp = buddies; tmp; tmp = tmp->next) {
201 GaimBuddy *buddy = tmp->data; 201 PurpleBuddy *buddy = tmp->data;
202 buddy->proto_data = NULL; 202 buddy->proto_data = NULL;
203 } 203 }
204 g_slist_free(buddies); 204 g_slist_free(buddies);
205 205
206 connections = g_list_remove(connections, gc); 206 connections = g_list_remove(connections, gc);
207 207
208 gaim_connection_set_state(gc, GAIM_DISCONNECTED); 208 purple_connection_set_state(gc, PURPLE_DISCONNECTED);
209 209
210 if (remove) 210 if (remove)
211 gaim_blist_remove_account(account); 211 purple_blist_remove_account(account);
212 212
213 gaim_signal_emit(gaim_connections_get_handle(), "signed-off", gc); 213 purple_signal_emit(purple_connections_get_handle(), "signed-off", gc);
214 214
215 #if 0 215 #if 0
216 /* see comment later in file on if 0'd same code */ 216 /* see comment later in file on if 0'd same code */
217 /* 217 /*
218 * XXX This is a hack! Remove this and replace it with a better event 218 * XXX This is a hack! Remove this and replace it with a better event
219 * notification system. 219 * notification system.
220 */ 220 */
221 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { 221 for (wins = purple_get_windows(); wins != NULL; wins = wins->next) {
222 GaimConvWindow *win = (GaimConvWindow *)wins->data; 222 PurpleConvWindow *win = (PurpleConvWindow *)wins->data;
223 gaim_conversation_update(gaim_conv_window_get_conversation_at(win, 0), 223 purple_conversation_update(purple_conv_window_get_conversation_at(win, 0),
224 GAIM_CONV_ACCOUNT_OFFLINE); 224 PURPLE_CONV_ACCOUNT_OFFLINE);
225 } 225 }
226 #endif 226 #endif
227 227
228 gaim_account_request_close_with_account(account); 228 purple_account_request_close_with_account(account);
229 gaim_request_close_with_handle(gc); 229 purple_request_close_with_handle(gc);
230 gaim_notify_close_with_handle(gc); 230 purple_notify_close_with_handle(gc);
231 231
232 gaim_debug_info("connection", "Destroying connection %p\n", gc); 232 purple_debug_info("connection", "Destroying connection %p\n", gc);
233 233
234 gaim_account_set_connection(account, NULL); 234 purple_account_set_connection(account, NULL);
235 235
236 g_free(gc->password); 236 g_free(gc->password);
237 g_free(gc->display_name); 237 g_free(gc->display_name);
238 238
239 if (gc->disconnect_timeout) 239 if (gc->disconnect_timeout)
240 gaim_timeout_remove(gc->disconnect_timeout); 240 purple_timeout_remove(gc->disconnect_timeout);
241 241
242 GAIM_DBUS_UNREGISTER_POINTER(gc); 242 PURPLE_DBUS_UNREGISTER_POINTER(gc);
243 g_free(gc); 243 g_free(gc);
244 } 244 }
245 245
246 /* 246 /*
247 * d:)->-< 247 * d:)->-<
252 * 252 *
253 * d8D->-< DANCE! 253 * d8D->-< DANCE!
254 */ 254 */
255 255
256 void 256 void
257 gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state) 257 purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state)
258 { 258 {
259 GaimConnectionUiOps *ops; 259 PurpleConnectionUiOps *ops;
260 260
261 g_return_if_fail(gc != NULL); 261 g_return_if_fail(gc != NULL);
262 262
263 if (gc->state == state) 263 if (gc->state == state)
264 return; 264 return;
265 265
266 gc->state = state; 266 gc->state = state;
267 267
268 ops = gaim_connections_get_ui_ops(); 268 ops = purple_connections_get_ui_ops();
269 269
270 if (gc->state == GAIM_CONNECTING) { 270 if (gc->state == PURPLE_CONNECTING) {
271 connections_connecting = g_list_append(connections_connecting, gc); 271 connections_connecting = g_list_append(connections_connecting, gc);
272 } 272 }
273 else { 273 else {
274 connections_connecting = g_list_remove(connections_connecting, gc); 274 connections_connecting = g_list_remove(connections_connecting, gc);
275 } 275 }
276 276
277 if (gc->state == GAIM_CONNECTED) { 277 if (gc->state == PURPLE_CONNECTED) {
278 GaimAccount *account; 278 PurpleAccount *account;
279 GaimPresence *presence; 279 PurplePresence *presence;
280 280
281 account = gaim_connection_get_account(gc); 281 account = purple_connection_get_account(gc);
282 presence = gaim_account_get_presence(account); 282 presence = purple_account_get_presence(account);
283 283
284 /* Set the time the account came online */ 284 /* Set the time the account came online */
285 gaim_presence_set_login_time(presence, time(NULL)); 285 purple_presence_set_login_time(presence, time(NULL));
286 286
287 if (gaim_prefs_get_bool("/core/logging/log_system")) 287 if (purple_prefs_get_bool("/core/logging/log_system"))
288 { 288 {
289 GaimLog *log = gaim_account_get_log(account, TRUE); 289 PurpleLog *log = purple_account_get_log(account, TRUE);
290 290
291 if (log != NULL) 291 if (log != NULL)
292 { 292 {
293 char *msg = g_strdup_printf(_("+++ %s signed on"), 293 char *msg = g_strdup_printf(_("+++ %s signed on"),
294 gaim_account_get_username(account)); 294 purple_account_get_username(account));
295 gaim_log_write(log, GAIM_MESSAGE_SYSTEM, 295 purple_log_write(log, PURPLE_MESSAGE_SYSTEM,
296 gaim_account_get_username(account), 296 purple_account_get_username(account),
297 gaim_presence_get_login_time(presence), 297 purple_presence_get_login_time(presence),
298 msg); 298 msg);
299 g_free(msg); 299 g_free(msg);
300 } 300 }
301 } 301 }
302 302
303 if (ops != NULL && ops->connected != NULL) 303 if (ops != NULL && ops->connected != NULL)
304 ops->connected(gc); 304 ops->connected(gc);
305 305
306 gaim_blist_add_account(account); 306 purple_blist_add_account(account);
307 307
308 gaim_signal_emit(gaim_connections_get_handle(), "signed-on", gc); 308 purple_signal_emit(purple_connections_get_handle(), "signed-on", gc);
309 309
310 serv_set_permit_deny(gc); 310 serv_set_permit_deny(gc);
311 311
312 update_keepalive(gc, TRUE); 312 update_keepalive(gc, TRUE);
313 } 313 }
314 else if (gc->state == GAIM_DISCONNECTED) { 314 else if (gc->state == PURPLE_DISCONNECTED) {
315 GaimAccount *account = gaim_connection_get_account(gc); 315 PurpleAccount *account = purple_connection_get_account(gc);
316 316
317 if (gaim_prefs_get_bool("/core/logging/log_system")) 317 if (purple_prefs_get_bool("/core/logging/log_system"))
318 { 318 {
319 GaimLog *log = gaim_account_get_log(account, FALSE); 319 PurpleLog *log = purple_account_get_log(account, FALSE);
320 320
321 if (log != NULL) 321 if (log != NULL)
322 { 322 {
323 char *msg = g_strdup_printf(_("+++ %s signed off"), 323 char *msg = g_strdup_printf(_("+++ %s signed off"),
324 gaim_account_get_username(account)); 324 purple_account_get_username(account));
325 gaim_log_write(log, GAIM_MESSAGE_SYSTEM, 325 purple_log_write(log, PURPLE_MESSAGE_SYSTEM,
326 gaim_account_get_username(account), time(NULL), 326 purple_account_get_username(account), time(NULL),
327 msg); 327 msg);
328 g_free(msg); 328 g_free(msg);
329 } 329 }
330 } 330 }
331 331
332 gaim_account_destroy_log(account); 332 purple_account_destroy_log(account);
333 333
334 if (ops != NULL && ops->disconnected != NULL) 334 if (ops != NULL && ops->disconnected != NULL)
335 ops->disconnected(gc); 335 ops->disconnected(gc);
336 } 336 }
337 } 337 }
338 338
339 void 339 void
340 gaim_connection_set_account(GaimConnection *gc, GaimAccount *account) 340 purple_connection_set_account(PurpleConnection *gc, PurpleAccount *account)
341 { 341 {
342 g_return_if_fail(gc != NULL); 342 g_return_if_fail(gc != NULL);
343 g_return_if_fail(account != NULL); 343 g_return_if_fail(account != NULL);
344 344
345 gc->account = account; 345 gc->account = account;
346 } 346 }
347 347
348 void 348 void
349 gaim_connection_set_display_name(GaimConnection *gc, const char *name) 349 purple_connection_set_display_name(PurpleConnection *gc, const char *name)
350 { 350 {
351 g_return_if_fail(gc != NULL); 351 g_return_if_fail(gc != NULL);
352 352
353 g_free(gc->display_name); 353 g_free(gc->display_name);
354 gc->display_name = g_strdup(name); 354 gc->display_name = g_strdup(name);
355 } 355 }
356 356
357 GaimConnectionState 357 PurpleConnectionState
358 gaim_connection_get_state(const GaimConnection *gc) 358 purple_connection_get_state(const PurpleConnection *gc)
359 { 359 {
360 g_return_val_if_fail(gc != NULL, GAIM_DISCONNECTED); 360 g_return_val_if_fail(gc != NULL, PURPLE_DISCONNECTED);
361 361
362 return gc->state; 362 return gc->state;
363 } 363 }
364 364
365 GaimAccount * 365 PurpleAccount *
366 gaim_connection_get_account(const GaimConnection *gc) 366 purple_connection_get_account(const PurpleConnection *gc)
367 { 367 {
368 g_return_val_if_fail(gc != NULL, NULL); 368 g_return_val_if_fail(gc != NULL, NULL);
369 369
370 return gc->account; 370 return gc->account;
371 } 371 }
372 372
373 const char * 373 const char *
374 gaim_connection_get_password(const GaimConnection *gc) 374 purple_connection_get_password(const PurpleConnection *gc)
375 { 375 {
376 g_return_val_if_fail(gc != NULL, NULL); 376 g_return_val_if_fail(gc != NULL, NULL);
377 377
378 return gc->password; 378 return gc->password;
379 } 379 }
380 380
381 const char * 381 const char *
382 gaim_connection_get_display_name(const GaimConnection *gc) 382 purple_connection_get_display_name(const PurpleConnection *gc)
383 { 383 {
384 g_return_val_if_fail(gc != NULL, NULL); 384 g_return_val_if_fail(gc != NULL, NULL);
385 385
386 return gc->display_name; 386 return gc->display_name;
387 } 387 }
388 388
389 void 389 void
390 gaim_connection_update_progress(GaimConnection *gc, const char *text, 390 purple_connection_update_progress(PurpleConnection *gc, const char *text,
391 size_t step, size_t count) 391 size_t step, size_t count)
392 { 392 {
393 GaimConnectionUiOps *ops; 393 PurpleConnectionUiOps *ops;
394 394
395 g_return_if_fail(gc != NULL); 395 g_return_if_fail(gc != NULL);
396 g_return_if_fail(text != NULL); 396 g_return_if_fail(text != NULL);
397 g_return_if_fail(step < count); 397 g_return_if_fail(step < count);
398 g_return_if_fail(count > 1); 398 g_return_if_fail(count > 1);
399 399
400 ops = gaim_connections_get_ui_ops(); 400 ops = purple_connections_get_ui_ops();
401 401
402 if (ops != NULL && ops->connect_progress != NULL) 402 if (ops != NULL && ops->connect_progress != NULL)
403 ops->connect_progress(gc, text, step, count); 403 ops->connect_progress(gc, text, step, count);
404 } 404 }
405 405
406 void 406 void
407 gaim_connection_notice(GaimConnection *gc, const char *text) 407 purple_connection_notice(PurpleConnection *gc, const char *text)
408 { 408 {
409 GaimConnectionUiOps *ops; 409 PurpleConnectionUiOps *ops;
410 410
411 g_return_if_fail(gc != NULL); 411 g_return_if_fail(gc != NULL);
412 g_return_if_fail(text != NULL); 412 g_return_if_fail(text != NULL);
413 413
414 ops = gaim_connections_get_ui_ops(); 414 ops = purple_connections_get_ui_ops();
415 415
416 if (ops != NULL && ops->notice != NULL) 416 if (ops != NULL && ops->notice != NULL)
417 ops->notice(gc, text); 417 ops->notice(gc, text);
418 } 418 }
419 419
420 static gboolean 420 static gboolean
421 gaim_connection_disconnect_cb(gpointer data) 421 purple_connection_disconnect_cb(gpointer data)
422 { 422 {
423 GaimAccount *account = data; 423 PurpleAccount *account = data;
424 char *password = g_strdup(gaim_account_get_password(account)); 424 char *password = g_strdup(purple_account_get_password(account));
425 gaim_account_disconnect(account); 425 purple_account_disconnect(account);
426 gaim_account_set_password(account, password); 426 purple_account_set_password(account, password);
427 g_free(password); 427 g_free(password);
428 return FALSE; 428 return FALSE;
429 } 429 }
430 430
431 void 431 void
432 gaim_connection_error(GaimConnection *gc, const char *text) 432 purple_connection_error(PurpleConnection *gc, const char *text)
433 { 433 {
434 GaimConnectionUiOps *ops; 434 PurpleConnectionUiOps *ops;
435 435
436 g_return_if_fail(gc != NULL); 436 g_return_if_fail(gc != NULL);
437 437
438 if (text == NULL) { 438 if (text == NULL) {
439 g_critical("gaim_connection_error: check `text != NULL' failed"); 439 g_critical("purple_connection_error: check `text != NULL' failed");
440 text = _("Unknown error"); 440 text = _("Unknown error");
441 } 441 }
442 442
443 /* If we've already got one error, we don't need any more */ 443 /* If we've already got one error, we don't need any more */
444 if (gc->disconnect_timeout) 444 if (gc->disconnect_timeout)
445 return; 445 return;
446 446
447 ops = gaim_connections_get_ui_ops(); 447 ops = purple_connections_get_ui_ops();
448 448
449 if (ops != NULL && ops->report_disconnect != NULL) 449 if (ops != NULL && ops->report_disconnect != NULL)
450 ops->report_disconnect(gc, text); 450 ops->report_disconnect(gc, text);
451 451
452 gc->disconnect_timeout = gaim_timeout_add(0, gaim_connection_disconnect_cb, 452 gc->disconnect_timeout = purple_timeout_add(0, purple_connection_disconnect_cb,
453 gaim_connection_get_account(gc)); 453 purple_connection_get_account(gc));
454 } 454 }
455 455
456 void 456 void
457 gaim_connections_disconnect_all(void) 457 purple_connections_disconnect_all(void)
458 { 458 {
459 GList *l; 459 GList *l;
460 GaimConnection *gc; 460 PurpleConnection *gc;
461 461
462 while ((l = gaim_connections_get_all()) != NULL) { 462 while ((l = purple_connections_get_all()) != NULL) {
463 gc = l->data; 463 gc = l->data;
464 gc->wants_to_die = TRUE; 464 gc->wants_to_die = TRUE;
465 gaim_account_disconnect(gc->account); 465 purple_account_disconnect(gc->account);
466 } 466 }
467 } 467 }
468 468
469 GList * 469 GList *
470 gaim_connections_get_all(void) 470 purple_connections_get_all(void)
471 { 471 {
472 return connections; 472 return connections;
473 } 473 }
474 474
475 GList * 475 GList *
476 gaim_connections_get_connecting(void) 476 purple_connections_get_connecting(void)
477 { 477 {
478 return connections_connecting; 478 return connections_connecting;
479 } 479 }
480 480
481 void 481 void
482 gaim_connections_set_ui_ops(GaimConnectionUiOps *ops) 482 purple_connections_set_ui_ops(PurpleConnectionUiOps *ops)
483 { 483 {
484 connection_ui_ops = ops; 484 connection_ui_ops = ops;
485 } 485 }
486 486
487 GaimConnectionUiOps * 487 PurpleConnectionUiOps *
488 gaim_connections_get_ui_ops(void) 488 purple_connections_get_ui_ops(void)
489 { 489 {
490 return connection_ui_ops; 490 return connection_ui_ops;
491 } 491 }
492 492
493 void 493 void
494 gaim_connections_init(void) 494 purple_connections_init(void)
495 { 495 {
496 void *handle = gaim_connections_get_handle(); 496 void *handle = purple_connections_get_handle();
497 497
498 gaim_signal_register(handle, "signing-on", 498 purple_signal_register(handle, "signing-on",
499 gaim_marshal_VOID__POINTER, NULL, 1, 499 purple_marshal_VOID__POINTER, NULL, 1,
500 gaim_value_new(GAIM_TYPE_SUBTYPE, 500 purple_value_new(PURPLE_TYPE_SUBTYPE,
501 GAIM_SUBTYPE_CONNECTION)); 501 PURPLE_SUBTYPE_CONNECTION));
502 502
503 gaim_signal_register(handle, "signed-on", 503 purple_signal_register(handle, "signed-on",
504 gaim_marshal_VOID__POINTER, NULL, 1, 504 purple_marshal_VOID__POINTER, NULL, 1,
505 gaim_value_new(GAIM_TYPE_SUBTYPE, 505 purple_value_new(PURPLE_TYPE_SUBTYPE,
506 GAIM_SUBTYPE_CONNECTION)); 506 PURPLE_SUBTYPE_CONNECTION));
507 507
508 gaim_signal_register(handle, "signing-off", 508 purple_signal_register(handle, "signing-off",
509 gaim_marshal_VOID__POINTER, NULL, 1, 509 purple_marshal_VOID__POINTER, NULL, 1,
510 gaim_value_new(GAIM_TYPE_SUBTYPE, 510 purple_value_new(PURPLE_TYPE_SUBTYPE,
511 GAIM_SUBTYPE_CONNECTION)); 511 PURPLE_SUBTYPE_CONNECTION));
512 512
513 gaim_signal_register(handle, "signed-off", 513 purple_signal_register(handle, "signed-off",
514 gaim_marshal_VOID__POINTER, NULL, 1, 514 purple_marshal_VOID__POINTER, NULL, 1,
515 gaim_value_new(GAIM_TYPE_SUBTYPE, 515 purple_value_new(PURPLE_TYPE_SUBTYPE,
516 GAIM_SUBTYPE_CONNECTION)); 516 PURPLE_SUBTYPE_CONNECTION));
517 } 517 }
518 518
519 void 519 void
520 gaim_connections_uninit(void) 520 purple_connections_uninit(void)
521 { 521 {
522 gaim_signals_unregister_by_instance(gaim_connections_get_handle()); 522 purple_signals_unregister_by_instance(purple_connections_get_handle());
523 } 523 }
524 524
525 void * 525 void *
526 gaim_connections_get_handle(void) 526 purple_connections_get_handle(void)
527 { 527 {
528 return &connections_handle; 528 return &connections_handle;
529 } 529 }