Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.plugin.notificationwiring
Class NotificationManager

java.lang.Object
  extended by net.java.sip.communicator.plugin.notificationwiring.NotificationManager
All Implemented Interfaces:
EventListener, Recorder.Listener, AdHocChatRoomMessageListener, CallChangeListener, CallListener, CallPeerConferenceListener, CallPeerListener, CallPeerSecurityListener, ChatRoomMessageListener, FileTransferListener, LocalUserAdHocChatRoomPresenceListener, LocalUserChatRoomPresenceListener, MessageListener, TypingNotificationsListener, org.osgi.framework.ServiceListener

public class NotificationManager
extends Object
implements MessageListener, org.osgi.framework.ServiceListener, FileTransferListener, TypingNotificationsListener, CallListener, CallChangeListener, CallPeerListener, CallPeerSecurityListener, ChatRoomMessageListener, LocalUserChatRoomPresenceListener, LocalUserAdHocChatRoomPresenceListener, AdHocChatRoomMessageListener, CallPeerConferenceListener, Recorder.Listener

Listens for all kinds of events and triggers when needed a notification, a popup or sound one or other.

Author:
Damian Minkov

Field Summary
static String BUSY_CALL
          Default event type for a busy call.
static String CALL_SAVED
          Default event type for call been saved using a recorder.
static String CALL_SECURITY_ERROR
          Default event type for security error on a call.
static String CALL_SECURITY_ON
          Default event type for activated security on a call.
static ImageID DEFAULT_USER_PHOTO
          The image used, when a contact has no photo specified.
static String DIALING
          Default event type for dialing.
static String HANG_UP
          Default event type for hanging up calls.
static String INCOMING_CALL
          Default event type for receiving calls (incoming calls).
static String INCOMING_FILE
          Default event type for incoming file transfers.
static String INCOMING_MESSAGE
          Default event type for receiving messages.
static String OUTGOING_CALL
          Default event type for outgoing calls.
static String PROACTIVE_NOTIFICATION
          Default event type for proactive notifications (typing notifications when chatting).
static String SECURITY_MESSAGE
          Default event type when a secure message received.
 
Constructor Summary
NotificationManager()
           
 
Method Summary
 void callEnded(CallEvent event)
          Implements CallListener.callEnded.
 void callPeerAdded(CallPeerEvent evt)
          Implements the CallChangeListener.callPeerAdded method.
 void callPeerRemoved(CallPeerEvent evt)
          Implements the CallChangeListener.callPeerRemoved method.
 void callStateChanged(CallChangeEvent evt)
          Call state changed.
 void conferenceFocusChanged(CallPeerConferenceEvent conferenceEvent)
          Call peer has changed.
 void conferenceMemberAdded(CallPeerConferenceEvent conferenceEvent)
          Indicates that the given conference member has been added to the given peer.
 void conferenceMemberRemoved(CallPeerConferenceEvent conferenceEvent)
          Indicates that the given conference member has been removed from the given peer.
 void fileTransferCreated(FileTransferCreatedEvent event)
          Nothing to do here, because we already know when a file transfer is created.
 void fileTransferRequestCanceled(FileTransferRequestEvent event)
          Called when an IncomingFileTransferRequest has been canceled from the contact who sent it.
 void fileTransferRequestReceived(FileTransferRequestEvent event)
          When a request has been received we show a notification.
 void fileTransferRequestRejected(FileTransferRequestEvent event)
          Called when a new IncomingFileTransferRequest has been rejected.
static void fireChatNotification(Object chatContact, String eventType, String messageTitle, String message)
          Fires a chat message notification for the given event type through the NotificationService.
static NotificationData fireNotification(String eventType)
          Fires a notification for the given event type through the NotificationService.
static NotificationData fireNotification(String eventType, String messageTitle, String message)
          Fires a message notification for the given event type through the NotificationService.
static NotificationData fireNotification(String eventType, String messageTitle, String message, Map<String,String> extra)
          Fires a message notification for the given event type through the NotificationService.
static BufferedImage getImage(ImageID imageID)
          Loads an image from a given image identifier.
static Map<Object,ProtocolProviderFactory> getProtocolProviderFactories()
          Returns all ProtocolProviderFactorys obtained from the bundle context.
static List<ProtocolProviderService> getProtocolProviders()
          Returns all protocol providers currently registered.
 void incomingCallReceived(CallEvent event)
          Implements CallListener.incomingCallReceived.
(package private)  void init()
          Initialize, register default notifications and start listening for new protocols or removed one and find any that are already registered.
 boolean isConference(Call call)
          Checks if the contained call is a conference call.
 void localUserAdHocPresenceChanged(LocalUserAdHocChatRoomPresenceChangeEvent evt)
          Implements the LocalUserAdHocChatRoomPresenceListener.localUserPresenceChanged method
 void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt)
          Implements the LocalUserChatRoomPresenceListener.localUserPresenceChanged method.
 void messageDelivered(AdHocChatRoomMessageDeliveredEvent evt)
          Implements the ChatRoomMessageListener.messageDelivered method.
 void messageDelivered(ChatRoomMessageDeliveredEvent evt)
          Implements the ChatRoomMessageListener.messageDelivered method.
 void messageDelivered(MessageDeliveredEvent evt)
          Fired when message is delivered.
 void messageDeliveryFailed(AdHocChatRoomMessageDeliveryFailedEvent evt)
          Implements AdHocChatRoomMessageListener.messageDeliveryFailed method.
 void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt)
          Implements the ChatRoomMessageListener.messageDeliveryFailed method.
 void messageDeliveryFailed(MessageDeliveryFailedEvent evt)
          Fired when message deliver fail.
 void messageReceived(AdHocChatRoomMessageReceivedEvent evt)
          Implements the AdHocChatRoomMessageListener.messageReceived method.
 void messageReceived(ChatRoomMessageReceivedEvent evt)
          Implements the ChatRoomMessageListener.messageReceived method.
 void messageReceived(MessageReceivedEvent evt)
          Fired on new messages.
 void outgoingCallCreated(CallEvent event)
          Do nothing.
 void peerAddressChanged(CallPeerChangeEvent evt)
          Fired when peer's address is changed
 void peerDisplayNameChanged(CallPeerChangeEvent evt)
          Fired when peer's display name is changed
 void peerImageChanged(CallPeerChangeEvent evt)
          Fired when peer's image is changed
 void peerStateChanged(CallPeerChangeEvent evt)
          Fired when peer's state is changed
 void peerTransportAddressChanged(CallPeerChangeEvent evt)
          Fired when peer's transport is changed
 void recorderStopped(Recorder recorder)
          Notifies that a specific Recorder has stopped recording the media associated with it.
 void securityMessageRecieved(CallPeerSecurityMessageEvent event)
          Processes the received security message.
 void securityNegotiationStarted(CallPeerSecurityNegotiationStartedEvent securityNegotiationStartedEvent)
          The handler for the security event received.
 void securityOff(CallPeerSecurityOffEvent securityOffEvent)
          Indicates the new state through the security indicator components.
 void securityOn(CallPeerSecurityOnEvent evt)
          When a securityOnEvent is received.
 void securityTimeout(CallPeerSecurityTimeoutEvent securityTimeoutEvent)
          The handler for the security event received.
 void serviceChanged(org.osgi.framework.ServiceEvent event)
          Implements the ServiceListener method.
static void stopSound(NotificationData data)
          Stops all sounds for the given event type.
 void typingNotificationReceived(TypingNotificationEvent event)
          Informs the user what is the typing state of his chat contacts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_USER_PHOTO

public static final ImageID DEFAULT_USER_PHOTO
The image used, when a contact has no photo specified.


CALL_SAVED

public static final String CALL_SAVED
Default event type for call been saved using a recorder.

See Also:
Constant Field Values

INCOMING_FILE

public static final String INCOMING_FILE
Default event type for incoming file transfers.

See Also:
Constant Field Values

CALL_SECURITY_ERROR

public static final String CALL_SECURITY_ERROR
Default event type for security error on a call.

See Also:
Constant Field Values

CALL_SECURITY_ON

public static final String CALL_SECURITY_ON
Default event type for activated security on a call.

See Also:
Constant Field Values

SECURITY_MESSAGE

public static final String SECURITY_MESSAGE
Default event type when a secure message received.

See Also:
Constant Field Values

PROACTIVE_NOTIFICATION

public static final String PROACTIVE_NOTIFICATION
Default event type for proactive notifications (typing notifications when chatting).

See Also:
Constant Field Values

HANG_UP

public static final String HANG_UP
Default event type for hanging up calls.

See Also:
Constant Field Values

DIALING

public static final String DIALING
Default event type for dialing.

See Also:
Constant Field Values

BUSY_CALL

public static final String BUSY_CALL
Default event type for a busy call.

See Also:
Constant Field Values

OUTGOING_CALL

public static final String OUTGOING_CALL
Default event type for outgoing calls.

See Also:
Constant Field Values

INCOMING_CALL

public static final String INCOMING_CALL
Default event type for receiving calls (incoming calls).

See Also:
Constant Field Values

INCOMING_MESSAGE

public static final String INCOMING_MESSAGE
Default event type for receiving messages.

See Also:
Constant Field Values
Constructor Detail

NotificationManager

public NotificationManager()
Method Detail

init

void init()
Initialize, register default notifications and start listening for new protocols or removed one and find any that are already registered.


getProtocolProviderFactories

public static Map<Object,ProtocolProviderFactory> getProtocolProviderFactories()
Returns all ProtocolProviderFactorys obtained from the bundle context.

Returns:
all ProtocolProviderFactorys obtained from the bundle context

getProtocolProviders

public static List<ProtocolProviderService> getProtocolProviders()
Returns all protocol providers currently registered.

Returns:
all protocol providers currently registered.

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent event)
Implements the ServiceListener method. Verifies whether the passed event concerns a ProtocolProviderService and adds the corresponding listeners.

Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
Parameters:
event - The ServiceEvent object.

fireNotification

public static NotificationData fireNotification(String eventType,
                                                String messageTitle,
                                                String message)
Fires a message notification for the given event type through the NotificationService.

Parameters:
eventType - the event type for which we fire a notification
messageTitle - the title of the message
message - the content of the message
Returns:
A reference to the fired notification to stop it.

fireNotification

public static NotificationData fireNotification(String eventType,
                                                String messageTitle,
                                                String message,
                                                Map<String,String> extra)
Fires a message notification for the given event type through the NotificationService.

Parameters:
eventType - the event type for which we fire a notification
messageTitle - the title of the message
message - the content of the message
extra - additional event data for external processing
Returns:
A reference to the fired notification to stop it.

fireChatNotification

public static void fireChatNotification(Object chatContact,
                                        String eventType,
                                        String messageTitle,
                                        String message)
Fires a chat message notification for the given event type through the NotificationService.

Parameters:
chatContact - the chat contact to which the chat message corresponds; the chat contact could be a Contact or a ChatRoom.
eventType - the event type for which we fire a notification
messageTitle - the title of the message
message - the content of the message

fireNotification

public static NotificationData fireNotification(String eventType)
Fires a notification for the given event type through the NotificationService. The event type is one of the static constants defined in this class.

Parameters:
eventType - the event type for which we want to fire a notification
Returns:
A reference to the fired notification to stop it.

stopSound

public static void stopSound(NotificationData data)
Stops all sounds for the given event type.

Parameters:
data - the event type for which we should stop sounds. One of the static event types defined in this class.

getImage

public static BufferedImage getImage(ImageID imageID)
Loads an image from a given image identifier.

Parameters:
imageID - The identifier of the image.
Returns:
The image for the given identifier.

isConference

public boolean isConference(Call call)
Checks if the contained call is a conference call.

Parameters:
call - the call to check
Returns:
true if the contained Call is a conference call, otherwise - returns false.

messageReceived

public void messageReceived(MessageReceivedEvent evt)
Fired on new messages.

Specified by:
messageReceived in interface MessageListener
Parameters:
evt - the MessageReceivedEvent containing details on the received message

messageDelivered

public void messageDelivered(MessageDeliveredEvent evt)
Fired when message is delivered.

Specified by:
messageDelivered in interface MessageListener
Parameters:
evt - the MessageDeliveredEvent containing details on the delivered message

messageDeliveryFailed

public void messageDeliveryFailed(MessageDeliveryFailedEvent evt)
Fired when message deliver fail.

Specified by:
messageDeliveryFailed in interface MessageListener
Parameters:
evt - the MessageDeliveryFailedEvent containing details on the failed message

fileTransferRequestReceived

public void fileTransferRequestReceived(FileTransferRequestEvent event)
When a request has been received we show a notification.

Specified by:
fileTransferRequestReceived in interface FileTransferListener
Parameters:
event - FileTransferRequestEvent
See Also:
FileTransferListener.fileTransferRequestReceived(FileTransferRequestEvent)

fileTransferCreated

public void fileTransferCreated(FileTransferCreatedEvent event)
Nothing to do here, because we already know when a file transfer is created.

Specified by:
fileTransferCreated in interface FileTransferListener
Parameters:
event - the FileTransferCreatedEvent that notified us

fileTransferRequestRejected

public void fileTransferRequestRejected(FileTransferRequestEvent event)
Called when a new IncomingFileTransferRequest has been rejected. Nothing to do here, because we are the one who rejects the request.

Specified by:
fileTransferRequestRejected in interface FileTransferListener
Parameters:
event - the FileTransferRequestEvent containing the received request which was rejected.

fileTransferRequestCanceled

public void fileTransferRequestCanceled(FileTransferRequestEvent event)
Called when an IncomingFileTransferRequest has been canceled from the contact who sent it.

Specified by:
fileTransferRequestCanceled in interface FileTransferListener
Parameters:
event - the FileTransferRequestEvent containing the request which was canceled.

typingNotificationReceived

public void typingNotificationReceived(TypingNotificationEvent event)
Informs the user what is the typing state of his chat contacts.

Specified by:
typingNotificationReceived in interface TypingNotificationsListener
Parameters:
event - the event containing details on the typing notification

incomingCallReceived

public void incomingCallReceived(CallEvent event)
Implements CallListener.incomingCallReceived. When a call is received plays the ring phone sound to the user and gathers caller information that may be used by a user-specified command (incomingCall event trigger).

Specified by:
incomingCallReceived in interface CallListener
Parameters:
event - the CallEvent

outgoingCallCreated

public void outgoingCallCreated(CallEvent event)
Do nothing. Implements CallListener.outGoingCallCreated.

Specified by:
outgoingCallCreated in interface CallListener
Parameters:
event - the CallEvent

callEnded

public void callEnded(CallEvent event)
Implements CallListener.callEnded. Stops sounds that are playing at the moment if there're any.

Specified by:
callEnded in interface CallListener
Parameters:
event - the CallEvent

callPeerAdded

public void callPeerAdded(CallPeerEvent evt)
Implements the CallChangeListener.callPeerAdded method.

Specified by:
callPeerAdded in interface CallChangeListener
Parameters:
evt - the CallPeerEvent that notifies us for the change

callPeerRemoved

public void callPeerRemoved(CallPeerEvent evt)
Implements the CallChangeListener.callPeerRemoved method.

Specified by:
callPeerRemoved in interface CallChangeListener
Parameters:
evt - the CallPeerEvent that has been triggered

callStateChanged

public void callStateChanged(CallChangeEvent evt)
Call state changed.

Specified by:
callStateChanged in interface CallChangeListener
Parameters:
evt - the CallChangeEvent instance containing the source

peerStateChanged

public void peerStateChanged(CallPeerChangeEvent evt)
Fired when peer's state is changed

Specified by:
peerStateChanged in interface CallPeerListener
Parameters:
evt - fired CallPeerEvent

peerDisplayNameChanged

public void peerDisplayNameChanged(CallPeerChangeEvent evt)
Fired when peer's display name is changed

Specified by:
peerDisplayNameChanged in interface CallPeerListener
Parameters:
evt - fired CallPeerEvent

peerAddressChanged

public void peerAddressChanged(CallPeerChangeEvent evt)
Fired when peer's address is changed

Specified by:
peerAddressChanged in interface CallPeerListener
Parameters:
evt - fired CallPeerEvent

peerTransportAddressChanged

public void peerTransportAddressChanged(CallPeerChangeEvent evt)
Fired when peer's transport is changed

Specified by:
peerTransportAddressChanged in interface CallPeerListener
Parameters:
evt - fired CallPeerEvent

peerImageChanged

public void peerImageChanged(CallPeerChangeEvent evt)
Fired when peer's image is changed

Specified by:
peerImageChanged in interface CallPeerListener
Parameters:
evt - fired CallPeerEvent

securityOn

public void securityOn(CallPeerSecurityOnEvent evt)
When a securityOnEvent is received.

Specified by:
securityOn in interface CallPeerSecurityListener
Parameters:
evt - the event we received

securityOff

public void securityOff(CallPeerSecurityOffEvent securityOffEvent)
Indicates the new state through the security indicator components.

Specified by:
securityOff in interface CallPeerSecurityListener
Parameters:
securityOffEvent - the event we received

securityTimeout

public void securityTimeout(CallPeerSecurityTimeoutEvent securityTimeoutEvent)
The handler for the security event received. The security event represents a timeout trying to establish a secure connection. Most probably the other peer doesn't support it.

Specified by:
securityTimeout in interface CallPeerSecurityListener
Parameters:
securityTimeoutEvent - the security timeout event received

securityNegotiationStarted

public void securityNegotiationStarted(CallPeerSecurityNegotiationStartedEvent securityNegotiationStartedEvent)
The handler for the security event received. The security event for starting establish a secure connection.

Specified by:
securityNegotiationStarted in interface CallPeerSecurityListener
Parameters:
securityNegotiationStartedEvent - the security started event received

securityMessageRecieved

public void securityMessageRecieved(CallPeerSecurityMessageEvent event)
Processes the received security message.

Specified by:
securityMessageRecieved in interface CallPeerSecurityListener
Parameters:
event - the event we received

messageReceived

public void messageReceived(ChatRoomMessageReceivedEvent evt)
Implements the ChatRoomMessageListener.messageReceived method.
Obtains the corresponding ChatPanel and process the message there.

Specified by:
messageReceived in interface ChatRoomMessageListener
Parameters:
evt - the ChatRoomMessageReceivedEvent that notified us that a message has been received

messageDelivered

public void messageDelivered(ChatRoomMessageDeliveredEvent evt)
Implements the ChatRoomMessageListener.messageDelivered method.

Specified by:
messageDelivered in interface ChatRoomMessageListener
Parameters:
evt - the ChatRoomMessageDeliveredEvent that notified us that the message was delivered to its destination

messageDeliveryFailed

public void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt)
Implements the ChatRoomMessageListener.messageDeliveryFailed method.

Specified by:
messageDeliveryFailed in interface ChatRoomMessageListener
Parameters:
evt - the ChatRoomMessageDeliveryFailedEvent that notified us of a delivery failure

localUserPresenceChanged

public void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt)
Implements the LocalUserChatRoomPresenceListener.localUserPresenceChanged method.

Specified by:
localUserPresenceChanged in interface LocalUserChatRoomPresenceListener
Parameters:
evt - the LocalUserChatRoomPresenceChangeEvent that notified us

localUserAdHocPresenceChanged

public void localUserAdHocPresenceChanged(LocalUserAdHocChatRoomPresenceChangeEvent evt)
Implements the LocalUserAdHocChatRoomPresenceListener.localUserPresenceChanged method

Specified by:
localUserAdHocPresenceChanged in interface LocalUserAdHocChatRoomPresenceListener
Parameters:
evt - the LocalUserAdHocChatRoomPresenceChangeEvent that notified us of a presence change

messageReceived

public void messageReceived(AdHocChatRoomMessageReceivedEvent evt)
Implements the AdHocChatRoomMessageListener.messageReceived method.

Specified by:
messageReceived in interface AdHocChatRoomMessageListener
Parameters:
evt - the AdHocChatRoomMessageReceivedEvent that notified us

messageDelivered

public void messageDelivered(AdHocChatRoomMessageDeliveredEvent evt)
Implements the ChatRoomMessageListener.messageDelivered method.

Specified by:
messageDelivered in interface AdHocChatRoomMessageListener
Parameters:
evt - the ChatRoomMessageDeliveredEvent that notified us that the message was delivered to its destination

messageDeliveryFailed

public void messageDeliveryFailed(AdHocChatRoomMessageDeliveryFailedEvent evt)
Implements AdHocChatRoomMessageListener.messageDeliveryFailed method.
In the conversation area shows an error message, explaining the problem.

Specified by:
messageDeliveryFailed in interface AdHocChatRoomMessageListener
Parameters:
evt - the AdHocChatRoomMessageDeliveryFailedEvent that notified us

conferenceFocusChanged

public void conferenceFocusChanged(CallPeerConferenceEvent conferenceEvent)
Call peer has changed.

Specified by:
conferenceFocusChanged in interface CallPeerConferenceListener
Parameters:
conferenceEvent - a CallPeerConferenceEvent with ID CallPeerConferenceEvent#CONFERENCE_FOCUS_CHANGED

conferenceMemberAdded

public void conferenceMemberAdded(CallPeerConferenceEvent conferenceEvent)
Indicates that the given conference member has been added to the given peer.

Specified by:
conferenceMemberAdded in interface CallPeerConferenceListener
Parameters:
conferenceEvent - the event

conferenceMemberRemoved

public void conferenceMemberRemoved(CallPeerConferenceEvent conferenceEvent)
Indicates that the given conference member has been removed from the given peer.

Specified by:
conferenceMemberRemoved in interface CallPeerConferenceListener
Parameters:
conferenceEvent - the event

recorderStopped

public void recorderStopped(Recorder recorder)
Notifies that a specific Recorder has stopped recording the media associated with it.

Specified by:
recorderStopped in interface Recorder.Listener
Parameters:
recorder - the Recorder which has stopped recording its associated media

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.