Adds option to enable/disable task bar / dock alerts. Alert main window on incoming calls.

Adds recompiled linux binaries for junbound.
cusax-fix
Damian Minkov 13 years ago
parent 1472dc8cc2
commit fad7b70203

Binary file not shown.

@ -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

@ -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 <code>windowID</code> 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 <tt>CallEvent</tt> containing the source call.
*/
public void callEnded(CallEvent event)
{}
}

@ -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,

@ -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

@ -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 <code>true</code> if window alerter is enabled (tack bar or
* dock icon).
*
* @return <code>true</code> if window alerter is enables,
* <code>false</code> 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 <code>true</code> if a string with a alphabetical character migth
* be considered as a phone number. <code>false</code> otherwise.

Loading…
Cancel
Save