aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/nogaim.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2012-12-22 01:14:26 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2012-12-22 01:14:26 +0100
commitcc6fdf8fe5a044db58ed74e69673cf4270080d45 (patch)
treed58edb70d76e84bf24016fccf9cd27764ea7ae4c /protocols/nogaim.c
parent92d30446251591a6805168f51a4b07ff65b3cc24 (diff)
parent573e274c58bf7d154b35ab5cd9d0b711f7ede715 (diff)
Merging JSON branch. It's very stable by now, and I want more testers.
Diffstat (limited to 'protocols/nogaim.c')
-rw-r--r--protocols/nogaim.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index 773e3877..2f85a3eb 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -260,12 +260,32 @@ static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond )
{
struct im_connection *ic = d;
+ if( ( ic->flags & OPT_PONGS ) && !( ic->flags & OPT_PONGED ) )
+ {
+ /* This protocol is expected to ack keepalives and hasn't
+ since the last time we were here. */
+ imcb_error( ic, "Connection timeout" );
+ imc_logout( ic, TRUE );
+ return FALSE;
+ }
+ ic->flags &= ~OPT_PONGED;
+
if( ic->acc->prpl->keepalive )
ic->acc->prpl->keepalive( ic );
return TRUE;
}
+void start_keepalives( struct im_connection *ic, int interval )
+{
+ b_event_remove( ic->keepalive );
+ ic->keepalive = b_timeout_add( interval, send_keepalive, ic );
+
+ /* Connecting successfully counts as a first successful pong. */
+ if( ic->flags & OPT_PONGS )
+ ic->flags |= OPT_PONGED;
+}
+
void imcb_connected( struct im_connection *ic )
{
/* MSN servers sometimes redirect you to a different server and do
@@ -276,9 +296,8 @@ void imcb_connected( struct im_connection *ic )
imcb_log( ic, "Logged in" );
- b_event_remove( ic->keepalive );
- ic->keepalive = b_timeout_add( 60000, send_keepalive, ic );
ic->flags |= OPT_LOGGED_IN;
+ start_keepalives( ic, 60000 );
/* Necessary to send initial presence status, even if we're not away. */
imc_away_send_update( ic );