Separate notification service from its handlers

cusax-fix
Ingo Bauersachs 14 years ago
parent 6102f58f12
commit c543e54197

@ -915,8 +915,9 @@
bundle-sparkle, bundle-plugin-branding,
bundle-systemactivitynotifications,
bundle-osdependent,bundle-browserlauncher,
bundle-pluginmanager,bundle-skinmanager,bundle-notification,
bundle-notification-config,bundle-contacteventhandler,
bundle-pluginmanager,bundle-skinmanager,
bundle-notification-service,bundle-notification-handlers,bundle-notification-config,
bundle-contacteventhandler,
bundle-plugin-contactinfo,bundle-plugin-chatalerter, bundle-keybindings,
bundle-plugin-keybindingChooser,bundle-plugin-globalproxyconfig,
bundle-jfontchooserlib,bundle-update,bundle-plugin-update,
@ -2050,12 +2051,19 @@ javax.swing.event, javax.swing.border"/>
</target>
<!-- BUNDLE-NOTIFICATION -->
<target name="bundle-notification">
<target name="bundle-notification-service">
<!-- Creates a bundle for the notifications.-->
<jar compress="false" destfile="${bundles.dest}/notification.jar"
manifest="${src}/net/java/sip/communicator/impl/notification/notification.manifest.mf">
<jar compress="false" destfile="${bundles.dest}/notification-service.jar"
manifest="${src}/net/java/sip/communicator/service/notification/notification.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/service/notification"
prefix="net/java/sip/communicator/service/notification"/>
</jar>
</target>
<target name="bundle-notification-handlers">
<!-- Creates a bundle for the notifications.-->
<jar compress="false" destfile="${bundles.dest}/notification-handlers.jar"
manifest="${src}/net/java/sip/communicator/impl/notification/notification.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/impl/notification"
prefix="net/java/sip/communicator/impl/notification"/>
</jar>

@ -33,17 +33,18 @@ felix.auto.start.10= \
felix.auto.start.20= \
reference:file:sc-bundles/util.jar \
reference:file:lib/bundle/log4j.jar \
reference:file:lib/bundle/commons-logging.jar
reference:file:lib/bundle/commons-logging.jar \
reference:file:sc-bundles/fileaccess.jar
felix.auto.start.30= \
reference:file:sc-bundles/fileaccess.jar
reference:file:sc-bundles/configuration.jar \
reference:file:sc-bundles/notification-service.jar \
felix.auto.start.35= \
reference:file:sc-bundles/commons-codec.jar \
reference:file:sc-bundles/httputil.jar
felix.auto.start.40= \
reference:file:sc-bundles/configuration.jar \
reference:file:sc-bundles/jmdnslib.jar \
reference:file:sc-bundles/jnalib.jar \
reference:file:sc-bundles/provdisc.jar \
@ -108,7 +109,7 @@ felix.auto.start.60= \
reference:file:sc-bundles/filehistory.jar \
reference:file:sc-bundles/metahistory.jar \
reference:file:sc-bundles/keybindings.jar \
reference:file:sc-bundles/notification.jar \
reference:file:sc-bundles/notification-handlers.jar \
reference:file:sc-bundles/contactsource.jar
felix.auto.start.66= \

@ -22,77 +22,33 @@ public class CommandNotificationHandlerImpl
private Logger logger
= Logger.getLogger(CommandNotificationHandlerImpl.class);
private String commandDescriptor;
private boolean isEnabled = true;
/**
* Creates an instance of <tt>CommandNotificationHandlerImpl</tt> by
* specifying the <tt>commandDescriptor</tt>, which will point us to the
* command to execute.
*
* @param commandDescriptor a String that should point us to the command to
* execute
* {@inheritDoc}
*/
public CommandNotificationHandlerImpl(String commandDescriptor)
public String getActionType()
{
this.commandDescriptor = commandDescriptor;
return NotificationAction.ACTION_COMMAND;
}
/**
* Executes the <tt>command</tt>, given by the containing
* <tt>commandDescriptor</tt>.
* Executes the command, given by the <tt>commandDescriptor</tt> of the
* action.
*
* @param action the action to act upon.
*/
public void execute()
public void execute(CommandNotificationAction action)
{
if(StringUtils.isNullOrEmpty(commandDescriptor, true))
if(StringUtils.isNullOrEmpty(action.getDescriptor(), true))
return;
try
{
Runtime.getRuntime().exec(commandDescriptor);
Runtime.getRuntime().exec(action.getDescriptor());
}
catch (IOException e)
{
logger.error("Failed execute the following command: "
+ commandDescriptor, e);
+ action.getDescriptor(), e);
}
}
/**
* Returns the command descriptor.
*
* @return the command descriptor
*/
public String getDescriptor()
{
return commandDescriptor;
}
/**
* Returns TRUE if this notification action handler is enabled and FALSE
* otherwise. While the notification handler for the command action type
* is disabled no programs will be executed when the
* <tt>fireNotification</tt> method is called.
*
* @return TRUE if this notification action handler is enabled and FALSE
* otherwise
*/
public boolean isEnabled()
{
return isEnabled;
}
/**
* Enables or disables this notification handler. While the notification
* handler for the command action type is disabled no programs will be
* executed when the <tt>fireNotification</tt> method is called.
*
* @param isEnabled TRUE to enable this notification handler, FALSE to
* disable it.
*/
public void setEnabled(boolean isEnabled)
{
this.isEnabled = isEnabled;
}
}

@ -8,6 +8,7 @@
import net.java.sip.communicator.service.notification.*;
import net.java.sip.communicator.util.*;
import static net.java.sip.communicator.service.notification.LogMessageNotificationAction.*;
/**
* An implementation of the <tt>LogMessageNotificationHandler</tt> interface.
@ -23,72 +24,27 @@ public class LogMessageNotificationHandlerImpl
private Logger logger
= Logger.getLogger(LogMessageNotificationHandlerImpl.class);
private String logType;
private boolean isEnabled = true;
/**
* Creates an instance of <tt>LogMessageNotificationHandlerImpl</tt> by
* specifying the log type.
*
* @param logType the type of the log
*/
public LogMessageNotificationHandlerImpl(String logType)
{
this.logType = logType;
}
/**
* Returns the type of the log
*
* @return the type of the log
* {@inheritDoc}
*/
public String getLogType()
public String getActionType()
{
return logType;
return NotificationAction.ACTION_LOG_MESSAGE;
}
/**
* Logs a message through the sip communicator Logger.
*
* @param action the action to act upon
* @param message the message coming from the event
*/
public void logMessage(String message)
public void logMessage(LogMessageNotificationAction action, String message)
{
if (logType.equals(LogMessageNotificationHandler.ERROR_LOG_TYPE))
if (action.getLogType().equals(ERROR_LOG_TYPE))
logger.error(message);
else if(logType.equals(LogMessageNotificationHandler.INFO_LOG_TYPE))
if (logger.isInfoEnabled())
logger.info(message);
else if(logType.equals(LogMessageNotificationHandler.TRACE_LOG_TYPE))
if (logger.isTraceEnabled())
logger.trace(message);
}
/**
* Returns TRUE if this notification action handler is enabled and FALSE
* otherwise. While the notification handler for the log message action type
* is disabled no messages will be logged when the
* <tt>fireNotification</tt> method is called.
*
* @return TRUE if this notification action handler is enabled and FALSE
* otherwise
*/
public boolean isEnabled()
{
return isEnabled;
}
/**
* Enables or disables this notification handler. While the notification
* handler for the log message action type is disabled no messages will be
* logged when the <tt>fireNotification</tt> method is called.
*
* @param isEnabled TRUE to enable this notification handler, FALSE to
* disable it.
*/
public void setEnabled(boolean isEnabled)
{
this.isEnabled = isEnabled;
else if(action.getLogType().equals(INFO_LOG_TYPE))
logger.info(message);
else if(action.getLogType().equals(TRACE_LOG_TYPE))
logger.trace(message);
}
}

@ -7,7 +7,6 @@
package net.java.sip.communicator.impl.notification;
import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.neomedia.*;
import net.java.sip.communicator.service.notification.*;
@ -29,73 +28,65 @@ public class NotificationActivator
private final Logger logger = Logger.getLogger(NotificationActivator.class);
protected static BundleContext bundleContext;
private static ConfigurationService configService;
private static AudioNotifierService audioNotifierService;
private static SystrayService systrayService;
private static NotificationService notificationService;
private static ResourceManagementService resourcesService;
private static UIService uiService = null;
private static MediaService mediaService;
private CommandNotificationHandler commandHandler;
private LogMessageNotificationHandler logMessageHandler;
private PopupMessageNotificationHandler popupMessageHandler;
private SoundNotificationHandler soundHandler;
public void start(BundleContext bc) throws Exception
{
bundleContext = bc;
try
{
logger.logEntry();
logger.info("Notification handler Service...[ STARTED ]");
try {
// Create the notification service implementation
notificationService = new NotificationServiceImpl();
// Get the notification service implementation
ServiceReference notifReference = bundleContext
.getServiceReference(NotificationService.class.getName());
if (logger.isInfoEnabled())
logger.info("Notification Service...[ STARTED ]");
notificationService = (NotificationService) bundleContext
.getService(notifReference);
bundleContext.registerService(NotificationService.class.getName(),
notificationService, null);
commandHandler = new CommandNotificationHandlerImpl();
logMessageHandler = new LogMessageNotificationHandlerImpl();
popupMessageHandler = new PopupMessageNotificationHandlerImpl();
soundHandler = new SoundNotificationHandlerImpl();
notificationService.addActionHandler(commandHandler);
notificationService.addActionHandler(logMessageHandler);
notificationService.addActionHandler(popupMessageHandler);
notificationService.addActionHandler(soundHandler);
new NotificationManager().init();
if (logger.isInfoEnabled())
logger.info("Notification Service ...[REGISTERED]");
logger.logEntry();
logger.info("Notification handler Service ...[REGISTERED]");
}
finally {
finally
{
logger.logExit();
}
}
public void stop(BundleContext bc) throws Exception
{
if (logger.isInfoEnabled())
logger.info("UI Service ...[STOPPED]");
}
/**
* Returns the <tt>ConfigurationService</tt> obtained from the bundle
* context.
* @return the <tt>ConfigurationService</tt> obtained from the bundle
* context
*/
public static ConfigurationService getConfigurationService()
{
if(configService == null)
{
ServiceReference configReference = bundleContext
.getServiceReference(ConfigurationService.class.getName());
configService = (ConfigurationService) bundleContext
.getService(configReference);
}
notificationService.removeActionHandler(commandHandler.getActionType());
notificationService.removeActionHandler(logMessageHandler.getActionType());
notificationService.removeActionHandler(popupMessageHandler.getActionType());
notificationService.removeActionHandler(soundHandler.getActionType());
return configService;
logger.info("Notification handler Service ...[STOPPED]");
}
/**
* Returns the <tt>AudioNotifierService</tt> obtained from the bundle
* context.
@ -118,7 +109,7 @@ public static AudioNotifierService getAudioNotifier()
return audioNotifierService;
}
/**
* Returns the <tt>SystrayService</tt> obtained from the bundle context.
*

@ -68,6 +68,67 @@ public class NotificationManager
*/
private Map<Contact,Long> proactiveTimer = new HashMap<Contact, Long>();
/**
* Default event type for call been saved using a recorder.
*/
public static final String CALL_SAVED = "CallSaved";
/**
* Default event type for incoming file transfers.
*/
public static final String INCOMING_FILE = "IncomingFile";
/**
* Default event type for security error on a call.
*/
public static final String CALL_SECURITY_ERROR = "CallSecurityError";
/**
* Default event type for activated security on a call.
*/
public static final String CALL_SECURITY_ON = "CallSecurityOn";
/**
* Default event type when a secure message received.
*/
public static final String SECURITY_MESSAGE = "SecurityMessage";
/**
* Default event type for
* proactive notifications (typing notifications when chatting).
*/
public static final String PROACTIVE_NOTIFICATION = "ProactiveNotification";
/**
* Default event type for hanging up calls.
*/
public static final String HANG_UP = "HangUp";
/**
* Default event type for dialing.
*/
public static final String DIALING = "Dialing";
/**
* Default event type for a busy call.
*/
public static final String BUSY_CALL = "BusyCall";
/**
* Default event type for outgoing calls.
*/
public static final String OUTGOING_CALL = "OutgoingCall";
/**
* Default event type for receiving calls (incoming calls).
*/
public static final String INCOMING_CALL = "IncomingCall";
/**
* Default event type for receiving messages.
*/
public static final String INCOMING_MESSAGE = "IncomingMessage";
/**
* Initialize, register default notifications and start listening for
* new protocols or removed one and find any that are already registered.
@ -101,120 +162,108 @@ private void registerDefaultNotifications()
// Register incoming message notifications.
notificationService.registerDefaultNotificationForEvent(
NotificationService.INCOMING_MESSAGE,
NotificationService.ACTION_POPUP_MESSAGE,
NotificationManager.INCOMING_MESSAGE,
NotificationAction.ACTION_POPUP_MESSAGE,
null,
null);
notificationService.registerDefaultNotificationForEvent(
NotificationService.INCOMING_MESSAGE,
NotificationService.ACTION_SOUND,
NotificationManager.INCOMING_MESSAGE,
NotificationAction.ACTION_SOUND,
SoundProperties.INCOMING_MESSAGE,
null);
// Register incoming call notifications.
notificationService.registerDefaultNotificationForEvent(
NotificationService.INCOMING_CALL,
NotificationService.ACTION_POPUP_MESSAGE,
NotificationManager.INCOMING_CALL,
NotificationAction.ACTION_POPUP_MESSAGE,
null,
null);
SoundNotificationHandler inCallSoundHandler
= notificationService
.createSoundNotificationHandler(SoundProperties.INCOMING_CALL,
2000);
SoundNotificationAction inCallSoundHandler
= new SoundNotificationAction(SoundProperties.INCOMING_CALL, 2000);
notificationService.registerDefaultNotificationForEvent(
NotificationService.INCOMING_CALL,
NotificationService.ACTION_SOUND,
NotificationManager.INCOMING_CALL,
inCallSoundHandler);
// Register outgoing call notifications.
SoundNotificationHandler outCallSoundHandler
= notificationService
.createSoundNotificationHandler(SoundProperties.OUTGOING_CALL,
3000);
SoundNotificationAction outCallSoundHandler
= new SoundNotificationAction(SoundProperties.OUTGOING_CALL, 3000);
notificationService.registerDefaultNotificationForEvent(
NotificationService.OUTGOING_CALL,
NotificationService.ACTION_SOUND,
NotificationManager.OUTGOING_CALL,
outCallSoundHandler);
// Register busy call notifications.
SoundNotificationHandler busyCallSoundHandler
= notificationService
.createSoundNotificationHandler(SoundProperties.BUSY, 1);
SoundNotificationAction busyCallSoundHandler
= new SoundNotificationAction(SoundProperties.BUSY, 1);
notificationService.registerDefaultNotificationForEvent(
NotificationService.BUSY_CALL,
NotificationService.ACTION_SOUND,
NotificationManager.BUSY_CALL,
busyCallSoundHandler);
// Register dial notifications.
SoundNotificationHandler dialSoundHandler
= notificationService
.createSoundNotificationHandler(SoundProperties.DIALING, 0);
SoundNotificationAction dialSoundHandler
= new SoundNotificationAction(SoundProperties.DIALING, 0);
notificationService.registerDefaultNotificationForEvent(
NotificationService.DIALING,
NotificationService.ACTION_SOUND,
NotificationManager.DIALING,
dialSoundHandler);
// Register the hangup sound notification.
SoundNotificationHandler hangupSoundHandler
= notificationService
.createSoundNotificationHandler(SoundProperties.HANG_UP, -1);
SoundNotificationAction hangupSoundHandler
= new SoundNotificationAction(SoundProperties.HANG_UP, -1);
notificationService.registerDefaultNotificationForEvent(
NotificationService.HANG_UP,
NotificationService.ACTION_SOUND,
NotificationManager.HANG_UP,
hangupSoundHandler);
// Register proactive notifications.
notificationService.registerDefaultNotificationForEvent(
NotificationService.PROACTIVE_NOTIFICATION,
NotificationService.ACTION_POPUP_MESSAGE,
NotificationManager.PROACTIVE_NOTIFICATION,
NotificationAction.ACTION_POPUP_MESSAGE,
null,
null);
// Register warning message notifications.
notificationService.registerDefaultNotificationForEvent(
NotificationService.SECURITY_MESSAGE,
NotificationService.ACTION_POPUP_MESSAGE,
NotificationManager.SECURITY_MESSAGE,
NotificationAction.ACTION_POPUP_MESSAGE,
null,
null);
// Register sound notification for security state on during a call.
notificationService.registerDefaultNotificationForEvent(
NotificationService.CALL_SECURITY_ON,
NotificationService.ACTION_SOUND,
NotificationManager.CALL_SECURITY_ON,
NotificationAction.ACTION_SOUND,
SoundProperties.CALL_SECURITY_ON,
null);
// Register sound notification for security state off during a call.
notificationService.registerDefaultNotificationForEvent(
NotificationService.CALL_SECURITY_ERROR,
NotificationService.ACTION_SOUND,
NotificationManager.CALL_SECURITY_ERROR,
NotificationAction.ACTION_SOUND,
SoundProperties.CALL_SECURITY_ERROR,
null);
// Register sound notification for incoming files.
notificationService.registerDefaultNotificationForEvent(
NotificationService.INCOMING_FILE,
NotificationService.ACTION_POPUP_MESSAGE,
NotificationManager.INCOMING_FILE,
NotificationAction.ACTION_POPUP_MESSAGE,
null,
null);
notificationService.registerDefaultNotificationForEvent(
NotificationService.INCOMING_FILE,
NotificationService.ACTION_SOUND,
NotificationManager.INCOMING_FILE,
NotificationAction.ACTION_SOUND,
SoundProperties.INCOMING_FILE,
null);
// Register notification for saved calls.
notificationService.registerDefaultNotificationForEvent(
NotificationService.CALL_SAVED,
NotificationService.ACTION_POPUP_MESSAGE,
NotificationManager.CALL_SAVED,
NotificationAction.ACTION_POPUP_MESSAGE,
null,
null);
}
@ -537,7 +586,7 @@ public static void fireChatNotification(Object chatContact,
if(notificationService == null)
return;
NotificationActionHandler popupActionHandler = null;
NotificationAction popupActionHandler = null;
UIService uiService = NotificationActivator.getUIService();
Chat chatPanel = null;
@ -570,12 +619,12 @@ else if (chatContact instanceof ChatRoom)
if (chatPanel != null)
{
if (eventType.equals(NotificationService.INCOMING_MESSAGE)
if (eventType.equals(NotificationManager.INCOMING_MESSAGE)
&& chatPanel.isChatFocused())
{
popupActionHandler = notificationService
.getEventNotificationActionHandler(eventType,
NotificationService.ACTION_POPUP_MESSAGE);
.getEventNotificationAction(eventType,
NotificationAction.ACTION_POPUP_MESSAGE);
popupActionHandler.setEnabled(false);
}
@ -623,14 +672,15 @@ public static void stopSound(String eventType)
if(notificationService == null)
return;
SoundNotificationHandler soundHandler
= (SoundNotificationHandler) notificationService
.getEventNotificationActionHandler(
eventType, NotificationService.ACTION_SOUND);
Iterable<NotificationHandler> soundHandlers =
notificationService.getActionHandlers(
NotificationAction.ACTION_SOUND);
//TODO make SoundNotificationHandler handle multiple sound at once
// There can be no sound action handler for this event type
if(soundHandler != null)
soundHandler.stop();
if(soundHandlers != null)
for(NotificationHandler handler : soundHandlers)
((SoundNotificationHandler)handler).stop();
}
/**
@ -675,10 +725,10 @@ public static BufferedImage getImage(ImageID imageID)
*/
private static void stopAllTelephonySounds()
{
NotificationManager.stopSound(NotificationService.DIALING);
NotificationManager.stopSound(NotificationService.BUSY_CALL);
NotificationManager.stopSound(NotificationService.INCOMING_CALL);
NotificationManager.stopSound(NotificationService.OUTGOING_CALL);
NotificationManager.stopSound(NotificationManager.DIALING);
NotificationManager.stopSound(NotificationManager.BUSY_CALL);
NotificationManager.stopSound(NotificationManager.INCOMING_CALL);
NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);
}
/**
@ -763,7 +813,7 @@ public void messageReceived(MessageReceivedEvent evt)
fireChatNotification(
evt.getSourceContact(),
NotificationService.INCOMING_MESSAGE,
NotificationManager.INCOMING_MESSAGE,
title,
evt.getSourceMessage().getContent());
}
@ -810,7 +860,7 @@ public void fileTransferRequestReceived(FileTransferRequestEvent event)
NotificationManager
.fireChatNotification(
sourceContact,
NotificationService.INCOMING_FILE,
NotificationManager.INCOMING_FILE,
title,
request.getFileName());
}
@ -910,7 +960,7 @@ public void typingNotificationReceived(TypingNotificationEvent event)
NotificationManager.fireChatNotification(
contact,
NotificationService.PROACTIVE_NOTIFICATION,
NotificationManager.PROACTIVE_NOTIFICATION,
contact.getDisplayName(),
NotificationActivator.getResources()
.getI18NString("service.gui.PROACTIVE_NOTIFICATION"));
@ -935,7 +985,7 @@ public void incomingCallReceived(CallEvent event)
.getCallPeers().next().getDisplayName();
NotificationManager.fireNotification(
NotificationService.INCOMING_CALL,
NotificationManager.INCOMING_CALL,
"",
NotificationActivator.getResources()
.getI18NString("service.gui.INCOMING_CALL",
@ -988,7 +1038,7 @@ public void callEnded(CallEvent event)
stopAllTelephonySounds();
// Play the hangup sound.
NotificationManager.fireNotification(NotificationService.HANG_UP);
NotificationManager.fireNotification(NotificationManager.HANG_UP);
}
catch(Throwable t)
{
@ -1055,11 +1105,11 @@ public void peerStateChanged(CallPeerChangeEvent evt)
|| newState == CallPeerState.CONNECTING)
{
NotificationManager
.fireNotification(NotificationService.DIALING);
.fireNotification(NotificationManager.DIALING);
}
else
{
NotificationManager.stopSound(NotificationService.DIALING);
NotificationManager.stopSound(NotificationManager.DIALING);
}
if (newState == CallPeerState.ALERTING_REMOTE_SIDE
@ -1069,17 +1119,17 @@ public void peerStateChanged(CallPeerChangeEvent evt)
&& oldState != CallPeerState.CONNECTING_WITH_EARLY_MEDIA)
{
NotificationManager
.fireNotification(NotificationService.OUTGOING_CALL);
.fireNotification(NotificationManager.OUTGOING_CALL);
}
else if (newState == CallPeerState.BUSY)
{
NotificationManager.stopSound(NotificationService.OUTGOING_CALL);
NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);
// We start the busy sound only if we're in a simple call.
if (!isConference(sourcePeer.getCall()))
{
NotificationManager.fireNotification(
NotificationService.BUSY_CALL);
NotificationManager.BUSY_CALL);
}
}
else if (newState == CallPeerState.CONNECTING_INCOMING_CALL ||
@ -1088,9 +1138,9 @@ else if (newState == CallPeerState.CONNECTING_INCOMING_CALL ||
if (!CallPeerState.isOnHold(oldState))
{
NotificationManager
.stopSound(NotificationService.OUTGOING_CALL);
.stopSound(NotificationManager.OUTGOING_CALL);
NotificationManager
.stopSound(NotificationService.INCOMING_CALL);
.stopSound(NotificationManager.INCOMING_CALL);
}
}
else if (newState == CallPeerState.CONNECTING_WITH_EARLY_MEDIA)
@ -1098,16 +1148,16 @@ else if (newState == CallPeerState.CONNECTING_WITH_EARLY_MEDIA)
//this means a call with early media. make sure that we are not
//playing local notifications any more.
NotificationManager
.stopSound(NotificationService.OUTGOING_CALL);
.stopSound(NotificationManager.OUTGOING_CALL);
}
else if (newState == CallPeerState.CONNECTED)
{
if (!CallPeerState.isOnHold(oldState))
{
NotificationManager
.stopSound(NotificationService.OUTGOING_CALL);
.stopSound(NotificationManager.OUTGOING_CALL);
NotificationManager
.stopSound(NotificationService.INCOMING_CALL);
.stopSound(NotificationManager.INCOMING_CALL);
}
}
else if (newState == CallPeerState.DISCONNECTED
@ -1115,7 +1165,7 @@ else if (newState == CallPeerState.DISCONNECTED
{
stopAllTelephonySounds();
NotificationManager.fireNotification(NotificationService.HANG_UP);
NotificationManager.fireNotification(NotificationManager.HANG_UP);
}
}
catch(Throwable t)
@ -1171,7 +1221,7 @@ public void securityOn(CallPeerSecurityOnEvent evt)
|| !evt.getSecurityController().requiresSecureSignalingTransport())
{
NotificationManager.fireNotification(
NotificationService.CALL_SECURITY_ON);
NotificationManager.CALL_SECURITY_ON);
}
}
catch(Throwable t)
@ -1221,12 +1271,12 @@ public void securityMessageRecieved(CallPeerSecurityMessageEvent event)
messageTitle = NotificationActivator.getResources()
.getI18NString("service.gui.SECURITY_ERROR");
NotificationManager.fireNotification(
NotificationService.CALL_SECURITY_ERROR);
NotificationManager.CALL_SECURITY_ERROR);
}
}
NotificationManager.fireNotification(
NotificationService.SECURITY_MESSAGE,
NotificationManager.SECURITY_MESSAGE,
messageTitle,
event.getI18nMessage());
}
@ -1291,7 +1341,7 @@ public void messageReceived(ChatRoomMessageReceivedEvent evt)
NotificationManager.fireChatNotification(
sourceChatRoom,
NotificationService.INCOMING_MESSAGE,
NotificationManager.INCOMING_MESSAGE,
title,
messageContent);
}
@ -1411,7 +1461,7 @@ public void messageReceived(AdHocChatRoomMessageReceivedEvent evt)
NotificationManager.fireChatNotification(
sourceChatRoom,
NotificationService.INCOMING_MESSAGE,
NotificationManager.INCOMING_MESSAGE,
title,
messageContent);
}
@ -1472,7 +1522,7 @@ public void conferenceMemberAdded(CallPeerConferenceEvent conferenceEvent)
if (securityEvent instanceof CallPeerSecurityOnEvent)
{
NotificationManager.fireNotification(
NotificationService.CALL_SECURITY_ON);
NotificationManager.CALL_SECURITY_ON);
}
}
}
@ -1503,7 +1553,7 @@ public void recorderStopped(Recorder recorder)
try
{
NotificationManager.fireNotification(
NotificationService.CALL_SAVED,
NotificationManager.CALL_SAVED,
NotificationActivator.getResources().getI18NString(
"plugin.callrecordingconfig.CALL_SAVED"),
NotificationActivator.getResources().getI18NString(

@ -18,71 +18,35 @@
public class PopupMessageNotificationHandlerImpl
implements PopupMessageNotificationHandler
{
private String defaultMessage;
private boolean isEnabled = true;
/**
* Creates an instance of <tt>PopupMessageNotificationHandlerImpl</tt> by
* specifying the default message to use if no message is specified.
*
* @param defaultMessage the default message to use if no message is
* specified
* {@inheritDoc}
*/
public PopupMessageNotificationHandlerImpl(String defaultMessage)
public String getActionType()
{
this.defaultMessage = defaultMessage;
}
/**
* Return the default message to use if no message is specified.
*
* @return the default message to use if no message is specified.
*/
public String getDefaultMessage()
{
return defaultMessage;
return NotificationAction.ACTION_POPUP_MESSAGE;
}
/**
* Shows a popup message through the <tt>SystrayService</tt>.
*
* @param message the message to show in the popup
* Shows the given <tt>PopupMessage</tt>
*
* @param action the action to act upon
* @param title the title of the given message
* @param message the message to use if and where appropriate (e.g. with
* systray or log notification.)
* @param icon the icon to show in the notification if and where
* appropriate
* @param tag additional info to be used by the notification handler
*/
public void popupMessage(PopupMessage message)
public void popupMessage(PopupMessageNotificationAction action,
String title,
String message,
byte[] icon,
Object tag)
{
SystrayService systray = NotificationActivator.getSystray();
if(systray == null)
return;
systray.showPopupMessage(message);
}
/**
* Returns TRUE if this notification action handler is enabled and FALSE
* otherwise. While the notification handler for the pop-up message action
* type is disabled no messages will be popped up when the
* <tt>fireNotification</tt> method is called.
*
* @return TRUE if this notification action handler is enabled and FALSE
* otherwise
*/
public boolean isEnabled()
{
return isEnabled;
}
/**
* Enables or disables this notification handler. While the notification
* handler for the pop-up message action type is disabled no messages will
* be popped up when the <tt>fireNotification</tt> method is called.
*
* @param isEnabled TRUE to enable this notification handler, FALSE to
* disable it.
*/
public void setEnabled(boolean isEnabled)
{
this.isEnabled = isEnabled;
systray.showPopupMessage(new PopupMessage(title, message, icon, tag));
}
}

@ -18,81 +18,47 @@
public class SoundNotificationHandlerImpl
implements SoundNotificationHandler
{
private String soundFileDescriptor;
/**
* By default we don't play sounds in loop.
*/
private int loopInterval = -1;
/**
* The audio clip that manages to play the sound.
*/
private SCAudioClip audio;
/**
* Indicates if this handler is enabled.
*/
private boolean isEnabled = true;
/**
* Creates an instance of <tt>SoundNotificationHandlerImpl</tt> by
* specifying the sound file descriptor.
*
* @param soundDescriptor the sound file descriptor
* {@inheritDoc}
*/
public SoundNotificationHandlerImpl(String soundDescriptor)
public String getActionType()
{
this.soundFileDescriptor = soundDescriptor;
}
/**
* Creates an instance of <tt>SoundNotificationHandlerImpl</tt> by
* specifying the sound file descriptor and the loop interval.
*
* @param soundDescriptor the sound file descriptor
* @param loopInterval the loop interval
*/
public SoundNotificationHandlerImpl( String soundDescriptor,
int loopInterval)
{
this.soundFileDescriptor = soundDescriptor;
this.loopInterval = loopInterval;
}
/**
* Returns the loop interval. This is the interval of milliseconds to wait
* before repeating the sound, when playing a sound in loop. By default this
* method returns -1.
*
* @return the loop interval
*/
public int getLoopInterval()
{
return loopInterval;
return NotificationAction.ACTION_SOUND;
}
/**
* Plays the sound given by the containing <tt>soundFileDescriptor</tt>. The
* sound is played in loop if the loopInterval is defined.
* @param action the action to act upon.
*/
public void start()
public void start(SoundNotificationAction action)
{
AudioNotifierService audioNotifService
= NotificationActivator.getAudioNotifier();
if(audioNotifService == null
|| StringUtils.isNullOrEmpty(soundFileDescriptor, true))
|| StringUtils.isNullOrEmpty(action.getDescriptor(), true))
return;
audio = audioNotifService.createAudio(soundFileDescriptor);
//stop any previous audio notification
if(audio != null)
{
stop();
}
audio = audioNotifService.createAudio(action.getDescriptor());
// it is possible that audio cannot be created
if(audio == null)
return;
if(loopInterval > -1)
audio.playInLoop(loopInterval);
if(action.getLoopInterval() > -1)
audio.playInLoop(action.getLoopInterval());
else
audio.play();
}
@ -105,51 +71,11 @@ public void stop()
AudioNotifierService audioNotifService
= NotificationActivator.getAudioNotifier();
if(audioNotifService == null)
return;
if(audio == null)
if(audioNotifService == null || audio == null)
return;
audio.stop();
audioNotifService.destroyAudio(audio);
}
/**
* Returns the descriptor pointing to the sound to be played.
*
* @return the descriptor pointing to the sound to be played.
*/
public String getDescriptor()
{
return soundFileDescriptor;
}
/**
* Returns TRUE if this notification action handler is enabled and FALSE
* otherwise. While the notification handler for the sound action type is
* disabled no sounds will be played when the <tt>fireNotification</tt>
* method is called.
*
* @return TRUE if this notification action handler is enabled and FALSE
* otherwise
*/
public boolean isEnabled()
{
return isEnabled;
}
/**
* Enables or disables this notification handler. While the notification
* handler for the sound action type is disabled no sounds will be played
* when the <tt>fireNotification</tt> method is called.
*
* @param isEnabled TRUE to enable this notification handler, FALSE to
* disable it.
*/
public void setEnabled(boolean isEnabled)
{
this.isEnabled = isEnabled;
audio = null;
}
}

@ -4,11 +4,10 @@ Bundle-Description: An implementation of the Notification service.
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
System-Bundle: yes
Export-Package: net.java.sip.communicator.service.notification,
net.java.sip.communicator.service.notification.event
Import-Package: org.osgi.framework,
javax.imageio,
net.java.sip.communicator.util,
net.java.sip.communicator.service.notification,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.service.contactlist,
net.java.sip.communicator.service.audionotifier,

@ -115,7 +115,7 @@ public LoggingConfigForm()
LoggingUtilsActivator.getNotificationService()
.registerDefaultNotificationForEvent(
LOGFILES_ARCHIVED,
NotificationService.ACTION_POPUP_MESSAGE,
NotificationAction.ACTION_POPUP_MESSAGE,
null,
null);
}

@ -326,7 +326,7 @@ public void insertUpdate(DocumentEvent event)
NotificationConfigurationActivator.getNotificationService()
.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_COMMAND,
NotificationAction.ACTION_COMMAND,
entry.getProgramFile(),
""
);
@ -338,7 +338,7 @@ public void insertUpdate(DocumentEvent event)
NotificationConfigurationActivator.getNotificationService()
.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_SOUND,
NotificationAction.ACTION_SOUND,
entry.getSoundFile(),
""
);
@ -366,7 +366,7 @@ public void removeUpdate(DocumentEvent event)
NotificationConfigurationActivator.getNotificationService()
.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_COMMAND,
NotificationAction.ACTION_COMMAND,
entry.getProgramFile(),
""
);
@ -378,7 +378,7 @@ public void removeUpdate(DocumentEvent event)
NotificationConfigurationActivator.getNotificationService()
.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_SOUND,
NotificationAction.ACTION_SOUND,
entry.getSoundFile(),
""
);

@ -8,7 +8,6 @@
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
@ -132,30 +131,24 @@ public void valueChanged(ListSelectionEvent e)
*/
private void initTableData()
{
Iterator<String> registeredEvents
= notificationService.getRegisteredEvents();
NotificationEntry entry;
while (registeredEvents.hasNext())
for(String eventType : notificationService.getRegisteredEvents())
{
String eventType = registeredEvents.next();
PopupMessageNotificationHandler popupHandler
= (PopupMessageNotificationHandler) notificationService
.getEventNotificationActionHandler(
eventType, NotificationService.ACTION_POPUP_MESSAGE);
CommandNotificationHandler programHandler
= (CommandNotificationHandler) notificationService
.getEventNotificationActionHandler(
eventType, NotificationService.ACTION_COMMAND);
SoundNotificationHandler soundHandler
= (SoundNotificationHandler) notificationService
.getEventNotificationActionHandler(
eventType, NotificationService.ACTION_SOUND);
entry = new NotificationEntry(
PopupMessageNotificationAction popupHandler
= (PopupMessageNotificationAction) notificationService
.getEventNotificationAction(
eventType, NotificationAction.ACTION_POPUP_MESSAGE);
CommandNotificationAction programHandler
= (CommandNotificationAction) notificationService
.getEventNotificationAction(
eventType, NotificationAction.ACTION_COMMAND);
SoundNotificationAction soundHandler
= (SoundNotificationAction) notificationService
.getEventNotificationAction(
eventType, NotificationAction.ACTION_SOUND);
NotificationEntry entry = new NotificationEntry(
notificationService.isActive(eventType),
programHandler != null && programHandler.isEnabled(),
(programHandler != null) ? programHandler.getDescriptor() : null,
@ -460,7 +453,7 @@ public void mouseClicked(MouseEvent e)
{
notificationService.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_COMMAND,
NotificationAction.ACTION_COMMAND,
entry.getProgramFile(),
"");
}
@ -468,7 +461,7 @@ public void mouseClicked(MouseEvent e)
{
notificationService.removeEventNotificationAction(
entry.getEvent(),
NotificationService.ACTION_COMMAND);
NotificationAction.ACTION_COMMAND);
}
break;
case 2:
@ -479,7 +472,7 @@ public void mouseClicked(MouseEvent e)
{
notificationService.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_POPUP_MESSAGE,
NotificationAction.ACTION_POPUP_MESSAGE,
"",
"");
}
@ -487,7 +480,7 @@ public void mouseClicked(MouseEvent e)
{
notificationService.removeEventNotificationAction(
entry.getEvent(),
NotificationService.ACTION_POPUP_MESSAGE);
NotificationAction.ACTION_POPUP_MESSAGE);
}
break;
case 3:
@ -498,7 +491,7 @@ public void mouseClicked(MouseEvent e)
{
notificationService.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_SOUND,
NotificationAction.ACTION_SOUND,
entry.getSoundFile(),
"");
}
@ -506,7 +499,7 @@ public void mouseClicked(MouseEvent e)
{
notificationService.removeEventNotificationAction(
entry.getEvent(),
NotificationService.ACTION_SOUND);
NotificationAction.ACTION_SOUND);
}
break;
};
@ -524,7 +517,7 @@ public void actionAdded(NotificationActionTypeEvent event)
String eventName = event.getSourceEventType();
NotificationEntry entry = getNotificationEntry(eventName);
NotificationActionHandler handler = event.getActionHandler();
NotificationAction handler = event.getActionHandler();
boolean isActionEnabled = (handler != null && handler.isEnabled());
if(entry == null)
@ -535,25 +528,25 @@ public void actionAdded(NotificationActionTypeEvent event)
entry.setEvent(eventName);
if(event.getSourceActionType()
.equals(NotificationService.ACTION_POPUP_MESSAGE))
if(event.getActionHandler().getActionType()
.equals(NotificationAction.ACTION_POPUP_MESSAGE))
{
entry.setPopup(isActionEnabled);
}
else if(event.getSourceActionType()
.equals(NotificationService.ACTION_COMMAND))
else if(event.getActionHandler().getActionType()
.equals(NotificationAction.ACTION_COMMAND))
{
entry.setProgram(isActionEnabled);
entry.setProgramFile(((CommandNotificationHandler)event
entry.setProgramFile(((CommandNotificationAction)event
.getActionHandler()).getDescriptor());
}
else if(event.getSourceActionType()
.equals(NotificationService.ACTION_SOUND))
else if(event.getActionHandler().getActionType()
.equals(NotificationAction.ACTION_SOUND))
{
entry.setSound(isActionEnabled);
entry.setSoundFile(((SoundNotificationHandler)event
entry.setSoundFile(((SoundNotificationAction)event
.getActionHandler()).getDescriptor());
}
entry.setEnabled(notificationService.isActive(eventName));
@ -574,19 +567,19 @@ public void actionRemoved(NotificationActionTypeEvent event)
if(entry == null)
return;
if(event.getSourceActionType()
.equals(NotificationService.ACTION_POPUP_MESSAGE))
if(event.getActionHandler().getActionType()
.equals(NotificationAction.ACTION_POPUP_MESSAGE))
{
entry.setPopup(false);
}
else if(event.getSourceActionType()
.equals(NotificationService.ACTION_COMMAND))
else if(event.getActionHandler().getActionType()
.equals(NotificationAction.ACTION_COMMAND))
{
entry.setProgram(false);
entry.setProgramFile("");
}
else if(event.getSourceActionType()
.equals(NotificationService.ACTION_SOUND))
else if(event.getActionHandler().getActionType()
.equals(NotificationAction.ACTION_SOUND))
{
entry.setSound(false);
entry.setSoundFile("");
@ -608,16 +601,16 @@ public void actionChanged(NotificationActionTypeEvent event)
if(entry == null)
return;
if(event.getSourceActionType()
.equals(NotificationService.ACTION_COMMAND))
if(event.getActionHandler().getActionType()
.equals(NotificationAction.ACTION_COMMAND))
{
entry.setProgramFile(((CommandNotificationHandler)event
entry.setProgramFile(((CommandNotificationAction)event
.getActionHandler()).getDescriptor());
}
else if(event.getSourceActionType()
.equals(NotificationService.ACTION_SOUND))
else if(event.getActionHandler().getActionType()
.equals(NotificationAction.ACTION_SOUND))
{
entry.setSoundFile(((SoundNotificationHandler)event
entry.setSoundFile(((SoundNotificationAction)event
.getActionHandler()).getDescriptor());
}
@ -638,20 +631,20 @@ public void eventTypeAdded(NotificationEventTypeEvent event)
if(entry == null)
{
PopupMessageNotificationHandler popupHandler
= (PopupMessageNotificationHandler) notificationService
.getEventNotificationActionHandler(
eventName, NotificationService.ACTION_POPUP_MESSAGE);
CommandNotificationHandler programHandler
= (CommandNotificationHandler) notificationService
.getEventNotificationActionHandler(
eventName, NotificationService.ACTION_COMMAND);
SoundNotificationHandler soundHandler
= (SoundNotificationHandler) notificationService
.getEventNotificationActionHandler(
eventName, NotificationService.ACTION_SOUND);
PopupMessageNotificationAction popupHandler
= (PopupMessageNotificationAction) notificationService
.getEventNotificationAction(
eventName, NotificationAction.ACTION_POPUP_MESSAGE);
CommandNotificationAction programHandler
= (CommandNotificationAction) notificationService
.getEventNotificationAction(
eventName, NotificationAction.ACTION_COMMAND);
SoundNotificationAction soundHandler
= (SoundNotificationAction) notificationService
.getEventNotificationAction(
eventName, NotificationAction.ACTION_SOUND);
entry = new NotificationEntry(
notificationService.isActive(event.getSourceEventType()),

@ -299,7 +299,7 @@ public static NotificationService getNotificationService()
notificationService.registerDefaultNotificationForEvent(
NETWORK_NOTIFICATIONS,
NotificationService.ACTION_POPUP_MESSAGE,
NotificationAction.ACTION_POPUP_MESSAGE,
null,
null);
}

@ -0,0 +1,42 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.notification;
/**
* An implementation of the <tt>CommandNotificationHandler</tt> interface.
*
* @author Yana Stamcheva
*/
public class CommandNotificationAction
extends NotificationAction
{
private String commandDescriptor;
/**
* Creates an instance of <tt>CommandNotification</tt> by
* specifying the <tt>commandDescriptor</tt>, which will point us to the
* command to execute.
*
* @param commandDescriptor a String that should point us to the command to
* execute
*/
public CommandNotificationAction(String commandDescriptor)
{
super(NotificationAction.ACTION_COMMAND);
this.commandDescriptor = commandDescriptor;
}
/**
* Returns the command descriptor.
*
* @return the command descriptor
*/
public String getDescriptor()
{
return commandDescriptor;
}
}

@ -13,17 +13,11 @@
* @author Yana Stamcheva
*/
public interface CommandNotificationHandler
extends NotificationActionHandler
extends NotificationHandler
{
/**
* Executes the program pointed by the descriptor.
* Executes the program pointed by the descriptor.
* @param action the action to act upon
*/
public void execute();
/**
* Returns the descriptor pointing to the command to be executed.
*
* @return the descriptor pointing to the command to be executed.
*/
public String getDescriptor();
public void execute(CommandNotificationAction action);
}

@ -0,0 +1,58 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.notification;
/**
* An implementation of the <tt>LogMessageNotificationHandler</tt> interface.
*
* @author Yana Stamcheva
*/
public class LogMessageNotificationAction
extends NotificationAction
{
/**
* Indicates that this log is of type trace. If this <tt>logType</tt> is set
* the messages would be logged as trace logs.
*/
public static final String TRACE_LOG_TYPE = "TraceLog";
/**
* Indicates that this log is of type info. If this <tt>logType</tt> is set
* the messages would be logged as info logs.
*/
public static final String INFO_LOG_TYPE = "InfoLog";
/**
* Indicates that this log is of type error. If this <tt>logType</tt> is set
* the messages would be logged as error logs.
*/
public static final String ERROR_LOG_TYPE = "ErrorLog";
private String logType;
/**
* Creates an instance of <tt>LogMessageNotificationHandlerImpl</tt> by
* specifying the log type.
*
* @param logType the type of the log
*/
public LogMessageNotificationAction(String logType)
{
super(NotificationAction.ACTION_LOG_MESSAGE);
this.logType = logType;
}
/**
* Returns the type of the log
*
* @return the type of the log
*/
public String getLogType()
{
return logType;
}
}

@ -14,37 +14,13 @@
* @author Yana Stamcheva
*/
public interface LogMessageNotificationHandler
extends NotificationActionHandler
extends NotificationHandler
{
/**
* Indicates that this log is of type trace. If this <tt>logType</tt> is set
* the messages would be logged as trace logs.
*/
public static final String TRACE_LOG_TYPE = "TraceLog";
/**
* Indicates that this log is of type info. If this <tt>logType</tt> is set
* the messages would be logged as info logs.
*/
public static final String INFO_LOG_TYPE = "InfoLog";
/**
* Indicates that this log is of type error. If this <tt>logType</tt> is set
* the messages would be logged as error logs.
*/
public static final String ERROR_LOG_TYPE = "ErrorLog";
/**
* Returns the type of the log. One of the XXX_LOG_TYPE-s declared in this
* interface.
* @return the type of the log. One of the XXX_LOG_TYPE-s declared in this
* interface.
*/
public String getLogType();
/**
* Logs the given message.
*
* @param action the action to act upon
* @param message the message to log
*/
public void logMessage(String message);
public void logMessage(LogMessageNotificationAction action, String message);
}

@ -4,18 +4,16 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.notification;
package net.java.sip.communicator.service.notification;
import java.util.*;
import net.java.sip.communicator.service.notification.*;
/**
* Represents an event notification.
*
* @author Yana Stamcheva
*/
public class EventNotification
public class Notification
{
/**
* Indicates if this event notification is currently active. By default all
@ -27,8 +25,8 @@ public class EventNotification
* Contains all actions which will be executed when this event notification
* is fired.
*/
private final Hashtable<String, Action> actionsTable
= new Hashtable<String, Action>();
private final Hashtable<String, NotificationAction> actionsTable
= new Hashtable<String, NotificationAction>();
/**
* Creates an instance of <tt>EventNotification</tt> by specifying the
@ -36,26 +34,22 @@ public class EventNotification
*
* @param eventType the name of the event
*/
public EventNotification(String eventType)
public Notification(String eventType)
{
}
/**
* Adds the given <tt>actionType</tt> to the list of actions for this event
* notifications.
*
* @param actionType one of NotificationService.ACTION_XXX constants
* @param actionHandler the the handler that will process the given action
* @param action the the handler that will process the given action
* type.
*
* @return the previous value of the actionHandler for the given actionType,
* if one existed, NULL if the actionType is a new one
*/
public Object addAction(String actionType,
NotificationActionHandler actionHandler)
public Object addAction(NotificationAction action)
{
Action action = new Action(actionType, actionHandler);
return actionsTable.put(actionType, action);
return actionsTable.put(action.getActionType(), action);
}
/**
@ -73,7 +67,7 @@ public void removeAction(String actionType)
*
* @return the set of actions registered for this event notification
*/
public Map<String, Action> getActions()
public Map<String, NotificationAction> getActions()
{
return actionsTable;
}
@ -87,57 +81,11 @@ public Map<String, Action> getActions()
* @return the <tt>Action</tt> corresponding to the given
* <tt>actionType</tt>
*/
public Action getAction(String actionType)
public NotificationAction getAction(String actionType)
{
return actionsTable.get(actionType);
}
/**
* The representation of an action, containing the corresponding
* action type, action descriptor and the default message associated with
* the action.
*/
public static class Action
{
private final String actionType;
private final NotificationActionHandler actionHandler;
/**
* Creates an instance of <tt>Action</tt> by specifying the type of the
* action, the descriptor and the default message.
*
* @param actionType one of NotificationService.ACTION_XXX constants
* @param actionHandler the handler that will process the given action
* type
*/
Action( String actionType,
NotificationActionHandler actionHandler)
{
this.actionType = actionType;
this.actionHandler = actionHandler;
}
/**
* Returns the the handler that will process the given action
* type.
* @return the the handler that will process the given action
* type.
*/
public NotificationActionHandler getActionHandler()
{
return actionHandler;
}
/**
* Return the action type name.
* @return the action type name.
*/
public String getActionType()
{
return actionType;
}
}
/**
* Indicates if this event notification is currently active.
*

@ -0,0 +1,95 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.notification;
/**
* Base class for actions of a notification.
*
* @author Ingo Bauersachs
*/
public abstract class NotificationAction
{
/**
* The sound action type indicates that a sound would be played, when a
* notification is fired.
*/
public static final String ACTION_SOUND = "SoundAction";
/**
* The popup message action type indicates that a window (or a systray
* popup), containing the corresponding notification message would be poped
* up, when a notification is fired.
*/
public static final String ACTION_POPUP_MESSAGE = "PopupMessageAction";
/**
* The log message action type indicates that a message would be logged,
* when a notification is fired.
*/
public static final String ACTION_LOG_MESSAGE = "LogMessageAction";
/**
* The command action type indicates that a command would be executed,
* when a notification is fired.
*/
public static final String ACTION_COMMAND = "CommandAction";
/**
* Indicates if this handler is enabled.
*/
private boolean isEnabled = true;
/**
* The action type name.
*/
private String actionType;
/**
* Creates a new instance of this class.
* @param actionType The action type name.
*/
protected NotificationAction(String actionType)
{
this.actionType = actionType;
}
/**
* Return the action type name.
* @return the action type name.
*/
public String getActionType()
{
return actionType;
}
/**
* Returns TRUE if this notification action handler is enabled and FALSE
* otherwise. While the notification handler for the sound action type is
* disabled no sounds will be played when the <tt>fireNotification</tt>
* method is called.
*
* @return TRUE if this notification action handler is enabled and FALSE
* otherwise
*/
public boolean isEnabled()
{
return isEnabled;
}
/**
* Enables or disables this notification handler. While the notification
* handler for the sound action type is disabled no sounds will be played
* when the <tt>fireNotification</tt> method is called.
*
* @param isEnabled TRUE to enable this notification handler, FALSE to
* disable it.
*/
public void setEnabled(boolean isEnabled)
{
this.isEnabled = isEnabled;
}
}

@ -1,38 +0,0 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.notification;
/**
* The <tt>NotificationActionHandler</tt> is the parent interface of all specific
* notification handlers used for handling different action types. This
* interface is used in the NotificationService in all methods dealing with
* action handlers.
*
* @author Yana Stamcheva
*/
public interface NotificationActionHandler
{
/**
* Returns TRUE if this notification action handler is enabled and FALSE
* otherwise. While the notification handler for an action type is disabled
* no notifications will be fired for this action type.
*
* @return TRUE if this notification action handler is enabled and FALSE
* otherwise
*/
public boolean isEnabled();
/**
* Enables or disables this notification handler. While the notification
* handler for an action type is disabled no notifications will be fired
* for this action type.
*
* @param isEnabled TRUE to enable this notification handler, FALSE to
* disable it.
*/
public void setEnabled(boolean isEnabled);
}

@ -0,0 +1,24 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.notification;
/**
* The <tt>NotificationActionHandler</tt> is the parent interface of all specific
* notification handlers used for handling different action types. This
* interface is used in the NotificationService in all methods dealing with
* action handlers.
*
* @author Yana Stamcheva
*/
public interface NotificationHandler
{
/**
* Gets the type of this handler.
* @return the type of this handler.
*/
String getActionType();
}

@ -6,8 +6,6 @@
*/
package net.java.sip.communicator.service.notification;
import java.util.*;
/**
* This service is previewed for use by bundles that implement some kind of
* user notification (e.g. playing sounds, poping systray tooltips, or
@ -22,238 +20,79 @@
*/
public interface NotificationService
{
/**
* The log message action type indicates that a message would be logged,
* when a notification is fired.
*/
public static final String ACTION_LOG_MESSAGE = "LogMessageAction";
/**
* The popup message action type indicates that a window (or a systray
* popup), containing the corresponding notification message would be poped
* up, when a notification is fired.
*/
public static final String ACTION_POPUP_MESSAGE = "PopupMessageAction";
/**
* The sound action type indicates that a sound would be played, when a
* notification is fired.
*/
public static final String ACTION_SOUND = "SoundAction";
/**
* The command action type indicates that a command would be executed,
* when a notification is fired.
*/
public static final String ACTION_COMMAND = "CommandAction";
/**
* Default event type for receiving messages.
*/
public static final String INCOMING_MESSAGE = "IncomingMessage";
/**
* Default event type for receiving calls (incoming calls).
*/
public static final String INCOMING_CALL = "IncomingCall";
/**
* Default event type for outgoing calls.
*/
public static final String OUTGOING_CALL = "OutgoingCall";
/**
* Default event type for a busy call.
*/
public static final String BUSY_CALL = "BusyCall";
/**
* Default event type for dialing.
*/
public static final String DIALING = "Dialing";
/**
* Default event type for hanging up calls.
*/
public static final String HANG_UP = "HangUp";
/**
* Default event type for
* proactive notifications (typing notifications when chatting).
*/
public static final String PROACTIVE_NOTIFICATION = "ProactiveNotification";
/**
* Default event type when a secure message received.
*/
public static final String SECURITY_MESSAGE = "SecurityMessage";
/**
* Default event type for activated security on a call.
*/
public static final String CALL_SECURITY_ON = "CallSecurityOn";
/**
* Default event type for security error on a call.
*/
public static final String CALL_SECURITY_ERROR = "CallSecurityError";
/**
* Default event type for incoming file transfers.
*/
public static final String INCOMING_FILE = "IncomingFile";
/**
* Default event type for call been saved using a recorder.
*/
public static final String CALL_SAVED = "CallSaved";
/**
* Creates a <tt>SoundNotificationHandler</tt>, by specifying the
* path pointing to the sound file and the loop interval if the sound should
* be played in loop. If the sound should be played just once the loop
* interval should be set to -1. The <tt>SoundNotificationHandler</tt> is
* the one that would take care of playing the sound, when a notification
* is fired.
*
* @param soundFileDescriptor the path pointing to the sound file
* @param loopInterval the interval of milliseconds to repeat the sound in
* loop
* @return the <tt>SoundNotificationHandler</tt> is the one, that would take
* care of playing the given sound, when a notification is fired
*/
public SoundNotificationHandler createSoundNotificationHandler(
String soundFileDescriptor,
int loopInterval);
/**
* Creates a <tt>PopupMessageNotificationHandler</tt>, by specifying the
* default message to show, when no message is provided to the
* <tt>fireNotification</tt> method. The
* <tt>PopupMessageNotificationHandler</tt> is the one that would take care
* of showing a popup message (through the systray service for example),
* when a notification is fired.
*
* @param defaultMessage the message to show if not message is provided to
* the <tt>fireNotification</tt> method
* @return the <tt>PopupMessageNotificationHandler</tt> is the one, that
* would take care of showing a popup message (through the systray service
* for example), when a notification is fired.
*/
public PopupMessageNotificationHandler createPopupMessageNotificationHandler(
String defaultMessage);
/**
* Creates a <tt>LogMessageNotificationHandler</tt>, by specifying the
* type of the log (error, trace, info, etc.). The
* <tt>LogMessageNotificationHandler</tt> is the one that would take care
* of logging a message (through the application log system), when a
* notification is fired.
*
* @param logType the type of the log (error, trace, etc.). One of the types
* defined in the <tt>LogMessageNotificationHandler</tt> interface
* @return the <tt>LogMessageNotificationHandler</tt> is the one, that would
* take care of logging a message (through the application log system), when
* a notification is fired.
*/
public LogMessageNotificationHandler createLogMessageNotificationHandler(
String logType);
/**
* Creates a <tt>CommandNotificationHandler</tt>, by specifying the path to
* the command file to execute, when a notification is fired. The
* <tt>CommandNotificationHandler</tt> is the one that would take care
* of executing the given program, when a notification is fired.
*
* @param commandFileDescriptor the path to the file containing the program
* to execute
* @return the <tt>CommandNotificationHandler</tt> is the one, that would
* take care of executing a program, when a notification is fired.
*/
public CommandNotificationHandler createCommandNotificationHandler(
String commandFileDescriptor);
/**
* Registers a notification for the given <tt>eventType</tt> by specifying
* the type of the action to be performed when a notification is fired for
* this event and the corresponding <tt>handler</tt> that should be used to
* handle the action. Unlike the other <tt>registerNotificationForEvent</tt>
* the action to be performed when a notification is fired for this event.
*
* Unlike the other <tt>registerNotificationForEvent</tt>
* method, this one allows the user to specify its own
* <tt>NotificationHandler</tt>, which would be used to handle notifications
* <tt>NotificationAction</tt>, which would be used to handle notifications
* for the specified <tt>actionType</tt>.
*
* @param eventType the name of the event (as defined by the plug-in that's
* registering it) that we are setting an action for.
* @param actionType the type of the action that is to be executed when the
* specified event occurs (could be one of the ACTION_XXX fields).
* @param handler the <tt>NotificationActionHandler</tt>, which would be
* @param action the <tt>NotificationAction</tt>, which would be
* used to perform the notification action.
* @throws IllegalArgumentException if the specified <tt>handler</tt> do not
* correspond to the given <tt>actionType</tt>.
*/
public void registerNotificationForEvent( String eventType,
String actionType,
NotificationActionHandler handler)
throws IllegalArgumentException;
public void registerNotificationForEvent(String eventType,
NotificationAction action);
/**
* Registers a Default notification for the given <tt>eventType</tt> by specifying
* the type of the action to be performed when a notification is fired for
* this event and the corresponding <tt>handler</tt> that should be used to
* handle the action. Unlike the other
* <tt>registerDefaultNotificationForEvent</tt>
* method, this one allows the user to specify its own
* <tt>NotificationHandler</tt>, which would be used to handle notifications
* for the specified <tt>actionType</tt>.
* Default events are stored or executed at first run or when they are
* missing in the configuration. Also the registered default events
* are used when restoreDefaults is called.
* Registers a default notification for the given <tt>eventType</tt> by
* specifying the action to be performed when a notification is fired for
* this event.
*
* Unlike the other <tt>registerDefaultNotificationForEvent</tt> method,
* this one allows the user to specify its own <tt>NotificationAction</tt>,
* which would be used to handle notifications.
*
* Default events are stored or executed at first run or when they are
* missing in the configuration. Also the registered default events are used
* when restoreDefaults is called.
*
* @param eventType the name of the event (as defined by the plug-in that's
* registering it) that we are setting an action for.
* @param actionType the type of the action that is to be executed when the
* specified event occurs (could be one of the ACTION_XXX fields).
* registering it) that we are setting an action for.
* @param handler the <tt>NotificationActionHandler</tt>, which would be
* used to perform the notification action.
* @throws IllegalArgumentException if the specified <tt>handler</tt> do not
* correspond to the given <tt>actionType</tt>.
* used to perform the notification action.
*/
public void registerDefaultNotificationForEvent( String eventType,
String actionType,
NotificationActionHandler handler)
throws IllegalArgumentException;
public void registerDefaultNotificationForEvent(String eventType,
NotificationAction handler);
/**
* Registers a default notification for the given <tt>eventType</tt> by specifying
* the type of the action to be performed when a notification is fired for
* this event, the <tt>actionDescriptor</tt> for sound and command actions
* and the <tt>defaultMessage</tt> for popup and log actions. Actions
* registered by this method would be handled by some default
* Registers a default notification for the given <tt>eventType</tt> by
* specifying the type of the action to be performed when a notification is
* fired for this event, the <tt>actionDescriptor</tt> for sound and command
* actions and the <tt>defaultMessage</tt> for popup and log actions.
*
* Actions registered by this method would be handled by some default
* <tt>NotificationHandler</tt>s, declared by the implementation.
* <p>
* The method allows registering more than one actionType for a specific
* event. Setting twice the same <tt>actionType</tt> for the same
* <tt>eventType</tt> however would cause the first setting to be
* event. Setting the same <tt>actionType</tt> for the same
* <tt>eventType</tt> twice however would cause the first setting to be
* overridden.
* Default events are stored or executed at first run or when they are
* missing in the configuration. Also the registered default events
*
* Default events are stored or executed at first run or when
* they are missing in the configuration. Also the registered default events
* are used when restoreDefaults is called.
*
*
* @param eventType the name of the event (as defined by the plug-in that's
* registering it) that we are setting an action for.
* registering it) that we are setting an action for.
* @param actionType the type of the action that is to be executed when the
* specified event occurs (could be one of the ACTION_XXX fields).
* specified event occurs (could be one of the ACTION_XXX
* fields).
* @param actionDescriptor a String containing a description of the action
* (a URI to the sound file for audio notifications or a command line for
* exec action types) that should be executed when the action occurs.
* (a URI to the sound file for audio notifications or a command
* line for exec action types) that should be executed when the
* action occurs.
* @param defaultMessage the default message to use if no specific message
* has been provided when firing the notification.
* has been provided when firing the notification.
*/
public void registerDefaultNotificationForEvent( String eventType,
String actionType,
String actionDescriptor,
String defaultMessage);
public void registerDefaultNotificationForEvent(String eventType,
String actionType,
String actionDescriptor,
String defaultMessage);
/**
* Registers a notification for the given <tt>eventType</tt> by specifying
* the type of the action to be performed when a notification is fired for
@ -263,44 +102,46 @@ public void registerDefaultNotificationForEvent( String eventType,
* <tt>NotificationHandler</tt>s, declared by the implementation.
* <p>
* The method allows registering more than one actionType for a specific
* event. Setting twice the same <tt>actionType</tt> for the same
* <tt>eventType</tt> however would cause the first setting to be
* event. Setting the same <tt>actionType</tt> for the same
* <tt>eventType</tt> twice however would cause the first setting to be
* overridden.
*
*
* @param eventType the name of the event (as defined by the plug-in that's
* registering it) that we are setting an action for.
* registering it) that we are setting an action for.
* @param actionType the type of the action that is to be executed when the
* specified event occurs (could be one of the ACTION_XXX fields).
* specified event occurs (could be one of the ACTION_XXX
* fields).
* @param actionDescriptor a String containing a description of the action
* (a URI to the sound file for audio notifications or a command line for
* exec action types) that should be executed when the action occurs.
* (a URI to the sound file for audio notifications or a command
* line for exec action types) that should be executed when the
* action occurs.
* @param defaultMessage the default message to use if no specific message
* has been provided when firing the notification.
* has been provided when firing the notification.
*/
public void registerNotificationForEvent( String eventType,
String actionType,
String actionDescriptor,
String defaultMessage);
/**
* Deletes all registered events and actions
* and registers and saves the default events as current.
*/
public void restoreDefaults();
/**
* Removes the given <tt>eventType</tt> from the list of event notifications.
* This means that we delete here all registered notifications for the given
* <tt>eventType</tt>.
* Removes the given <tt>eventType</tt> from the list of event
* notifications. This means that we delete here all registered
* notifications for the given <tt>eventType</tt>.
* <p>
* This method does nothing if the given <tt>eventType</tt> is not contained
* in the list of registered event types.
*
*
* @param eventType the name of the event (as defined by the plugin that's
* registering it) to be removed.
* registering it) to be removed.
*/
public void removeEventNotification(String eventType);
/**
* Removes the event notification corresponding to the specified
* <tt>actionType</tt> and <tt>eventType</tt>.
@ -309,57 +150,40 @@ public void registerNotificationForEvent( String eventType,
* <tt>actionType</tt> are not contained in the list of registered types.
*
* @param eventType the name of the event (as defined by the plugin that's
* registering it) for which we'll remove the notification.
* registering it) for which we'll remove the notification.
* @param actionType the type of the action that is to be executed when the
* specified event occurs (could be one of the ACTION_XXX fields).
* specified event occurs (could be one of the ACTION_XXX
* fields).
*/
public void removeEventNotificationAction( String eventType,
String actionType);
/**
* Returns an iterator over a list of all events registered in this
* notification service. Each line in the returned list consists of
* a String, representing the name of the event (as defined by the plugin
* that registered it).
*
* @return an iterator over a list of all events registered in this
* notifications service
*/
public Iterator<String> getRegisteredEvents();
/**
* Returns a Map containing all action types (as keys) and actionDescriptors
* (as values) that have been registered for <tt>eventType</tt>.
* <p>
* This method returns <b>null</b> if the given <tt>eventType</tt> is not
* contained in the list of registered event types.
* notification service. Each line in the returned list consists of a
* String, representing the name of the event (as defined by the plugin that
* registered it).
*
* @param eventType the name of the event that we'd like to retrieve actions
* for.
* @return a <tt>Map</tt> containing the <tt>actionType</tt>s (as keys) and
* <tt>actionHandler</tt>s (as values) that should be executed when
* an event with the specified name has occurred, or null if no actions
* have been defined for <tt>eventType</tt>.
* @return an iterator over a list of all events registered in this
* notifications service
*/
public Map<String, NotificationActionHandler> getEventNotifications(
String eventType);
public Iterable<String> getRegisteredEvents();
/**
* Returns the <tt>NotificationActionHandler</tt> corresponding to the given
* event and action types.
* Returns the <tt>NotificationAction</tt> corresponding to the given event
* and action type.
* <p>
* This method returns <b>null</b> if the given <tt>eventType</tt> or
* <tt>actionType</tt> are not contained in the list of registered types.
*
*
* @param eventType the type of the event that we'd like to retrieve.
* @param actionType the type of the action that we'd like to retrieve a
* descriptor for.
* @return the <tt>NotificationActionHandler</tt> corresponding to the given
* event and action types
* descriptor for.
* @return the <tt>NotificationAction</tt> corresponding to the given event
* and action type
*/
public NotificationActionHandler getEventNotificationActionHandler(
String eventType,
String actionType);
public NotificationAction getEventNotificationAction(String eventType,
String actionType);
/**
* Registers a listener that would be notified of changes that have occurred
@ -381,6 +205,26 @@ public void addNotificationChangeListener(
public void removeNotificationChangeListener(
NotificationChangeListener listener);
/**
* Adds an object that executes the actual action of a notification action.
* @param handler The handler that executes the action.
*/
public void addActionHandler(NotificationHandler handler);
/**
* Removes an object that executes the actual action of notification action.
* @param actionType The handler type to remove.
*/
public void removeActionHandler(String actionType);
/**
* Gets at list of handler for the specified action type.
*
* @param actionType the type for which the list of handlers should be
* retrieved or <tt>null</tt> if all handlers shall be returned.
*/
public Iterable<NotificationHandler> getActionHandlers(String actionType);
/**
* Fires all notifications registered for the specified <tt>eventType</tt>
* using <tt>message</tt> as a notification message wherever appropriate

@ -0,0 +1,77 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.notification;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
/**
* The <tt>NotificationActivator</tt> is the activator of the notification
* bundle.
*
* @author Yana Stamcheva
*/
public class NotificationServiceActivator
implements BundleActivator
{
private final Logger logger
= Logger.getLogger(NotificationServiceActivator.class);
protected static BundleContext bundleContext;
private static ConfigurationService configService;
private ServiceRegistration notificationService;
public void start(BundleContext bc) throws Exception
{
bundleContext = bc;
try
{
logger.logEntry();
logger.info("Notification Service...[ STARTED ]");
notificationService = bundleContext.registerService(
NotificationService.class.getName(),
new NotificationServiceImpl(),
null);
logger.info("Notification Service ...[REGISTERED]");
}
finally
{
logger.logExit();
}
}
public void stop(BundleContext bc) throws Exception
{
notificationService.unregister();
logger.info("Notification Service ...[STOPPED]");
}
/**
* Returns the <tt>ConfigurationService</tt> obtained from the bundle
* context.
* @return the <tt>ConfigurationService</tt> obtained from the bundle
* context
*/
public static ConfigurationService getConfigurationService()
{
if(configService == null)
{
ServiceReference configReference = bundleContext
.getServiceReference(ConfigurationService.class.getName());
configService = (ConfigurationService) bundleContext
.getService(configReference);
}
return configService;
}
}

@ -0,0 +1,41 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.notification;
/**
* An implementation of the <tt>PopupMessageNotificationHandler</tt> interface.
*
* @author Yana Stamcheva
*/
public class PopupMessageNotificationAction
extends NotificationAction
{
private String defaultMessage;
/**
* Creates an instance of <tt>PopupMessageNotificationHandlerImpl</tt> by
* specifying the default message to use if no message is specified.
*
* @param defaultMessage the default message to use if no message is
* specified
*/
public PopupMessageNotificationAction(String defaultMessage)
{
super(NotificationAction.ACTION_POPUP_MESSAGE);
this.defaultMessage = defaultMessage;
}
/**
* Return the default message to use if no message is specified.
*
* @return the default message to use if no message is specified.
*/
public String getDefaultMessage()
{
return defaultMessage;
}
}

@ -6,8 +6,6 @@
*/
package net.java.sip.communicator.service.notification;
import net.java.sip.communicator.service.systray.*;
/**
* The <tt>PopupMessageNotificationHandler</tt> interface is meant to be
* implemented by the notification bundle in order to provide handling of
@ -16,21 +14,22 @@
* @author Yana Stamcheva
*/
public interface PopupMessageNotificationHandler
extends NotificationActionHandler
extends NotificationHandler
{
/**
* Returns the default message to be used when no message is provided to the
* <tt>popupMessage</tt> method.
*
* @return the default message to be used when no message is provided to the
* <tt>popupMessage</tt> method.
*/
public String getDefaultMessage();
/**
* Shows the given <tt>PopupMessage</tt>
*
* @param message the message to show in the popup
* @param action the action to act upon
* @param title the title of the given message
* @param message the message to use if and where appropriate (e.g. with
* systray or log notification.)
* @param icon the icon to show in the notification if and where
* appropriate
* @param tag additional info to be used by the notification handler
*/
public void popupMessage(PopupMessage message);
public void popupMessage(PopupMessageNotificationAction action,
String title,
String message,
byte[] icon,
Object tag);
}

@ -0,0 +1,75 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.notification;
/**
* An implementation of the <tt>SoundNotificationHandlerImpl</tt> interface.
*
* @author Yana Stamcheva
*/
public class SoundNotificationAction
extends NotificationAction
{
/**
* Interval of milliseconds to wait before repeating the sound. -1 means no
* repetition.
*/
private int loopInterval;
/**
* the descriptor pointing to the sound to be played.
*/
private String soundFileDescriptor;
/**
* Creates an instance of <tt>SoundNotification</tt> by
* specifying the sound file descriptor. The sound is played once.
*
* @param soundDescriptor the sound file descriptor
*/
public SoundNotificationAction(String soundDescriptor)
{
this(soundDescriptor, -1);
}
/**
* Creates an instance of <tt>SoundNotification</tt> by
* specifying the sound file descriptor and the loop interval.
*
* @param soundDescriptor the sound file descriptor
* @param loopInterval the loop interval
*/
public SoundNotificationAction( String soundDescriptor,
int loopInterval)
{
super(NotificationAction.ACTION_SOUND);
this.soundFileDescriptor = soundDescriptor;
this.loopInterval = loopInterval;
}
/**
* Returns the loop interval. This is the interval of milliseconds to wait
* before repeating the sound, when playing a sound in loop. By default this
* method returns -1.
*
* @return the loop interval
*/
public int getLoopInterval()
{
return loopInterval;
}
/**
* Returns the descriptor pointing to the sound to be played.
*
* @return the descriptor pointing to the sound to be played.
*/
public String getDescriptor()
{
return soundFileDescriptor;
}
}

@ -14,30 +14,15 @@
* @author Yana Stamcheva
*/
public interface SoundNotificationHandler
extends NotificationActionHandler
extends NotificationHandler
{
/**
* Returns the loop interval. This is the interval of milliseconds to wait
* before repeating the sound, when playing a sound in loop. If this method
* returns -1 the sound should not played in loop.
*
* @return the loop interval
*/
public int getLoopInterval();
/**
* Returns the descriptor pointing to the sound to be played.
*
* @return the descriptor pointing to the sound to be played.
*/
public String getDescriptor();
/**
* Start playing the sound pointed by <tt>getDescriotor</tt>. This
* method should check the loopInterval value to distinguish whether to play
* a simple sound or to play it in loop.
* @param action the action to act upon
*/
public void start();
public void start(SoundNotificationAction action);
/**
* Stops playing the sound pointing by <tt>getDescriptor</tt>. This method

@ -39,11 +39,6 @@ public class NotificationActionTypeEvent
*/
public static final String ACTION_CHANGED = "ActionChanged";
/**
* The type of the notification action that is being added.
*/
private String sourceActionType = null;
/**
* The type of the event that a new action is being added for.
*/
@ -54,7 +49,7 @@ public class NotificationActionTypeEvent
* string) that will be performed when notifications are being fired for
* the corresponding event type.
*/
private NotificationActionHandler actionHandler = null;
private NotificationAction actionHandler = null;
/**
* The type of this event. One of the static field constants declared in
@ -69,34 +64,21 @@ public class NotificationActionTypeEvent
* @param eventType the type of this event. One of the static fields
* declared in this class
* @param sourceEventType the event type for which this event occured
* @param sourceActionType the action type corresponding to this event
* @param actionHandler the <tt>NotificationActionHandler</tt> that handles
* the given action
*/
public NotificationActionTypeEvent( NotificationService source,
String eventType,
String sourceEventType,
String sourceActionType,
NotificationActionHandler actionHandler)
NotificationAction actionHandler)
{
super(source);
this.eventType = eventType;
this.sourceEventType = sourceEventType;
this.sourceActionType = sourceActionType;
this.actionHandler = actionHandler;
}
/**
* Returns the action type, for which this event is about.
*
* @return the action type, for which this event is about.
*/
public String getSourceActionType()
{
return sourceActionType;
}
/**
* Returns the event type, to which the given action belongs.
*
@ -114,7 +96,7 @@ public String getSourceEventType()
* @return the <tt>NotificationActionHandler</tt> that handles the action,
* for which this event is about.
*/
public NotificationActionHandler getActionHandler()
public NotificationAction getActionHandler()
{
return actionHandler;
}

@ -0,0 +1,11 @@
Bundle-Activator: net.java.sip.communicator.service.notification.NotificationServiceActivator
Bundle-Name: Notifications
Bundle-Description: An implementation of the Notification service.
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
System-Bundle: yes
Export-Package: net.java.sip.communicator.service.notification,
net.java.sip.communicator.service.notification.event
Import-Package: org.osgi.framework,
net.java.sip.communicator.util,
net.java.sip.communicator.service.configuration

@ -127,7 +127,7 @@ public void testNotificationHandling()
= (NotificationService) bc.getService(serviceReference);
notificationService.fireNotification(
NotificationService.ACTION_POPUP_MESSAGE,
NotificationAction.ACTION_POPUP_MESSAGE,
messageStart,
messageStart,
null,

Loading…
Cancel
Save