diff --git a/lib/native/linux-64/libjunbound.so b/lib/native/linux-64/libjunbound.so
index 30442b35d..08a31453b 100644
Binary files a/lib/native/linux-64/libjunbound.so and b/lib/native/linux-64/libjunbound.so differ
diff --git a/lib/native/linux/libjunbound.so b/lib/native/linux/libjunbound.so
index 1f59db22e..853cf4258 100644
Binary files a/lib/native/linux/libjunbound.so and b/lib/native/linux/libjunbound.so differ
diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties
index ee0be10e4..d6d38ac9f 100644
--- a/resources/languages/resources.properties
+++ b/resources/languages/resources.properties
@@ -880,6 +880,7 @@ plugin.facebookaccregwizz.USERNAME_AND_PASSWORD=Username and Password
# generalconfig
plugin.generalconfig.AUTO_START=Auto-start {0} when computer restarts or reboots
+plugin.generalconfig.CHATALERTS_ON_MESSAGE=Use task bar / dock alerts on incoming calls and chats
plugin.generalconfig.GROUP_CHAT_MESSAGES=Group chat messages in one window
plugin.generalconfig.LOG_HISTORY=Log chat history
plugin.generalconfig.SHOW_HISTORY=Show
diff --git a/src/net/java/sip/communicator/plugin/chatalerter/ChatAlerterActivator.java b/src/net/java/sip/communicator/plugin/chatalerter/ChatAlerterActivator.java
index 5e907b485..4f5723523 100644
--- a/src/net/java/sip/communicator/plugin/chatalerter/ChatAlerterActivator.java
+++ b/src/net/java/sip/communicator/plugin/chatalerter/ChatAlerterActivator.java
@@ -11,12 +11,17 @@
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
+import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.Logger;
import org.jdesktop.jdic.misc.*;
+import org.jitsi.service.configuration.*;
import org.jitsi.util.*;
import org.osgi.framework.*;
+import java.beans.*;
+import java.util.*;
+
/**
* Chat Alerter plugin.
*
@@ -34,7 +39,9 @@ public class ChatAlerterActivator
ChatRoomMessageListener,
AdHocChatRoomMessageListener,
LocalUserChatRoomPresenceListener,
- LocalUserAdHocChatRoomPresenceListener
+ LocalUserAdHocChatRoomPresenceListener,
+ PropertyChangeListener,
+ CallListener
{
/**
* The logger for this class.
@@ -51,6 +58,11 @@ public class ChatAlerterActivator
*/
private UIService uiService;
+ /**
+ * Whether we are started.
+ */
+ private boolean started = false;
+
/**
* Starts this bundle.
* @param bc bundle context.
@@ -58,8 +70,19 @@ public class ChatAlerterActivator
*/
public void start(BundleContext bc) throws Exception
{
+ this.bundleContext = bc;
+
+ ServiceUtils.getService(bundleContext, ConfigurationService.class)
+ .addPropertyChangeListener(
+ ConfigurationUtils.ALERTER_ENABLED_PROP, this);
+
try
{
+ if(!ConfigurationUtils.isAlerterEnabled())
+ {
+ return;
+ }
+
// try to load native libs, if it fails don't do anything
if(!OSUtils.IS_MAC)
Alerter.newInstance();
@@ -71,9 +94,16 @@ public void start(BundleContext bc) throws Exception
exception);
return;
}
-
- this.bundleContext = bc;
+ startInternal(bc);
+ }
+
+ /**
+ * Starts the impl and adds necessary listeners.
+ * @param bc the current bundle context.
+ */
+ private void startInternal(BundleContext bc)
+ {
// start listening for newly register or removed protocol providers
bc.addServiceListener(this);
@@ -109,7 +139,8 @@ public void start(BundleContext bc) throws Exception
this.handleProviderAdded(provider);
}
}
-
+
+ this.started = true;
}
/**
@@ -118,6 +149,19 @@ public void start(BundleContext bc) throws Exception
* @throws Exception
*/
public void stop(BundleContext bc) throws Exception
+ {
+ stopInternal(bc);
+
+ ServiceUtils.getService(bundleContext, ConfigurationService.class)
+ .removePropertyChangeListener(
+ ConfigurationUtils.ALERTER_ENABLED_PROP, this);
+ }
+
+ /**
+ * Stops the impl and removes necessary listeners.
+ * @param bc the current bundle context.
+ */
+ private void stopInternal(BundleContext bc)
{
// start listening for newly register or removed protocol providers
bc.removeServiceListener(this);
@@ -150,6 +194,8 @@ public void stop(BundleContext bc) throws Exception
this.handleProviderRemoved(provider);
}
}
+
+ this.started = false;
}
/**
@@ -208,6 +254,14 @@ private void handleProviderAdded(ProtocolProviderService provider)
if (logger.isTraceEnabled())
logger.trace("Service did not have a multi im op. set.");
}
+
+ OperationSetBasicTelephony> basicTelephonyOpSet
+ = provider.getOperationSet(OperationSetBasicTelephony.class);
+
+ if (basicTelephonyOpSet != null)
+ {
+ basicTelephonyOpSet.addCallListener(this);
+ }
}
/**
@@ -225,6 +279,14 @@ private void handleProviderRemoved(ProtocolProviderService provider)
{
opSetIm.removeMessageListener(this);
}
+
+ OperationSetSmsMessaging opSetSms
+ = provider.getOperationSet(OperationSetSmsMessaging.class);
+
+ if (opSetSms != null)
+ {
+ opSetSms.removeMessageListener(this);
+ }
OperationSetMultiUserChat opSetMultiUChat
= provider.getOperationSet(OperationSetMultiUserChat.class);
@@ -234,6 +296,14 @@ private void handleProviderRemoved(ProtocolProviderService provider)
for (ChatRoom room : opSetMultiUChat.getCurrentlyJoinedChatRooms())
room.removeMessageListener(this);
}
+
+ OperationSetBasicTelephony> basicTelephonyOpSet
+ = provider.getOperationSet(OperationSetBasicTelephony.class);
+
+ if (basicTelephonyOpSet != null)
+ {
+ basicTelephonyOpSet.removeCallListener(this);
+ }
}
/**
@@ -293,11 +363,20 @@ public void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt)
* visual clue such as flashing it in the task bar on Windows and Linux.
*/
private void alertChatWindow()
+ {
+ alertWindow(ExportedWindow.CHAT_WINDOW);
+ }
+
+ /**
+ * Alerts the windowID by using a platform-dependent
+ * visual clue such as flashing it in the task bar on Windows and Linux,
+ * or the bouncing the dock icon under macosx.
+ */
+ private void alertWindow(WindowID windowID)
{
try
{
- ExportedWindow win
- = getUIService().getExportedWindow(ExportedWindow.CHAT_WINDOW);
+ ExportedWindow win = getUIService().getExportedWindow(windowID);
if (win == null)
return;
@@ -409,4 +488,76 @@ public UIService getUIService()
return uiService;
}
+
+ /**
+ * Waits for enable/disable property change.
+ * @param evt the event of change
+ */
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ if(!evt.getPropertyName()
+ .equals(ConfigurationUtils.ALERTER_ENABLED_PROP))
+ return;
+
+ try
+ {
+ if(ConfigurationUtils.isAlerterEnabled() && !started)
+ {
+ startInternal(bundleContext);
+ }
+ else if(!ConfigurationUtils.isAlerterEnabled() && started)
+ {
+ stopInternal(bundleContext);
+ }
+ }
+ catch(Throwable t)
+ {
+ logger.error("Error starting/stopping on configuration change");
+ }
+ }
+
+ /**
+ * This method is called by a protocol provider whenever an incoming call is
+ * received.
+ *
+ * @param event a CallEvent instance describing the new incoming call
+ */
+ public void incomingCallReceived(CallEvent event)
+ {
+ Call call = event.getSourceCall();
+
+ /*
+ * INCOMING_CALL should be dispatched for a Call
+ * only while there is a CallPeer in the
+ * INCOMING_CALL state.
+ */
+ Iterator extends CallPeer> peerIter = call.getCallPeers();
+ boolean alert = false;
+ while (peerIter.hasNext())
+ {
+ CallPeer peer = peerIter.next();
+ if (CallPeerState.INCOMING_CALL.equals(peer.getState()))
+ {
+ alert = true;
+ break;
+ }
+ }
+
+ if(alert)
+ alertWindow(ExportedWindow.MAIN_WINDOW);
+ }
+
+ /**
+ * Not used.
+ * @param event a CalldEvent instance describing the new outgoing call.
+ */
+ public void outgoingCallCreated(CallEvent event)
+ {}
+
+ /**
+ * Not used
+ * @param event the CallEvent containing the source call.
+ */
+ public void callEnded(CallEvent event)
+ {}
}
diff --git a/src/net/java/sip/communicator/plugin/chatalerter/chatalerter.manifest.mf b/src/net/java/sip/communicator/plugin/chatalerter/chatalerter.manifest.mf
index cd6349c87..dae5365ef 100644
--- a/src/net/java/sip/communicator/plugin/chatalerter/chatalerter.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/chatalerter/chatalerter.manifest.mf
@@ -6,6 +6,7 @@ Bundle-Version: 0.0.1
System-Bundle: yes
Import-Package: org.osgi.framework,
org.jitsi.util,
+ org.jitsi.service.configuration,
net.java.sip.communicator.util,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.protocol,
diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java
index 6bb65222f..7721f1889 100644
--- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java
+++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java
@@ -237,6 +237,7 @@ private Component createMessageConfigPanel()
configPanel.add(createSendMessagePanel());
configPanel.add(createTypingNitificationsCheckBox());
configPanel.add(createBringToFrontCheckBox());
+ configPanel.add(createChatAlertsOnMessageCheckbox());
configPanel.add(createMultichatCheckbox());
return configPanel;
@@ -269,6 +270,33 @@ public void actionPerformed(ActionEvent e)
return groupMessagesCheckBox;
}
+ /**
+ * Initializes the window alert on message check box.
+ * @return the created check box
+ */
+ private Component createChatAlertsOnMessageCheckbox()
+ {
+ final JCheckBox chatAlertOnMessageCheckBox = new SIPCommCheckBox();
+ chatAlertOnMessageCheckBox.setText(
+ Resources.getString(
+ "plugin.generalconfig.CHATALERTS_ON_MESSAGE"));
+
+ chatAlertOnMessageCheckBox.setAlignmentX(JCheckBox.LEFT_ALIGNMENT);
+ chatAlertOnMessageCheckBox.setSelected(
+ ConfigurationUtils.isAlerterEnabled());
+
+ chatAlertOnMessageCheckBox.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ ConfigurationUtils.setAlerterEnabled(
+ chatAlertOnMessageCheckBox.isSelected());
+ }
+ });
+
+ return chatAlertOnMessageCheckBox;
+ }
+
/**
* Initializes the group messages check box.
* @return the created check box
diff --git a/src/net/java/sip/communicator/util/ConfigurationUtils.java b/src/net/java/sip/communicator/util/ConfigurationUtils.java
index b8c1a7040..67dcfee1b 100644
--- a/src/net/java/sip/communicator/util/ConfigurationUtils.java
+++ b/src/net/java/sip/communicator/util/ConfigurationUtils.java
@@ -310,6 +310,17 @@ public class ConfigurationUtils
*/
private static boolean acceptPhoneNumberWithAlphaChars;
+ /**
+ * The name of the single interface property.
+ */
+ public static final String ALERTER_ENABLED_PROP
+ = "plugin.chatalerter.ENABLED";
+
+ /**
+ * Indicates if window (task bar or dock icon) alerter is enabled.
+ */
+ private static boolean alerterEnabled;
+
/**
* Loads all user interface configurations.
*/
@@ -783,6 +794,9 @@ public static void loadGuiConfigurations()
isNormalizePhoneNumber
= configService.getBoolean("impl.gui.NORMALIZE_PHONE_NUMBER", true);
+ alerterEnabled
+ = configService.getBoolean(ALERTER_ENABLED_PROP, true);
+
// Load the "ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS" property.
acceptPhoneNumberWithAlphaChars
= configService.getBoolean(
@@ -1437,6 +1451,31 @@ public static void setNormalizePhoneNumber(boolean isNormalize)
Boolean.toString(isNormalize));
}
+ /**
+ * Returns true if window alerter is enabled (tack bar or
+ * dock icon).
+ *
+ * @return true if window alerter is enables,
+ * false otherwise.
+ */
+ public static boolean isAlerterEnabled()
+ {
+ return alerterEnabled;
+ }
+
+ /**
+ * Updates the "plugin.chatalerter.ENABLED" property.
+ *
+ * @param isEnabled indicates whether to enable or disable alerter.
+ */
+ public static void setAlerterEnabled(boolean isEnabled)
+ {
+ alerterEnabled = isEnabled;
+
+ configService.setProperty(ALERTER_ENABLED_PROP,
+ Boolean.toString(isEnabled));
+ }
+
/**
* Returns true if a string with a alphabetical character migth
* be considered as a phone number. false otherwise.