comparison src/connection.c @ 6485:70d5122bc3ff

[gaim-migrate @ 6999] Removed the old event system and replaced it with a much better signal system. There will most likely be some bugs in this, but it seems to be working for now. Plugins can now generate their own signals, and other plugins can find those plugins and connect to them. This could give plugins a form of IPC. It's also useful for other things. It's rather flexible, except for the damn marshalling, but there's no way around that that I or the glib people can see. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 18 Aug 2003 01:03:43 +0000
parents 4aa3b1cec52b
children c8e31153eea7
comparison
equal deleted inserted replaced
6484:5ced8e111473 6485:70d5122bc3ff
27 #include "log.h" 27 #include "log.h"
28 #include "notify.h" 28 #include "notify.h"
29 #include "prefs.h" 29 #include "prefs.h"
30 #include "request.h" 30 #include "request.h"
31 #include "server.h" 31 #include "server.h"
32 #include "signals.h"
32 #include "sound.h" 33 #include "sound.h"
33 #include "util.h" 34 #include "util.h"
34 35
35 static GList *connections = NULL; 36 static GList *connections = NULL;
36 static GList *connections_connecting = NULL; 37 static GList *connections_connecting = NULL;
37 static GaimConnectionUiOps *connection_ui_ops = NULL; 38 static GaimConnectionUiOps *connection_ui_ops = NULL;
38 39
40 static int connections_handle;
39 41
40 GaimConnection * 42 GaimConnection *
41 gaim_connection_new(GaimAccount *account) 43 gaim_connection_new(GaimAccount *account)
42 { 44 {
43 GaimConnection *gc; 45 GaimConnection *gc;
149 return; 151 return;
150 } 152 }
151 153
152 gaim_connection_set_state(gc, GAIM_CONNECTING); 154 gaim_connection_set_state(gc, GAIM_CONNECTING);
153 155
156 gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc);
157
154 gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling serv_login\n"); 158 gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling serv_login\n");
155 159
156 connections = g_list_append(connections, gc); 160 connections = g_list_append(connections, gc);
157 161
158 serv_login(account); 162 serv_login(account);
178 182
179 if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) { 183 if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) {
180 if (gaim_connection_get_state(gc) != GAIM_CONNECTING) 184 if (gaim_connection_get_state(gc) != GAIM_CONNECTING)
181 gaim_blist_remove_account(gaim_connection_get_account(gc)); 185 gaim_blist_remove_account(gaim_connection_get_account(gc));
182 186
187 gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc);
188
183 serv_close(gc); 189 serv_close(gc);
184 190
185 connections = g_list_remove(connections, gc); 191 connections = g_list_remove(connections, gc);
186 192
187 gaim_connection_set_state(gc, GAIM_DISCONNECTED); 193 gaim_connection_set_state(gc, GAIM_DISCONNECTED);
188 194
189 gaim_event_broadcast(event_signoff, gc); 195 gaim_signal_emit(gaim_connections_get_handle(), "signed-off", gc);
196
190 system_log(log_signoff, gc, NULL, 197 system_log(log_signoff, gc, NULL,
191 OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); 198 OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON);
192 199
193 /* 200 /*
194 * XXX This is a hack! Remove this and replace it with a better event 201 * XXX This is a hack! Remove this and replace it with a better event
272 GaimWindow *win = (GaimWindow *)wins->data; 279 GaimWindow *win = (GaimWindow *)wins->data;
273 gaim_conversation_update(gaim_window_get_conversation_at(win, 0), 280 gaim_conversation_update(gaim_window_get_conversation_at(win, 0),
274 GAIM_CONV_ACCOUNT_ONLINE); 281 GAIM_CONV_ACCOUNT_ONLINE);
275 } 282 }
276 283
277 gaim_event_broadcast(event_signon, gc); 284 gaim_signal_emit(gaim_connections_get_handle(), "signed-on", gc);
285
278 system_log(log_signon, gc, NULL, 286 system_log(log_signon, gc, NULL,
279 OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); 287 OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON);
280 288
281 #if 0 289 #if 0
282 /* away option given? */ 290 /* away option given? */
445 { 453 {
446 return connections_connecting; 454 return connections_connecting;
447 } 455 }
448 456
449 void 457 void
458 gaim_connections_init(void)
459 {
460 void *handle = gaim_connections_get_handle();
461
462 gaim_signal_register(handle, "signing-on", gaim_marshal_VOID__POINTER);
463 gaim_signal_register(handle, "signed-on", gaim_marshal_VOID__POINTER);
464 gaim_signal_register(handle, "signing-off", gaim_marshal_VOID__POINTER);
465 gaim_signal_register(handle, "signed-off", gaim_marshal_VOID__POINTER);
466 }
467
468 void
469 gaim_connections_uninit(void)
470 {
471 gaim_signals_unregister_by_instance(gaim_connections_get_handle());
472 }
473
474 void *
475 gaim_connections_get_handle(void)
476 {
477 return &connections_handle;
478 }
479
480 void
450 gaim_set_connection_ui_ops(GaimConnectionUiOps *ops) 481 gaim_set_connection_ui_ops(GaimConnectionUiOps *ops)
451 { 482 {
452 connection_ui_ops = ops; 483 connection_ui_ops = ops;
453 } 484 }
454 485
455 GaimConnectionUiOps * 486 GaimConnectionUiOps *
456 gaim_get_connection_ui_ops(void) 487 gaim_get_connection_ui_ops(void)
457 { 488 {
458 return connection_ui_ops; 489 return connection_ui_ops;
459 } 490 }
460