[Tkabber-dev] r95 - trunk/plugins/green

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Feb 11 21:10:24 MSK 2008


Author: kostix
Date: 2008-02-11 21:10:24 +0300 (Mon, 11 Feb 2008)
New Revision: 95

Modified:
   trunk/plugins/green/green.tcl
Log:
Redone logic for waiting the network to come up:
 now we don't block on resume, just set a timed event
 which, when fired checks each saved connection to
 see whether the user hasn't re-established it
 manually yet. Thus GUI don't block and processing
 of WM_POWERBROADCAST isn't blocked either.


Modified: trunk/plugins/green/green.tcl
===================================================================
--- trunk/plugins/green/green.tcl	2008-02-07 00:00:09 UTC (rev 94)
+++ trunk/plugins/green/green.tcl	2008-02-11 18:10:24 UTC (rev 95)
@@ -60,23 +60,25 @@
 
 proc green::on_resume {} {
 	variable options
+	variable active
+
 	if {!$options(resume_sessions)} return
-
-	variable active
 	if {[llength $active] == 0} return
 
-	after 0 [namespace current]::do_resume
+	after idle after [expr {$options(resume_delay) * 1000}] \
+		[namespace current]::do_resume
 }
 
 proc green::do_resume {} {
-	variable options
 	variable active
 
-	after [expr {$options(resume_delay) * 1000}]
-
 	set lcs [lsearch -all -inline -regexp [info vars ::*] ::loginconf\\d+]
 	if {[llength $lcs] == 0} {
-		login [array get ::loginconf]
+		upvar 0 ::loginconf lc
+		set jid $lc(user)@$lc(server)
+		if {[lsearch -exact $active $jid] >= 0 && ![jid_connected $jid]} {
+			login [array get ::loginconf]
+		}
 	} else {
 		foreach vlc $lcs {
 			upvar 0 $vlc lc
@@ -84,7 +86,7 @@
 					|| ![info exists lc(server)]} continue
 			set jid $lc(user)@$lc(server)
 			foreach saved $active {
-				if {[string equal $saved $jid]} {
+				if {[string equal $saved $jid] && ![jid_connected $jid]} {
 					login [concat [array get ::loginconf] [array get lc]]
 				}
 			}
@@ -92,3 +94,14 @@
 	}
 }
 
+proc green::jid_connected jid {
+	set ref [node_and_server_from_jid $jid]
+	foreach connid [::jlib::connections] {
+		set cjid [::jlib::connection_bare_jid $connid]
+		if {[string equal $ref $cjid]} {
+			return 1
+		}
+	}
+	return 0
+}
+



More information about the Tkabber-dev mailing list