Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.gui.main.chat.conference
Class ConferenceChatManager

java.lang.Object
  extended by net.java.sip.communicator.impl.gui.main.chat.conference.ConferenceChatManager
All Implemented Interfaces:
EventListener, AdHocChatRoomInvitationListener, AdHocChatRoomInvitationRejectionListener, AdHocChatRoomMessageListener, ChatRoomInvitationListener, ChatRoomInvitationRejectionListener, ChatRoomMessageListener, LocalUserAdHocChatRoomPresenceListener, LocalUserChatRoomPresenceListener, org.osgi.framework.ServiceListener

public class ConferenceChatManager
extends Object
implements ChatRoomMessageListener, ChatRoomInvitationListener, ChatRoomInvitationRejectionListener, AdHocChatRoomMessageListener, AdHocChatRoomInvitationListener, AdHocChatRoomInvitationRejectionListener, LocalUserChatRoomPresenceListener, LocalUserAdHocChatRoomPresenceListener, org.osgi.framework.ServiceListener

The ConferenceChatManager is the one that manages both chat room and ad-hoc chat rooms invitations.

Author:
Yana Stamcheva, Lubomir Marinov, Valentin Martinet

Constructor Summary
ConferenceChatManager()
          Creates an instance of ConferenceChatManager.
 
Method Summary
 void acceptInvitation(AdHocChatRoomInvitation invitation, OperationSetAdHocMultiUserChat multiUserChatOpSet)
          Called to accept an incoming invitation.
 void acceptInvitation(ChatRoomInvitation invitation)
          Called to accept an incoming invitation.
 void addAdHocChatRoomListChangeListener(AdHocChatRoomListChangeListener l)
          Adds the given AdHocChatRoomListChangeListener that will listen for all changes of the chat room list data model.
 void addChatRoomListChangeListener(ChatRoomListChangeListener l)
          Adds the given ChatRoomListChangeListener that will listen for all changes of the chat room list data model.
 void addHistoryWindowForChatRoom(ChatRoomWrapper chatRoomWrapper, HistoryWindow historyWindow)
          Adds a history window for a given chat room in the table of opened history windows.
 boolean containsHistoryWindowForChatRoom(ChatRoomWrapper chatRoomWrapper)
          Checks if there's an open history window for the given chat room.
 AdHocChatRoomWrapper createAdHocChatRoom(ProtocolProviderService protocolProvider, Collection<String> contacts, String reason)
          Creates an ad-hoc chat room, by specifying the ad-hoc chat room name, the parent protocol provider and eventually, the contacts invited to participate in this ad-hoc chat room.
 ChatRoomWrapper createChatRoom(ProtocolProviderService protocolProvider, Collection<String> contacts, String reason)
          Creates a chat room, by specifying the chat room name, the parent protocol provider and eventually, the contacts invited to participate in this chat room.
 ChatRoomWrapper createChatRoom(String roomName, ProtocolProviderService protocolProvider, Collection<String> contacts, String reason)
          Creates a chat room, by specifying the chat room name, the parent protocol provider and eventually, the contacts invited to participate in this chat room.
 ChatRoomWrapper createChatRoom(String roomName, ProtocolProviderService protocolProvider, Collection<String> contacts, String reason, boolean join, boolean persistent)
          Creates a chat room, by specifying the chat room name, the parent protocol provider and eventually, the contacts invited to participate in this chat room.
 AdHocChatRoomList getAdHocChatRoomList()
          Returns all chat room providers currently contained in the ad-hoc chat room list.
 ChatRoomList getChatRoomList()
          Returns all chat room providers currently contained in the chat room list.
 List<String> getExistingChatRooms(ChatRoomProviderWrapper chatRoomProvider)
          Returns existing chat rooms for the given chatRoomProvider.
 HistoryWindow getHistoryWindowForChatRoom(ChatRoomWrapper chatRoomWrapper)
          Returns the history window for the given chat room.
 void invitationReceived(AdHocChatRoomInvitationReceivedEvent evt)
          Indicates that an invitation has been received and opens the invitation dialog to notify the user.
 void invitationReceived(ChatRoomInvitationReceivedEvent evt)
          Handles ChatRoomInvitationReceivedEvent-s.
 void invitationRejected(AdHocChatRoomInvitationRejectedEvent evt)
          Called when an invitee rejects an invitation previously sent by us.
 void invitationRejected(ChatRoomInvitationRejectedEvent evt)
          Called when an invitee rejects an invitation previously sent by us.
(package private) static boolean isPrivate(ChatRoom chatRoom)
          Determines whether a specific ChatRoom is private i.e.
 void joinChatRoom(AdHocChatRoom chatRoom)
          Joins the given chat room and manages all the exceptions that could occur during the join process.
 void joinChatRoom(AdHocChatRoomWrapper chatRoomWrapper)
          Joins the given ad-hoc chat room
 void joinChatRoom(ChatRoom chatRoom)
          Joins the given chat room and manages all the exceptions that could occur during the join process.
 void joinChatRoom(ChatRoom chatRoom, String nickname, byte[] password)
          Joins the given chat room and manages all the exceptions that could occur during the join process.
 void joinChatRoom(ChatRoomWrapper chatRoomWrapper)
          Join chat room.
 void joinChatRoom(ChatRoomWrapper chatRoomWrapper, String nickName, byte[] password)
          Joins the given chat room with the given password and manages all the exceptions that could occur during the join process.
 void joinChatRoom(String chatRoomName, ChatRoomProviderWrapper chatRoomProvider)
          Joins the room with the given name though the given chat room provider.
 void leaveChatRoom(AdHocChatRoomWrapper chatRoomWrapper)
          Leaves the given ChatRoom.
 void leaveChatRoom(ChatRoomWrapper chatRoomWrapper)
          Leaves the given ChatRoom.
 void localUserAdHocPresenceChanged(LocalUserAdHocChatRoomPresenceChangeEvent evt)
          Implements the LocalUserAdHocChatRoomPresenceListener.localUserPresenceChanged method
 void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt)
          Implements the LocalUserChatRoomPresenceListener.localUserPresenceChanged method.
 void messageDelivered(AdHocChatRoomMessageDeliveredEvent evt)
          Implements the AdHocChatRoomMessageListener.messageDelivered method.
 void messageDelivered(ChatRoomMessageDeliveredEvent evt)
          Implements the ChatRoomMessageListener.messageDelivered method.
 void messageDeliveryFailed(AdHocChatRoomMessageDeliveryFailedEvent evt)
          Implements AdHocChatRoomMessageListener.messageDeliveryFailed method.
 void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt)
          Implements the ChatRoomMessageListener.messageDeliveryFailed method.
 void messageReceived(AdHocChatRoomMessageReceivedEvent evt)
          Implements the AdHocChatRoomMessageListener.messageReceived method.
 void messageReceived(ChatRoomMessageReceivedEvent evt)
          Implements the ChatRoomMessageListener.messageReceived method.
 void rejectInvitation(OperationSetAdHocMultiUserChat multiUserChatAdHocOpSet, AdHocChatRoomInvitation invitation, String reason)
          Rejects the given invitation with the specified reason.
 void rejectInvitation(OperationSetMultiUserChat multiUserChatOpSet, ChatRoomInvitation invitation, String reason)
          Rejects the given invitation with the specified reason.
 void removeAdHocChatRoomListChangeListener(AdHocChatRoomListChangeListener l)
          Removes the given AdHocChatRoomListChangeListener.
 void removeChatRoom(ChatRoomWrapper chatRoomWrapper)
          Removes the given chat room from the UI.
 void removeChatRoomListChangeListener(ChatRoomListChangeListener l)
          Removes the given ChatRoomListChangeListener.
 void removeHistoryWindowForChatRoom(ChatRoomWrapper chatRoomWrapper)
          Removes the history window for the given chat room.
 void serviceChanged(org.osgi.framework.ServiceEvent event)
          Handles ServiceEvents triggered by adding or removing a ProtocolProviderService.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConferenceChatManager

public ConferenceChatManager()
Creates an instance of ConferenceChatManager.

Method Detail

getChatRoomList

public ChatRoomList getChatRoomList()
Returns all chat room providers currently contained in the chat room list.

Returns:
all chat room providers currently contained in the chat room list.

getAdHocChatRoomList

public AdHocChatRoomList getAdHocChatRoomList()
Returns all chat room providers currently contained in the ad-hoc chat room list.

Returns:
all chat room providers currently contained in the ad-hoc chat room list.

invitationReceived

public void invitationReceived(ChatRoomInvitationReceivedEvent evt)
Handles ChatRoomInvitationReceivedEvent-s.

Specified by:
invitationReceived in interface ChatRoomInvitationListener
Parameters:
evt - the ChatRoomInvitationReceivedEvent that contains the newly received invitation and its source provider.

invitationRejected

public void invitationRejected(ChatRoomInvitationRejectedEvent evt)
Description copied from interface: ChatRoomInvitationRejectionListener
Called when an invitee rejects an invitation previously sent by us.

Specified by:
invitationRejected in interface ChatRoomInvitationRejectionListener
Parameters:
evt - the instance of the ChatRoomInvitationRejectedEvent containing the rejected chat room invitation as well as the source provider where this happened.

messageDelivered

public void messageDelivered(ChatRoomMessageDeliveredEvent evt)
Implements the ChatRoomMessageListener.messageDelivered method.
Shows the message in the conversation area and clears the write message area.

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

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

isPrivate

static boolean isPrivate(ChatRoom chatRoom)
Determines whether a specific ChatRoom is private i.e. represents a one-to-one conversation which is not a channel. Since the interface ChatRoom does not expose the private property, an heuristic is used as a workaround: (1) a system ChatRoom is obviously not private and (2) a ChatRoom is private if it has only one ChatRoomMember who is not the local user.

Parameters:
chatRoom - the ChatRoom to be determined as private or not
Returns:
true if the specified ChatRoom is private; otherwise, false

messageDeliveryFailed

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

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

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

localUserPresenceChanged

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

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

acceptInvitation

public void acceptInvitation(ChatRoomInvitation invitation)
Called to accept an incoming invitation. Adds the invitation chat room to the list of chat rooms and joins it.

Parameters:
invitation - the invitation to accept.

acceptInvitation

public void acceptInvitation(AdHocChatRoomInvitation invitation,
                             OperationSetAdHocMultiUserChat multiUserChatOpSet)
                      throws OperationFailedException
Called to accept an incoming invitation. Adds the invitation chat room to the list of chat rooms and joins it.

Parameters:
invitation - the invitation to accept
multiUserChatOpSet - the operation set for chat conferencing
Throws:
OperationFailedException - if the accept fails

rejectInvitation

public void rejectInvitation(OperationSetMultiUserChat multiUserChatOpSet,
                             ChatRoomInvitation invitation,
                             String reason)
Rejects the given invitation with the specified reason.

Parameters:
multiUserChatOpSet - the operation set to use for rejecting the invitation
invitation - the invitation to reject
reason - the reason for the rejection

rejectInvitation

public void rejectInvitation(OperationSetAdHocMultiUserChat multiUserChatAdHocOpSet,
                             AdHocChatRoomInvitation invitation,
                             String reason)
Rejects the given invitation with the specified reason.

Parameters:
multiUserChatAdHocOpSet - the operation set to use for rejecting the invitation
invitation - the invitation to reject
reason - the reason for the rejection

joinChatRoom

public void joinChatRoom(ChatRoomWrapper chatRoomWrapper,
                         String nickName,
                         byte[] password)
Joins the given chat room with the given password and manages all the exceptions that could occur during the join process.

Parameters:
chatRoomWrapper - the chat room to join.
nickName - the nickname we choose for the given chat room.
password - the password.

createChatRoom

public ChatRoomWrapper createChatRoom(ProtocolProviderService protocolProvider,
                                      Collection<String> contacts,
                                      String reason)
Creates a chat room, by specifying the chat room name, the parent protocol provider and eventually, the contacts invited to participate in this chat room.

Parameters:
protocolProvider - the parent protocol provider.
contacts - the contacts invited when creating the chat room.
reason -
Returns:
the ChatRoomWrapper corresponding to the created room

createChatRoom

public ChatRoomWrapper createChatRoom(String roomName,
                                      ProtocolProviderService protocolProvider,
                                      Collection<String> contacts,
                                      String reason)
Creates a chat room, by specifying the chat room name, the parent protocol provider and eventually, the contacts invited to participate in this chat room.

Parameters:
roomName - the name of the room
protocolProvider - the parent protocol provider.
contacts - the contacts invited when creating the chat room.
reason -
Returns:
the ChatRoomWrapper corresponding to the created room

createChatRoom

public ChatRoomWrapper createChatRoom(String roomName,
                                      ProtocolProviderService protocolProvider,
                                      Collection<String> contacts,
                                      String reason,
                                      boolean join,
                                      boolean persistent)
Creates a chat room, by specifying the chat room name, the parent protocol provider and eventually, the contacts invited to participate in this chat room.

Parameters:
roomName - the name of the room
protocolProvider - the parent protocol provider.
contacts - the contacts invited when creating the chat room.
reason -
join - whether we should join the room after creating it.
persistent - whether the newly created room will be persistent.
Returns:
the ChatRoomWrapper corresponding to the created room

createAdHocChatRoom

public AdHocChatRoomWrapper createAdHocChatRoom(ProtocolProviderService protocolProvider,
                                                Collection<String> contacts,
                                                String reason)
Creates an ad-hoc chat room, by specifying the ad-hoc chat room name, the parent protocol provider and eventually, the contacts invited to participate in this ad-hoc chat room.

Parameters:
protocolProvider - the parent protocol provider.
contacts - the contacts invited when creating the chat room.
reason - the reason for this invitation
Returns:
the AdHocChatRoomWrapper corresponding to the created ad hoc chat room

joinChatRoom

public void joinChatRoom(ChatRoomWrapper chatRoomWrapper)
Join chat room.

Parameters:
chatRoomWrapper -

joinChatRoom

public void joinChatRoom(AdHocChatRoomWrapper chatRoomWrapper)
Joins the given ad-hoc chat room

Parameters:
chatRoomWrapper -

removeChatRoom

public void removeChatRoom(ChatRoomWrapper chatRoomWrapper)
Removes the given chat room from the UI.

Parameters:
chatRoomWrapper - the chat room to remove.

joinChatRoom

public void joinChatRoom(ChatRoom chatRoom)
Joins the given chat room and manages all the exceptions that could occur during the join process.

Parameters:
chatRoom - the chat room to join

joinChatRoom

public void joinChatRoom(AdHocChatRoom chatRoom)
Joins the given chat room and manages all the exceptions that could occur during the join process.

Parameters:
chatRoom - the chat room to join

joinChatRoom

public void joinChatRoom(ChatRoom chatRoom,
                         String nickname,
                         byte[] password)
Joins the given chat room and manages all the exceptions that could occur during the join process.

Parameters:
chatRoom - the chat room to join
nickname - the nickname we're using to join
password - the password we're using to join

joinChatRoom

public void joinChatRoom(String chatRoomName,
                         ChatRoomProviderWrapper chatRoomProvider)
Joins the room with the given name though the given chat room provider.

Parameters:
chatRoomName - the name of the room to join.
chatRoomProvider - the chat room provider to join through.

leaveChatRoom

public void leaveChatRoom(ChatRoomWrapper chatRoomWrapper)
Leaves the given ChatRoom.

Parameters:
chatRoomWrapper - the ChatRoom to leave.

leaveChatRoom

public void leaveChatRoom(AdHocChatRoomWrapper chatRoomWrapper)
Leaves the given ChatRoom.

Parameters:
chatRoomWrapper - the ChatRoom to leave.

getExistingChatRooms

public List<String> getExistingChatRooms(ChatRoomProviderWrapper chatRoomProvider)
Returns existing chat rooms for the given chatRoomProvider.

Parameters:
chatRoomProvider - the ChatRoomProviderWrapper, which chat rooms we're looking for
Returns:
existing chat rooms for the given chatRoomProvider

containsHistoryWindowForChatRoom

public boolean containsHistoryWindowForChatRoom(ChatRoomWrapper chatRoomWrapper)
Checks if there's an open history window for the given chat room.

Parameters:
chatRoomWrapper - the chat room wrapper to check for
Returns:
TRUE if there's an opened history window for the given chat room, FALSE otherwise.

getHistoryWindowForChatRoom

public HistoryWindow getHistoryWindowForChatRoom(ChatRoomWrapper chatRoomWrapper)
Returns the history window for the given chat room.

Parameters:
chatRoomWrapper - the chat room wrapper to search for
Returns:
the history window for the given chat room

addHistoryWindowForChatRoom

public void addHistoryWindowForChatRoom(ChatRoomWrapper chatRoomWrapper,
                                        HistoryWindow historyWindow)
Adds a history window for a given chat room in the table of opened history windows.

Parameters:
chatRoomWrapper - the chat room wrapper to add
historyWindow - the history window to add

removeHistoryWindowForChatRoom

public void removeHistoryWindowForChatRoom(ChatRoomWrapper chatRoomWrapper)
Removes the history window for the given chat room.

Parameters:
chatRoomWrapper - the chat room wrapper to remove the history window

addChatRoomListChangeListener

public void addChatRoomListChangeListener(ChatRoomListChangeListener l)
Adds the given ChatRoomListChangeListener that will listen for all changes of the chat room list data model.

Parameters:
l - the listener to add.

removeChatRoomListChangeListener

public void removeChatRoomListChangeListener(ChatRoomListChangeListener l)
Removes the given ChatRoomListChangeListener.

Parameters:
l - the listener to remove.

addAdHocChatRoomListChangeListener

public void addAdHocChatRoomListChangeListener(AdHocChatRoomListChangeListener l)
Adds the given AdHocChatRoomListChangeListener that will listen for all changes of the chat room list data model.

Parameters:
l - the listener to add.

removeAdHocChatRoomListChangeListener

public void removeAdHocChatRoomListChangeListener(AdHocChatRoomListChangeListener l)
Removes the given AdHocChatRoomListChangeListener.

Parameters:
l - the listener to remove.

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent event)
Handles ServiceEvents triggered by adding or removing a ProtocolProviderService. Updates the list of available chat rooms and chat room servers.

Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
Parameters:
event - The event to handle.

invitationReceived

public void invitationReceived(AdHocChatRoomInvitationReceivedEvent evt)
Indicates that an invitation has been received and opens the invitation dialog to notify the user.

Specified by:
invitationReceived in interface AdHocChatRoomInvitationListener
Parameters:
evt - the AdHocChatRoomInvitationReceivedEvent that notified us

messageDelivered

public void messageDelivered(AdHocChatRoomMessageDeliveredEvent evt)
Implements the AdHocChatRoomMessageListener.messageDelivered method.
Shows the message in the conversation area and clears the write message area.

Specified by:
messageDelivered in interface AdHocChatRoomMessageListener
Parameters:
evt - the AdHocChatRoomMessageDeliveredEvent that notified us

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

messageReceived

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

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

invitationRejected

public void invitationRejected(AdHocChatRoomInvitationRejectedEvent evt)
Description copied from interface: AdHocChatRoomInvitationRejectionListener
Called when an invitee rejects an invitation previously sent by us.

Specified by:
invitationRejected in interface AdHocChatRoomInvitationRejectionListener
Parameters:
evt - the instance of the AdHocChatRoomInvitationRejectedEvent containing the rejected ad-hoc chat room invitation as well as the source provider where this happened.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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