--- a/libpurple/protocols/jabber/bosh.c Wed Apr 21 17:43:36 2010 +0000 +++ b/libpurple/protocols/jabber/bosh.c Wed Apr 21 19:07:19 2010 +0000 @@ -78,13 +78,11 @@ } state; guint8 failed_connections; - int max_inactivity; int wait; int max_requests; int requests; - guint inactivity_timer; guint send_timer; }; @@ -239,8 +237,6 @@ if (conn->send_timer) purple_timeout_remove(conn->send_timer); - if (conn->inactivity_timer) - purple_timeout_remove(conn->inactivity_timer); purple_circ_buffer_destroy(conn->pending); @@ -433,34 +429,14 @@ return FALSE; } -static gboolean -bosh_inactivity_cb(gpointer data) +void +jabber_bosh_connection_send_keepalive(PurpleBOSHConnection *bosh) { - PurpleBOSHConnection *bosh = data; - bosh->inactivity_timer = 0; - if (bosh->send_timer != 0) purple_timeout_remove(bosh->send_timer); /* clears bosh->send_timer */ send_timer_cb(bosh); - - return FALSE; -} - -static void -restart_inactivity_timer(PurpleBOSHConnection *conn) -{ - if (conn->inactivity_timer != 0) { - purple_timeout_remove(conn->inactivity_timer); - conn->inactivity_timer = 0; - } - - if (conn->max_inactivity != 0) { - conn->inactivity_timer = - purple_timeout_add_seconds(conn->max_inactivity - 5 /* rounding */, - bosh_inactivity_cb, conn); - } } static void jabber_bosh_connection_received(PurpleBOSHConnection *conn, xmlnode *node) { @@ -541,19 +517,20 @@ } if (inactivity) { - conn->max_inactivity = atoi(inactivity); - if (conn->max_inactivity <= 5) { + js->max_inactivity = atoi(inactivity); + if (js->max_inactivity <= 5) { purple_debug_warning("jabber", "Ignoring bogusly small inactivity: %s\n", inactivity); - conn->max_inactivity = 0; + /* Leave it at the default */ } else { - /* TODO: Integrate this with jabber.c keepalive checks... */ /* TODO: Can this check fail? It shouldn't */ - if (conn->inactivity_timer == 0) { + js->max_inactivity -= 5; /* rounding */ + + if (js->inactivity_timer == 0) { purple_debug_misc("jabber", "Starting BOSH inactivity timer " "for %d secs (compensating for rounding)\n", - conn->max_inactivity - 5); - restart_inactivity_timer(conn); + js->max_inactivity); + jabber_stream_restart_inactivity_timer(js); } } } @@ -976,7 +953,7 @@ size_t len; /* Sending something to the server, restart the inactivity timer */ - restart_inactivity_timer(conn->bosh); + jabber_stream_restart_inactivity_timer(conn->bosh->js); data = g_strdup_printf("POST %s HTTP/1.1\r\n" "Host: %s\r\n"