pidgin: a81c5245: jabber: Support for requesting limited h...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Mar 6 18:05:54 EST 2011


----------------------------------------------------------------------
Revision: a81c5245795dd1fa56db435c6c4d98cd68c7acc9
Parent:   dfcd7327f9dca20e01e193aa8ac416625e69c3d0
Author:   darkrain42 at pidgin.im
Date:     03/06/11 18:03:47
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a81c5245795dd1fa56db435c6c4d98cd68c7acc9

Changelog: 

jabber: Support for requesting limited history when joining a MUC.

Patch from xnyhps, with some minor corrections by me.
Fixes #10986.
Refs #a14219.

Changes against parent dfcd7327f9dca20e01e193aa8ac416625e69c3d0

  patched  ChangeLog
  patched  ChangeLog.API
  patched  libpurple/protocols/jabber/chat.c

-------------- next part --------------
============================================================
--- ChangeLog	0a07d2dd67ce31dea43478e94d49bf6c9dc8d68a
+++ ChangeLog	e565d151c3cec49edda3ce7c20983a4bf2e5b80e
@@ -30,6 +30,9 @@ version 2.7.11 (??/??/????):
 	  Alkemade) (#a14527)
 	* Extend the /join command to support room JIDs, enabling you to join
 	  a room on any server.  (Solarius, Mat?j Cepl, wyuka) (#4526)
+	* Add support for receiving a limited amount of history when joining a
+	  room (not currently supported by Pidgin and Finch).  (Thijs Alkemade)
+	  (#10986, #a14219)
 
 version 2.7.10 (02/06/2011):
 	General:
============================================================
--- libpurple/protocols/jabber/chat.c	67fbff926f732214820637bdb280a711da90ddfa
+++ libpurple/protocols/jabber/chat.c	338a3fae5f4b20bacd627fb04c275c60fd12ad27
@@ -281,6 +281,14 @@ JabberChat *jabber_join_chat(JabberStrea
 
 	char *jid;
 
+	char *history_maxchars;
+	char *history_maxstanzas;
+	char *history_seconds;
+	char *history_since;
+
+	struct tm history_since_datetime;
+	const char *history_since_string = NULL;
+
 	chat = jabber_chat_new(js, room, server, handle, password, data);
 	if (chat == NULL)
 		return NULL;
@@ -297,6 +305,22 @@ JabberChat *jabber_join_chat(JabberStrea
 	xmlnode_set_attrib(presence, "to", jid);
 	g_free(jid);
 
+	history_maxchars   = g_hash_table_lookup(data, "history_maxchars");
+	history_maxstanzas = g_hash_table_lookup(data, "history_maxstanzas");
+	history_seconds    = g_hash_table_lookup(data, "history_seconds");
+	history_since      = g_hash_table_lookup(data, "history_since");
+
+	if (history_since) {
+		if (purple_str_to_time(history_since, TRUE, &history_since_datetime, NULL, NULL) != 0) {
+			history_since_string = purple_utf8_strftime("%Y-%m-%dT%H:%M:%SZ", &history_since_datetime);
+		} else {
+			history_since_string = NULL;
+
+			purple_debug_error("jabber", "Invalid date format for history_since"
+			                             " while requesting history: %s", history_since);
+		}
+	}
+
 	x = xmlnode_new_child(presence, "x");
 	xmlnode_set_namespace(x, "http://jabber.org/protocol/muc");
 
@@ -305,6 +329,27 @@ JabberChat *jabber_join_chat(JabberStrea
 		xmlnode_insert_data(p, password, -1);
 	}
 
+	if ((history_maxchars && *history_maxchars)
+	    || (history_maxstanzas && *history_maxstanzas)
+	    || (history_seconds && *history_seconds)
+	    || (history_since_string && *history_since_string)) {
+
+		xmlnode *history = xmlnode_new_child(x, "history");
+
+		if (history_maxchars && *history_maxchars) {
+			xmlnode_set_attrib(history, "maxchars", history_maxchars);
+		}
+		if (history_maxstanzas && *history_maxstanzas) {
+			xmlnode_set_attrib(history, "maxstanzas", history_maxstanzas);
+		}
+		if (history_seconds && *history_seconds) {
+			xmlnode_set_attrib(history, "seconds", history_seconds);
+		}
+		if (history_since_string && *history_since_string) {
+			xmlnode_set_attrib(history, "since", history_since_string);
+		}
+	}
+
 	jabber_send(js, presence);
 	xmlnode_free(presence);
 
============================================================
--- ChangeLog.API	9f87335f7aad74b3d67e05594334bde1a1a63f37
+++ ChangeLog.API	63ade2f79e828d08769b8316aa066de2733016d5
@@ -1,6 +1,15 @@ version 2.7.11 (??/??/????):
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
 version 2.7.11 (??/??/????):
+	* libpurple:
+		Added:
+		* Four entries in the GHashTable passed when joining
+		  an XMPP chat room which allow the UI to request a limited
+		  amount of history.  See XEP-0045 7.1.16 for details; the
+		  entries are named history_maxchars, history_maxstanzas,
+		  history_seconds, and history_since.  history_since must be
+		  interpretable by purple_str_to_time, and the prpl takes care
+		  of formatting the time properly.
 	* Perl:
 		Added:
 		* Purple::find_conversation_with_account


More information about the Commits mailing list