public class MockChatRoom extends AbstractChatRoom
cachedConferenceDescriptions, conferencePublishedListeners
Constructor and Description |
---|
MockChatRoom(MockProvider provider,
MockMultiUserChat parentOpSet,
java.lang.String roomName)
Creates an instance of MockChatRoom by specifying the
corresponding protocol provider, the multi user chat operation set
and the room name.
|
Modifier and Type | Method and Description |
---|---|
void |
addLocalUserRoleListener(ChatRoomLocalUserRoleListener listener)
Adds a listener that will be notified of changes in our role in the room
such as us being granded operator.
|
void |
addMemberPresenceListener(ChatRoomMemberPresenceListener listener)
Adds a listener that will be notified of changes in our participation in
the room such as us being kicked, join, left...
|
void |
addMemberPropertyChangeListener(ChatRoomMemberPropertyChangeListener listener)
Adds a listener that will be notified of changes in the property of a
room member such as the nickname being changed.
|
void |
addMemberRoleListener(ChatRoomMemberRoleListener listener)
Adds a listener that will be notified of changes of a member role in the
room such as being granded operator.
|
void |
addMessageListener(ChatRoomMessageListener listener)
Registers listener so that it would receive events every time a
new message is received on this chat room.
|
void |
addPropertyChangeListener(ChatRoomPropertyChangeListener listener)
Adds a listener that will be notified of changes in the property of the
room such as the subject being change or the room state being changed.
|
void |
banParticipant(ChatRoomMember chatRoomMember,
java.lang.String reason)
Bans a user from the room.
|
Message |
createMessage(byte[] content,
java.lang.String contentType,
java.lang.String contentEncoding,
java.lang.String subject)
Create a Message instance for sending arbitrary MIME-encoding content.
|
Message |
createMessage(java.lang.String messageText)
Create a Message instance for sending a simple text messages with default
(text/plain) content type and encoding.
|
void |
deliverMessage(Message msg,
java.lang.String from)
Methods for manipulating mock operation set as
deliver(receive) messageop
|
boolean |
destroy(java.lang.String reason,
java.lang.String alternateAddress)
Destroys the chat room.
|
java.util.Iterator<ChatRoomMember> |
getBanList()
Returns an Iterator over a set of ban masks for this chat room.
|
ChatRoomConfigurationForm |
getConfigurationForm()
Returns the ChatRoomConfigurationForm containing all
configuration properties for this chat room.
|
java.lang.String |
getIdentifier()
Returns the identifier of this ChatRoom.
|
java.util.List<ChatRoomMember> |
getMembers()
Returns a List of ChatRoomMembers corresponding to all
members currently participating in this room.
|
int |
getMembersCount()
Returns the number of participants that are currently in this chat room.
|
java.util.List<java.lang.String> |
getMembersWhiteList()
Returns the ids of the users that has the member role in the room.
|
java.lang.String |
getName()
Returns the name of this ChatRoom.
|
ProtocolProviderService |
getParentProvider()
Returns a reference to the provider that created this room.
|
Contact |
getPrivateContactByNickname(java.lang.String name)
Finds private messaging contact by nickname.
|
java.lang.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.
|
java.lang.String |
getUserNickname()
Returns the local user's nickname in the context of this chat room or
null if not currently joined.
|
ChatRoomMemberRole |
getUserRole()
Returns the local user role.
|
void |
grantAdmin(java.lang.String address)
Grants admin role to the participant given by address.
|
void |
grantMembership(java.lang.String address)
Grants membership role to the participant given by address.
|
void |
grantModerator(java.lang.String address)
Grants moderator role to the participant given by address.
|
void |
grantOwnership(java.lang.String address)
Grants ownership role to the participant given by address.
|
void |
grantVoice(java.lang.String address)
Grants voice to the participant given by address.
|
void |
invite(java.lang.String userAddress,
java.lang.String reason)
Invites another user to this room.
|
boolean |
isJoined()
Returns true if the local user is currently in the multi user chat
(after calling one of the
join() methods). |
boolean |
isPersistent()
Determines whether this chat room should be stored in the configuration
file or not.
|
boolean |
isSystem()
Returns
true if this chat room is a system room and
false otherwise. |
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 |
join(byte[] password)
Joins this chat room so that the user would start receiving events and
messages for it.
|
void |
joinAs(java.lang.String nickname)
Joins this chat room with the specified nickname so that the user would
start receiving events and messages for it.
|
void |
joinAs(java.lang.String nickname,
byte[] password)
Joins this chat room with the specified nickname and password so that the
user would start receiving events and messages for it.
|
void |
kickParticipant(ChatRoomMember chatRoomMember,
java.lang.String reason)
Kicks a visitor or participant from the room.
|
void |
leave()
Leave this chat room.
|
ConferenceDescription |
publishConference(ConferenceDescription cd,
java.lang.String name)
Publishes a ConferenceDescription to the chat room.
|
void |
removelocalUserRoleListener(ChatRoomLocalUserRoleListener listener)
Removes a listener that was being notified of changes in our role in this
chat room such as us being granded operator.
|
void |
removeMemberPresenceListener(ChatRoomMemberPresenceListener listener)
Removes a listener that was being notified of changes in the
participation of other chat room participants such as users being kicked,
join, left.
|
void |
removeMemberPropertyChangeListener(ChatRoomMemberPropertyChangeListener listener)
Removes a listener that was being notified of changes in the property of
a chat room member such as the nickname being changed.
|
void |
removeMemberRoleListener(ChatRoomMemberRoleListener listener)
Removes a listener that was being notified of changes of a member role in
this chat room such as us being granded operator.
|
void |
removeMessageListener(ChatRoomMessageListener listener)
Removes listener so that it won't receive any further message
events from this room.
|
void |
removePropertyChangeListener(ChatRoomPropertyChangeListener listener)
Removes a listener that was being notified of changes in the property of
the chat room such as the subject being change or the room state being
changed.
|
void |
revokeAdmin(java.lang.String address)
Revokes the admin role for the participant given by address.
|
void |
revokeMembership(java.lang.String address)
Revokes the membership role for the participant given by address.
|
void |
revokeModerator(java.lang.String address)
Revokes the moderator role for the participant given by address.
|
void |
revokeOwnership(java.lang.String address)
Revokes the ownership role for the participant given by address.
|
void |
revokeVoice(java.lang.String address)
Revokes the voice for the participant given by address.
|
void |
sendMessage(Message message)
Sends the message to the destination indicated by the
to contact.
|
void |
setLocalUserRole(ChatRoomMemberRole role)
Sets the local user role.
|
void |
setMembersWhiteList(java.util.List<java.lang.String> members)
Changes the list of users that has role member for this room.
|
void |
setNickname(java.lang.String nickname)
Changes the the local user's nickname in the context of this chatroom.
|
void |
setSubject(java.lang.String subject)
Sets the subject of this chat room.
|
void |
setUserNickname(java.lang.String nickname)
Changes the the local user's nickname in the context of this chatroom.
|
void |
updatePrivateContactPresenceStatus(Contact sourceContact)
Updates the presence status of private messaging contact.
|
void |
updatePrivateContactPresenceStatus(java.lang.String nickname)
Updates the presence status of private messaging contact.
|
addConferencePublishedListener, clearCachedConferenceDescriptionList, fireConferencePublishedEvent, getCachedConferenceDescriptions, getCachedConferenceDescriptionSize, processConferenceDescription, removeConferencePublishedListener
public MockChatRoom(MockProvider provider, MockMultiUserChat parentOpSet, java.lang.String roomName)
provider
- the corresponding ProtocolProviderServiceparentOpSet
- the corresponding OperationSetMultiUserChatroomName
- the name of the roompublic java.lang.String getName()
public void join() throws OperationFailedException
OperationFailedException
- with the corresponding code if an error
occurs while joining the room.public void join(byte[] password) throws OperationFailedException
password
- the password to use when authenticating on the chatroom.OperationFailedException
- with the corresponding code if an error
occurs while joining the room.public void joinAs(java.lang.String nickname) throws OperationFailedException
nickname
- the nickname to use.OperationFailedException
- with the corresponding code if an error
occurs while joining the room.public void joinAs(java.lang.String nickname, byte[] password) throws OperationFailedException
nickname
- the nickname to use.password
- a password necessary to authenticate when joining the
room.OperationFailedException
- with the corresponding code if an error
occurs while joining the room.public boolean isJoined()
join()
methods).public void leave()
public java.lang.String getSubject()
To be notified every time the room's subject change you should add a
ChatRoomChangelistener to this room.
addPropertyChangeListener(ChatRoomPropertyChangeListener)
To change the room's subject use setSubject(String)
.
public void setSubject(java.lang.String subject) throws OperationFailedException
subject
- the new subject that we'd like this room to haveOperationFailedException
public java.lang.String getUserNickname()
public void setNickname(java.lang.String nickname) throws OperationFailedException
nickname
- the new nickname within the room.OperationFailedException
- if the setting the new nickname changes
for some reason.public void addMemberPresenceListener(ChatRoomMemberPresenceListener listener)
listener
- a member participation listener.public void removeMemberPresenceListener(ChatRoomMemberPresenceListener listener)
listener
- a member participation listener.public void addLocalUserRoleListener(ChatRoomLocalUserRoleListener listener)
listener
- a local user role listener.public void removelocalUserRoleListener(ChatRoomLocalUserRoleListener listener)
listener
- a local user role listener.public void addMemberRoleListener(ChatRoomMemberRoleListener listener)
listener
- a member role listener.public void removeMemberRoleListener(ChatRoomMemberRoleListener listener)
listener
- a member role listener.public void addPropertyChangeListener(ChatRoomPropertyChangeListener listener)
listener
- a property change listener.public void removePropertyChangeListener(ChatRoomPropertyChangeListener listener)
listener
- a property change listener.public void invite(java.lang.String userAddress, java.lang.String reason)
If the room is password-protected, the invitee will receive a password to use to join the room. If the room is members-only, the the invitee may be added to the member list.
userAddress
- the address of the user to invite to the room.(one
may also invite users not on their contact list).reason
- a reason, subject, or welcome message that would tell the
the user why they are being invited.public java.util.List<ChatRoomMember> getMembers()
public int getMembersCount()
public void addMessageListener(ChatRoomMessageListener listener)
listener
- a MessageListener that would be notified every
time a new message is received on this chat room.public void removeMessageListener(ChatRoomMessageListener listener)
listener
- the MessageListener to remove from this roompublic Message createMessage(byte[] content, java.lang.String contentType, java.lang.String contentEncoding, java.lang.String subject)
content
- content valuecontentType
- the MIME-type for contentcontentEncoding
- encoding used for contentsubject
- a String subject or null for now subject.public Message createMessage(java.lang.String messageText)
messageText
- the string content of the message.public void sendMessage(Message message) throws OperationFailedException
message
- the Message to send.OperationFailedException
- if sending the message fails for some
reason.public ProtocolProviderService getParentProvider()
public java.util.Iterator<ChatRoomMember> getBanList()
public void deliverMessage(Message msg, java.lang.String from)
msg
- the message that we are to deliver.from
- delivered frompublic void setUserNickname(java.lang.String nickname) throws OperationFailedException
nickname
- the new nickname within the room.OperationFailedException
- if the setting the new nickname changes
for some reason.public java.lang.String getIdentifier()
public void banParticipant(ChatRoomMember chatRoomMember, java.lang.String reason) throws OperationFailedException
chatRoomMember
- the ChatRoomMember to be bannedreason
- the reason why the user was bannedOperationFailedException
- if an error occurs while banning a userpublic void kickParticipant(ChatRoomMember chatRoomMember, java.lang.String reason) throws OperationFailedException
chatRoomMember
- the ChatRoomMember to kick from the roomreason
- the reason why the participant is being kicked from the
roomOperationFailedException
- if an error occurs while kicking the
participantpublic ChatRoomConfigurationForm getConfigurationForm() throws OperationFailedException
OperationFailedException
- if the user doesn't have
permissions to see and change chat room configurationpublic void addMemberPropertyChangeListener(ChatRoomMemberPropertyChangeListener listener)
listener
- a room member property change listener.public void removeMemberPropertyChangeListener(ChatRoomMemberPropertyChangeListener listener)
listener
- a room member property change listener.public boolean isSystem()
true
if this chat room is a system room and
false
otherwise.true
if this chat room is a system room and
false
otherwise.public boolean isPersistent()
public void grantAdmin(java.lang.String address)
address
- the address of the participant to grant admin role topublic void grantMembership(java.lang.String address)
address
- the address of the participant to grant membership role topublic void grantModerator(java.lang.String address)
address
- the address of the participant to grant moderator role topublic void grantOwnership(java.lang.String address)
address
- the address of the participant to grant ownership role topublic void grantVoice(java.lang.String address)
address
- the address of the participant to grant voice topublic void revokeAdmin(java.lang.String address)
address
- the address of the participant to revoke admin role forpublic void revokeMembership(java.lang.String address)
address
- the address of the participant to revoke membership role
forpublic void revokeModerator(java.lang.String address)
address
- the address of the participant to revoke moderator role
forpublic void revokeOwnership(java.lang.String address)
address
- the address of the participant to revoke ownership role
forpublic void revokeVoice(java.lang.String address)
address
- the address of the participant to revoke voice forpublic ChatRoomMemberRole getUserRole()
public void setLocalUserRole(ChatRoomMemberRole role) throws OperationFailedException
role
- the role to setOperationFailedException
- if the operation don't succeedpublic ConferenceDescription publishConference(ConferenceDescription cd, java.lang.String name)
cd
- the description to publishname
- the name of the conferencepublic Contact getPrivateContactByNickname(java.lang.String name)
name
- the nickname of the contact.public void updatePrivateContactPresenceStatus(java.lang.String nickname)
nickname
- the nickname of the contact.public void updatePrivateContactPresenceStatus(Contact sourceContact)
sourceContact
- the contact.public boolean destroy(java.lang.String reason, java.lang.String alternateAddress)
reason
- the reason for destroying.alternateAddress
- the alternate addresspublic java.util.List<java.lang.String> getMembersWhiteList()
public void setMembersWhiteList(java.util.List<java.lang.String> members)
members
- the ids of user to have member role.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.