[Tkabber-dev] r1498 - in trunk/tkabber: . plugins/chat plugins/roster

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Sep 10 21:25:02 MSD 2008


Author: sergei
Date: 2008-09-10 21:25:01 +0400 (Wed, 10 Sep 2008)
New Revision: 1498

Added:
   trunk/tkabber/plugins/chat/disco.tcl
Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/disco.tcl
   trunk/tkabber/muc.tcl
   trunk/tkabber/plugins/roster/conferences.tcl
Log:
	* disco.tcl: Added procedure which returns features list for a node.

	* plugins/chat/disco.tcl: Added a new plugin which implements /disco
	  command in a chat window. The command opens disco window either for
	  the curernt chat JID or for any specified JID.

	* muc.tcl, plugins/roster/conferences.tcl: Added MUC menu for room
	  configuration etc. to conference JID nodes in disco and to
	  conference bookmarks in a roster.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2008-09-09 18:28:29 UTC (rev 1497)
+++ trunk/tkabber/ChangeLog	2008-09-10 17:25:01 UTC (rev 1498)
@@ -1,3 +1,15 @@
+2008-09-10  Sergei Golovan  <sgolovan at nes.ru>
+
+	* disco.tcl: Added procedure which returns features list for a node.
+
+	* plugins/chat/disco.tcl: Added a new plugin which implements /disco
+	  command in a chat window. The command opens disco window either for
+	  the curernt chat JID or for any specified JID.
+
+	* muc.tcl, plugins/roster/conferences.tcl: Added MUC menu for room
+	  configuration etc. to conference JID nodes in disco and to
+	  conference bookmarks in a roster.
+
 2008-09-09  Sergei Golovan  <sgolovan at nes.ru>
 
 	* msgs/ru.msg: Fixed Russian translation.

Modified: trunk/tkabber/disco.tcl
===================================================================
--- trunk/tkabber/disco.tcl	2008-09-09 18:28:29 UTC (rev 1497)
+++ trunk/tkabber/disco.tcl	2008-09-10 17:25:01 UTC (rev 1498)
@@ -255,6 +255,15 @@
     }
 }
 
+proc disco::get_jid_features {connid jid node} {
+    variable disco
+    if {[info exists disco(info,features,$connid,$jid,$node)]} {
+	return $disco(info,features,$connid,$jid,$node)
+    } else {
+	return {}
+    }
+}
+
 proc disco::get_jid_items {connid jid node} {
     variable disco
     if {[info exists disco(items,$connid,$jid,$node)]} {

Modified: trunk/tkabber/muc.tcl
===================================================================
--- trunk/tkabber/muc.tcl	2008-09-09 18:28:29 UTC (rev 1497)
+++ trunk/tkabber/muc.tcl	2008-09-10 17:25:01 UTC (rev 1498)
@@ -141,6 +141,10 @@
     trace vdelete ::muc::muc_compatible($group) w \
 	[list muc::add_conference_menu_items $m $chatid $idx]
 
+    add_muc_menu_items $m $chatid $idx
+}
+
+proc muc::add_muc_menu_items {m chatid idx} {
     set mm [menu $m.muc -tearoff 0]
 
     $mm add command -label [::msgcat::mc "Configure room"] \
@@ -164,6 +168,47 @@
     $m insert $idx cascade -label [::msgcat::mc "MUC"] -menu $mm
 }
 
+proc muc::disco_node_menu_setup {m bw tnode data parentdata} {
+    lassign $data type connid jid node
+    lassign $parentdata ptype pconnid pjid pnode
+    switch -- $type {
+	item {
+	    set identities [disco::get_jid_identities $connid $jid $node]
+	    set pidentities [disco::get_jid_identities $pconnid $pjid $pnode]
+
+	    set features [disco::get_jid_features $connid $jid $node]
+	    set pfeatures [disco::get_jid_features $pconnid $pjid $pnode]
+
+	    # JID with resource is not a room JID
+	    if {[node_and_server_from_jid $jid] != $jid} return
+
+	    # A room must have non-empty node
+	    if {[node_from_jid $jid] == ""} return
+
+	    if {[lempty $identities]} {
+		set identities $pidentities
+	    }
+
+	    if {[lempty $features]} {
+		set features $pfeatures
+	    }
+
+	    foreach id $identities {
+		if {[jlib::wrapper:getattr $id category] == "conference"} {
+		    foreach f $features {
+			if {[jlib::wrapper:getattr $f var] == $::NS(muc)} {
+			    add_muc_menu_items $m [chat::chatid $connid $jid] end
+			    return
+			}
+		    }
+		}
+	    }
+	}
+    }
+}
+
+hook::add disco_node_menu_hook muc::disco_node_menu_setup 60
+
 ###############################################################################
 
 proc muc::handle_commands {chatid user body type} {

Added: trunk/tkabber/plugins/chat/disco.tcl
===================================================================
--- trunk/tkabber/plugins/chat/disco.tcl	                        (rev 0)
+++ trunk/tkabber/plugins/chat/disco.tcl	2008-09-10 17:25:01 UTC (rev 1498)
@@ -0,0 +1,39 @@
+# $Id$
+
+namespace eval cdisco {}
+
+proc cdisco::handle_disco_command {chatid user body type} {
+    set connid [chat::get_connid $chatid]
+    set jid [chat::get_jid $chatid]
+    set bjid [node_and_server_from_jid $jid]
+
+    if {![chat::is_groupchat [chat::chat_id $connid $bjid]]} {
+	set jid $bjid
+    }
+
+    set body [string trim $body]
+
+    if {[string equal [string range $body 0 6] "/disco "]} {
+	set jid [string range $body 7 end]
+    } elseif {![string equal $body "/disco"]} {
+	return
+    }
+
+    disco::browser::open_win $jid -connection $connid
+    return stop
+}
+
+hook::add chat_send_message_hook \
+    [namespace current]::cdisco::handle_disco_command 50
+
+proc cdisco::disco_command_comp {chatid compsvar wordstart line} {
+    upvar 0 $compsvar comps
+
+    if {!$wordstart} {
+	lappend comps {/disco }
+    }
+}
+
+hook::add generate_completions_hook \
+    [namespace current]::cdisco::disco_command_comp
+


Property changes on: trunk/tkabber/plugins/chat/disco.tcl
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Modified: trunk/tkabber/plugins/roster/conferences.tcl
===================================================================
--- trunk/tkabber/plugins/roster/conferences.tcl	2008-09-09 18:28:29 UTC (rev 1497)
+++ trunk/tkabber/plugins/roster/conferences.tcl	2008-09-10 17:25:01 UTC (rev 1498)
@@ -783,6 +783,9 @@
 				  -group [node_from_jid $jid] \
 				  -connection $connid] \
 				  $args]
+
+    # TODO: Check for real MUC? Move to muc.tcl?
+    muc::add_muc_menu_items $m [chat::chatid $connid $jid] end
 }   
 
 hook::add roster_conference_popup_menu_hook \



More information about the Tkabber-dev mailing list