public class ChatRoomJabberImpl extends AbstractChatRoom
cachedConferenceDescriptions, conferencePublishedListeners
Constructor and Description |
---|
ChatRoomJabberImpl(org.jivesoftware.smackx.muc.MultiUserChat multiUserChat,
ProtocolProviderServiceJabberImpl provider)
Creates an instance of a chat room that has been.
|
Modifier and Type | Method and Description |
---|---|
void |
addConferenceCall(CallJabberImpl call)
Adds a CallJabberImpl instance to the list of conference calls
associated with the room.
|
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 status in the
room such as us being kicked, banned, or granted admin permissions.
|
void |
addMemberPropertyChangeListener(ChatRoomMemberPropertyChangeListener listener)
Adds the given listener to the list of listeners registered to
receive events upon modification of chat room member properties such as
its nickname being changed for example.
|
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 listener to the list of listeners registered to receive
events upon modification of chat room properties such as its subject
for example.
|
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.
|
boolean |
destroy(java.lang.String reason,
java.lang.String alternateAddress)
Destroys the chat room.
|
ChatRoomMemberJabberImpl |
findMemberForNickName(java.lang.String jabberID)
Finds the member of this chat room corresponding to the given nick name.
|
void |
fireMemberPropertyChangeEvent(ChatRoomMemberPropertyChangeEvent evt)
Delivers the specified event to all registered property change listeners.
|
(package private) void |
fireMessageEvent(java.util.EventObject evt)
Delivers the specified event to all registered message listeners.
|
java.util.Iterator<ChatRoomMember> |
getBanList()
Returns the list of banned users.
|
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 Members 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.
|
(package private) org.jivesoftware.smackx.muc.MultiUserChat |
getMultiUserChat()
Returns the internal stack used chat room instance.
|
java.lang.String |
getName()
Returns the name of this ChatRoom.
|
(package private) static java.lang.String |
getNickName(java.lang.String participantAddress)
Returns the nickname of the given participant name.
|
ProtocolProviderService |
getParentProvider()
Returns a reference to the provider that created this room.
|
Contact |
getPrivateContactByNickname(java.lang.String nickname)
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 local user role in the context of this chatroom.
|
void |
grantAdmin(java.lang.String jid)
Grants administrator privileges to another user.
|
void |
grantMembership(java.lang.String jid)
Grants membership to a user.
|
void |
grantModerator(java.lang.String nickname)
Grants moderator privileges to a participant or visitor.
|
void |
grantOwnership(java.lang.String jid)
Grants ownership privileges to another user.
|
void |
grantVoice(java.lang.String nickname)
Grants voice to a visitor in the room.
|
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()
The Jabber multi user chat implementation doesn't support system rooms.
|
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 member,
java.lang.String reason)
Kicks a participant from the room.
|
void |
leave()
Leave this chat room.
|
ConferenceDescription |
publishConference(ConferenceDescription cd,
java.lang.String name)
Publishes a conference to the room by sending a Presence IQ
which contains a ConferenceDescriptionPacketExtension
|
void |
publishPresenceStatus(java.lang.String newStatus)
Publishes new status message in chat room presence.
|
void |
removeConferenceCall(CallJabberImpl call)
Removes a CallJabberImpl instance from the list of conference
calls associated with the 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 status of
other chat room participants such as users being kicked, banned, or
granted admin permissions.
|
void |
removeMemberPropertyChangeListener(ChatRoomMemberPropertyChangeListener listener)
Removes the given listener from the list of listeners currently
registered for chat room member property change events.
|
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 |
removePresenceExtension(org.jivesoftware.smack.packet.PacketExtension extension)
Removes given PacketExtension from the MUC presence and
publishes it immediately.
|
void |
removePropertyChangeListener(ChatRoomPropertyChangeListener listener)
Removes listener from the list of listeneres current
registered for chat room modification events.
|
void |
revokeAdmin(java.lang.String jid)
Revokes administrator privileges from a user.
|
void |
revokeMembership(java.lang.String jid)
Revokes a user's membership.
|
void |
revokeModerator(java.lang.String nickname)
Revokes moderator privileges from another user.
|
void |
revokeOwnership(java.lang.String jid)
Revokes ownership privileges from another user.
|
void |
revokeVoice(java.lang.String nickname)
Revokes voice from a participant in the room.
|
void |
sendMessage(Message message)
Sends the message to the destination indicated by the
to contact.
|
void |
sendPresenceExtension(org.jivesoftware.smack.packet.PacketExtension extension)
Adds given PacketExtension to the MUC presence and publishes it
immediately.
|
void |
setLocalUserRole(ChatRoomMemberRole role)
Sets the new rolefor the local user in the context of this chatroom.
|
void |
setLocalUserRole(ChatRoomMemberRole role,
boolean isInitial)
Sets the new rolefor the local user in the context of this chatroom.
|
void |
setMembersWhiteList(java.util.List<java.lang.String> members)
Changes the list of users that has role member for this room.
|
void |
setSubject(java.lang.String subject)
Sets the subject of this chat room.
|
void |
setUserNickname(java.lang.String nickname)
Changes the local user nickname.
|
ChatRoomMemberJabberImpl |
smackParticipantToScMember(java.lang.String participant)
Returns the ChatRoomMember corresponding to the given smack
participant.
|
static ChatRoomMemberRole |
smackRoleToScRole(java.lang.String smackRole,
java.lang.String affiliation)
Returns that ChatRoomJabberRole instance corresponding to the
smackRole string.
|
void |
updatePrivateContactPresenceStatus(Contact contact)
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 ChatRoomJabberImpl(org.jivesoftware.smackx.muc.MultiUserChat multiUserChat, ProtocolProviderServiceJabberImpl provider)
multiUserChat
- MultiUserChatprovider
- a reference to the currently valid jabber protocol
provider.public void addPropertyChangeListener(ChatRoomPropertyChangeListener listener)
listener
- the ChatRoomChangeListener that is to be
registered for ChatRoomChangeEvent-s.public void removePropertyChangeListener(ChatRoomPropertyChangeListener listener)
listener
- the ChatRoomChangeListener to remove.public void addMemberPropertyChangeListener(ChatRoomMemberPropertyChangeListener listener)
listener
- the ChatRoomMemberPropertyChangeListener
that is to be registered for ChatRoomMemberPropertyChangeEvents.public void removeMemberPropertyChangeListener(ChatRoomMemberPropertyChangeListener listener)
listener
- the ChatRoomMemberPropertyChangeListener to
remove.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 void addMemberPresenceListener(ChatRoomMemberPresenceListener listener)
listener
- a participant status listener.public void removeMemberPresenceListener(ChatRoomMemberPresenceListener listener)
listener
- a participant status listener.public void addConferenceCall(CallJabberImpl call)
call
- the call to addpublic void removeConferenceCall(CallJabberImpl call)
call
- the call to remove.public 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 java.util.List<ChatRoomMember> getMembers()
public int getMembersCount()
public java.lang.String getName()
public java.lang.String getIdentifier()
public java.lang.String getUserNickname()
public Contact getPrivateContactByNickname(java.lang.String nickname)
nickname
- the nickname of the contact.public java.lang.String getSubject()
public void invite(java.lang.String userAddress, java.lang.String reason)
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 boolean isJoined()
join()
methods).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 join() throws OperationFailedException
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 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 static ChatRoomMemberRole smackRoleToScRole(java.lang.String smackRole, java.lang.String affiliation)
smackRole
- the smack role as returned by
Occupant.getRole().public ChatRoomMemberJabberImpl smackParticipantToScMember(java.lang.String participant)
participant
- the full participant name
(e.g. [email protected]/testuser)public boolean destroy(java.lang.String reason, java.lang.String alternateAddress)
reason
- the reason for destroying.alternateAddress
- the alternate addresspublic void leave()
public void sendMessage(Message message) throws OperationFailedException
message
- the Message to send.OperationFailedException
- if sending the message fails for some
reason.public void setSubject(java.lang.String subject) throws OperationFailedException
subject
- the new subject that we'd like this room to haveOperationFailedException
public ProtocolProviderService getParentProvider()
public ChatRoomMemberRole getUserRole()
public void setLocalUserRole(ChatRoomMemberRole role)
role
- the new role to be set for the local userpublic void setLocalUserRole(ChatRoomMemberRole role, boolean isInitial)
role
- the new role to be set for the local userisInitial
- if true this is initial role set.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 java.util.Iterator<ChatRoomMember> getBanList() throws OperationFailedException
OperationFailedException
- if we could not obtain the ban listpublic void setUserNickname(java.lang.String nickname) throws OperationFailedException
nickname
- the new nickname within the room.OperationFailedException
- if the new nickname already exist in
this roompublic void banParticipant(ChatRoomMember chatRoomMember, java.lang.String reason) throws OperationFailedException
chatRoomMember
- the ChatRoomMember to be banned.reason
- the reason why the user was banned.OperationFailedException
- if an error occurs while banning a user.
In particular, an error can occur if a moderator or a user with an
affiliation of "owner" or "admin" was tried to be banned or if the user
that is banning have not enough permissions to ban.public void kickParticipant(ChatRoomMember member, java.lang.String reason) throws OperationFailedException
member
- 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
participant. In particular, an error can occur if a moderator or a user
with an affiliation of "owner" or "admin" was intended to be kicked; or
if the participant that intended to kick another participant does not
have kicking privileges;void fireMessageEvent(java.util.EventObject evt)
evt
- the EventObject that we'd like delivered to all
registered message listeners.public ConferenceDescription publishConference(ConferenceDescription cd, java.lang.String name)
cd
- the description of the conference to announcename
- the name of the conferencepublic void publishPresenceStatus(java.lang.String newStatus)
newStatus
- the new status message to be published in the MUC.public void sendPresenceExtension(org.jivesoftware.smack.packet.PacketExtension extension)
extension
- the PacketExtension to be included in MUC
presence.public void removePresenceExtension(org.jivesoftware.smack.packet.PacketExtension extension)
extension
- the PacketExtension to be removed from the MUC
presence.public 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.public void fireMemberPropertyChangeEvent(ChatRoomMemberPropertyChangeEvent evt)
evt
- the ChatRoomMemberPropertyChangeEvent that we'd like
deliver to all registered member property change listeners.public ChatRoomConfigurationForm getConfigurationForm() throws OperationFailedException
OperationFailedException
- if the user doesn't have
permissions to see and change chat room configurationpublic boolean isSystem()
public boolean isPersistent()
public ChatRoomMemberJabberImpl findMemberForNickName(java.lang.String jabberID)
jabberID
- the nick name to search for.public void grantAdmin(java.lang.String jid)
jid
- the bare XMPP user ID of the user to grant administrator
privileges (e.g. "[email protected]").public void grantMembership(java.lang.String jid)
jid
- the bare XMPP user ID of the user to grant membership
privileges (e.g. "[email protected]").public void grantModerator(java.lang.String nickname)
nickname
- the nickname of the occupant to grant moderator
privileges.public void grantOwnership(java.lang.String jid)
jid
- the bare XMPP user ID of the user to grant ownership
privileges (e.g. "[email protected]").public void grantVoice(java.lang.String nickname)
nickname
- the nickname of the visitor to grant voice in the room
(e.g. "john").
XMPPException if an error occurs granting voice to a visitor. In
particular, a 403 error can occur if the occupant that intended to grant
voice is not a moderator in this room (i.e. Forbidden error); or a 400
error can occur if the provided nickname is not present in the room.public void revokeAdmin(java.lang.String jid)
jid
- the bare XMPP user ID of the user to grant administrator
privileges (e.g. "[email protected]").public void revokeMembership(java.lang.String jid)
jid
- the bare XMPP user ID of the user to revoke membership
(e.g. "[email protected]").public void revokeModerator(java.lang.String nickname)
nickname
- the nickname of the occupant to revoke moderator
privileges.public void revokeOwnership(java.lang.String jid)
jid
- the bare XMPP user ID of the user to revoke ownership
(e.g. "[email protected]").public void revokeVoice(java.lang.String nickname)
nickname
- the nickname of the participant to revoke voice
(e.g. "john").
XMPPException if an error occurs revoking voice from a participant.
In particular, a 405 error can occur if a moderator or a user
with an affiliation of "owner" or "admin" was tried to revoke his voice
(i.e. Not Allowed error); or a 400 error can occur if the provided
nickname is not present in the room.static java.lang.String getNickName(java.lang.String participantAddress)
participantAddress
- the address of the participantorg.jivesoftware.smackx.muc.MultiUserChat getMultiUserChat()
public void updatePrivateContactPresenceStatus(java.lang.String nickname)
nickname
- the nickname of the contact.public void updatePrivateContactPresenceStatus(Contact contact)
contact
- the contact.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.