/cpw/tomkiewicz/gg11: 11a130063ad0: Merge from trunk

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Thu Sep 27 18:07:38 EDT 2012


Changeset: 11a130063ad02e386b7077de9592f162a18b4f55
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2012-09-28 00:07 +0200
Branch:	 default
URL: http://hg.pidgin.im/cpw/tomkiewicz/gg11/rev/11a130063ad0

Description:

Merge from trunk

diffstat:

 configure.ac                            |  17 +++++++++++++++++
 libpurple/protocols/jabber/namespaces.h |   3 +++
 libpurple/protocols/jabber/presence.c   |  27 ++++++++++++++++++++++++++-
 libpurple/protocols/jabber/presence.h   |   1 +
 4 files changed, 47 insertions(+), 1 deletions(-)

diffs (119 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -816,6 +816,18 @@ AC_SUBST(LIBXML_CFLAGS)
 AC_SUBST(LIBXML_LIBS)
 
 dnl #######################################################################
+dnl # Check for JSON-GLib (required, if compiled with Gadu-Gadu support)
+dnl #######################################################################
+
+PKG_CHECK_MODULES([JSON], [json-glib-1.0], [enable_json="yes"], [enable_json="no"])
+
+dnl #######################################################################
+dnl # Check for libcurl (required)
+dnl #######################################################################
+
+PKG_CHECK_MODULES([LIBCURL], [libcurl])
+
+dnl #######################################################################
 dnl # Check for zlib (required)
 dnl #######################################################################
 
@@ -1303,6 +1315,10 @@ AC_CHECK_FUNC(uname)
 
 AC_ARG_ENABLE(fortify, [AC_HELP_STRING([--disable-fortify], [compile without FORTIFY_SOURCE support])], , enable_fortify=yes)
 
+if test \( "x$static_gg" = "xyes" -o "x$dynamic_gg" = "xyes" \) -a "x$enable_json" != "xyes" ; then
+	AC_MSG_ERROR([json-glib-1.0 not found (required, when compiling with Gadu-Gadu support)])
+fi
+
 DEBUG_CFLAGS="$DEBUG_CFLAGS -DPURPLE_DISABLE_DEPRECATED -DPIDGIN_DISABLE_DEPRECATED -DFINCH_DISABLE_DEPRECATED -DGNT_DISABLE_DEPRECATED"
 if test "x$GCC" = "xyes"; then
 	dnl We enable -Wall later.
@@ -2691,6 +2707,7 @@ echo Use X Session Management...... : $e
 echo Use startup notification...... : $enable_startup_notification
 echo Build with GtkSpell support... : $enable_gtkspell
 echo Build with GCR widgets........ : $enable_gcr
+echo Build with JSON support....... : $enable_json
 echo
 echo Build with plugin support..... : $enable_plugins
 echo Build with Mono support....... : $enable_mono
diff --git a/libpurple/protocols/jabber/namespaces.h b/libpurple/protocols/jabber/namespaces.h
--- a/libpurple/protocols/jabber/namespaces.h
+++ b/libpurple/protocols/jabber/namespaces.h
@@ -109,4 +109,7 @@
 #define NS_GOOGLE_SESSION_PHONE "http://www.google.com/session/phone"
 #define NS_GOOGLE_SESSION_VIDEO "http://www.google.com/session/video"
 
+/* Apple extension(s) */
+#define NS_APPLE_IDLE "http://www.apple.com/xmpp/idle"
+
 #endif /* PURPLE_JABBER_NAMESPACES_H_ */
diff --git a/libpurple/protocols/jabber/presence.c b/libpurple/protocols/jabber/presence.c
--- a/libpurple/protocols/jabber/presence.c
+++ b/libpurple/protocols/jabber/presence.c
@@ -1017,7 +1017,7 @@ void jabber_presence_parse(JabberStream 
 			pih(js, &presence, child);
 	}
 
-	if (presence.delayed && presence.idle) {
+	if (presence.delayed && presence.idle && presence.adjust_idle_for_delay) {
 		/* Delayed and idle, so update idle time */
 		presence.idle = presence.idle + (time(NULL) - presence.sent);
 	}
@@ -1172,11 +1172,33 @@ parse_delay(JabberStream *js, JabberPres
 }
 
 static void
+parse_apple_idle(JabberStream *js, JabberPresence *presence, xmlnode *x)
+{
+	xmlnode *since = xmlnode_get_child(x, "idle-since");
+	if (since) {
+		char *stamp = xmlnode_get_data_unescaped(since);
+		if (stamp) {
+			time_t tstamp = purple_str_to_time(stamp, TRUE, NULL, NULL, NULL);
+			if (tstamp != 0) {
+				presence->idle = time(NULL) - tstamp;
+				presence->adjust_idle_for_delay = FALSE;
+				if(presence->idle < 0) {
+					purple_debug_warning("jabber", "Received bogus idle timestamp %s\n", stamp);
+					presence->idle = 0;
+				}
+			}
+		}
+		g_free(stamp);
+	}
+}
+
+static void
 parse_idle(JabberStream *js, JabberPresence *presence, xmlnode *query)
 {
 	const gchar *seconds = xmlnode_get_attrib(query, "seconds");
 	if (seconds) {
 		presence->idle = atoi(seconds);
+		presence->adjust_idle_for_delay = TRUE;
 		if (presence->idle < 0) {
 			purple_debug_warning("jabber", "Received bogus idle time %s\n", seconds);
 			presence->idle = 0;
@@ -1276,6 +1298,9 @@ void jabber_presence_init(void)
 	jabber_presence_register_handler("x", NS_DELAYED_DELIVERY_LEGACY, parse_delay);
 	jabber_presence_register_handler("x", "http://jabber.org/protocol/muc#user", parse_muc_user);
 	jabber_presence_register_handler("x", "vcard-temp:x:update", parse_vcard_avatar);
+
+	/* Apple idle */
+	jabber_presence_register_handler("x", NS_APPLE_IDLE, parse_apple_idle);
 }
 
 void jabber_presence_uninit(void)
diff --git a/libpurple/protocols/jabber/presence.h b/libpurple/protocols/jabber/presence.h
--- a/libpurple/protocols/jabber/presence.h
+++ b/libpurple/protocols/jabber/presence.h
@@ -71,6 +71,7 @@ struct _JabberPresence {
 	gboolean delayed;
 	time_t sent;
 	int idle;
+	gboolean adjust_idle_for_delay;
 };
 
 typedef void (JabberPresenceHandler)(JabberStream *js, JabberPresence *presence,



More information about the Commits mailing list