[Tkabber-dev] r880 - in trunk/tkabber: . ifacetk plugins/chat plugins/general plugins/roster

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Jan 20 01:03:29 MSK 2007


Author: sergei
Date: 2007-01-20 01:03:20 +0300 (Sat, 20 Jan 2007)
New Revision: 880

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/chats.tcl
   trunk/tkabber/ifacetk/iface.tcl
   trunk/tkabber/ifacetk/iroster.tcl
   trunk/tkabber/muc.tcl
   trunk/tkabber/plugins/chat/chatstate.tcl
   trunk/tkabber/plugins/chat/events.tcl
   trunk/tkabber/plugins/chat/irc_commands.tcl
   trunk/tkabber/plugins/general/remote.tcl
   trunk/tkabber/plugins/roster/conferenceinfo.tcl
   trunk/tkabber/plugins/roster/conferences.tcl
   trunk/tkabber/presence.tcl
   trunk/tkabber/utils.tcl
Log:
	* plugins/roster/conferences.tcl: Do not autojoin already joined
	  conference room (this might change nickname, if it's unusual).

	* utils.tcl: Added two functions: lmap and lfilter to apply function
	  to list elements and to filter list using specified function.

	* chats.tcl, ifacetk/iface.tcl, ifacetk/iroster.tcl, muc.tcl,
	  plugins/chat/chatstate.tcl, plugins/chat/events.tcl,
	  plugins/chat/irc_commands.tcl, plugins/general/remote.tcl,
	  plugins/roster/conferenceinfo.tcl, plugins/roster/conferences.tcl,
	  presence.tcl: Code cleanup, removed almost all external references
	  to internal variables in ::chat namespace.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/ChangeLog	2007-01-19 22:03:20 UTC (rev 880)
@@ -1,3 +1,18 @@
+2007-01-19  Sergei Golovan  <sgolovan at nes.ru>
+
+	* plugins/roster/conferences.tcl: Do not autojoin already joined
+	  conference room (this might change nickname, if it's unusual).
+
+	* utils.tcl: Added two functions: lmap and lfilter to apply function
+	  to list elements and to filter list using specified function.
+
+	* chats.tcl, ifacetk/iface.tcl, ifacetk/iroster.tcl, muc.tcl,
+	  plugins/chat/chatstate.tcl, plugins/chat/events.tcl,
+	  plugins/chat/irc_commands.tcl, plugins/general/remote.tcl,
+	  plugins/roster/conferenceinfo.tcl, plugins/roster/conferences.tcl,
+	  presence.tcl: Code cleanup, removed almost all external references
+	  to internal variables in ::chat namespace.
+
 2007-01-18  Sergei Golovan  <sgolovan at nes.ru>
 
 	* muc.tcl: Fixed reporting own presences in MUC rooms.

Modified: trunk/tkabber/chats.tcl
===================================================================
--- trunk/tkabber/chats.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/chats.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -13,7 +13,6 @@
 
 
 namespace eval chat {
-    array set opened {}
     set enrichid 0
     custom::defgroup Chat [::msgcat::mc "Chat options."] -group Tkabber
     custom::defvar options(smart_scroll) 0 \
@@ -197,7 +196,6 @@
 proc chat::process_message_fallback \
      {connid from id type is_subject subject body err thread priority x} {
     global font
-    variable opened
     variable chats
 
     set chatid [chatid $connid $from]
@@ -261,8 +259,6 @@
 ###############################################################################
 
 proc chat::window_titles {chatid} {
-    variable chats
-
     set connid [get_connid $chatid]
     set jid [get_jid $chatid]
     set chatname [roster::itemconfig $connid \
@@ -288,23 +284,19 @@
     variable chats
     global grouproster
 	
-    if {![info exists chats(opened)]} return
-
-    foreach chatid $chats(opened) {
-	if {[cequal [get_connid $chatid] $connid]} {
-	    if {[is_groupchat $chatid]} {
-		if {[info exists ::muc::muc_password($chatid)]} {
-		    set password $::muc::muc_password($chatid)
-		} else {
-		    set password ""
-		}
-		muc::join_group $connid \
-		    [get_jid $chatid] \
-		    [get_our_groupchat_nick $chatid] \
-		    $password \
+    foreach chatid [opened $connid] {
+	if {[is_groupchat $chatid]} {
+	    if {[info exists ::muc::muc_password($chatid)]} {
+		set password $::muc::muc_password($chatid)
 	    } else {
-		set chats(status,$chatid) connected
+		set password ""
 	    }
+	    muc::join_group $connid \
+			    [get_jid $chatid] \
+			    [get_our_groupchat_nick $chatid] \
+			    $password
+	} else {
+	    set chats(status,$chatid) connected
 	}
     }
 }
@@ -315,32 +307,28 @@
     variable chats
     global statusdesc
 
-    if {![info exists chats(opened)]} return
+    foreach chatid [opened $connid] {
+	if {![winfo exists [chat_win $chatid]]} return
 
-    foreach chatid $chats(opened) {
-	if {[cequal $connid {}] || [cequal [get_connid $chatid] $connid]} {
-	    set jid [get_jid $chatid]
+	set jid [get_jid $chatid]
 
-	    set chatw [chat_win $chatid]
-	    if {[winfo exists $chatw] && \
-		    $chats(status,$chatid) != "disconnected"} {
-		set chats(status,$chatid) disconnected
-		add_message $chatid $jid error \
-		    [::msgcat::mc "Disconnected"] {}
-	    }
+	if {$chats(status,$chatid) != "disconnected"} {
+	    set chats(status,$chatid) disconnected
+	    add_message $chatid $jid error [::msgcat::mc "Disconnected"] {}
+	}
 
-	    set cw [winid $chatid]
+	set cw [winid $chatid]
 
-	    if {[winfo exists $cw.status.icon]} {
-		$cw.status.icon configure \
-		    -image [ifacetk::roster::get_jid_icon $connid $jid unavailable] \
-		    -helptext ""
-	    }
+	if {[winfo exists $cw.status.icon]} {
+	    $cw.status.icon configure \
+		-image [ifacetk::roster::get_jid_icon $connid $jid unavailable] \
+		-helptext ""
+	}
 
-	    if {[winfo exists $cw.status.desc]} {
-		$cw.status.desc configure -text "($statusdesc(unavailable))" \
-		    -helptext ""
-	    }
+	if {[winfo exists $cw.status.desc]} {
+	    $cw.status.desc configure \
+		-text "($statusdesc(unavailable))" \
+		-helptext ""
 	}
     }
 }
@@ -350,7 +338,6 @@
 proc chat::open_window {chatid type args} {
     global font font_bold font_italic font_bold_italic
     global chat_width chat_height
-    variable opened
     variable chats
     variable chat_id
     variable options
@@ -398,13 +385,9 @@
 	set chats(status,$chatid) connected
     }
     set chats(exit_status,$chatid) ""
-    lappend chats(opened) $chatid
+    add_to_opened $chatid
     
-    set opened($chatid) $cw
     set chat_id($cw) $chatid
-    #debugmsg chat $cw
-    #debugmsg chat [array names opened_chats]
-    #debugmsg chat $opened_chats($chatid)
 
     lassign [chat::window_titles $chatid] chats(tabtitlename,$chatid) \
 	chats(titlename,$chatid)
@@ -567,6 +550,7 @@
 
 proc chat::dropovercmd {chatid target source event x y op type data} {
     variable chats
+
     set chat_connid [get_connid $chatid]
     lassign $data jid_connid jid
 
@@ -618,13 +602,12 @@
 ###############################################################################
 
 proc chat::close_window {chatid} {
-    variable opened
     variable chats
     variable chat_id
 
-    if {![info exists opened($chatid)]} return
+    if {![is_opened $chatid]} return
 
-    unset opened($chatid)
+    remove_from_opened $chatid
 
     set connid [get_connid $chatid]
     set jid [get_jid $chatid]
@@ -632,10 +615,6 @@
     set cw [winid $chatid]
     unset chat_id($cw)
 
-    set idx [lsearch -exact $chats(opened) $chatid]
-    set chats(opened) [lreplace $chats(opened) $idx $idx]
-    debugmsg chat $chats(opened)
-
     if {[is_groupchat $chatid]} {
 	muc::leave_group $connid $jid [get_our_groupchat_nick $chatid] \
 			 $chats(exit_status,$chatid)
@@ -650,15 +629,60 @@
     hook::run close_chat_post_hook $chatid
 }
 
-proc chat::opened {} {
+##############################################################################
+
+proc chat::check_connid {connid chatid} {
+    if {[get_connid $chatid] == $connid} {
+	return 1
+    } else {
+	return 0
+    }
+}
+
+##############################################################################
+
+proc chat::opened {{connid {}}} {
     variable chats
-    if {[info exists chats(opened)]} {
+
+    if {![info exists chats(opened)]} {
+	return {}
+    } elseif {$connid != {}} {
+	return [lfilter [list [namespace current]::check_connid $connid] \
+			$chats(opened)]
+    } else {
 	return $chats(opened)
+    }
+}
+
+proc chat::is_opened {chatid} {
+    variable chats
+
+    if {[info exists chats(opened)] && \
+	    ([lsearch -exact $chats(opened) $chatid] >= 0)} {
+	return 1
     } else {
-	return {}
+	return 0
     }
 }
 
+proc chat::add_to_opened {chatid} {
+    variable chats
+
+    lappend chats(opened) $chatid
+    set chats(opened) [lsort -unique $chats(opened)]
+}
+
+proc chat::remove_from_opened {chatid} {
+    variable chats
+
+    set idx [lsearch -exact $chats(opened) $chatid]
+    if {$idx >= 0} {
+	set chats(opened) [lreplace $chats(opened) $idx $idx]
+    }
+}
+
+##############################################################################
+
 proc chat::users_win {chatid} {
     variable chats
     return $chats(userswin,$chatid)
@@ -674,6 +698,17 @@
     return $chats(inputwin,$chatid)
 }
 
+##############################################################################
+
+proc chat::is_chat {chatid} {
+    variable chats
+    if {[info exists chats(type,$chatid)]} {
+	return [cequal $chats(type,$chatid) chat]
+    } else {
+	return 1
+    }
+}
+
 proc chat::is_groupchat {chatid} {
     variable chats
     if {[info exists chats(type,$chatid)]} {
@@ -683,6 +718,8 @@
     }
 }
 
+##############################################################################
+
 proc chat::is_disconnected {chatid} {
     variable chats
 
@@ -695,6 +732,8 @@
 
 }
 
+##############################################################################
+
 proc chat::create_user_menu {m chatid} {
     menu $m -tearoff 0
 
@@ -756,10 +795,9 @@
 
 proc chat::add_message {chatid from type body x} {
     variable chats
-    variable opened
     variable options
 
-    if {[info exists opened($chatid)]} {
+    if {[is_opened $chatid]} {
 	set chatw [chat_win $chatid]
 
 	if {[lindex [$chatw yview] 1] == 1} {
@@ -773,7 +811,7 @@
 
     hook::run draw_message_hook $chatid $from $type $body $x
 
-    if {[info exists opened($chatid)]} {
+    if {[is_opened $chatid]} {
 	set chatw [chat_win $chatid]
 
 	if {![$chatw compare "end -1 chars linestart" == "end -1 chars"]} {
@@ -852,7 +890,6 @@
 proc chat::change_presence {connid jid type x args} {
     global grouproster
     variable chats
-    variable opened
     variable options
     global statusdesc
 
@@ -873,7 +910,7 @@
     set group [node_and_server_from_jid $jid]
     set chatid [chatid $connid $group]
 
-    if {[info exists opened($chatid)]} {
+    if {[is_opened $chatid]} {
 	if {[is_groupchat $chatid]} {
 	    debugmsg chat "ST: $connid $jid $status"
 	    if {[resource_from_jid $jid] == ""} {
@@ -934,7 +971,7 @@
     # This case traces both chat and private groupchat conversations:
     if {$options(gen_status_change_msgs)} {
 	set chatid [chatid $connid $jid]
-	if {[info exists opened($chatid)]} {
+	if {[is_opened $chatid]} {
 	    set msg [get_nick $connid $jid chat]
 	    append msg " " [::get_long_status_desc [::get_user_status $connid $jid]]
 	    set desc [::get_user_status_desc $connid $jid]
@@ -1069,24 +1106,22 @@
 }
 
 proc chat::restore_subject {chatid} {
-    variable opened
     variable chats
 
     set sw [winid $chatid].status.subject
 
-    if {[info exists opened($chatid)] && [winfo exists $sw]} {
+    if {[is_opened $chatid] && [winfo exists $sw]} {
 	$sw delete 0 end
 	$sw insert 0 $chats(subject,$chatid)
     }
 }
 
 proc chat::set_subject {chatid subject} {
-    variable opened
     variable chats
 
     set cw [winid $chatid]
 
-    if {[info exists opened($chatid)]} {
+    if {[is_opened $chatid]} {
 	$cw.status.subject delete 0 end
 	$cw.status.subject insert 0 $subject
 	set chats(subject,$chatid) $subject
@@ -1187,7 +1222,6 @@
 
 proc chat::invite_dialog {user {ignore_muc 0} args} {
     variable chats
-    variable opened
     global invite_gc
 
     foreach {opt val} $args {
@@ -1220,11 +1254,9 @@
 
     set titles {}
     set jids {}
-    foreach chatid [lsort [array names opened]] {
-        if {([get_connid $chatid] == $connid) && [is_groupchat $chatid]} {
-	    lappend jids $chatid [get_jid $chatid]
-            lappend titles $chatid [node_from_jid [get_jid $chatid]]
-	}
+    foreach chatid [lsort [lfilter [namespace current]::is_groupchat [opened $connid]]] {
+	lappend jids $chatid [get_jid $chatid]
+        lappend titles $chatid [node_from_jid [get_jid $chatid]]
     }
     if {[llength $titles] == 0} {
         MessageDlg ${gw}_err -aspect 50000 -icon info \
@@ -1245,7 +1277,6 @@
 
 proc chat::invite_dialog2 {jid ignore_muc args} {
     variable chats
-    variable opened
     global invite_gc
 
     foreach {opt val} $args {

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/ifacetk/iface.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -959,7 +959,7 @@
     variable number_msg
     variable personal_msg
 
-    set cw $chat::opened($chatid)
+    set cw [chat::winid $chatid]
 
     if {$usetabbar} {
 	set tabtitle $chat::chats(tabtitlename,$chatid)

Modified: trunk/tkabber/ifacetk/iroster.tcl
===================================================================
--- trunk/tkabber/ifacetk/iroster.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/ifacetk/iroster.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -356,17 +356,14 @@
 	}
 	if {$options(chats_group)} {
 	    set cgroup [list $chats_group_name]
-	    foreach chatid [array names chat::opened] {
-		set cid [chat::get_connid $chatid]
-		if {$cid == $connid} {
-		    set jid [chat::get_jid $chatid]
-		    lappend jidsingroup($cgroup) $jid
-		    if {[cequal [roster::itemconfig $connid $jid -isuser] ""]} {
-			roster::itemconfig $connid $jid -isuser 1
-			roster::itemconfig $connid $jid \
-			    -name [chat::get_nick $connid $jid chat]
-			roster::itemconfig $connid $jid -subsc none
-		    }
+	    foreach chatid [chat::opened $connid] {
+		set jid [chat::get_jid $chatid]
+		lappend jidsingroup($cgroup) $jid
+		if {[cequal [roster::itemconfig $connid $jid -isuser] ""]} {
+		    roster::itemconfig $connid $jid -isuser 1
+		    roster::itemconfig $connid $jid \
+			-name [chat::get_nick $connid $jid chat]
+		    roster::itemconfig $connid $jid -subsc none
 		}
 	    }
 	    if {[info exists jidsingroup($cgroup)]} {

Modified: trunk/tkabber/muc.tcl
===================================================================
--- trunk/tkabber/muc.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/muc.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -1544,12 +1544,9 @@
 	}
 	items {
 	    set res {}
-	    foreach chatid [array names chat::opened] {
-		set connid1 [chat::get_connid $chatid]
+	    foreach chatid [lfilter chat::is_groupchat [chat::opened $connid]] {
 		set group [chat::get_jid $chatid]
-		if {[cequal $connid $connid1] &&
-			[cequal $chat::chats(type,$chatid) groupchat] && \
-			[is_compatible $group]} {
+		if {[is_compatible $group]} {
 		    lappend res [jlib::wrapper:createtag item \
 				     -vars [list jid $group]]
 		}

Modified: trunk/tkabber/plugins/chat/chatstate.tcl
===================================================================
--- trunk/tkabber/plugins/chat/chatstate.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/plugins/chat/chatstate.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -121,7 +121,7 @@
     variable options
     variable chatstate
 
-    if {$::chat::chats(type,$chatid) != "chat"} return
+    if {![chat::is_chat $chatid]} return
     if {$sym == ""} return
     if {[info exists chatstate(composing,$chatid)] && \
 	    !$chatstate(composing,$chatid)} return
@@ -144,7 +144,7 @@
     variable chatstate
     global font
 
-    if {$::chat::chats(type,$chatid) != "chat"} return
+    if {![chat::is_chat $chatid]} return
 
     set cw [chat::winid $chatid]
 
@@ -162,7 +162,7 @@
 hook::add open_chat_post_hook [namespace current]::chatstate::setup_ui
 
 proc chatstate::clear_status_on_send {chatid user body type} {
-    if {$::chat::chats(type,$chatid) != "chat"} return
+    if {![chat::is_chat $chatid]} return
     clear_status $chatid
 }
 
@@ -195,7 +195,7 @@
     if {![info exists chatstate(windowactive,$chatid)] || \
 	    ($chatstate(windowactive,$chatid) == 0)} return
 
-    if {$::chat::chats(type,$chatid) != "chat"} return
+    if {![chat::is_chat $chatid]} return
     if {!$options(enable)} return
 
     set connid [chat::get_connid $chatid]

Modified: trunk/tkabber/plugins/chat/events.tcl
===================================================================
--- trunk/tkabber/plugins/chat/events.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/plugins/chat/events.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -160,7 +160,7 @@
     variable options
     variable events
 
-    if {$::chat::chats(type,$chatid) != "chat"} return
+    if {![chat::is_chat $chatid]} return
     if {![info exists events(displayed,$chatid)] || \
 	    !$events(displayed,$chatid)} return
 
@@ -188,7 +188,7 @@
     variable options
     variable events
 
-    if {$::chat::chats(type,$chatid) != "chat"} return
+    if {![chat::is_chat $chatid]} return
     if {$sym == ""} return
     if {![info exists events(composing,$chatid)] || \
 	    !$events(composing,$chatid)} return
@@ -215,7 +215,7 @@
     variable events
     global font
 
-    if {$::chat::chats(type,$chatid) != "chat"} return
+    if {![chat::is_chat $chatid]} return
 
     set cw [chat::winid $chatid]
 
@@ -233,7 +233,7 @@
 hook::add open_chat_post_hook [namespace current]::events::setup_ui
 
 proc events::clear_status_on_send {chatid user body type} {
-    if {$::chat::chats(type,$chatid) != "chat"} return
+    if {![chat::is_chat $chatid]} return
     clear_status $chatid
 }
 

Modified: trunk/tkabber/plugins/chat/irc_commands.tcl
===================================================================
--- trunk/tkabber/plugins/chat/irc_commands.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/plugins/chat/irc_commands.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -167,13 +167,9 @@
 		}
 	    }
 	} else {
-	    foreach chatid1 [chat::opened] {
-		if {[chat::get_connid $chatid1] == $connid} {
-		    if {[chat::is_groupchat $chatid1]} {
-			set jid [chat::get_jid $chatid1]
-			lappend jidcomps $prefix$jid$suffix
-		    }
-		}
+	    foreach chatid1 [lfilter chat::is_groupchat [chat::opened $connid]] {
+		set jid [chat::get_jid $chatid1]
+		lappend jidcomps $prefix$jid$suffix
 	    }
 	}
         set jidcomps [lsort -dictionary -unique $jidcomps]

Modified: trunk/tkabber/plugins/general/remote.tcl
===================================================================
--- trunk/tkabber/plugins/general/remote.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/plugins/general/remote.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -490,19 +490,15 @@
     set options {}
     set lang $state(lang)
     set connid $state(connid)
-    foreach chatid [chat::opened] {
+    foreach chatid [lfilter chat::is_groupchat [chat::opened $connid]] {
 	set jid [chat::get_jid $chatid]
-
-	if {![cequal [chat::get_connid $chatid] $connid]} continue
-	if {![chat::is_groupchat $chatid]} continue
-	if {[cequal [get_jid_presence_info show $connid $jid] ""]} continue
-
-	set nick [get_our_groupchat_nick $chatid]
-
-	lappend options [list $jid [format [::trans::trans $lang "%s at %s"] \
-					   $nick $jid]]
+	if {![cequal [get_jid_presence_info show $connid $jid] ""]} {
+	    set nick [get_our_groupchat_nick $chatid]
+	    lappend options [list $jid [format [::trans::trans $lang "%s at %s"] \
+					       $nick $jid]]
+	}
     }
-    if {[expr [llength $options] == 0]} {
+    if {[llength $options] == 0} {
 	return [list completed [jlib::wrapper:createtag note \
 				    -vars {type info} \
 				    -chdata [::trans::trans $lang \
@@ -583,14 +579,11 @@
 	set connid $state(connid)
 	set state(groupchats) ""
 
-	foreach chatid [chat::opened] {
+	foreach chatid [lfilter chat::is_groupchat [chat::opened $connid]] {
 	    set jid [chat::get_jid $chatid]
-
-	    if {![cequal [chat::get_connid $chatid] $connid]} continue
-	    if {![chat::is_groupchat $chatid]} continue
-	    if {[cequal [get_jid_presence_info show $connid $jid] ""]} continue
-
-	    lappend state(groupchats) $jid
+	    if {![cequal [get_jid_presence_info show $connid $jid] ""]} {
+		lappend state(groupchats) $jid
+	    }
 	}
     }
 
@@ -652,7 +645,7 @@
 
 	lappend options [list $id [format $msg $name $count]]
     }
-    if {[expr [llength $options] == 0]} {
+    if {[llength $options] == 0} {
 	return [list completed [jlib::wrapper:createtag note \
 				    -vars {type info} \
 				    -chdata \

Modified: trunk/tkabber/plugins/roster/conferenceinfo.tcl
===================================================================
--- trunk/tkabber/plugins/roster/conferenceinfo.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/plugins/roster/conferenceinfo.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -27,7 +27,7 @@
     upvar 0 $infovar info
 
     if {!$options(autoask)} return
-    if {[info exists chat::opened([chat::chatid $connid $jid])]} return
+    if {[chat::is_opened [chat::chatid $connid $jid]]} return
 
     if {![info exists data(error_browse,$jid)] || \
 	    ![info exists data(error_disco,$jid)]} return
@@ -77,7 +77,7 @@
 	    lassign [roster::get_category_and_subtype $connid $jid] \
 		category type
 	    if {$category == "conference" && [node_from_jid $jid] != "" && \
-		    ![info exists chat::opened([chat::chatid $connid $jid])]} {
+		    ![chat::is_opened [chat::chatid $connid $jid]]} {
 	    
 		set sec [clock seconds]
  

Modified: trunk/tkabber/plugins/roster/conferences.tcl
===================================================================
--- trunk/tkabber/plugins/roster/conferences.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/plugins/roster/conferences.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -691,7 +691,8 @@
 
     foreach idx [array names bookmarks $connid,jid,*] {
 	set jid $bookmarks($idx)
-	if {$bookmarks($connid,autojoin,$jid)} {
+	set chatid [chat::chatid $connid $jid]
+	if {$bookmarks($connid,autojoin,$jid) && ![chat::is_opened $chatid]} {
 	    autojoin_group $connid $jid
 	}
     }

Modified: trunk/tkabber/presence.tcl
===================================================================
--- trunk/tkabber/presence.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/presence.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -403,24 +403,22 @@
 		      -connection $connid
     }
 
-    foreach chatid [array names chat::opened] {
+    foreach chatid [lfilter chat::is_groupchat [chat::opened]] {
 	set connid [chat::get_connid $chatid]
 	set group [chat::get_jid $chatid]
-	if {[cequal $chat::chats(type,$chatid) groupchat]} {
-	    set nick [get_our_groupchat_nick $chatid]
+	set nick [get_our_groupchat_nick $chatid]
 
-	    if {$newstatus == "invisible"} {
-		set newst available
-	    } else {
-		set newst $newstatus
-	    }
-
-	    send_presence $newst \
-			  -to $group/$nick \
-			  -stat $status \
-			  -pri $userpriority \
-			  -connection $connid
+	if {$newstatus == "invisible"} {
+	    set newst available
+	} else {
+	    set newst $newstatus
 	}
+
+	send_presence $newst \
+		      -to $group/$nick \
+		      -stat $status \
+		      -pri $userpriority \
+		      -connection $connid
     }
 
     set curuserstatus $newstatus

Modified: trunk/tkabber/utils.tcl
===================================================================
--- trunk/tkabber/utils.tcl	2007-01-18 21:37:19 UTC (rev 879)
+++ trunk/tkabber/utils.tcl	2007-01-19 22:03:20 UTC (rev 880)
@@ -496,4 +496,22 @@
     set res
 }
 
+proc lmap {command list} {
+    set newlist {}
+    foreach elem $list {
+	lappend newlist [eval $command [list $elem]]
+    }
+    return $newlist
+}
+
+proc lfilter {command list} {
+    set newlist {}
+    foreach elem $list {
+	if {[eval $command [list $elem]]} {
+	    lappend newlist $elem
+	}
+    }
+    return $newlist
+}
+
 # vim:ts=8:sw=4:sts=4:noet



More information about the Tkabber-dev mailing list