comparison src/server.c @ 9234:f18eb3f22733

[gaim-migrate @ 10030] This appears to be somewhat hacky, but due to the lack of a timer in blist.c, we need a core place to emit buddy-idle-updated. server.c now maintains a list of idle buddies and emits the signal when appropriate. We really need a better way to do this, which I'll attempt to incorporate into the status rewrite, but perhaps the best way would involve the blist update timer being in blist.c. Anyhow, this works for now. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 08 Jun 2004 02:02:25 +0000
parents 1e51236d825e
children 7ae39c31e401
comparison
equal deleted inserted replaced
9233:0c352d0e4ddc 9234:f18eb3f22733
1053 1053
1054 g_free(name); 1054 g_free(name);
1055 g_free(message); 1055 g_free(message);
1056 } 1056 }
1057 1057
1058 1058 /*
1059 * NOTE: This is a bit hacky, but needed for core support for the
1060 * buddy-idle-updated signal. It's temporary, and will be replaced
1061 * with better code in the status rewrite.
1062 */
1063 static GList *idle_buddies = NULL;
1064 static guint idle_buddy_timeout_id = 0;
1065
1066 static gboolean
1067 idle_timeout_cb(void)
1068 {
1069 GList *l;
1070
1071 for (l = idle_buddies; l != NULL; l = l->next)
1072 {
1073 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-updated",
1074 l->data);
1075 }
1076
1077 return TRUE;
1078 }
1059 1079
1060 void serv_got_update(GaimConnection *gc, const char *name, int loggedin, 1080 void serv_got_update(GaimConnection *gc, const char *name, int loggedin,
1061 int evil, time_t signon, time_t idle, int type) 1081 int evil, time_t signon, time_t idle, int type)
1062 { 1082 {
1063 GaimAccount *account; 1083 GaimAccount *account;
1217 gaim_blist_update_buddy_status(b, type); 1237 gaim_blist_update_buddy_status(b, type);
1218 1238
1219 if (!old_idle && idle) 1239 if (!old_idle && idle)
1220 { 1240 {
1221 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle", b); 1241 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle", b);
1242
1243 idle_buddies = g_list_append(idle_buddies, b);
1244
1245 if (idle_buddy_timeout_id == 0)
1246 {
1247 idle_buddy_timeout_id = gaim_timeout_add(10000,
1248 (GSourceFunc)idle_timeout_cb, NULL);
1249 }
1222 } 1250 }
1223 else if (old_idle && !idle) 1251 else if (old_idle && !idle)
1224 { 1252 {
1225 gaim_signal_emit(gaim_blist_get_handle(), "buddy-unidle", b); 1253 gaim_signal_emit(gaim_blist_get_handle(), "buddy-unidle", b);
1226 } 1254
1227 else if (old_idle != idle) 1255 idle_buddies = g_list_remove(idle_buddies, b);
1228 { 1256
1229 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-updated", b); 1257 if (idle_buddies == NULL)
1258 {
1259 gaim_timeout_remove(idle_buddy_timeout_id);
1260 idle_buddy_timeout_id = 0;
1261 }
1230 } 1262 }
1231 1263
1232 if (c != NULL) 1264 if (c != NULL)
1233 gaim_conversation_update(c, GAIM_CONV_UPDATE_AWAY); 1265 gaim_conversation_update(c, GAIM_CONV_UPDATE_AWAY);
1234 1266