[Tkabber-dev] r102 - in trunk/plugins: . receipts receipts/images

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Apr 7 01:34:09 MSD 2008


Author: kostix
Date: 2008-04-07 01:34:08 +0400 (Mon, 07 Apr 2008)
New Revision: 102

Added:
   trunk/plugins/receipts/
   trunk/plugins/receipts/AUTHORS
   trunk/plugins/receipts/INSTALL
   trunk/plugins/receipts/README
   trunk/plugins/receipts/TODO
   trunk/plugins/receipts/images/
   trunk/plugins/receipts/images/confirmed.gif
   trunk/plugins/receipts/images/unconfirmed.gif
   trunk/plugins/receipts/license.terms
   trunk/plugins/receipts/receipts.tcl
Log:
receipts: Added preliminary implementation of new plugin implementing
 XEP-0184 "Message receipts".


Added: trunk/plugins/receipts/AUTHORS
===================================================================
--- trunk/plugins/receipts/AUTHORS	                        (rev 0)
+++ trunk/plugins/receipts/AUTHORS	2008-04-06 21:34:08 UTC (rev 102)
@@ -0,0 +1,2 @@
+Konstantin Khomoutov <flatworm at users.sourceforge.com>
+Artwork by Artem Bannikov <bannikov.artyom at gmail dot com>


Property changes on: trunk/plugins/receipts/AUTHORS
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/plugins/receipts/INSTALL
===================================================================
--- trunk/plugins/receipts/INSTALL	                        (rev 0)
+++ trunk/plugins/receipts/INSTALL	2008-04-06 21:34:08 UTC (rev 102)
@@ -0,0 +1,9 @@
+As usually, copy this directory under the ~/.tkabber/plugins directory
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/receipts/
+  ~/.tkabber/plugins/receipts/receipts.tcl
+
+Restart Tkabber, to get the plugin loaded.
+Consult the README file for the details about using this plugin.
+


Property changes on: trunk/plugins/receipts/INSTALL
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/plugins/receipts/README
===================================================================
--- trunk/plugins/receipts/README	                        (rev 0)
+++ trunk/plugins/receipts/README	2008-04-06 21:34:08 UTC (rev 102)
@@ -0,0 +1,23 @@
+$Id$
+"Message receipts" -- plugin for Tkabber.
+
+
+I. The Idea
+
+This plugin implements XEP-0184 "Message receipts": in
+one-to-one chat sessions it is able to request confirmations of
+reception of outgoing messages and reply to such requests coming
+from remote party.
+Rception status is tracked for each message placed in the chat
+log window of a chat session using special icon: when the
+message is sent, the icon depicts "unconfirmed" status, when the
+confirmation arrives for this message, the icon associated with
+this message is changed to depict "confirmed" status.
+
+
+II. Limitations
+
+Some important functionality is missing, see TODO for details.
+
+
+# vim:tw=64:noet


Property changes on: trunk/plugins/receipts/README
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/plugins/receipts/TODO
===================================================================
--- trunk/plugins/receipts/TODO	                        (rev 0)
+++ trunk/plugins/receipts/TODO	2008-04-06 21:34:08 UTC (rev 102)
@@ -0,0 +1,19 @@
+$Id$
+
+HIGH
+
+* Think of possible race condition when the receipts arrives
+  before the message is displayed.
+
+* Catch error responses (if any defined) and "blacklist" that
+  peer.
+
+* Provide Customize options.
+
+
+LOW
+
+* Honor peer's features, if available.
+
+
+# vim:tw=64:noet


Property changes on: trunk/plugins/receipts/TODO
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/plugins/receipts/images/confirmed.gif
===================================================================
(Binary files differ)


Property changes on: trunk/plugins/receipts/images/confirmed.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/plugins/receipts/images/unconfirmed.gif
===================================================================
(Binary files differ)


Property changes on: trunk/plugins/receipts/images/unconfirmed.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/plugins/receipts/license.terms
===================================================================
--- trunk/plugins/receipts/license.terms	                        (rev 0)
+++ trunk/plugins/receipts/license.terms	2008-04-06 21:34:08 UTC (rev 102)
@@ -0,0 +1,19 @@
+Copyright (c) 2008 Konstantin Khomoutov <flatworm at users.sourceforge.net>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.


Property changes on: trunk/plugins/receipts/license.terms
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/plugins/receipts/receipts.tcl
===================================================================
--- trunk/plugins/receipts/receipts.tcl	                        (rev 0)
+++ trunk/plugins/receipts/receipts.tcl	2008-04-06 21:34:08 UTC (rev 102)
@@ -0,0 +1,89 @@
+# $Id$
+# Support for XEP-0184 "Message Receipts" (v1.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.
+# See license.terms for legal details on usage and distribution.
+
+namespace eval receipts {
+    set ::NS(receipts) urn:xmpp:receipts
+
+    foreach item {confirmed unconfirmed} {
+	image create photo receipts/$item \
+	    -file [file join [file dirname [info script]] images $item.gif]
+    }
+    unset item
+
+    hook::add process_message_hook \
+	[namespace current]::process_message
+    hook::add chat_send_message_xlist_hook \
+	[namespace current]::attach_confirmation_request
+    hook::add draw_message_hook \
+	[namespace current]::mark_unconfirmed 5
+}
+
+proc receipts::process_message \
+	{connid from id type is_subject subject body err thread priority x} {
+    global NS
+    foreach element $x {
+	jlib::wrapper:splitxml $element tag vars isempty chdata children
+	switch -- $tag {
+	    request {
+		set xmlns [jlib::wrapper:getattr $vars xmlns]
+		if {![string equal $xmlns $NS(receipts)]} continue
+		process_receipt_request $connid $from $id
+	    }
+	    received {
+		set xmlns [jlib::wrapper:getattr $vars xmlns]
+		if {![string equal $xmlns $NS(receipts)]} continue
+		process_receipt_response $connid $from $id $type
+	    }
+	}
+    }
+}
+
+proc receipts::process_receipt_request {connid from id} {
+    global NS
+
+    jlib::send_msg $from -id $id \
+	-xlist [list [jlib::wrapper:createtag received \
+	    -vars [list xmlns $NS(receipts)]]] \
+	-connection $connid
+}
+
+proc receipts::process_receipt_response {connid from id type} {
+    if {![string equal $type chat]} return
+
+    set chatid [chat::chatid $connid $from]
+    set cw [chat::chat_win $chatid]
+
+    set name msgid_$id
+    if {[lsearch -exact [$cw image names] $name] >= 0} {
+	$cw image configure $name -image receipts/confirmed
+    }
+}
+
+proc receipts::mark_unconfirmed {chatid from type body x} {
+    if {![string equal $type chat]} return
+    if {![richtext::property_exists msgid]} return
+
+    set id [richtext::property_get msgid]
+
+    set cw [chat::chat_win $chatid]
+    $cw image create end -name msgid_$id -image receipts/unconfirmed
+}
+
+proc receipts::attach_confirmation_request {xlistVar chatid user body type} {
+    if {![chat::is_chat $chatid]} return
+
+    global NS chat_msg_id
+    upvar 2 $xlistVar xlist
+
+    lappend xlist [jlib::wrapper:createtag request \
+		    -vars [list xmlns $NS(receipts)]]
+
+    richtext::property_update msgid $chat_msg_id
+}
+
+# vim:ts=8:sw=4:sts=4:noet
+


Property changes on: trunk/plugins/receipts/receipts.tcl
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native



More information about the Tkabber-dev mailing list