From e1b4deac8001f5fb07cc73857e5e7bccbe74eb7f Mon Sep 17 00:00:00 2001 From: Vincent Lucas Date: Fri, 4 Jan 2013 14:59:47 +0000 Subject: [PATCH] Re-enables sound notification during on-going call by default. This behavior can be overridden by the net.java.sip.communicator.impl.notification.disableNotificationDuringCall property. --- .../notification/NotificationActivator.java | 27 +++++++++++++++++++ .../SoundNotificationHandlerImpl.java | 15 ++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/net/java/sip/communicator/impl/notification/NotificationActivator.java b/src/net/java/sip/communicator/impl/notification/NotificationActivator.java index 7cd65c3b6..178758e48 100644 --- a/src/net/java/sip/communicator/impl/notification/NotificationActivator.java +++ b/src/net/java/sip/communicator/impl/notification/NotificationActivator.java @@ -12,6 +12,7 @@ import net.java.sip.communicator.util.*; import org.jitsi.service.audionotifier.*; +import org.jitsi.service.configuration.*; import org.osgi.framework.*; /** @@ -42,6 +43,13 @@ public class NotificationActivator private PopupMessageNotificationHandler popupMessageHandler; private SoundNotificationHandler soundHandler; + /** + * The ConfigurationService registered in {@link #bundleContext} + * and used by the NotificationActivator instance to read and write + * configuration properties. + */ + private static ConfigurationService configurationService; + public void start(BundleContext bc) throws Exception { bundleContext = bc; @@ -145,4 +153,23 @@ public static UIService getUIService() uiService = ServiceUtils.getService(bundleContext, UIService.class); return uiService; } + + /** + * Returns a reference to a ConfigurationService implementation currently + * registered in the bundle context or null if no such implementation was + * found. + * + * @return a currently valid implementation of the ConfigurationService. + */ + public static ConfigurationService getConfigurationService() + { + if (configurationService == null) + { + configurationService + = ServiceUtils.getService( + bundleContext, + ConfigurationService.class); + } + return configurationService; + } } diff --git a/src/net/java/sip/communicator/impl/notification/SoundNotificationHandlerImpl.java b/src/net/java/sip/communicator/impl/notification/SoundNotificationHandlerImpl.java index b12d7dec0..cb1e48ea9 100644 --- a/src/net/java/sip/communicator/impl/notification/SoundNotificationHandlerImpl.java +++ b/src/net/java/sip/communicator/impl/notification/SoundNotificationHandlerImpl.java @@ -13,6 +13,7 @@ import net.java.sip.communicator.service.notification.*; import org.jitsi.service.audionotifier.*; +import org.jitsi.service.configuration.*; import org.jitsi.util.*; /** @@ -39,6 +40,12 @@ public class SoundNotificationHandlerImpl private Map playedClips = new WeakHashMap(); + /** + * Property to disable sound notification during an on-going call. + */ + private static final String PROP_DISABLE_NOTIFICATION_DURING_CALL = + "net.java.sip.communicator.impl.notification.disableNotificationDuringCall"; + /** * {@inheritDoc} */ @@ -81,7 +88,13 @@ private void play( // when playing notification in the call, can break the call and // no further communicating can be done after the notification. // So we skip playing notification if we have a call running - if(SCAudioClipDevice.PLAYBACK.equals(device)) + ConfigurationService cfg + = NotificationActivator.getConfigurationService(); + if(cfg != null + && cfg.getBoolean( + PROP_DISABLE_NOTIFICATION_DURING_CALL, + false) + && SCAudioClipDevice.PLAYBACK.equals(device)) { UIService uiService = NotificationActivator.getUIService();