notification service enhancements

cusax-fix
Yana Stamcheva 19 years ago
parent c477dd269d
commit 80b489dfea

@ -0,0 +1,29 @@
/*
* SIP Communicator, 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>CommandNotificationHandler</tt> interface is meant to be implemented
* by the notification bundle in order to provide handling of command actions.
*
* @author Yana Stamcheva
*/
public interface CommandNotificationHandler
extends NotificationActionHandler
{
/**
* Executes the program pointed by the descriptor.
*/
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();
}

@ -0,0 +1,50 @@
/*
* SIP Communicator, 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>LogMessageNotificationHandler</tt> interface is meant to be
* implemented by the notification bundle in order to provide handling of
* log actions.
*
* @author Yana Stamcheva
*/
public interface LogMessageNotificationHandler
extends NotificationActionHandler
{
/**
* 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 message the message to log
*/
public void logMessage(String message);
}

@ -0,0 +1,18 @@
/*
* SIP Communicator, 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
{}

@ -8,25 +8,59 @@
import java.util.*;
import net.java.sip.communicator.service.notification.event.*;
/**
*
* The <tt>NotificationChangeListener</tt> is notified any time an action
* type or an event type is added, removed or changed.
*
* @author Emil Ivov
* @author Yana Stamcheva
*/
public interface NotificationChangeListener
extends EventListener
{
/**
* This method gets called when a new notification action has been defined
* for one of the event types defined for a particular event type.
* for a particular event type.
*
* @param event the <tt>NotificationActionTypeEvent</tt>, which is
* dispatched when a new action has been added.
*/
public void actionAdded();
public void actionRemoved();
public void actionAdded(NotificationActionTypeEvent event);
public void actionChanged();
/**
* This method gets called when a notification action for a particular event
* type has been removed.
*
* @param event the <tt>NotificationActionTypeEvent</tt>, which is
* dispatched when an action has been removed.
*/
public void actionRemoved(NotificationActionTypeEvent event);
/**
* This method gets called when a notification action for a particular event
* type has been changed (for example the corresponding descriptor has
* changed).
*
* @param event the <tt>NotificationActionTypeEvent</tt>, which is
* dispatched when an action has been changed.
*/
public void actionChanged(NotificationActionTypeEvent event);
public void eventTypeAdded();
/**
* This method gets called when a new event type has been added.
*
* @param event the <tt>NotificationEventTypeEvent</tt>, which is dispatched
* when a new event type has been added
*/
public void eventTypeAdded(NotificationEventTypeEvent event);
/**
* This method gets called when an event type has been removed.
*
* @param event the <tt>NotificationEventTypeEvent</tt>, which is dispatched
* when an event type has been removed.
*/
public void eventTypeRemoved();
}

@ -1,4 +1,4 @@
/*r
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
@ -48,16 +48,107 @@ public interface NotificationService
public static final String ACTION_COMMAND = "CommandAction";
/**
* Registers the specified <tt>actionDescriptor</tt> as a notification that
* should be used every time an event with the specified <tt>eventType</tt>
* has occurred.
* 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>
* 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>.
*
* @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
* 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;
/**
* 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, 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
* overridden.
*
* @param eventType the name of the event (as defined by the plugin that's
* @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).
@ -67,10 +158,10 @@ public interface NotificationService
* @param defaultMessage the default message to use if no specific message
* has been provided when firing the notification.
*/
public void registerEventNotification(String eventType,
String actionType,
String actionDescriptor,
String defaultMessage);
public void registerNotificationForEvent( String eventType,
String actionType,
String actionDescriptor,
String defaultMessage);
/**
* Removes the given <tt>eventType</tt> from the list of event notifications.
@ -128,8 +219,8 @@ public void removeEventNotificationAction( String eventType,
public Map getEventNotifications(String eventType);
/**
* Returns the descriptor of the action of type <tt>actionType</tt> that
* should be executed when an event of <tt>eventType</tt> has occurred.
* Returns the <tt>NotificationActionHandler</tt> corresponding to the given
* event and action types.
* <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.
@ -137,11 +228,12 @@ public void removeEventNotificationAction( String eventType,
* @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 a String containing a descriptor of the action to be executed
* when an event of the specified type has occurred.
* @return the <tt>NotificationActionHandler</tt> corresponding to the given
* event and action types
*/
public String getEventNotificationActionDescriptor(String eventType,
String actionType);
public NotificationActionHandler getEventNotificationActionHandler(
String eventType,
String actionType);
/**
* Registers a listener that would be notified of changes that have occurred
@ -171,10 +263,14 @@ public String getEventNotificationActionDescriptor(String eventType,
*
* @param eventType the type of the event that we'd like to fire a
* notification for.
* @param messageTitle the message title to use if and where appropriate
* (e.g. with systray)
* @param message the message to use if and where appropriate (e.g. with
* systray or log notification.)
*/
public void fireNotification(String eventType, String message);
public void fireNotification( String eventType,
String messageTitle,
String message);
/**
* Fires all notifications registered for the specified <tt>eventType</tt>
@ -189,7 +285,7 @@ public String getEventNotificationActionDescriptor(String eventType,
* notification for.
*/
public void fireNotification(String eventType);
/**
* Activates or desactivates all notification actions related to the
* specified <tt>eventType</tt>. This method does nothing if the given

@ -0,0 +1,36 @@
/*
* SIP Communicator, 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>PopupMessageNotificationHandler</tt> interface is meant to be
* implemented by the notification bundle in order to provide handling of
* popup message actions.
*
* @author Yana Stamcheva
*/
public interface PopupMessageNotificationHandler
extends NotificationActionHandler
{
/**
* 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();
/**
* Pops up a message with the given <tt>message</tt> content and the given
* <tt>title</tt>.
*
* @param title the title of the popup
* @param message the message to show in the popup
*/
public void popupMessage(String title, String message);
}

@ -0,0 +1,47 @@
/*
* SIP Communicator, 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>SoundNotificationHandler</tt> interface is meant to be
* implemented by the notification bundle in order to provide handling of
* sound actions.
*
* @author Yana Stamcheva
*/
public interface SoundNotificationHandler
extends NotificationActionHandler
{
/**
* 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.
*/
public void start();
/**
* Stops playing the sound pointing by <tt>getDescriptor</tt>. This method
* is meant to be used to stop sounds that are played in loop.
*/
public void stop();
}

@ -1,57 +0,0 @@
/*
* SIP Communicator, 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.event;
import java.util.*;
import net.java.sip.communicator.service.notification.*;
/**
* Fired any time that a new action (i.e. of an action type previously not
* registered for the corresponding event type) has been added for an event
* type.
*
* @author Emil Ivov
*/
public class NotificationActionAddedEvent
extends EventObject
{
/**
* The type of the notification action that is being added.
*/
private String actionType = null;
/**
* The type of the event that a new action is being added for.
*/
private String eventType = null;
/**
* The descriptor of the action (i.e. audio file uri, or a command line
* string) that will be performed when notifications are being fired for
* the corresponding event type.
*/
private String actionDescriptor = null;
/**
* Creates an instance of this event according to the specified type.
* @param source NotificationService
* @param eventType String
* @param actionType String
* @param actionDescriptor String
*/
public NotificationActionAddedEvent(NotificationService source,
String eventType,
String actionType,
String actionDescriptor)
{
super(source);
this.eventType = eventType;
this.actionType = actionType;
this.actionDescriptor = actionDescriptor;
}
}

@ -0,0 +1,127 @@
/*
* SIP Communicator, 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.event;
import java.util.*;
import net.java.sip.communicator.service.notification.*;
/**
* Fired any time an action type is added, removed or changed.
*
* @author Emil Ivov
* @author Yana Stamcheva
*/
public class NotificationActionTypeEvent
extends EventObject
{
/**
* Indicates that a new action is added to an event type.
*/
public static final String ACTION_ADDED = "ActionAdded";
/**
* Indicates that an action was removed for a given event type.
*/
public static final String ACTION_REMOVED = "ActionRemoved";
/**
* Indicates that an action for a given event type has changed. For example
* the action descriptor is changed.
*/
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.
*/
private String sourceEventType = null;
/**
* The descriptor of the action (i.e. audio file uri, or a command line
* string) that will be performed when notifications are being fired for
* the corresponding event type.
*/
private NotificationActionHandler actionHandler = null;
/**
* The type of this event. One of the static field constants declared in
* this class.
*/
private String eventType = null;
/**
* Creates an instance of this event according to the specified type.
*
* @param source the <tt>NotificationService</tt> that dispatched this event
* @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)
{
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.
*
* @return the event type, to which the given action belongs
*/
public String getSourceEventType()
{
return sourceEventType;
}
/**
* Returns the <tt>NotificationActionHandler</tt> that handles the action,
* for which this event is about.
*
* @return the <tt>NotificationActionHandler</tt> that handles the action,
* for which this event is about.
*/
public NotificationActionHandler getActionHandler()
{
return actionHandler;
}
/**
* The type of this event. One of ACTION_XXX constants declared in this
* class.
*
* @return the type of this event
*/
public String getEventType()
{
return eventType;
}
}

@ -0,0 +1,80 @@
/*
* SIP Communicator, 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.event;
import java.util.*;
import net.java.sip.communicator.service.notification.*;
/**
* Fired any time an event type is added or removed.
*
* @author Emil Ivov
* @author Yana Stamcheva
*/
public class NotificationEventTypeEvent
extends EventObject
{
/**
* Indicates that a new event type is added.
*/
public static final String EVENT_TYPE_ADDED = "EventTypeAdded";
/**
* Indicates that an event type was removed.
*/
public static final String EVENT_TYPE_REMOVED = "EventTypeRemoved";
/**
* The type of the event that a new action is being added for.
*/
private String sourceEventType = null;
/**
* The type of this event. One of the static field constants declared in
* this class.
*/
private String eventType = null;
/**
* Creates an instance of this event according to the specified type.
*
* @param source the <tt>NotificationService</tt> that dispatched this event
* @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
*/
public NotificationEventTypeEvent( NotificationService source,
String eventType,
String sourceEventType)
{
super(source);
this.eventType = eventType;
this.sourceEventType = sourceEventType;
}
/**
* Returns the <tt>eventType</tt>, for which this event is about.
*
* @return the <tt>eventType</tt>, for which this event is about.
*/
public String getSourceEventType()
{
return sourceEventType;
}
/**
* The type of this event. One of EVENT_TYPE_XXX constants declared in this
* class.
*
* @return the type of this event
*/
public String getEventType()
{
return eventType;
}
}
Loading…
Cancel
Save