[Tkabber-dev] r1973 - in trunk/tkabber-plugins: . receipts

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Dec 3 05:10:43 MSK 2010


Author: kostix
Date: 2010-12-03 05:10:43 +0300 (Fri, 03 Dec 2010)
New Revision: 1973

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/receipts/receipts.tcl
Log:
Update receipts plugin to support v1.1 of XEP-0184

Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2010-12-01 08:59:49 UTC (rev 1972)
+++ trunk/tkabber-plugins/ChangeLog	2010-12-03 02:10:43 UTC (rev 1973)
@@ -1,3 +1,7 @@
+2010-12-03  Konstantin Khomoutov <flatworm at users.sourceforge.net>
+
+	* receipts/receipts.tcl: Implement support for XEP-0184 v1.1.
+
 2010-12-01  Sergei Golovan <sgolovan at nes.ru>
 
 	* latex/latex.tcl: Fixed processing blacklisted words.

Modified: trunk/tkabber-plugins/receipts/receipts.tcl
===================================================================
--- trunk/tkabber-plugins/receipts/receipts.tcl	2010-12-01 08:59:49 UTC (rev 1972)
+++ trunk/tkabber-plugins/receipts/receipts.tcl	2010-12-03 02:10:43 UTC (rev 1973)
@@ -1,5 +1,5 @@
 # $Id$
-# Support for XEP-0184 "Message Receipts" (v1.0).
+# Support for XEP-0184 "Message Receipts" (v1.1 and 1.0).
 # Written by Konstantin Khomoutov <flatworm at users.sourceforge.net>
 # Artwork by Artem Bannikov <bannikov.artyom at gmail dot com>
 # See README for usage guidelines.
@@ -98,6 +98,10 @@
     return [roster::is_trusted $xlib $from]
 }
 
+# When parsing the <received> element, we prefer the value of its "id"
+# attribute, if present, over the value of the "id" attribute of the
+# enclosing <message> element. This allows to support both v1.1
+# and v1.0 versions of XEP-0184.
 proc receipts::process_message \
 	{xlib from id type is_subject subject body err thread priority x} {
     foreach element $x {
@@ -110,16 +114,22 @@
 	    }
 	    received {
 		if {![string equal $xmlns $::NS(receipts)]} continue
+		set id [::xmpp::xml::getAttr $attrs id $id]
 		process_receipt_response $xlib $from $id $type
 	    }
 	}
     }
 }
 
+# XMPP-0184 v1.1 suggests mirroring the id attribute of the source
+# message only in the <received> tag; mirroring of this attribute
+# in the <message> tag is the requirement of v1.0 and below.
+# We maintain both of them for backwards compatibility.
 proc receipts::process_receipt_request {xlib from id} {
     ::xmpp::sendMessage $xlib $from -id $id \
 	-xlist [list [::xmpp::xml::create received \
-				-xmlns $::NS(receipts)]]
+				-xmlns $::NS(receipts) \
+				-attrs [list id $id]]]
 }
 
 proc receipts::process_receipt_response {xlib from id type} {



More information about the Tkabber-dev mailing list