comparison 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
comparison
equal deleted inserted replaced
6484:5ced8e111473 6485:70d5122bc3ff
27 #include "notify.h" 27 #include "notify.h"
28 #include "prefs.h" 28 #include "prefs.h"
29 #include "privacy.h" 29 #include "privacy.h"
30 #include "prpl.h" 30 #include "prpl.h"
31 #include "server.h" 31 #include "server.h"
32 #include "signals.h"
32 #include "util.h" 33 #include "util.h"
33 34
34 #define PATHSIZE 1024 35 #define PATHSIZE 1024
35 36
36 struct gaim_buddy_list *gaimbuddylist = NULL; 37 struct gaim_buddy_list *gaimbuddylist = NULL;
98 { 99 {
99 struct gaim_buddy_list *gbl = g_new0(struct gaim_buddy_list, 1); 100 struct gaim_buddy_list *gbl = g_new0(struct gaim_buddy_list, 1);
100 101
101 gbl->ui_ops = gaim_get_blist_ui_ops(); 102 gbl->ui_ops = gaim_get_blist_ui_ops();
102 103
103 gbl->buddies = g_hash_table_new ((GHashFunc)_gaim_blist_hbuddy_hash, 104 gbl->buddies = g_hash_table_new ((GHashFunc)_gaim_blist_hbuddy_hash,
104 (GEqualFunc)_gaim_blist_hbuddy_equal); 105 (GEqualFunc)_gaim_blist_hbuddy_equal);
105 106
106 if (gbl->ui_ops != NULL && gbl->ui_ops->new_list != NULL) 107 if (gbl->ui_ops != NULL && gbl->ui_ops->new_list != NULL)
107 gbl->ui_ops->new_list(gbl); 108 gbl->ui_ops->new_list(gbl);
108 109
109 gaim_prefs_connect_callback("/core/buddies/use_server_alias", blist_pref_cb, NULL); 110 gaim_prefs_connect_callback("/core/buddies/use_server_alias",
111 blist_pref_cb, NULL);
112
110 113
111 return gbl; 114 return gbl;
112 } 115 }
113 116
114 void 117 void
153 156
154 ops = gaimbuddylist->ui_ops; 157 ops = gaimbuddylist->ui_ops;
155 158
156 if((status & UC_UNAVAILABLE) != (buddy->uc & UC_UNAVAILABLE)) { 159 if((status & UC_UNAVAILABLE) != (buddy->uc & UC_UNAVAILABLE)) {
157 if(status & UC_UNAVAILABLE) 160 if(status & UC_UNAVAILABLE)
158 gaim_event_broadcast(event_buddy_away, buddy->account->gc, buddy->name); 161 gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy);
159 else 162 else
160 gaim_event_broadcast(event_buddy_back, buddy->account->gc, buddy->name); 163 gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy);
161 } 164 }
162 165
163 buddy->uc = status; 166 buddy->uc = status;
164 if (ops) 167 if (ops)
165 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); 168 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
194 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; 197 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
195 gboolean do_timer = FALSE; 198 gboolean do_timer = FALSE;
196 199
197 if (!GAIM_BUDDY_IS_ONLINE(buddy) && presence) { 200 if (!GAIM_BUDDY_IS_ONLINE(buddy) && presence) {
198 buddy->present = GAIM_BUDDY_SIGNING_ON; 201 buddy->present = GAIM_BUDDY_SIGNING_ON;
199 gaim_event_broadcast(event_buddy_signon, buddy->account->gc, buddy->name); 202 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-on", buddy);
200 do_timer = TRUE; 203 do_timer = TRUE;
201 ((struct group *)((GaimBlistNode *)buddy)->parent)->online++; 204 ((struct group *)((GaimBlistNode *)buddy)->parent)->online++;
202 } else if(GAIM_BUDDY_IS_ONLINE(buddy) && !presence) { 205 } else if(GAIM_BUDDY_IS_ONLINE(buddy) && !presence) {
203 buddy->present = GAIM_BUDDY_SIGNING_OFF; 206 buddy->present = GAIM_BUDDY_SIGNING_OFF;
204 gaim_event_broadcast(event_buddy_signoff, buddy->account->gc, buddy->name); 207 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-off", buddy);
205 do_timer = TRUE; 208 do_timer = TRUE;
206 ((struct group *)((GaimBlistNode *)buddy)->parent)->online--; 209 ((struct group *)((GaimBlistNode *)buddy)->parent)->online--;
207 } 210 }
208 211
209 if(do_timer) { 212 if(do_timer) {
1790 "buddy list. It has not been loaded.")); 1793 "buddy list. It has not been loaded."));
1791 gaim_notify_error(NULL, NULL, _("Buddy List Error"), msg); 1794 gaim_notify_error(NULL, NULL, _("Buddy List Error"), msg);
1792 g_free(msg); 1795 g_free(msg);
1793 } 1796 }
1794 } else if(g_list_length(gaim_accounts_get_all())) { 1797 } else if(g_list_length(gaim_accounts_get_all())) {
1798 #if 0
1795 GMainContext *ctx; 1799 GMainContext *ctx;
1796 1800
1797 #if 0
1798 /* rob wants to inform the user that their buddy lists are 1801 /* rob wants to inform the user that their buddy lists are
1799 * being converted */ 1802 * being converted */
1800 msg = g_strdup_printf(_("Gaim is converting your old buddy lists " 1803 msg = g_strdup_printf(_("Gaim is converting your old buddy lists "
1801 "to a new format, which will now be located at %s"), 1804 "to a new format, which will now be located at %s"),
1802 filename); 1805 filename);
2085 return 0; 2088 return 0;
2086 2089
2087 return group->online; 2090 return group->online;
2088 } 2091 }
2089 2092
2090 2093 void *
2094 gaim_blist_get_handle(void)
2095 {
2096 static int handle;
2097
2098 return &handle;
2099 }
2100
2101 void
2102 gaim_blist_init(void)
2103 {
2104 void *handle = gaim_blist_get_handle();
2105
2106 gaim_signal_register(handle, "buddy-away", gaim_marshal_VOID__POINTER);
2107 gaim_signal_register(handle, "buddy-back", gaim_marshal_VOID__POINTER);
2108
2109 gaim_signal_register(handle, "buddy-idle",
2110 gaim_marshal_VOID__POINTER_POINTER);
2111 gaim_signal_register(handle, "buddy-unidle",
2112 gaim_marshal_VOID__POINTER_POINTER);
2113
2114 gaim_signal_register(handle, "buddy-signed-on",
2115 gaim_marshal_VOID__POINTER);
2116 gaim_signal_register(handle, "buddy-signed-off",
2117 gaim_marshal_VOID__POINTER);
2118
2119 gaim_signal_register(handle, "update-idle", gaim_marshal_VOID);
2120 }
2121
2122 void
2123 gaim_blist_uninit(void)
2124 {
2125 gaim_signals_unregister_by_instance(gaim_blist_get_handle());
2126 }