changeset 22195:6419554aadd9

merge of '7a2d6f31a70791d5e6e8af6fae041e30d5a1c48f' and 'a0479b7ebd8713b6442fb2ecb8238b7e71be61b5'
author Sean Egan <seanegan@gmail.com>
date Fri, 25 Jan 2008 00:51:06 +0000
parents 17e21fa1db57 (current diff) 252b96b6a32c (diff)
children 6c7cf4654d10
files ChangeLog.API libpurple/protocols/myspace/myspace.c libpurple/protocols/oscar/flap_connection.c
diffstat 13 files changed, 42 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/connection.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/connection.c	Fri Jan 25 00:51:06 2008 +0000
@@ -52,8 +52,19 @@
 	PurpleConnection *gc = data;
 	PurplePluginProtocolInfo *prpl_info = NULL;
 
-	if (gc != NULL && gc->prpl != NULL)
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+	if (gc == NULL)
+		return;
+
+	/* Only send keep-alives if we haven't heard from the
+ 	 * server in a while.
+ 	 */
+	if ((time(NULL) - gc->last_received) < KEEPALIVE_INTERVAL)
+		return;
+
+	if (gc->prpl == NULL)
+		return;
+
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
 
 	if (prpl_info && prpl_info->keepalive)
 		prpl_info->keepalive(gc);
--- a/libpurple/connection.h	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/connection.h	Fri Jan 25 00:51:06 2008 +0000
@@ -251,6 +251,8 @@
 	gboolean wants_to_die;
 
 	guint disconnect_timeout;    /**< Timer used for nasty stack tricks  */
+	time_t last_received;        /**< When we last received a packet. Set by the
+					  prpl to avoid sending unneeded keepalives */
 };
 
 #ifdef __cplusplus
--- a/libpurple/protocols/gg/gg.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/gg/gg.c	Fri Jan 25 00:51:06 2008 +0000
@@ -1314,7 +1314,7 @@
 			_("Unable to read socket"));
 		return;
 	}
-
+	gc->last_received = time(NULL);
 	switch (ev->type) {
 		case GG_EVENT_NONE:
 			/* Nothing happened. */
--- a/libpurple/protocols/irc/irc.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/irc/irc.c	Fri Jan 25 00:51:06 2008 +0000
@@ -572,6 +572,7 @@
 {
 	char *cur, *end;
 
+	irc->account->gc->last_received = time(NULL);
 	irc->inbufused += len;
 	irc->inbuf[irc->inbufused] = '\0';
 
--- a/libpurple/protocols/jabber/jabber.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Fri Jan 25 00:51:06 2008 +0000
@@ -432,6 +432,7 @@
 	}
 
 	while((len = purple_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) {
+		gc->last_received = time(NULL);
 		buf[len] = '\0';
 		purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf);
 		jabber_parser_process(js, buf, len);
@@ -459,6 +460,7 @@
 		return;
 
 	if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) {
+		gc->last_received = time(NULL);
 #ifdef HAVE_CYRUS_SASL
 		if (js->sasl_maxbuf>0) {
 			const char *out;
--- a/libpurple/protocols/msn/servconn.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/msn/servconn.c	Fri Jan 25 00:51:06 2008 +0000
@@ -391,6 +391,7 @@
 	session = servconn->session;
 
 	len = read(servconn->fd, buf, sizeof(buf) - 1);
+	servconn->session->account->gc->last_connected = time(NULL);
 
 	if (len <= 0) {
 		switch (errno) {
--- a/libpurple/protocols/msnp9/servconn.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/msnp9/servconn.c	Fri Jan 25 00:51:06 2008 +0000
@@ -387,6 +387,7 @@
 	session = servconn->session;
 
 	len = read(servconn->fd, buf, sizeof(buf) - 1);
+	servconn->session->account->gc->last_received = time(NULL);
 
 	if (len < 0 && errno == EAGAIN)
 		return;
--- a/libpurple/protocols/myspace/myspace.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Fri Jan 25 00:51:06 2008 +0000
@@ -2475,6 +2475,7 @@
 	 * the file descriptor, but it sometimes differs from the 'source' parameter.
 	 */
 	n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0);
+	gc->last_received = time(NULL);
 
 	if (n < 0 && errno == EAGAIN) {
 		return;
--- a/libpurple/protocols/oscar/flap_connection.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/oscar/flap_connection.c	Fri Jan 25 00:51:06 2008 +0000
@@ -817,6 +817,7 @@
 						OSCAR_DISCONNECT_LOST_CONNECTION, g_strerror(errno));
 				break;
 			}
+			conn->od->gc->last_received = time(NULL);
 
 			/* If we don't even have a complete FLAP header then do nothing */
 			conn->header_received += read;
--- a/libpurple/protocols/sametime/sametime.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/sametime/sametime.c	Fri Jan 25 00:51:06 2008 +0000
@@ -1695,7 +1695,9 @@
   int len;
 
   len = read(sock, buf, BUF_LEN);
-  if(len > 0) mwSession_recv(session, buf, len);
+  if(len > 0) {
+    mwSession_recv(session, buf, len);
+  }
 
   return len;
 }
--- a/libpurple/protocols/simple/simple.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/simple/simple.c	Fri Jan 25 00:51:06 2008 +0000
@@ -1675,7 +1675,7 @@
 		if(sip->fd == source) sip->fd = -1;
 		return;
 	}
-
+	gc->last_received = time(NULL);
 	conn->inbufused += len;
 	conn->inbuf[conn->inbufused] = '\0';
 
--- a/libpurple/protocols/yahoo/yahoo.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Fri Jan 25 00:51:06 2008 +0000
@@ -2506,7 +2506,7 @@
 				_("Server closed the connection."));
 		return;
 	}
-
+	gc->last_received = time(NULL);
 	yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen);
 	memcpy(yd->rxqueue + yd->rxlen, buf, len);
 	yd->rxlen += len;
--- a/pidgin/gtkimhtml.c	Thu Jan 24 05:25:02 2008 +0000
+++ b/pidgin/gtkimhtml.c	Fri Jan 25 00:51:06 2008 +0000
@@ -1455,6 +1455,9 @@
 	gtk_text_buffer_create_tag(imhtml->text_buffer, "SUP", "rise", 5000, NULL);
 	gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL);
 	gtk_text_buffer_create_tag(imhtml->text_buffer, "search", "background", "#22ff00", "weight", "bold", NULL);
+#if GTK_CHECK_VERSION(2,10,10)
+	gtk_text_buffer_create_tag(imhtml->text_buffer, "comment", "invisible", FALSE, NULL);
+#endif
 
 	/* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */
 	imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2);
@@ -2981,10 +2984,15 @@
 
 					gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
 
+#if GTK_CHECK_VERSION(2,10,10)
+					wpos = g_snprintf (ws, len, "%s", tag);
+					gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL);
+#else
 					if (imhtml->show_comments && !(options & GTK_IMHTML_NO_COMMENTS)) {
 						wpos = g_snprintf (ws, len, "%s", tag);
 						gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
 					}
+#endif
 					ws[0] = '\0'; wpos = 0;
 
 					/* NEW_BIT (NEW_COMMENT_BIT); */
@@ -3130,6 +3138,12 @@
 void       gtk_imhtml_show_comments    (GtkIMHtml        *imhtml,
 					gboolean          show)
 {
+#if GTK_CHECK_VERSION(2,10,10)
+	GtkTextTag *tag;
+	tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), "comment");
+	if (tag)
+		g_object_set(G_OBJECT(tag), "invisible", !show, NULL);
+#endif
 	imhtml->show_comments = show;
 }