# HG changeset patch # User andrew.victor@mxit.com # Date 1318969541 0 # Node ID 50cd80d3554e6c3d32c10650b65c599abb2db48b # Parent 2ec94166be4398588bdc17abbd8b354d3fc0d379 Add a purple_connection_update_last_received() function to update the PurpleConnection->last_received value. diff -r 2ec94166be43 -r 50cd80d3554e ChangeLog.API --- a/ChangeLog.API Tue Oct 18 18:47:48 2011 +0000 +++ b/ChangeLog.API Tue Oct 18 20:25:41 2011 +0000 @@ -13,6 +13,7 @@ * purple_conv_chat_cb_set_ui_data * purple_connection_get_flags * purple_connection_set_flags + * purple_connection_update_last_received * purple_conversation_get_ui_data * purple_conversation_set_ui_data * purple_notify_searchresult_column_is_visible diff -r 2ec94166be43 -r 50cd80d3554e libpurple/connection.c --- a/libpurple/connection.c Tue Oct 18 18:47:48 2011 +0000 +++ b/libpurple/connection.c Tue Oct 18 20:25:41 2011 +0000 @@ -627,6 +627,13 @@ } } +void purple_connection_update_last_received(PurpleConnection *gc) +{ + g_return_if_fail(gc != NULL); + + gc->last_received = time(NULL); +} + void purple_connections_disconnect_all(void) { diff -r 2ec94166be43 -r 50cd80d3554e libpurple/connection.h --- a/libpurple/connection.h Tue Oct 18 18:47:48 2011 +0000 +++ b/libpurple/connection.h Tue Oct 18 20:25:41 2011 +0000 @@ -447,6 +447,14 @@ gboolean purple_connection_error_is_fatal (PurpleConnectionError reason); +/** + * Indicate that a packet was received on the connection. + * Set by the prpl to avoid sending unneeded keepalives. + * + * @param gc The connection. + */ +void purple_connection_update_last_received(PurpleConnection *gc); + /*@}*/ /**************************************************************************/ diff -r 2ec94166be43 -r 50cd80d3554e libpurple/protocols/irc/irc.c --- a/libpurple/protocols/irc/irc.c Tue Oct 18 18:47:48 2011 +0000 +++ b/libpurple/protocols/irc/irc.c Tue Oct 18 20:25:41 2011 +0000 @@ -648,7 +648,7 @@ PurpleConnection *connection = purple_account_get_connection(irc->account); char *cur, *end; - connection->last_received = time(NULL); + purple_connection_update_last_received(connection); irc->inbufused += len; irc->inbuf[irc->inbufused] = '\0'; diff -r 2ec94166be43 -r 50cd80d3554e libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Tue Oct 18 18:47:48 2011 +0000 +++ b/libpurple/protocols/jabber/jabber.c Tue Oct 18 20:25:41 2011 +0000 @@ -653,7 +653,7 @@ } while((len = purple_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { - gc->last_received = time(NULL); + purple_connection_update_last_received(gc); buf[len] = '\0'; purple_debug_info("jabber", "Recv (ssl)(%d): %s\n", len, buf); jabber_parser_process(js, buf, len); @@ -687,7 +687,7 @@ g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { - gc->last_received = time(NULL); + purple_connection_update_last_received(gc); #ifdef HAVE_CYRUS_SASL if (js->sasl_maxbuf > 0) { const char *out; diff -r 2ec94166be43 -r 50cd80d3554e libpurple/protocols/msn/httpconn.c --- a/libpurple/protocols/msn/httpconn.c Tue Oct 18 18:47:48 2011 +0000 +++ b/libpurple/protocols/msn/httpconn.c Tue Oct 18 20:25:41 2011 +0000 @@ -287,7 +287,7 @@ if (servconn->type == MSN_SERVCONN_NS) { PurpleConnection *gc = purple_account_get_connection(servconn->session->account); - gc->last_received = time(NULL); + purple_connection_update_last_received(gc); } len = read(httpconn->fd, buf, sizeof(buf) - 1); diff -r 2ec94166be43 -r 50cd80d3554e libpurple/protocols/msn/servconn.c --- a/libpurple/protocols/msn/servconn.c Tue Oct 18 18:47:48 2011 +0000 +++ b/libpurple/protocols/msn/servconn.c Tue Oct 18 20:25:41 2011 +0000 @@ -423,7 +423,7 @@ if (servconn->type == MSN_SERVCONN_NS) { PurpleConnection *gc = purple_account_get_connection(servconn->session->account); - gc->last_received = time(NULL); + purple_connection_update_last_received(gc); } len = read(servconn->fd, buf, sizeof(buf) - 1); diff -r 2ec94166be43 -r 50cd80d3554e libpurple/protocols/oscar/flap_connection.c --- a/libpurple/protocols/oscar/flap_connection.c Tue Oct 18 18:47:48 2011 +0000 +++ b/libpurple/protocols/oscar/flap_connection.c Tue Oct 18 20:25:41 2011 +0000 @@ -921,7 +921,7 @@ OSCAR_DISCONNECT_LOST_CONNECTION, g_strerror(errno)); break; } - conn->od->gc->last_received = time(NULL); + purple_connection_update_last_received(conn->od->gc); /* If we don't even have a complete FLAP header then do nothing */ conn->header_received += read; diff -r 2ec94166be43 -r 50cd80d3554e libpurple/protocols/simple/simple.c --- a/libpurple/protocols/simple/simple.c Tue Oct 18 18:47:48 2011 +0000 +++ b/libpurple/protocols/simple/simple.c Tue Oct 18 20:25:41 2011 +0000 @@ -1705,7 +1705,7 @@ if(sip->fd == source) sip->fd = -1; return; } - gc->last_received = time(NULL); + purple_connection_update_last_received(gc); conn->inbufused += len; conn->inbuf[conn->inbufused] = '\0'; diff -r 2ec94166be43 -r 50cd80d3554e libpurple/protocols/yahoo/libymsg.c --- a/libpurple/protocols/yahoo/libymsg.c Tue Oct 18 18:47:48 2011 +0000 +++ b/libpurple/protocols/yahoo/libymsg.c Tue Oct 18 20:25:41 2011 +0000 @@ -3155,7 +3155,7 @@ _("Server closed the connection")); return; } - gc->last_received = time(NULL); + purple_connection_update_last_received(gc); yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); memcpy(yd->rxqueue + yd->rxlen, buf, len); yd->rxlen += len;