[Tkabber-dev] r1543 - trunk/tkabber

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Oct 18 11:02:28 MSD 2008


Author: sergei
Date: 2008-10-18 11:02:27 +0400 (Sat, 18 Oct 2008)
New Revision: 1543

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/muc.tcl
   trunk/tkabber/presence.tcl
Log:
	* presence.tcl: Added packet ID to available presence options.

	* muc.tcl: Fixed changing nicknames.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2008-10-18 06:08:30 UTC (rev 1542)
+++ trunk/tkabber/ChangeLog	2008-10-18 07:02:27 UTC (rev 1543)
@@ -8,6 +8,10 @@
 	* joingrdialog.tcl, plugins/roster/conferences.tcl: Use JID command
 	  with optional resource.
 
+	* presence.tcl: Added packet ID to available presence options.
+
+	* muc.tcl: Fixed changing nicknames.
+
 2008-10-17  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/general/sound.tcl: Cleared sound external program option

Modified: trunk/tkabber/muc.tcl
===================================================================
--- trunk/tkabber/muc.tcl	2008-10-18 06:08:30 UTC (rev 1542)
+++ trunk/tkabber/muc.tcl	2008-10-18 07:02:27 UTC (rev 1543)
@@ -1314,8 +1314,10 @@
 proc muc::change_nick {chatid nick} {
     global userstatus textstatus
     global statusdesc
+    variable pids
 
     set group [chat::get_jid $chatid]
+    set xlib [chat::get_xlib $chatid]
 
     if {![is_compatible $group]} {
 	variable pending_nicks
@@ -1334,27 +1336,50 @@
 	set tstatus $textstatus
     }
 
-    send_custom_presence [chat::get_xlib $chatid] $group/$nick $status \
-	-status $tstatus \
-	-command [list muc::process_change_nick $chatid]
+    set id [::xmpp::packetID $xlib]
+    set pids($xlib,$id) $chatid
+
+    send_custom_presence $xlib $group/$nick $status \
+			 -status $tstatus \
+			 -id $id
 }
 
 
-proc muc::process_change_nick {chatid xlib from type x args} {
-    if {![cequal $type error]} {
+proc muc::process_change_nick {xlib from type x args} {
+    variable pids
+
+    set status ""
+    set error [::msgcat:: mc "Error"]
+    foreach {key val} $args {
+	switch -- $key {
+	    -id     {set id $val}
+	    -status {set status $val}
+	    -error  {set error [::xmpp::stanzaerror::message $val]}
+	}
+    }
+
+    if {![info exists id] || ![info exists pids($xlib,$id)]} {
 	return
     }
 
+    set chatid $pids($xlib,$id)
+    unset pids($xlib,$id)
+
+    if {![string equal $type error]} {
+	return
+    }
+
     if {![is_compatible [chat::get_jid $chatid]] && \
 	    [is_changing_nick $chatid]} {
 	variable pending_nicks
 	unset pending_nicks($chatid)
     }
-    chat::add_message $chatid [node_and_server_from_jid $from] error \
-	[::msgcat::mc "Error %s" [::xmpp::xml::getAttr $args -status]] {}
-    return break
+
+    chat::add_message $chatid [::xmpp::jid::stripResource $from] error $error {}
+    return stop
 }
 
+hook::add client_presence_hook muc::process_change_nick 10
 
 proc muc::is_changing_nick {chatid} {
     variable pending_nicks
@@ -1366,6 +1391,16 @@
     }
 }
 
+proc muc::clear_changing_nicks {xlib} {
+    variable pending_nicks
+    variable pids
+
+    array unset pending_nicks [list $xlib *]
+    array unset pids $xlib,*
+}
+
+hook::add disconnected_hook muc::clear_changing_nicks
+
 ###############################################################################
 
 proc muc::request_negotiation {xlib group} {

Modified: trunk/tkabber/presence.tcl
===================================================================
--- trunk/tkabber/presence.tcl	2008-10-18 06:08:30 UTC (rev 1542)
+++ trunk/tkabber/presence.tcl	2008-10-18 07:02:27 UTC (rev 1543)
@@ -484,6 +484,7 @@
     set stat ""
     foreach {opt val} $args {
 	switch -- $opt {
+	    -id       { lappend newargs -id $val }
 	    -to       { lappend newargs -to $val }
 	    -priority { lappend newargs -priority $val }
 	    -xlist    { set xlist $val }



More information about the Tkabber-dev mailing list