From dad9377496bb70a4c955feb44b1d96761729ba6c Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Wed, 20 Jun 2012 09:10:54 +0000 Subject: [PATCH] Improves updating away status. --- .../windows-64/sysactivitynotifications.dll | Bin 56320 -> 56320 bytes .../windows/sysactivitynotifications.dll | Bin 48640 -> 48640 bytes ...ystemActivityNotificationsServiceImpl.java | 12 +++++++++ .../autoaway/AutoAwayWatcher.java | 24 ++++++++++++++++++ .../SystemActivityNotificationsService.java | 8 ++++++ 5 files changed, 44 insertions(+) diff --git a/lib/native/windows-64/sysactivitynotifications.dll b/lib/native/windows-64/sysactivitynotifications.dll index df4c6c6eeb3778a47ec921528e48800468911d84..1a301e6dbe4621aec42b729375dc19a8d1247477 100644 GIT binary patch delta 208 zcmZqJ!Q8Ned4dh&jfu9-^(_Wl{u~IrwH}7os~4=F0_3k(cUgZDNT1a7Tz?!ae|!B5 zuz2D6>tNb({XsD84yJ=LlQTeOFhD_oD+5DH8!LlkYP26r>;r?60yh&E149c?qzo)N zak(KgkTLPLF582%3=B<7lld6cm~t2=2QnE?&SZ3DWSG33Q5{HL2b2H7q&ky26NA&{ LK&A-BMJzV}oWn{^ delta 116 zcmZqJ!Q8Ned4dgN!$ezWr2tn3hLko|hL0N`_%lGk2L?SQZYCx%h8Cbe$i!b}%%>U| zCmS>BvOyF~PGeMKy1+DfBa`vugN&|>0h8I8)PbZvm<$J!29xWV)R_#NHaG6tz_^Iz F1_0IN9!mfK diff --git a/lib/native/windows/sysactivitynotifications.dll b/lib/native/windows/sysactivitynotifications.dll index 103c65648c5a029cbaaf9f3c4a8f2189d1b975d2..be2376660c99eb89408e6c554e136053a02cf4f6 100644 GIT binary patch delta 217 zcmZqp!_@GHX@U*ojfu9-^@W?hdz)UKDFMS#OW7r?f&8eY#uB+e+GaJEgb`SNhC~ur z+(<$ROfyNCfN2&m9h8}z0WyOD3Ibdi7ZM){a|7b7?>2f8Mzo3%77wCU{P*{ z4YELn01!`@xJiwPfnnk;dDg8A3^SM}{!?Sxz&_cKQHj-J6$69AWM9TWMuy4r8P$R0 VaWMIwQJsmwX|p2J1ja=yy8sEKJ!Aj? delta 161 zcmZqp!_@GHX@U)7!$ezWqX1V11|LQihKCy;_%lGk0|q{2Zbl|ChBBal3q){(ERYre z;scYp7}a#|9%5i%VsKyti-Ckea$p)xfdm=0tYu&bnB2%H!}@`NA%kafA(Qdsjf}30 d29v)tssl-RCJ^b)q|RjEv^j9m3&uq(y8xiHA9nx% diff --git a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java index c3dc2f5bc..ea3c78fb3 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java +++ b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java @@ -203,6 +203,18 @@ public void removeIdleSystemChangeListener( } } + /** + * The time since last user input. The time the system has been idle. + * @return time the system has been idle. + */ + public long getTimeSinceLastInput() + { + if(SystemActivityNotifications.isLoaded()) + return SystemActivityNotifications.getLastInput(); + else + return -1; + } + /** * Callback method when receiving notifications. * diff --git a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java index 38f671098..62c84b386 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java @@ -355,6 +355,30 @@ else if(evt.getNewState().equals( { start(); } + else + { + // or check are we away + if(getSystemActivityNotificationsService() + .getTimeSinceLastInput() + > StatusUpdateThread.getTimer()*60*1000) + { + // we are away, so update the newly registered provider + // do it in new thread to give the provider + // time dispatch his status + new Thread(new Runnable() + { + public void run() + { + try{ + Thread.sleep(1000); + } + catch(Throwable t){} + + changeProtocolsToAway(); + } + }).start(); + } + } } } } diff --git a/src/net/java/sip/communicator/service/sysactivity/SystemActivityNotificationsService.java b/src/net/java/sip/communicator/service/sysactivity/SystemActivityNotificationsService.java index 621f1eb29..8280a541c 100644 --- a/src/net/java/sip/communicator/service/sysactivity/SystemActivityNotificationsService.java +++ b/src/net/java/sip/communicator/service/sysactivity/SystemActivityNotificationsService.java @@ -63,4 +63,12 @@ public void removeIdleSystemChangeListener( * @return whether the supplied event id is supported. */ public boolean isSupported(int eventID); + + /** + * The time since last user input. The time the system has been idle. + * Or -1 if there is no such information or error has occured. + * @return time the system has been idle. + */ + public long getTimeSinceLastInput(); + }