changeset 27451:01927ce552bc

propagate from branch 'im.pidgin.pidgin' (head ac87c285c7056f86005dc157b9870745de471f74) to branch 'im.pidgin.cpw.darkrain42.obsolete' (head c09ec70d7a13deec0ac8624876b13f027d581846)
author Paul Aurich <paul@darkrain42.org>
date Mon, 06 Jul 2009 04:38:08 +0000
parents b41b69e8b341 (current diff) add3989f682e (diff)
children ebd9630ffc77
files libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/message.c libpurple/protocols/jabber/presence.c
diffstat 6 files changed, 57 insertions(+), 113 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/iq.c	Mon Jul 06 04:19:26 2009 +0000
+++ b/libpurple/protocols/jabber/iq.c	Mon Jul 06 04:38:08 2009 +0000
@@ -168,28 +168,19 @@
 	}
 }
 
-static void jabber_iq_time_parse(JabberStream *js, const char *from,
-                                 JabberIqType type, const char *id,
-                                 xmlnode *child)
+static void jabber_time_parse(JabberStream *js, const char *from,
+                              JabberIqType type, const char *id,
+                              xmlnode *child)
 {
-	const char *xmlns;
 	JabberIq *iq;
 	time_t now_t;
-	struct tm now_local;
-	struct tm now_utc;
-	struct tm *now;
+	struct tm *tm;
 
 	time(&now_t);
-	now = localtime(&now_t);
-	memcpy(&now_local, now, sizeof(struct tm));
-	now = gmtime(&now_t);
-	memcpy(&now_utc, now, sizeof(struct tm));
-
-	xmlns = xmlnode_get_namespace(child);
 
 	if(type == JABBER_IQ_GET) {
-		xmlnode *utc;
-		const char *date, *tz, *display;
+		xmlnode *tzo, *utc;
+		const char *date, *tz;
 
 		iq = jabber_iq_new(js, JABBER_IQ_RESULT);
 		jabber_iq_set_id(iq, id);
@@ -197,27 +188,23 @@
 			xmlnode_set_attrib(iq->node, "to", from);
 
 		child = xmlnode_new_child(iq->node, child->name);
-		xmlnode_set_namespace(child, xmlns);
-		utc = xmlnode_new_child(child, "utc");
-
-		if(!strcmp("urn:xmpp:time", xmlns)) {
-			tz = purple_get_tzoff_str(&now_local, TRUE);
-			xmlnode_insert_data(xmlnode_new_child(child, "tzo"), tz, -1);
+		xmlnode_set_namespace(child, "urn:xmpp:time");
 
-			date = purple_utf8_strftime("%FT%TZ", &now_utc);
-			xmlnode_insert_data(utc, date, -1);
-		} else { /* jabber:iq:time */
-			tz = purple_utf8_strftime("%Z", &now_local);
-			xmlnode_insert_data(xmlnode_new_child(child, "tz"), tz, -1);
+		/* <tzo>-06:00</tzo> */
+		tm = localtime(&now_t);
+		tz = purple_get_tzoff_str(tm, TRUE);
+		tzo = xmlnode_new_child(child, "tzo");
+		xmlnode_insert_data(tzo, tz, -1);
 
-			date = purple_utf8_strftime("%Y%m%dT%T", &now_utc);
-			xmlnode_insert_data(utc, date, -1);
-
-			display = purple_utf8_strftime("%d %b %Y %T", &now_local);
-			xmlnode_insert_data(xmlnode_new_child(child, "display"), display, -1);
-		}
+		/* <utc>2006-12-19T17:58:35Z</utc> */
+		tm = gmtime(&now_t);
+		date = purple_utf8_strftime("%FT%TZ", tm);
+		utc = xmlnode_new_child(child, "utc");
+		xmlnode_insert_data(utc, date, -1);
 
 		jabber_iq_send(iq);
+	} else {
+		/* TODO: Errors */
 	}
 }
 
@@ -488,7 +475,6 @@
 			jabber_register_parse);
 	jabber_iq_register_handler("query", "jabber:iq:roster",
 			jabber_roster_parse);
-	jabber_iq_register_handler("query", "jabber:iq:time", jabber_iq_time_parse);
 	jabber_iq_register_handler("query", "jabber:iq:version",
 			jabber_iq_version_parse);
 #ifdef USE_VV
@@ -497,7 +483,7 @@
 #endif
 	jabber_iq_register_handler("block", "urn:xmpp:blocking", jabber_blocklist_parse_push);
 	jabber_iq_register_handler("unblock", "urn:xmpp:blocking", jabber_blocklist_parse_push);
-	jabber_iq_register_handler("time", "urn:xmpp:time", jabber_iq_time_parse);
+	jabber_iq_register_handler("time", "urn:xmpp:time", jabber_time_parse);
 
 }
 
--- a/libpurple/protocols/jabber/jabber.c	Mon Jul 06 04:19:26 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Mon Jul 06 04:38:08 2009 +0000
@@ -3449,7 +3449,6 @@
 	/* initialize jabber_features list */
 	jabber_add_feature("jabber:iq:last", 0);
 	jabber_add_feature("jabber:iq:oob", 0);
-	jabber_add_feature("jabber:iq:time", 0);
 	jabber_add_feature("urn:xmpp:time", 0);
 	jabber_add_feature("jabber:iq:version", 0);
 	jabber_add_feature("jabber:x:conference", 0);
--- a/libpurple/protocols/jabber/jabber.h	Mon Jul 06 04:19:26 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Mon Jul 06 04:38:08 2009 +0000
@@ -25,7 +25,7 @@
 typedef enum {
 	JABBER_CAP_NONE           = 0,
 	JABBER_CAP_XHTML          = 1 << 0,
-	JABBER_CAP_COMPOSING      = 1 << 1,
+/*	JABBER_CAP_COMPOSING      = 1 << 1, */
 	JABBER_CAP_SI             = 1 << 2,
 	JABBER_CAP_SI_FILE_XFER   = 1 << 3,
 	JABBER_CAP_BYTESTREAMS    = 1 << 4,
--- a/libpurple/protocols/jabber/message.c	Mon Jul 06 04:19:26 2009 +0000
+++ b/libpurple/protocols/jabber/message.c	Mon Jul 06 04:38:08 2009 +0000
@@ -125,15 +125,10 @@
 		}
 	} else {
 		if(jbr) {
-			if(JM_TS_JEP_0085 == (jm->typing_style & JM_TS_JEP_0085)) {
+			if (jm->chat_state != JM_STATE_NONE)
 				jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED;
-			} else {
+			else
 				jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED;
-			}
-
-			if(JM_TS_JEP_0022 == (jm->typing_style & JM_TS_JEP_0022)) {
-				jbr->capabilities |= JABBER_CAP_COMPOSING;
-			}
 
 			if(jbr->thread_id)
 				g_free(jbr->thread_id);
@@ -550,6 +545,7 @@
 	jm->js = js;
 	jm->sent = time(NULL);
 	jm->delayed = FALSE;
+	jm->chat_state = JM_STATE_NONE;
 
 	if(type) {
 		if(!strcmp(type, "normal"))
@@ -723,19 +719,14 @@
 			}
 		} else if(!strcmp(child->name, "active") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
 			jm->chat_state = JM_STATE_ACTIVE;
-			jm->typing_style |= JM_TS_JEP_0085;
 		} else if(!strcmp(child->name, "composing") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
 			jm->chat_state = JM_STATE_COMPOSING;
-			jm->typing_style |= JM_TS_JEP_0085;
 		} else if(!strcmp(child->name, "paused") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
 			jm->chat_state = JM_STATE_PAUSED;
-			jm->typing_style |= JM_TS_JEP_0085;
 		} else if(!strcmp(child->name, "inactive") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
 			jm->chat_state = JM_STATE_INACTIVE;
-			jm->typing_style |= JM_TS_JEP_0085;
 		} else if(!strcmp(child->name, "gone") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
 			jm->chat_state = JM_STATE_GONE;
-			jm->typing_style |= JM_TS_JEP_0085;
 		} else if(!strcmp(child->name, "event") && !strcmp(xmlns,"http://jabber.org/protocol/pubsub#event")) {
 			xmlnode *items;
 			jm->type = JABBER_MESSAGE_EVENT;
@@ -749,18 +740,7 @@
 			if(timestamp)
 				jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL);
 		} else if(!strcmp(child->name, "x")) {
-			if(!strcmp(xmlns, "jabber:x:event")) {
-				if(xmlnode_get_child(child, "composing")) {
-					if(jm->chat_state == JM_STATE_ACTIVE)
-						jm->chat_state = JM_STATE_COMPOSING;
-					jm->typing_style |= JM_TS_JEP_0022;
-				}
-			} else if(!strcmp(xmlns, "jabber:x:delay")) {
-				const char *timestamp = xmlnode_get_attrib(child, "stamp");
-				jm->delayed = TRUE;
-				if(timestamp)
-					jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL);
-			} else if(!strcmp(xmlns, "jabber:x:conference") &&
+			if(!strcmp(xmlns, "jabber:x:conference") &&
 					jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE &&
 					jm->type != JABBER_MESSAGE_ERROR) {
 				const char *jid = xmlnode_get_attrib(child, "jid");
@@ -1056,36 +1036,30 @@
 		xmlnode_insert_data(child, jm->thread_id, -1);
 	}
 
-	if(JM_TS_JEP_0022 == (jm->typing_style & JM_TS_JEP_0022)) {
-		child = xmlnode_new_child(message, "x");
-		xmlnode_set_namespace(child, "jabber:x:event");
-		if(jm->chat_state == JM_STATE_COMPOSING || jm->body)
-			xmlnode_new_child(child, "composing");
+	child = NULL;
+	switch(jm->chat_state)
+	{
+		case JM_STATE_ACTIVE:
+			child = xmlnode_new_child(message, "active");
+			break;
+		case JM_STATE_COMPOSING:
+			child = xmlnode_new_child(message, "composing");
+			break;
+		case JM_STATE_PAUSED:
+			child = xmlnode_new_child(message, "paused");
+			break;
+		case JM_STATE_INACTIVE:
+			child = xmlnode_new_child(message, "inactive");
+			break;
+		case JM_STATE_GONE:
+			child = xmlnode_new_child(message, "gone");
+			break;
+		case JM_STATE_NONE:
+			/* yep, nothing */
+			break;
 	}
-
-	if(JM_TS_JEP_0085 == (jm->typing_style & JM_TS_JEP_0085)) {
-		child = NULL;
-		switch(jm->chat_state)
-		{
-			case JM_STATE_ACTIVE:
-				child = xmlnode_new_child(message, "active");
-				break;
-			case JM_STATE_COMPOSING:
-				child = xmlnode_new_child(message, "composing");
-				break;
-			case JM_STATE_PAUSED:
-				child = xmlnode_new_child(message, "paused");
-				break;
-			case JM_STATE_INACTIVE:
-				child = xmlnode_new_child(message, "inactive");
-				break;
-			case JM_STATE_GONE:
-				child = xmlnode_new_child(message, "gone");
-				break;
-		}
-		if(child)
-			xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates");
-	}
+	if(child)
+		xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates");
 
 	if(jm->subject) {
 		child = xmlnode_new_child(message, "subject");
@@ -1180,14 +1154,12 @@
 		if(jbr->thread_id)
 			jm->thread_id = jbr->thread_id;
 
-		if(jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED) {
-			jm->typing_style |= JM_TS_JEP_0085;
+		if (jbr->chat_states == JABBER_CHAT_STATES_UNSUPPORTED)
+			jm->chat_state = JM_STATE_NONE;
+		else {
 			/* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states)
 			   jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */
 		}
-
-		if(jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED)
-			jm->typing_style |= JM_TS_JEP_0022;
 	}
 
 	tmp = purple_utf8_strip_unprintables(msg);
@@ -1265,7 +1237,7 @@
 
 	g_free(resource);
 
-	if(!jbr || !((jbr->capabilities & JABBER_CAP_COMPOSING) || (jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED)))
+	if (!jbr || (jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED))
 		return 0;
 
 	/* TODO: figure out threading */
@@ -1282,14 +1254,8 @@
 	else
 		jm->chat_state = JM_STATE_ACTIVE;
 
-	if(jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED) {
-		jm->typing_style |= JM_TS_JEP_0085;
-		/* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states)
-			jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */
-	}
-
-	if(jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED)
-		jm->typing_style |= JM_TS_JEP_0022;
+	/* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states)
+		jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */
 
 	jabber_message_send(jm);
 	jabber_message_free(jm);
--- a/libpurple/protocols/jabber/message.h	Mon Jul 06 04:19:26 2009 +0000
+++ b/libpurple/protocols/jabber/message.h	Mon Jul 06 04:38:08 2009 +0000
@@ -53,11 +53,7 @@
 	char *error;
 	char *thread_id;
 	enum {
-		JM_TS_NONE = 0,
-		JM_TS_JEP_0022 = 0x1,
-		JM_TS_JEP_0085 = 0x2
-	} typing_style;
-	enum {
+		JM_STATE_NONE,
 		JM_STATE_ACTIVE,
 		JM_STATE_COMPOSING,
 		JM_STATE_PAUSED,
--- a/libpurple/protocols/jabber/presence.c	Mon Jul 06 04:19:26 2009 +0000
+++ b/libpurple/protocols/jabber/presence.c	Mon Jul 06 04:38:08 2009 +0000
@@ -601,7 +601,7 @@
 			/* The rest of the cases used to check xmlns individually. */
 			continue;
 		} else if(!strcmp(y->name, "delay") && !strcmp(xmlns, "urn:xmpp:delay")) {
-			/* XXX: compare the time.  jabber:x:delay can happen on presence packets that aren't really and truly delayed */
+			/* XXX: compare the time.  urn:xmpp:delay can happen on presence packets that aren't really and truly delayed */
 			delayed = TRUE;
 			stamp = xmlnode_get_attrib(y, "stamp");
 		} else if(!strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) {
@@ -609,10 +609,7 @@
 		} else if (g_str_equal(y->name, "nick") && g_str_equal(xmlns, "http://jabber.org/protocol/nick")) {
 			nickname = xmlnode_get_data(y);
 		} else if(!strcmp(y->name, "x")) {
-			if(!strcmp(xmlns, "jabber:x:delay")) {
-				/* XXX: compare the time.  jabber:x:delay can happen on presence packets that aren't really and truly delayed */
-				delayed = TRUE;
-				stamp = xmlnode_get_attrib(y, "stamp");
+			if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user")) {
 			} else if(!strcmp(xmlns, "vcard-temp:x:update")) {
 				xmlnode *photo = xmlnode_get_child(y, "photo");
 				if(photo) {