Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.yahoo
Class AdHocChatRoomYahooImpl

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

public class AdHocChatRoomYahooImpl
extends Object
implements AdHocChatRoom

Represents a Yahoo ad-hoc chat room, where multiple chat users could communicate in a many-to-many fashion.

Author:
Rupert Burchardi, Valentin Martinet

Constructor Summary
AdHocChatRoomYahooImpl(ymsg.network.YahooConference multiUserChat, ProtocolProviderServiceYahooImpl provider)
          Creates an instance of a chat room that has been.
 
Method Summary
 void addChatRoomParticipant(Contact participant)
          Adds a participant to the ad-hoc chat room participant 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 messageText)
          Create a Message instance for sending a simple text messages with default (text/plain) content type and encoding.
 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.
 void fireParticipantPresenceEvent(Contact participant, String eventID, String eventReason)
          Creates the corresponding AdHocChatRoomParticipantPresenceChangeEvent and notifies all AdHocChatRoomParticipantPresenceListeners that a Contact has joined or left this AdHocChatRoom.
 String getIdentifier()
          Returns the identifier of this AdHocChatRoom.
 String getName()
          Returns the name of this AdHocChatRoom.
 ProtocolProviderService getParentProvider()
          Returns the protocol provider service that created us.
 List<Contact> getParticipants()
          Returns a List of Contacts corresponding to all members currently participating in this room.
 int getParticipantsCount()
          Returns the number of participants that are currently in this ad-hoc chat room.
 String getUserNickname()
          Returns the local user's nickname in the context of this chat room or null if not currently joined.
 ymsg.network.YahooConference getYahooConference()
          Returns the yahoo conference model of this chat room.
 void invite(String userAddress, String reason)
          Invites another user to this room.
 boolean isPersistent()
          Determines whether this chat room should be stored in the configuration file or not.
 boolean isSystem()
          Indicates whether or not this chat room is corresponding to a server channel.
 void join()
          Joins this 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 removeChatRoomParticipant(Contact participant)
          Removes the specified ad-hoc chat room participant from the participants list of this ad-hoc chat room.
 void removeMessageListener(AdHocChatRoomMessageListener listener)
          Removes listener so that it won't receive any further message events from this room.
 void removeParticipantPresenceListener(AdHocChatRoomParticipantPresenceListener listener)
          Removes a listener that was being notified of changes in the status of other chat room participants.
 void sendMessage(Message message)
          Sends the message to the destination indicated by the to contact.
 void updateParticipantsList()
          Updates the member list of the chat room.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdHocChatRoomYahooImpl

public AdHocChatRoomYahooImpl(ymsg.network.YahooConference multiUserChat,
                              ProtocolProviderServiceYahooImpl provider)
Creates an instance of a chat room that has been.

Parameters:
multiUserChat - MultiUserChat
provider - a reference to the currently valid jabber protocol provider.
Method Detail

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(AdHocChatRoomMessageListener listener)
Removes listener so that it won't receive any further message events from this room.

Specified by:
removeMessageListener in interface AdHocChatRoom
Parameters:
listener - The MessageListener to remove from this room

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.

removeParticipantPresenceListener

public void removeParticipantPresenceListener(AdHocChatRoomParticipantPresenceListener listener)
Removes a listener that was being notified of changes in the status of other chat room participants.

Specified by:
removeParticipantPresenceListener in interface AdHocChatRoom
Parameters:
listener - A participant status listener.

createMessage

public Message createMessage(String messageText)
Create a Message instance for sending a simple text messages with default (text/plain) content type and encoding.

Specified by:
createMessage in interface AdHocChatRoom
Parameters:
messageText - the string content of the message.
Returns:
Message the newly created message

getParticipants

public List<Contact> getParticipants()
Returns a List of Contacts corresponding to all members currently participating in this room.

Specified by:
getParticipants in interface AdHocChatRoom
Returns:
a List of Contact corresponding to all room members.

updateParticipantsList

public void updateParticipantsList()
Updates the member list of the chat room.


getIdentifier

public String getIdentifier()
Returns the identifier of this AdHocChatRoom.

Specified by:
getIdentifier in interface AdHocChatRoom
Returns:
a String containing the identifier of this AdHocChatRoom.

getParticipantsCount

public int getParticipantsCount()
Returns the number of participants that are currently in this ad-hoc chat room.

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

getName

public String getName()
Returns the name of this AdHocChatRoom.

Specified by:
getName in interface AdHocChatRoom
Returns:
a String containing the name of this AdHocChatRoom.

getParentProvider

public ProtocolProviderService getParentProvider()
Returns the protocol provider service that created us.

Specified by:
getParentProvider in interface AdHocChatRoom
Returns:
the protocol provider service that created us.

getUserNickname

public String getUserNickname()
Returns the local user's nickname in the context of this chat room or null if not currently joined.

Returns:
the nickname currently being used by the local user in the context of the local ad-hoc chat room.

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 identifier of the contact (email address or yahoo id)
reason - The invite reason, which is send to the invitee.

isSystem

public boolean isSystem()
Indicates whether or not this chat room is corresponding to a server channel. Note: Returns always false.

Returns:
Always false since system chat room can't be joined with current yahoo library.

join

public void join()
          throws OperationFailedException
Joins this 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
Throws:
OperationFailedException - with the corresponding code if an error occurs while joining the room.

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

sendMessage

public void sendMessage(Message message)
                 throws OperationFailedException
Sends the message to the destination indicated by the to contact.

Specified by:
sendMessage in interface AdHocChatRoom
Parameters:
message - The Message to send.
Throws:
OperationFailedException - if the underlying stack is not registered or initialized or if the chat room is not joined.

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

fireParticipantPresenceEvent

public void fireParticipantPresenceEvent(Contact participant,
                                         String eventID,
                                         String eventReason)
Creates the corresponding AdHocChatRoomParticipantPresenceChangeEvent and notifies all AdHocChatRoomParticipantPresenceListeners that a Contact has joined or left this AdHocChatRoom.

Parameters:
participant - the Contact that this
eventID - the identifier of the event
eventReason - the reason of the event

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.

removeChatRoomParticipant

public void removeChatRoomParticipant(Contact participant)
Removes the specified ad-hoc chat room participant from the participants list of this ad-hoc chat room.

Parameters:
participant - The member, who should be removed from the ad-hoc chat room participants list.

addChatRoomParticipant

public void addChatRoomParticipant(Contact participant)
Adds a participant to the ad-hoc chat room participant list.

Parameters:
participant - The participant, who should be added to the ad-hoc chat room participant list.

getYahooConference

public ymsg.network.YahooConference getYahooConference()
Returns the yahoo conference model of this chat room.

Returns:
The yahoo conference.

isPersistent

public boolean isPersistent()
Determines whether this chat room should be stored in the configuration file or not. If the chat room is persistent it still will be shown after a restart in the chat room list. A non-persistent chat room will be only in the chat room list until the the program is running.

Returns:
true if this chat room is persistent, false otherwise

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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