Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.msn
Class AdHocChatRoomMsnImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.msn.AdHocChatRoomMsnImpl
All Implemented Interfaces:
AdHocChatRoom

public class AdHocChatRoomMsnImpl
extends Object
implements AdHocChatRoom

Implements ad-hoc chat rooms for MSN.

Author:
Rupert Burchardi, Valentin Martinet

Field Summary
 Vector<EventObject> messageBuffer
          A Message buffer, will keep all messages until the MSN ad-hoc chat room is ready.
 
Constructor Summary
AdHocChatRoomMsnImpl(String name, ProtocolProviderServiceMsnImpl provider)
          Creates a new ad-hoc chat room for MSN named name, using the protocol provider provider.
AdHocChatRoomMsnImpl(String name, ProtocolProviderServiceMsnImpl provider, net.sf.jml.MsnSwitchboard switchboard)
          Creates a new ad-hoc chat room for MSN named name, using the protocol provider provider and the msn switchboard switchboard.
 
Method Summary
 void addAdHocChatRoomParticipant(String id, Contact participant)
          Adds a participant to the participants list.
 void addMessageListener(AdHocChatRoomMessageListener listener)
          Registers listener so that it would receive events every time a new message is received on this chat room.
 void addParticipantPresenceListener(AdHocChatRoomParticipantPresenceListener listener)
          Adds a listener that will be notified of changes in our status in the room.
 Message createMessage(String text)
          Creates a Message for this ad-hoc chat room containing text.
 Contact findParticipantForAddress(String address)
          Finds the participant of this ad-hoc chat room corresponding to the given address.
 void fireMessageEvent(EventObject evt)
          Notifies all interested listeners that a AdHocChatRoomMessageDeliveredEvent, AdHocChatRoomMessageReceivedEvent or a AdHocChatRoomMessageDeliveryFailedEvent has been fired.
 Contact getAdHocChatRoomParticipant(String id)
          Returns the participant of this ad-hoc chat room which corresponds to the given id.
 String getIdentifier()
          Returns the identifier of this ad-hoc chat room.
 String getName()
          Returns the name of this ad-hoc chatroom
 ProtocolProviderService getParentProvider()
          Returns the parent provider
 List<Contact> getParticipants()
          Returns a list containing all the Contacts who participate in this ad-hoc chat room.
 int getParticipantsCount()
          Returns the number of Contacts who participate in this ad-hoc chat room.
 String getSubject()
           
 void invite(String userAddress, String reason)
          Invites another user to this room.
 boolean isSystem()
           
 void join()
          Joins this ad-hoc chat room with the nickname of the local user so that the user would start receiving events and messages for it.
 void leave()
          Leave this chat room.
 void removeMessageListener(AdHocChatRoomMessageListener listener)
          Removes the given message listener.
 void removeMessageListener(ChatRoomMessageListener listener)
          Removes listener so that it won't receive any further message events from this room.
 void removeParticipant(String id)
          Removes the participant of this ad-hoc chat room which corresponds to the given id.
 void removeParticipantPresenceListener(AdHocChatRoomParticipantPresenceListener listener)
          Removes the given participant presence listener.
 void sendMessage(Message message)
          Sends the given message through the participants of this ad-hoc chat room.
 void setSwitchboard(net.sf.jml.MsnSwitchboard switchboard)
          Sets the corresponding switchboard.
 void updateParticipantsList(net.sf.jml.MsnSwitchboard switchboard)
          Fills the participants list with all participants inside the switchboard (ad-hoc chat room).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messageBuffer

public Vector<EventObject> messageBuffer
A Message buffer, will keep all messages until the MSN ad-hoc chat room is ready.

Constructor Detail

AdHocChatRoomMsnImpl

public AdHocChatRoomMsnImpl(String name,
                            ProtocolProviderServiceMsnImpl provider)
Creates a new ad-hoc chat room for MSN named name, using the protocol provider provider.

Parameters:
name -
provider -

AdHocChatRoomMsnImpl

public AdHocChatRoomMsnImpl(String name,
                            ProtocolProviderServiceMsnImpl provider,
                            net.sf.jml.MsnSwitchboard switchboard)
Creates a new ad-hoc chat room for MSN named name, using the protocol provider provider and the msn switchboard switchboard.

Parameters:
name -
provider -
switchboard -
Method Detail

addParticipantPresenceListener

public void addParticipantPresenceListener(AdHocChatRoomParticipantPresenceListener listener)
Adds a listener that will be notified of changes in our status in the room.

Specified by:
addParticipantPresenceListener in interface AdHocChatRoom
Parameters:
listener - a participant status listener.

addMessageListener

public void addMessageListener(AdHocChatRoomMessageListener listener)
Registers listener so that it would receive events every time a new message is received on this chat room.

Specified by:
addMessageListener in interface AdHocChatRoom
Parameters:
listener - a MessageListener that would be notified every time a new message is received on this chat room.

removeMessageListener

public void removeMessageListener(ChatRoomMessageListener listener)
Removes listener so that it won't receive any further message events from this room.

Parameters:
listener - the MessageListener to remove from this room

findParticipantForAddress

public Contact findParticipantForAddress(String address)
Finds the participant of this ad-hoc chat room corresponding to the given address.

Parameters:
address - the address to search for.
Returns:
the participant of this chat room corresponding to the given nick name.

createMessage

public Message createMessage(String text)
Creates a Message for this ad-hoc chat room containing text.

Specified by:
createMessage in interface AdHocChatRoom
Parameters:
text -
Returns:
Message the newly created Message

getName

public String getName()
Returns the name of this ad-hoc chatroom

Specified by:
getName in interface AdHocChatRoom
Returns:
String

getParentProvider

public ProtocolProviderService getParentProvider()
Returns the parent provider

Specified by:
getParentProvider in interface AdHocChatRoom
Returns:
ProtocolProviderService

getParticipants

public List<Contact> getParticipants()
Returns a list containing all the Contacts who participate in this ad-hoc chat room.

Specified by:
getParticipants in interface AdHocChatRoom
Returns:
List

getAdHocChatRoomParticipant

public Contact getAdHocChatRoomParticipant(String id)
Returns the participant of this ad-hoc chat room which corresponds to the given id.

Parameters:
id - ID of the participant
Returns:
Contact the corresponding Contact

addAdHocChatRoomParticipant

public void addAdHocChatRoomParticipant(String id,
                                        Contact participant)
Adds a participant to the participants list.

Parameters:
participant - The participant (Contact) to add.

removeParticipant

public void removeParticipant(String id)
Removes the participant of this ad-hoc chat room which corresponds to the given id.

Parameters:
id - ID of the participant

getParticipantsCount

public int getParticipantsCount()
Returns the number of Contacts who participate in this ad-hoc chat room.

Specified by:
getParticipantsCount in interface AdHocChatRoom
Returns:
int the number of Contacts, currently participating in this ad-hoc room.

getSubject

public String getSubject()

invite

public void invite(String userAddress,
                   String reason)
Invites another user to this room. If we're not joined nothing will happen.

Specified by:
invite in interface AdHocChatRoom
Parameters:
userAddress - the address of the user (email address) to invite to the room.(one may also invite users not on their contact list).
reason - You cannot specify a Reason inside the msn protocol

join

public void join()
Description copied from interface: AdHocChatRoom
Joins this ad-hoc chat room with the nickname of the local user so that the user would start receiving events and messages for it.

Specified by:
join in interface AdHocChatRoom

leave

public void leave()
Leave this chat room. Once this method is called, the user won't be listed as a member of the chat room any more and no further chat events will be delivered. Depending on the underlying protocol and implementation leave() might cause the room to be destroyed if it has been created by the local user.

Specified by:
leave in interface AdHocChatRoom

isSystem

public boolean isSystem()

sendMessage

public void sendMessage(Message message)
                 throws OperationFailedException
Sends the given message through the participants of this ad-hoc chat room.

Specified by:
sendMessage in interface AdHocChatRoom
Parameters:
message - the message to delivered
Throws:
OperationFailedException - if send fails

setSwitchboard

public void setSwitchboard(net.sf.jml.MsnSwitchboard switchboard)
Sets the corresponding switchboard.

Parameters:
switchboard - Corresponding switchboard.

fireMessageEvent

public void fireMessageEvent(EventObject evt)
Notifies all interested listeners that a AdHocChatRoomMessageDeliveredEvent, AdHocChatRoomMessageReceivedEvent or a AdHocChatRoomMessageDeliveryFailedEvent has been fired.

Parameters:
evt - The specific event

updateParticipantsList

public void updateParticipantsList(net.sf.jml.MsnSwitchboard switchboard)
Fills the participants list with all participants inside the switchboard (ad-hoc chat room).

Parameters:
switchboard - The corresponding switchboard

getIdentifier

public String getIdentifier()
Returns the identifier of this ad-hoc chat room.

Specified by:
getIdentifier in interface AdHocChatRoom
Returns:
a String containing the identifier of this ad-hoc room

removeParticipantPresenceListener

public void removeParticipantPresenceListener(AdHocChatRoomParticipantPresenceListener listener)
Removes the given participant presence listener.

Specified by:
removeParticipantPresenceListener in interface AdHocChatRoom
Parameters:
listener - the listener to remove

removeMessageListener

public void removeMessageListener(AdHocChatRoomMessageListener listener)
Removes the given message listener.

Specified by:
removeMessageListener in interface AdHocChatRoom
Parameters:
listener - the listener to remove

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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