comparison src/server.c @ 10745:ca69d597a5e2

[gaim-migrate @ 12347] Get rid of serv_close (I got rid of serv_login earlier today). committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 27 Mar 2005 01:59:39 +0000
parents 94cc67130789
children bf5e48215158
comparison
equal deleted inserted replaced
10744:1b927566fcc4 10745:ca69d597a5e2
42 #include "gtkutils.h" 42 #include "gtkutils.h"
43 43
44 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600 44 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600
45 #define SEX_BEFORE_RESENDING_AUTORESPONSE "Only after you're married" 45 #define SEX_BEFORE_RESENDING_AUTORESPONSE "Only after you're married"
46 46
47 static gboolean send_keepalive(gpointer d)
48 {
49 GaimConnection *gc = d;
50 GaimPluginProtocolInfo *prpl_info = NULL;
51
52 if (gc != NULL && gc->prpl != NULL)
53 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
54
55 if (prpl_info && prpl_info->keepalive)
56 prpl_info->keepalive(gc);
57
58 return TRUE;
59 }
60
61 static void update_keepalive(GaimConnection *gc, gboolean on)
62 {
63 if (on && !gc->keep_alive) {
64 gaim_debug(GAIM_DEBUG_INFO, "server", "allowing NOP\n");
65 gc->keep_alive = gaim_timeout_add(60000, send_keepalive, gc);
66 } else if (!on && gc->keep_alive > 0) {
67 gaim_debug(GAIM_DEBUG_INFO, "server", "removing NOP\n");
68 gaim_timeout_remove(gc->keep_alive);
69 gc->keep_alive = 0;
70 }
71 }
72
73 void serv_close(GaimConnection *gc)
74 {
75 GaimPluginProtocolInfo *prpl_info = NULL;
76
77 while (gc->buddy_chats) {
78 GaimConversation *b = gc->buddy_chats->data;
79
80 gc->buddy_chats = g_slist_remove(gc->buddy_chats, b);
81 gaim_conv_chat_left(GAIM_CONV_CHAT(b));
82 }
83
84 if (gc->idle_timer > 0)
85 gaim_timeout_remove(gc->idle_timer);
86 gc->idle_timer = 0;
87
88 update_keepalive(gc, FALSE);
89
90 if (gc->prpl != NULL) {
91 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
92
93 if (prpl_info->close)
94 (prpl_info->close)(gc);
95 }
96 }
97
98 void serv_touch_idle(GaimConnection *gc) 47 void serv_touch_idle(GaimConnection *gc)
99 { 48 {
100 /* Are we idle? If so, not anymore */ 49 /* Are we idle? If so, not anymore */
101 if (gc->is_idle > 0) { 50 if (gc->is_idle > 0) {
102 gc->is_idle = 0; 51 gc->is_idle = 0;
123 if (gc->idle_timer > 0) 72 if (gc->idle_timer > 0)
124 gaim_timeout_remove(gc->idle_timer); 73 gaim_timeout_remove(gc->idle_timer);
125 74
126 gc->idle_timer = gaim_timeout_add(20000, check_idle, gc); 75 gc->idle_timer = gaim_timeout_add(20000, check_idle, gc);
127 serv_touch_idle(gc); 76 serv_touch_idle(gc);
128
129 update_keepalive(gc, TRUE);
130 } 77 }
131 78
132 /* This should return the elapsed time in seconds in which Gaim will not send 79 /* This should return the elapsed time in seconds in which Gaim will not send
133 * typing notifications. 80 * typing notifications.
134 * if it returns zero, it will not send any more typing notifications 81 * if it returns zero, it will not send any more typing notifications