aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/generalconfig
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2012-08-24 09:43:09 +0000
committerDamian Minkov <damencho@jitsi.org>2012-08-24 09:43:09 +0000
commit97ed9feac048834714bf58f8470985e9bfd1b543 (patch)
treea3635d63b20665aca5748a856bdcffda056fd254 /src/net/java/sip/communicator/plugin/generalconfig
parent8004132d5cc9afb7ab921da8dbaa0fd5eff10829 (diff)
downloadjitsi-97ed9feac048834714bf58f8470985e9bfd1b543.zip
jitsi-97ed9feac048834714bf58f8470985e9bfd1b543.tar.gz
jitsi-97ed9feac048834714bf58f8470985e9bfd1b543.tar.bz2
Fixes autoway listening for idle, a bug where it adds listening for 0sec. of idle time.
Diffstat (limited to 'src/net/java/sip/communicator/plugin/generalconfig')
-rw-r--r--src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java81
1 files changed, 64 insertions, 17 deletions
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 303b013..780f050 100644
--- a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java
+++ b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java
@@ -90,7 +90,37 @@ public class AutoAwayWatcher
}
}
);
+ }
+
+ /**
+ * Starts and add needed listeners.
+ */
+ private void start()
+ {
+ if(idleListener == null)
+ {
+
+ idleListener = new IdleListener();
+
+ SystemActivityNotificationsService
+ systemActivityNotificationsService
+ = getSystemActivityNotificationsService();
+
+ systemActivityNotificationsService.addIdleSystemChangeListener(
+ StatusUpdateThread.getTimer() * 60 * 1000,
+ idleListener);
+ systemActivityNotificationsService
+ .addSystemActivityChangeListener(idleListener);
+ startListeningForNewProviders();
+ }
+ }
+
+ /**
+ * Start listening for new providers and their registration states.
+ */
+ private void startListeningForNewProviders()
+ {
// listen for new providers
GeneralConfigPluginActivator.bundleContext.addServiceListener(this);
@@ -100,7 +130,7 @@ public class AutoAwayWatcher
{
protocolProviderRefs = GeneralConfigPluginActivator.bundleContext
.getServiceReferences(ProtocolProviderService.class.getName(),
- null);
+ null);
}
catch (InvalidSyntaxException ex)
{
@@ -126,23 +156,41 @@ public class AutoAwayWatcher
}
/**
- * Starts and add needed listeners.
+ * Stop listening for new providers and their registration states.
*/
- private void start()
+ private void stopListeningForNewProviders()
{
- if(idleListener == null)
+ // stop listen for new providers
+ GeneralConfigPluginActivator.bundleContext.removeServiceListener(this);
+
+ // lets check current providers and remove registration state listener
+ ServiceReference[] protocolProviderRefs = null;
+ try
{
- idleListener = new IdleListener();
+ protocolProviderRefs = GeneralConfigPluginActivator.bundleContext
+ .getServiceReferences(ProtocolProviderService.class.getName(),
+ null);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ // this shouldn't happen since we're providing no parameter string
+ // but let's log just in case.
+ logger.error(
+ "Error while retrieving service refs", ex);
+ return;
+ }
- SystemActivityNotificationsService
- systemActivityNotificationsService
- = getSystemActivityNotificationsService();
+ // in case we found any
+ if (protocolProviderRefs != null)
+ {
+ for (int i = 0; i < protocolProviderRefs.length; i++)
+ {
+ ProtocolProviderService provider = (ProtocolProviderService)
+ GeneralConfigPluginActivator.bundleContext
+ .getService(protocolProviderRefs[i]);
- systemActivityNotificationsService.addIdleSystemChangeListener(
- StatusUpdateThread.getTimer() * 60 * 1000,
- idleListener);
- systemActivityNotificationsService
- .addSystemActivityChangeListener(idleListener);
+ this.handleProviderRemoved(provider);
+ }
}
}
@@ -156,7 +204,7 @@ public class AutoAwayWatcher
}
/**
- * Stops and removes the listeners, without the global service listener.
+ * Stops and removes the listeners.
*/
private void stopInner()
{
@@ -171,6 +219,8 @@ public class AutoAwayWatcher
systemActivityNotificationsService
.removeSystemActivityChangeListener(idleListener);
+ stopListeningForNewProviders();
+
idleListener = null;
}
}
@@ -329,9 +379,6 @@ public class AutoAwayWatcher
ProtocolProviderService provider)
{
lastStates.remove(provider);
-
- if(lastStates.size() == 0)
- stopInner();
}
/**