SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.icq
Class AdHocChatRoomIcqImpl

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

public class AdHocChatRoomIcqImpl
extends Object
implements AdHocChatRoom

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

Author:
Valentin Martinet

Constructor Summary
AdHocChatRoomIcqImpl(net.kano.joustsim.oscar.oscar.service.chatrooms.ChatInvitation chatInvitation, ProtocolProviderServiceIcqImpl icqProvider)
          Constructor for chat room instances, with a given chat room invitation.
AdHocChatRoomIcqImpl(String roomName, net.kano.joustsim.oscar.oscar.service.chatrooms.ChatRoomSession chatRoomSession, ProtocolProviderServiceIcqImpl icqProvider)
          Constructor for chat room instances.
 
Method Summary
 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 such as us being kicked, banned, or granted admin permissions.
 Message createMessage(byte[] content, String contentType, String contentEncoding, String subject)
          Create a Message instance for sending arbitrary MIME-encoding content.
 Message createMessage(String messageText)
          Create a Message instance for sending a simple text messages with default (text/plain) content type and encoding.
 Contact findParticipantForNickName(String nickName)
          Finds the member of this chat room corresponding to the given nick name.
 void fireMessageEvent(EventObject evt)
          Notifies all interested listeners that a ChatRoomMessageDeliveredEvent, ChatRoomMessageReceivedEvent or a ChatRoomMessageDeliveryFailedEvent has been fired.
 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 participants currently participating in this room.
 int getParticipantsCount()
          Returns the number of participants that are currently in this chat room.
 String getSubject()
          Returns the last known room subject/theme or null if the user hasn't joined the room or the room does not have a subject yet.
 String getUserNickname()
          Returns the local user's nickname in the context of this chat room or null if not currently joined.
 void invite(String userAddress, String reason)
          Invites another user to this room.
 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 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 ad-hoc chat room participants.
 void sendMessage(Message message)
          Sends the message to the destination indicated by the to contact.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdHocChatRoomIcqImpl

public AdHocChatRoomIcqImpl(net.kano.joustsim.oscar.oscar.service.chatrooms.ChatInvitation chatInvitation,
                            ProtocolProviderServiceIcqImpl icqProvider)
Constructor for chat room instances, with a given chat room invitation. If this constructor is used the user was invited to a chat room.

Parameters:
chatInvitation - Chat room invitation that the user received from the ICQ network
icqProvider - The ICQ provider

AdHocChatRoomIcqImpl

public AdHocChatRoomIcqImpl(String roomName,
                            net.kano.joustsim.oscar.oscar.service.chatrooms.ChatRoomSession chatRoomSession,
                            ProtocolProviderServiceIcqImpl icqProvider)
Constructor for chat room instances.

Parameters:
roomName - The name of the chat room.
chatRoomSession - Chat room session from the icq network
icqProvider - The icq provider
Method Detail

addParticipantPresenceListener

public void addParticipantPresenceListener(AdHocChatRoomParticipantPresenceListener listener)
Adds a listener that will be notified of changes in our status in the room such as us being kicked, banned, or granted admin permissions.

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.

createMessage

public Message createMessage(byte[] content,
                             String contentType,
                             String contentEncoding,
                             String subject)
Create a Message instance for sending arbitrary MIME-encoding content.

Parameters:
content - content value
contentType - the MIME-type for content
contentEncoding - encoding used for content
subject - a String subject or null for now subject.
Returns:
the newly created message.

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

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.

getParticipants

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

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

getParticipantsCount

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

Specified by:
getParticipantsCount in interface AdHocChatRoom
Returns:
the number of Contacts, currently participating in this 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 ChatRoom.

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.

getSubject

public String getSubject()
Returns the last known room subject/theme or null if the user hasn't joined the room or the room does not have a subject yet.

To be notified every time the room's subject change you should add a ChatRoomPropertyChangelistener to this room.

Returns:
the room subject or null if the user hasn't joined the room or the room does not have a subject yet.

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 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 address of the user (email address) to invite to the room.(one may also invite users not on their contact list).
reason - invitation message

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

removeParticipantPresenceListener

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

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

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

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 ChatRoomMessageDeliveredEvent, ChatRoomMessageReceivedEvent or a ChatRoomMessageDeliveryFailedEvent has been fired.

Parameters:
evt - The specific event

findParticipantForNickName

public Contact findParticipantForNickName(String nickName)
Finds the member of this chat room corresponding to the given nick name.

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

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

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