class NotificationServiceImpl extends java.lang.Object implements NotificationService
Modifier and Type | Field and Description |
---|---|
static int |
NUM_ACTIONS
Defines the number of actions that have to be registered before cached
notifications are fired.
|
Constructor and Description |
---|
NotificationServiceImpl()
Creates an instance of NotificationServiceImpl by loading all
previously saved notifications.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionHandler(NotificationHandler handler)
Adds an object that executes the actual action of a notification action.
|
void |
addNotificationChangeListener(NotificationChangeListener listener)
Adds the given listener to the list of change listeners.
|
NotificationData |
fireNotification(java.lang.String eventType)
If there is a registered event notification of the given
eventType and the event notification is currently activated, we
go through the list of registered actions and execute them.
|
NotificationData |
fireNotification(java.lang.String eventType,
java.lang.String title,
java.lang.String message,
byte[] icon)
If there is a registered event notification of the given
eventType and the event notification is currently activated, the
list of registered actions is executed.
|
NotificationData |
fireNotification(java.lang.String eventType,
java.lang.String title,
java.lang.String message,
byte[] icon,
java.util.Map<java.lang.String,java.lang.Object> extras)
If there is a registered event notification of the given
eventType and the event notification is currently activated, the
list of registered actions is executed.
|
java.lang.Iterable<NotificationHandler> |
getActionHandlers(java.lang.String actionType)
Gets a list of handler for the specified action type.
|
NotificationAction |
getEventNotificationAction(java.lang.String eventType,
java.lang.String actionType)
Returns the notification action corresponding to the given
eventType and actionType.
|
java.lang.Iterable<java.lang.String> |
getRegisteredEvents()
Returns an iterator over a list of all events registered in this
notification service.
|
boolean |
isActive(java.lang.String eventType)
Finds the EventNotification corresponding to the given
eventType and returns its isActive status.
|
boolean |
isPlayingNotification(NotificationData data)
Tells if the given sound notification is currently played.
|
void |
registerDefaultNotificationForEvent(java.lang.String eventType,
NotificationAction action)
Creates a new default EventNotification or obtains the
corresponding existing one and registers a new action in it.
|
void |
registerDefaultNotificationForEvent(java.lang.String eventType,
java.lang.String actionType,
java.lang.String actionDescriptor,
java.lang.String defaultMessage)
Creates a new default EventNotification or obtains the corresponding
existing one and registers a new action in it.
|
void |
registerNotificationForEvent(java.lang.String eventType,
NotificationAction action)
Creates a new EventNotification or obtains the corresponding
existing one and registers a new action in it.
|
void |
registerNotificationForEvent(java.lang.String eventType,
java.lang.String actionType,
java.lang.String actionDescriptor,
java.lang.String defaultMessage)
Creates a new EventNotification or obtains the corresponding
existing one and registers a new action in it.
|
void |
removeActionHandler(java.lang.String actionType)
Removes an object that executes the actual action of notification action.
|
void |
removeEventNotification(java.lang.String eventType)
Removes the EventNotification corresponding to the given
eventType from the table of registered event notifications.
|
void |
removeEventNotificationAction(java.lang.String eventType,
java.lang.String actionType)
Removes the given actionType from the list of actions registered for the
given eventType.
|
void |
removeNotificationChangeListener(NotificationChangeListener listener)
Removes the given listener from the list of change listeners.
|
void |
restoreDefaults()
Deletes all registered events and actions
and registers and saves the default events as current.
|
void |
setActive(java.lang.String eventType,
boolean isActive)
Finds the EventNotification corresponding to the given
eventType and marks it as activated/deactivated.
|
void |
stopNotification(NotificationData data)
Stops a notification if notification is continuous, like playing sounds
in loop.
|
public static final int NUM_ACTIONS
NotificationServiceImpl()
public void addActionHandler(NotificationHandler handler)
addActionHandler
in interface NotificationService
handler
- The handler that executes the action.public void addNotificationChangeListener(NotificationChangeListener listener)
addNotificationChangeListener
in interface NotificationService
listener
- the listener that we'd like to register to listen for
changes in the event notifications stored by this service.public NotificationData fireNotification(java.lang.String eventType)
fireNotification
in interface NotificationService
eventType
- the type of the event that we'd like to fire a
notification for.public NotificationData fireNotification(java.lang.String eventType, java.lang.String title, java.lang.String message, byte[] icon)
fireNotification
in interface NotificationService
eventType
- the type of the event that we'd like to fire a
notification for.title
- the title of the given messagemessage
- the message to use if and where appropriate (e.g. with
systray or log notification.)icon
- the icon to show in the notification if and where appropriatepublic NotificationData fireNotification(java.lang.String eventType, java.lang.String title, java.lang.String message, byte[] icon, java.util.Map<java.lang.String,java.lang.Object> extras)
fireNotification
in interface NotificationService
eventType
- the type of the event that we'd like to fire a
notification for.title
- the title of the given messagemessage
- the message to use if and where appropriate (e.g. with
systray or log notification.)icon
- the icon to show in the notification if and where appropriateextras
- additiona/extra NotificationHandler
-specific data
to be provided to the firing of the specified notification(s). The
well-known keys are defined by the NotificationData
XXX_EXTRA constants.public java.lang.Iterable<NotificationHandler> getActionHandlers(java.lang.String actionType)
getActionHandlers
in interface NotificationService
actionType
- the type for which the list of handlers should be
retrieved or null if all handlers shall be returned.public NotificationAction getEventNotificationAction(java.lang.String eventType, java.lang.String actionType)
getEventNotificationAction
in interface NotificationService
eventType
- the type of the event that we'd like to retrieve.actionType
- the type of the action that we'd like to retrieve a
descriptor for.public java.lang.Iterable<java.lang.String> getRegisteredEvents()
getRegisteredEvents
in interface NotificationService
public boolean isActive(java.lang.String eventType)
isActive
in interface NotificationService
eventType
- the name of the event (as defined by the plugin that's
registered it) that we are checking.true
if actions for the specified eventType
are activated, false
- otherwise. If the given
eventType is not contained in the list of registered event
types - returns false
.public void registerDefaultNotificationForEvent(java.lang.String eventType, NotificationAction action)
registerDefaultNotificationForEvent
in interface NotificationService
eventType
- the name of the event (as defined by the plugin that's
registering it) that we are setting an action for.action
- the NotificationAction to registerpublic void registerDefaultNotificationForEvent(java.lang.String eventType, java.lang.String actionType, java.lang.String actionDescriptor, java.lang.String defaultMessage)
registerDefaultNotificationForEvent
in interface NotificationService
eventType
- the name of the event (as defined by the plugin that's
registering it) that we are setting an action for.actionType
- the type of the action that is to be executed when the
specified event occurs (could be one of the ACTION_XXX fields).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.defaultMessage
- the default message to use if no specific message
has been provided when firing the notification.public void registerNotificationForEvent(java.lang.String eventType, NotificationAction action)
registerNotificationForEvent
in interface NotificationService
eventType
- the name of the event (as defined by the plugin that's
registering it) that we are setting an action for.action
- the NotificationAction responsible for
handling the given actionTypepublic void registerNotificationForEvent(java.lang.String eventType, java.lang.String actionType, java.lang.String actionDescriptor, java.lang.String defaultMessage)
registerNotificationForEvent
in interface NotificationService
eventType
- the name of the event (as defined by the plugin that's
registering it) that we are setting an action for.actionType
- the type of the action that is to be executed when the
specified event occurs (could be one of the ACTION_XXX fields).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.defaultMessage
- the default message to use if no specific message
has been provided when firing the notification.public void removeActionHandler(java.lang.String actionType)
removeActionHandler
in interface NotificationService
actionType
- The handler type to remove.public void removeEventNotification(java.lang.String eventType)
removeEventNotification
in interface NotificationService
eventType
- the name of the event (as defined by the plugin that's
registering it) to be removed.public void removeEventNotificationAction(java.lang.String eventType, java.lang.String actionType)
removeEventNotificationAction
in interface NotificationService
eventType
- the name of the event (as defined by the plugin that's
registering it) for which we'll remove the notification.actionType
- the type of the action that is to be executed when the
specified event occurs (could be one of the ACTION_XXX fields).public void removeNotificationChangeListener(NotificationChangeListener listener)
removeNotificationChangeListener
in interface NotificationService
listener
- the listener that we'd like to removepublic void restoreDefaults()
restoreDefaults
in interface NotificationService
public void setActive(java.lang.String eventType, boolean isActive)
setActive
in interface NotificationService
eventType
- the name of the event, which actions should be activated
/deactivated.isActive
- indicates whether to activate or deactivate the actions
related to the specified eventType.public void stopNotification(NotificationData data)
stopNotification
in interface NotificationService
data
- the data that has been returned when firing the event..public boolean isPlayingNotification(NotificationData data)
isPlayingNotification
in interface NotificationService
data
- Additional data for the event.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.