[Tkabber-dev] r1620 - in trunk/tkabber: . plugins/general

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Dec 10 15:33:51 MSK 2008


Author: sergei
Date: 2008-12-10 15:33:50 +0300 (Wed, 10 Dec 2008)
New Revision: 1620

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/general/autoaway.tcl
Log:
	* plugins/general/autoaway.tcl: Start timer at Tkabber start and
	  stop at exit instead of connect/disconnect to prevent racing with
	  reconnection code.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2008-11-26 15:02:08 UTC (rev 1619)
+++ trunk/tkabber/ChangeLog	2008-12-10 12:33:50 UTC (rev 1620)
@@ -1,3 +1,9 @@
+2008-12-10  Sergei Golovan  <sgolovan at nes.ru>
+
+	* plugins/general/autoaway.tcl: Start timer at Tkabber start and
+	  stop at exit instead of connect/disconnect to prevent racing with
+	  reconnection code.
+
 2008-11-26  Sergei Golovan  <sgolovan at nes.ru>
 
 	* login.tcl: Refixed bug with incorrect disconnecting from the server

Modified: trunk/tkabber/plugins/general/autoaway.tcl
===================================================================
--- trunk/tkabber/plugins/general/autoaway.tcl	2008-11-26 15:02:08 UTC (rev 1619)
+++ trunk/tkabber/plugins/general/autoaway.tcl	2008-12-10 12:33:50 UTC (rev 1620)
@@ -7,7 +7,6 @@
     variable savepriority 0
 }
 
-
 proc autoaway::load {} {
     global tcl_platform
     global idle_command
@@ -69,8 +68,8 @@
 	[::msgcat::mc "Set priority to 0 when moving to extended away state."] \
 	-group AutoAway -type boolean
 
-    hook::add connected_hook    [namespace current]::after_idle
-    hook::add disconnected_hook [namespace current]::after_idle_cancel
+    hook::add finload_hook [namespace current]::after_idle
+    hook::add quit_hook    [namespace current]::after_idle_cancel 10
 }
 
 
@@ -93,7 +92,7 @@
     global userstatus textstatus userpriority
 
     if {[connections] == {}} {
-        if {![cequal $savestatus ""]} {
+        if {![string equal $savestatus ""]} {
 	    if {$options(drop_priority) && ($userpriority >= 0)} {
 		set userpriority $savepriority
 	    }
@@ -123,7 +122,7 @@
     set idletime [eval $idle_command]
 
     if {$idletime < [expr {$options(awaytime)*60*1000}]} {
-        if {![cequal $savestatus ""]} {
+        if {![string equal $savestatus ""]} {
 	    if {$options(drop_priority) && ($userpriority >= 0)} {
 		set userpriority $savepriority
 	    }
@@ -132,7 +131,7 @@
 	    set savetext ""
             set userstatus $savestatus
             set savestatus ""
-            set_status [::msgcat::mc "Returning from auto-away"]
+	    set_status [::msgcat::mc "Returning from auto-away"]
         }
 
         return
@@ -144,7 +143,7 @@
             set savestatus $userstatus
 	    set savetext $textstatus
 	    set savepriority $userpriority
-	    if {![cequal $options(status) ""]} {
+	    if {![string equal $options(status) ""]} {
 	       set textstatus $options(status)
 	    }
             if {$idletime >= [expr {$options(xatime)*60*1000}]} {
@@ -152,26 +151,26 @@
 		    set userpriority 0
 		}
                 set userstatus xa
-                set_status [::msgcat::mc "Moving to extended away"]
+		set_status [::msgcat::mc "Moving to extended away"]
             } else {
                 set userstatus away
-                set_status [::msgcat::mc "Starting auto-away"]
+		set_status [::msgcat::mc "Starting auto-away"]
             }
             return
         }
 
         away {
-            if {(![cequal $savestatus ""]) && \
+            if {(![string equal $savestatus ""]) && \
 		    ($idletime >= [expr {$options(xatime)*60*1000}])} {
 		set savepriority $userpriority
-		if {![cequal $options(status) ""]} {
+		if {![string equal $options(status) ""]} {
 		    set textstatus $options(status)
 		}
 		if {$options(drop_priority) && ($userpriority >= 0)} {
 		    set userpriority 0
 		}
                 set userstatus xa
-                set_status [::msgcat::mc "Moving to extended away"]
+		set_status [::msgcat::mc "Moving to extended away"]
                 return
             }
         }
@@ -180,11 +179,17 @@
         }
     }
 
-    if {![cequal $savestatus ""]} {
+    if {![string equal $savestatus ""]} {
         set_status [::msgcat::mc "Idle for %s" [format_time [expr {$idletime/1000}]]]
     }
 }
 
+proc autoaway::set_status {status} {
+    if {[llength [connections]] > 0} {
+	::set_status $status
+    }
+}
+
 proc autoaway::AquaIdleTime {} {
     catch { set line [read [set fd [open {|ioreg -x -c IOHIDSystem}]]] }
     close $fd



More information about the Tkabber-dev mailing list