comparison src/server.c @ 9993:bdec08a8fc5b

[gaim-migrate @ 10906] Remove away.c and away.h And get rid of some code in server.c that I'm pretty sure doesn't do anything committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 09 Sep 2004 03:36:35 +0000
parents 5b13241a32c8
children 32467b63f55a
comparison
equal deleted inserted replaced
9992:7596ad640b56 9993:bdec08a8fc5b
34 #include "sound.h" 34 #include "sound.h"
35 #include "status.h" 35 #include "status.h"
36 #include "util.h" 36 #include "util.h"
37 37
38 /* XXX UI Stuff */ 38 /* XXX UI Stuff */
39 #include "away.h"
40 #include "gtkdialogs.h" 39 #include "gtkdialogs.h"
41 #include "gaim.h" 40 #include "gaim.h"
42 #include "gtkimhtml.h" 41 #include "gtkimhtml.h"
43 #include "gtkutils.h" 42 #include "gtkutils.h"
44 43
45 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600 44 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600
46 #define SEX_BEFORE_RESENDING_AUTORESPONSE "Only after you're married" 45 #define SEX_BEFORE_RESENDING_AUTORESPONSE "Only after you're married"
47
48 static void add_idle_buddy(GaimBuddy *buddy);
49 static void remove_idle_buddy(GaimBuddy *buddy);
50 46
51 void serv_login(GaimAccount *account) 47 void serv_login(GaimAccount *account)
52 { 48 {
53 GaimPlugin *p = gaim_find_prpl(gaim_account_get_protocol_id(account)); 49 GaimPlugin *p = gaim_find_prpl(gaim_account_get_protocol_id(account));
54 GaimPluginProtocolInfo *prpl_info = NULL; 50 GaimPluginProtocolInfo *prpl_info = NULL;
394 390
395 void serv_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) 391 void serv_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group)
396 { 392 {
397 GaimPluginProtocolInfo *prpl_info = NULL; 393 GaimPluginProtocolInfo *prpl_info = NULL;
398 394
399 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy)))
400 remove_idle_buddy(buddy);
401
402 if (gc != NULL && gc->prpl != NULL) 395 if (gc != NULL && gc->prpl != NULL)
403 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 396 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
404 397
405 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && prpl_info->remove_buddy) 398 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && prpl_info->remove_buddy)
406 prpl_info->remove_buddy(gc, buddy, group); 399 prpl_info->remove_buddy(gc, buddy, group);
416 if (gc != NULL && gc->prpl != NULL) 409 if (gc != NULL && gc->prpl != NULL)
417 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 410 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
418 411
419 if (prpl_info && g_list_find(gaim_connections_get_all(), gc)) { 412 if (prpl_info && g_list_find(gaim_connections_get_all(), gc)) {
420 if (prpl_info->remove_buddies) { 413 if (prpl_info->remove_buddies) {
421 GList *curb;
422 for (curb = buddies; curb != NULL; curb = curb->next) {
423 GaimBuddy *buddy = curb->data;
424 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy)))
425 remove_idle_buddy(buddy);
426 }
427 prpl_info->remove_buddies(gc, buddies, groups); 414 prpl_info->remove_buddies(gc, buddies, groups);
428 } else { 415 } else {
429 GList *curb = buddies; 416 GList *curb = buddies;
430 GList *curg = groups; 417 GList *curg = groups;
431 while ((curb != NULL) && (curg != NULL)) { 418 while ((curb != NULL) && (curg != NULL)) {
1065 g_free(name); 1052 g_free(name);
1066 g_free(message); 1053 g_free(message);
1067 } 1054 }
1068 1055
1069 /* 1056 /*
1070 * NOTE: This is a bit hacky, but needed for core support for the
1071 * buddy-idle-updated signal. It's temporary, and will be replaced
1072 * with better code in the status rewrite.
1073 */
1074 static GList *idle_buddies = NULL;
1075 static guint idle_buddy_timeout_id = 0;
1076
1077 static gboolean
1078 idle_timeout_cb(void)
1079 {
1080 GList *l, *l_next;
1081
1082 for (l = idle_buddies; l != NULL; l = l_next)
1083 {
1084 GaimBuddy *buddy = (GaimBuddy *)l->data;
1085
1086 l_next = l->next;
1087
1088 if (!GAIM_BUDDY_IS_ONLINE(buddy) ||
1089 gaim_presence_is_idle(gaim_buddy_get_presence(buddy)))
1090 {
1091 remove_idle_buddy(buddy);
1092 }
1093 else
1094 {
1095 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-updated",
1096 l->data);
1097 }
1098 }
1099
1100 return TRUE;
1101 }
1102
1103 static void
1104 add_idle_buddy(GaimBuddy *buddy)
1105 {
1106 idle_buddies = g_list_append(idle_buddies, buddy);
1107
1108 if (idle_buddy_timeout_id == 0)
1109 {
1110 idle_buddy_timeout_id = gaim_timeout_add(10000,
1111 (GSourceFunc)idle_timeout_cb, NULL);
1112 }
1113 }
1114
1115 static void
1116 remove_idle_buddy(GaimBuddy *buddy)
1117 {
1118 idle_buddies = g_list_remove(idle_buddies, buddy);
1119
1120 if (idle_buddies == NULL)
1121 {
1122 gaim_timeout_remove(idle_buddy_timeout_id);
1123 idle_buddy_timeout_id = 0;
1124 }
1125 }
1126
1127 /*
1128 * @param idle The time at which the buddy became idle, in seconds 1057 * @param idle The time at which the buddy became idle, in seconds
1129 * since the epoch. 1058 * since the epoch.
1130 */ 1059 */
1131 void serv_got_update(GaimConnection *gc, const char *name, gboolean loggedin, 1060 void serv_got_update(GaimConnection *gc, const char *name, gboolean loggedin,
1132 time_t signon) 1061 time_t signon)