comparison src/server.c @ 9236:e8d86fd68552

[gaim-migrate @ 10033] This one shouldn't crash. We really need a better system here. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 08 Jun 2004 02:12:40 +0000
parents 7ae39c31e401
children fac583b4ecdf
comparison
equal deleted inserted replaced
9235:7ae39c31e401 9236:e8d86fd68552
40 #include "gtkutils.h" 40 #include "gtkutils.h"
41 #include "ui.h" 41 #include "ui.h"
42 42
43 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600 43 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600
44 44
45 static void add_idle_buddy(GaimBuddy *buddy);
46 static void remove_idle_buddy(GaimBuddy *buddy);
47
45 void serv_login(GaimAccount *account) 48 void serv_login(GaimAccount *account)
46 { 49 {
47 GaimPlugin *p = gaim_find_prpl(gaim_account_get_protocol_id(account)); 50 GaimPlugin *p = gaim_find_prpl(gaim_account_get_protocol_id(account));
48 GaimPluginProtocolInfo *prpl_info = NULL; 51 GaimPluginProtocolInfo *prpl_info = NULL;
49 52
418 421
419 422
420 void serv_remove_buddy(GaimConnection *g, const char *name, const char *group) 423 void serv_remove_buddy(GaimConnection *g, const char *name, const char *group)
421 { 424 {
422 GaimPluginProtocolInfo *prpl_info = NULL; 425 GaimPluginProtocolInfo *prpl_info = NULL;
426 GaimBuddy *buddy;
427
428 buddy = gaim_find_buddy(gaim_connection_get_account(g), name);
429
430 if (buddy->idle > 0)
431 remove_idle_buddy(buddy);
423 432
424 if (g != NULL && g->prpl != NULL) 433 if (g != NULL && g->prpl != NULL)
425 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 434 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
426 435
427 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->remove_buddy) 436 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->remove_buddy)
1053 1062
1054 g_free(name); 1063 g_free(name);
1055 g_free(message); 1064 g_free(message);
1056 } 1065 }
1057 1066
1058 1067 /*
1068 * NOTE: This is a bit hacky, but needed for core support for the
1069 * buddy-idle-updated signal. It's temporary, and will be replaced
1070 * with better code in the status rewrite.
1071 */
1072 static GList *idle_buddies = NULL;
1073 static guint idle_buddy_timeout_id = 0;
1074
1075 static gboolean
1076 idle_timeout_cb(void)
1077 {
1078 GList *l;
1079
1080 for (l = idle_buddies; l != NULL; l = l->next)
1081 {
1082 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-updated",
1083 l->data);
1084 }
1085
1086 return TRUE;
1087 }
1088
1089 static void
1090 add_idle_buddy(GaimBuddy *buddy)
1091 {
1092 idle_buddies = g_list_append(idle_buddies, buddy);
1093
1094 if (idle_buddy_timeout_id == 0)
1095 {
1096 idle_buddy_timeout_id = gaim_timeout_add(10000,
1097 (GSourceFunc)idle_timeout_cb, NULL);
1098 }
1099 }
1100
1101 static void
1102 remove_idle_buddy(GaimBuddy *buddy)
1103 {
1104 idle_buddies = g_list_remove(idle_buddies, buddy);
1105
1106 if (idle_buddies == NULL)
1107 {
1108 gaim_timeout_remove(idle_buddy_timeout_id);
1109 idle_buddy_timeout_id = 0;
1110 }
1111 }
1059 1112
1060 void serv_got_update(GaimConnection *gc, const char *name, int loggedin, 1113 void serv_got_update(GaimConnection *gc, const char *name, int loggedin,
1061 int evil, time_t signon, time_t idle, int type) 1114 int evil, time_t signon, time_t idle, int type)
1062 { 1115 {
1063 GaimAccount *account; 1116 GaimAccount *account;
1217 gaim_blist_update_buddy_status(b, type); 1270 gaim_blist_update_buddy_status(b, type);
1218 1271
1219 if (!old_idle && idle) 1272 if (!old_idle && idle)
1220 { 1273 {
1221 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle", b); 1274 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle", b);
1275
1276 add_idle_buddy(b);
1222 } 1277 }
1223 else if (old_idle && !idle) 1278 else if (old_idle && !idle)
1224 { 1279 {
1225 gaim_signal_emit(gaim_blist_get_handle(), "buddy-unidle", b); 1280 gaim_signal_emit(gaim_blist_get_handle(), "buddy-unidle", b);
1226 } 1281
1227 else if (old_idle != idle) 1282 remove_idle_buddy(b);
1228 {
1229 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-updated", b);
1230 } 1283 }
1231 1284
1232 if (c != NULL) 1285 if (c != NULL)
1233 gaim_conversation_update(c, GAIM_CONV_UPDATE_AWAY); 1286 gaim_conversation_update(c, GAIM_CONV_UPDATE_AWAY);
1234 1287