diff src/blist.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 2311f3761ed2
children b6f7fcafc908
line wrap: on
line diff
--- a/src/blist.c	Sun Aug 17 17:55:46 2003 +0000
+++ b/src/blist.c	Mon Aug 18 01:03:43 2003 +0000
@@ -29,6 +29,7 @@
 #include "privacy.h"
 #include "prpl.h"
 #include "server.h"
+#include "signals.h"
 #include "util.h"
 
 #define PATHSIZE 1024
@@ -100,13 +101,15 @@
 
 	gbl->ui_ops = gaim_get_blist_ui_ops();
 
-	gbl->buddies = g_hash_table_new ((GHashFunc)_gaim_blist_hbuddy_hash, 
+	gbl->buddies = g_hash_table_new ((GHashFunc)_gaim_blist_hbuddy_hash,
 					 (GEqualFunc)_gaim_blist_hbuddy_equal);
 
 	if (gbl->ui_ops != NULL && gbl->ui_ops->new_list != NULL)
 		gbl->ui_ops->new_list(gbl);
 
-	gaim_prefs_connect_callback("/core/buddies/use_server_alias", blist_pref_cb, NULL);
+	gaim_prefs_connect_callback("/core/buddies/use_server_alias",
+								blist_pref_cb, NULL);
+
 
 	return gbl;
 }
@@ -155,9 +158,9 @@
 
 	if((status & UC_UNAVAILABLE) != (buddy->uc & UC_UNAVAILABLE)) {
 		if(status & UC_UNAVAILABLE)
-			gaim_event_broadcast(event_buddy_away, buddy->account->gc, buddy->name);
+			gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy);
 		else
-			gaim_event_broadcast(event_buddy_back, buddy->account->gc, buddy->name);
+			gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy);
 	}
 
 	buddy->uc = status;
@@ -196,12 +199,12 @@
 
 	if (!GAIM_BUDDY_IS_ONLINE(buddy) && presence) {
 		buddy->present = GAIM_BUDDY_SIGNING_ON;
-		gaim_event_broadcast(event_buddy_signon, buddy->account->gc, buddy->name);
+		gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-on", buddy);
 		do_timer = TRUE;
 		((struct group *)((GaimBlistNode *)buddy)->parent)->online++;
 	} else if(GAIM_BUDDY_IS_ONLINE(buddy) && !presence) {
 		buddy->present = GAIM_BUDDY_SIGNING_OFF;
-		gaim_event_broadcast(event_buddy_signoff, buddy->account->gc, buddy->name);
+		gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-off", buddy);
 		do_timer = TRUE;
 		((struct group *)((GaimBlistNode *)buddy)->parent)->online--;
 	}
@@ -1792,9 +1795,9 @@
 			g_free(msg);
 		}
 	} else if(g_list_length(gaim_accounts_get_all())) {
+#if 0
 		GMainContext *ctx;
 
-#if 0
 		/* rob wants to inform the user that their buddy lists are
 		 * being converted */
 		msg = g_strdup_printf(_("Gaim is converting your old buddy lists "
@@ -2087,4 +2090,37 @@
 	return group->online;
 }
 
+void *
+gaim_blist_get_handle(void)
+{
+	static int handle;
 
+	return &handle;
+}
+
+void
+gaim_blist_init(void)
+{
+	void *handle = gaim_blist_get_handle();
+
+	gaim_signal_register(handle, "buddy-away", gaim_marshal_VOID__POINTER);
+	gaim_signal_register(handle, "buddy-back", gaim_marshal_VOID__POINTER);
+
+	gaim_signal_register(handle, "buddy-idle",
+						 gaim_marshal_VOID__POINTER_POINTER);
+	gaim_signal_register(handle, "buddy-unidle",
+						 gaim_marshal_VOID__POINTER_POINTER);
+
+	gaim_signal_register(handle, "buddy-signed-on",
+						 gaim_marshal_VOID__POINTER);
+	gaim_signal_register(handle, "buddy-signed-off",
+						 gaim_marshal_VOID__POINTER);
+
+	gaim_signal_register(handle, "update-idle", gaim_marshal_VOID);
+}
+
+void
+gaim_blist_uninit(void)
+{
+	gaim_signals_unregister_by_instance(gaim_blist_get_handle());
+}