comparison src/connection.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 4228b6d78506
children bf5e48215158
comparison
equal deleted inserted replaced
10744:1b927566fcc4 10745:ca69d597a5e2
39 static GList *connections_connecting = NULL; 39 static GList *connections_connecting = NULL;
40 static GaimConnectionUiOps *connection_ui_ops = NULL; 40 static GaimConnectionUiOps *connection_ui_ops = NULL;
41 41
42 static int connections_handle; 42 static int connections_handle;
43 43
44 static gboolean
45 send_keepalive(gpointer data)
46 {
47 GaimConnection *gc = data;
48 GaimPluginProtocolInfo *prpl_info = NULL;
49
50 if (gc != NULL && gc->prpl != NULL)
51 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
52
53 if (prpl_info && prpl_info->keepalive)
54 prpl_info->keepalive(gc);
55
56 return TRUE;
57 }
58
59 static void
60 update_keepalive(GaimConnection *gc, gboolean on)
61 {
62 if (on && !gc->keepalive)
63 {
64 gaim_debug_info("connection", "Activating keepalive.\n");
65 gc->keepalive = gaim_timeout_add(30000, send_keepalive, gc);
66 }
67 else if (!on && gc->keepalive > 0)
68 {
69 gaim_debug_info("connection", "Deactivating keepalive.\n");
70 gaim_timeout_remove(gc->keepalive);
71 gc->keepalive = 0;
72 }
73 }
74
44 void 75 void
45 gaim_connection_new(GaimAccount *account, gboolean regist, const char *password) 76 gaim_connection_new(GaimAccount *account, gboolean regist, const char *password)
46 { 77 {
47 GaimConnection *gc; 78 GaimConnection *gc;
48 GaimPlugin *prpl; 79 GaimPlugin *prpl;
117 148
118 g_return_if_fail(gc != NULL); 149 g_return_if_fail(gc != NULL);
119 150
120 account = gaim_connection_get_account(gc); 151 account = gaim_connection_get_account(gc);
121 152
122 if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) { 153 if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED)
154 {
123 GList *wins; 155 GList *wins;
124 GaimPresence *presence = NULL; 156 GaimPresence *presence = NULL;
157 GaimPluginProtocolInfo *prpl_info = NULL;
125 158
126 gaim_debug_info("connection", "Disconnecting connection %p\n", gc); 159 gaim_debug_info("connection", "Disconnecting connection %p\n", gc);
127 160
128 if (gaim_connection_get_state(gc) != GAIM_CONNECTING) 161 if (gaim_connection_get_state(gc) != GAIM_CONNECTING)
129 gaim_blist_remove_account(gaim_connection_get_account(gc)); 162 gaim_blist_remove_account(account);
130 163
131 gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc); 164 gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc);
132 165
133 serv_close(gc); 166 while (gc->buddy_chats)
167 {
168 GaimConversation *b = gc->buddy_chats->data;
169
170 gc->buddy_chats = g_slist_remove(gc->buddy_chats, b);
171 gaim_conv_chat_left(GAIM_CONV_CHAT(b));
172 }
173
174 if (gc->idle_timer > 0)
175 gaim_timeout_remove(gc->idle_timer);
176 gc->idle_timer = 0;
177
178 update_keepalive(gc, FALSE);
179
180 if (gc->prpl != NULL)
181 {
182 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
183
184 if (prpl_info->close)
185 (prpl_info->close)(gc);
186 }
134 187
135 connections = g_list_remove(connections, gc); 188 connections = g_list_remove(connections, gc);
136 189
137 gaim_connection_set_state(gc, GAIM_DISCONNECTED); 190 gaim_connection_set_state(gc, GAIM_DISCONNECTED);
138 191
274 serv_add_buddies(gc, add_buds); 327 serv_add_buddies(gc, add_buds);
275 g_list_free(add_buds); 328 g_list_free(add_buds);
276 } 329 }
277 330
278 serv_set_permit_deny(gc); 331 serv_set_permit_deny(gc);
332
333 update_keepalive(gc, TRUE);
279 } 334 }
280 else if (gc->state == GAIM_DISCONNECTED) { 335 else if (gc->state == GAIM_DISCONNECTED) {
281 GaimAccount *account = gaim_connection_get_account(gc); 336 GaimAccount *account = gaim_connection_get_account(gc);
282 337
283 if(gaim_prefs_get_bool("/core/logging/log_system") && 338 if(gaim_prefs_get_bool("/core/logging/log_system") &&