public class ChatManager
extends java.lang.Object
implements org.jivesoftware.smack.chat.ChatManagerListener
Workspace
. The ChatManager is responsible
for creation and removal of chat rooms, transcripts, and transfers and room invitations.Modifier and Type | Field and Description |
---|---|
static java.awt.Color[] |
COLORS |
static java.awt.Color |
ERROR_COLOR |
static java.awt.Color |
FROM_COLOR |
static java.awt.Color |
NOTIFICATION_COLOR |
static java.awt.Color |
TO_COLOR |
Modifier and Type | Method and Description |
---|---|
void |
activateChat(java.lang.String jid,
java.lang.String nickname)
Activate a chat room with the selected user.
|
void |
addChatMessageHandler(ChatMessageHandler handler) |
void |
addChatRoomListener(ChatRoomListener listener)
Used to listen for rooms opening, closing or being
activated( already opened, but tabbed to )
|
void |
addContactItemHandler(ContactItemHandler handler)
Adds a new
ContactItemHandler . |
void |
addGlobalMessageListener(GlobalMessageListener listener)
Adds a new
GlobalMessageListener . |
void |
addInvitationListener(RoomInvitationListener listener)
Adds a
RoomInvitationListener . |
void |
addMessageFilter(MessageFilter filter)
Adds a new
MessageFilter . |
void |
addSparkTabHandler(SparkTabHandler decorator)
Adds a new
ContainerDecorator . |
void |
addTranscriptWindowInterceptor(TranscriptWindowInterceptor interceptor)
Adds a TranscriptWindowInterceptor.
|
void |
addTypingNotification(ChatRoom chatRoom)
Adds a room where the user is typing.
|
void |
cancelledNotification(java.lang.String from,
org.jivesoftware.smackx.chatstates.ChatState state) |
void |
chatCreated(org.jivesoftware.smack.chat.Chat chat,
boolean isLocal) |
boolean |
chatRoomExists(java.lang.String jid)
Checks if a
ChatRoom exists. |
void |
composingNotification(java.lang.String from) |
boolean |
containsTypingNotification(ChatRoom chatRoom)
Returns true if the
ChatRoom state is in typing mode. |
ChatRoom |
createChatRoom(java.lang.String userJID,
java.lang.String nickname,
java.lang.String title)
Creates and/or opens a chat room with the specified user.
|
ChatRoom |
createConferenceRoom(java.lang.String roomName,
java.lang.String serviceName)
Creates a new public Conference Room.
|
void |
filterIncomingMessage(ChatRoom room,
org.jivesoftware.smack.packet.Message message)
Filters all incoming messages.
|
void |
filterOutgoingMessage(ChatRoom room,
org.jivesoftware.smack.packet.Message message)
Notifies all
MessageFilter s about a new outgoing message. |
boolean |
fireContactItemDoubleClicked(ContactItem item)
Notifies all
ContactItemHandlers that a ContactItem was double-clicked. |
boolean |
fireContactItemPresenceChanged(ContactItem item,
org.jivesoftware.smack.packet.Presence presence)
Notifies all
ContactItemHandler s of presence changes. |
void |
fireGlobalMessageReceievedListeners(ChatRoom chatRoom,
org.jivesoftware.smack.packet.Message message)
Notifies all
GlobalMessageListeners of a new incoming message. |
void |
fireGlobalMessageSentListeners(ChatRoom chatRoom,
org.jivesoftware.smack.packet.Message message)
Notifies all
GlobalMessageListeners of a new message sent. |
void |
fireMessageReceived(org.jivesoftware.smack.packet.Message message) |
ChatContainer |
getChatContainer()
Returns all ChatRooms currently active.
|
ChatRoom |
getChatRoom(java.lang.String jid)
Returns the
ChatRoom for the giving jid. |
java.lang.String |
getDefaultConferenceService()
Returns the default conference service.
|
GroupChatRoom |
getGroupChat(java.lang.String roomName)
Returns the MultiUserChat associated with the specified roomname.
|
javax.swing.Icon |
getIconForContactHandler(java.lang.String jid)
Returns the icon from a
ContactItemHandler . |
static ChatManager |
getInstance()
Returns the singleton instance of
ChatManager ,
creating it if necessary. |
java.util.Collection<RoomInvitationListener> |
getInvitationListeners()
Returns all registered
RoomInvitationListener s. |
java.util.Collection<MessageFilter> |
getMessageFilters()
Returns a Collection of MessageFilters registered to Spark.
|
java.util.Collection<ContactItem> |
getSelectedContactItems()
Returns all selected users in the
ContactList . |
javax.swing.Icon |
getTabIconForContactHandler(org.jivesoftware.smack.packet.Presence presence)
Returns the icon to use in the tab.
|
java.util.Collection<TranscriptWindowInterceptor> |
getTranscriptWindowInterceptors()
Returns the list of
TranscriptWindowInterceptors . |
void |
handleURIMapping(java.lang.String arguments)
Handles XMPP URI Mappings.
|
boolean |
isStaleRoom(ChatRoom chatRoom)
Returns true if the room is "stale".
|
void |
notifySparkTabHandlers(java.awt.Component component)
Notifies all
ContainerDecorator |
void |
removeChat(ChatRoom chatRoom)
Removes the personal 1 to 1 chat from the ChatFrame.
|
void |
removeChatMessageHandler(ChatMessageHandler handler) |
void |
removeChatRoomListener(ChatRoomListener listener)
Simplace facade for chatroom.
|
void |
removeContactItemHandler(ContactItemHandler handler)
Removes a
ContactItemHandler . |
void |
removeGlobalMessageListener(GlobalMessageListener listener)
Removes a
GlobalMessageListener . |
void |
removeInvitationListener(RoomInvitationListener listener)
Removes a
RoomInvitationListener . |
void |
removeMessageFilter(MessageFilter filter)
Removes a
MessageFilter . |
void |
removeSparkTabHandler(SparkTabHandler decorator)
Removes a
ContainerDecorator |
void |
removeTranscriptWindowInterceptor(TranscriptWindowInterceptor interceptor)
Removes a TranscriptWindowInterceptor.
|
void |
removeTypingNotification(ChatRoom chatRoom)
Removes a room from the typing notification list.
|
public static java.awt.Color TO_COLOR
public static java.awt.Color FROM_COLOR
public static java.awt.Color NOTIFICATION_COLOR
public static java.awt.Color ERROR_COLOR
public static java.awt.Color[] COLORS
public static ChatManager getInstance()
ChatManager
,
creating it if necessary.
ChatManager
public void addChatRoomListener(ChatRoomListener listener)
listener
- the ChatRoomListener to addpublic void removeChatRoomListener(ChatRoomListener listener)
listener
- the ChatRoomListener to removepublic void removeChat(ChatRoom chatRoom)
chatRoom
- the ChatRoom to remove.public ChatContainer getChatContainer()
public GroupChatRoom getGroupChat(java.lang.String roomName) throws ChatNotFoundException
roomName
- the name of the chat room.ChatNotFoundException
- thrown if no ChatRoom is found.public ChatRoom createChatRoom(java.lang.String userJID, java.lang.String nickname, java.lang.String title)
userJID
- the jid of the user to chat with.nickname
- the nickname to use for the user.title
- the title to use for the room.ChatRoom
.public ChatRoom getChatRoom(java.lang.String jid)
ChatRoom
for the giving jid. If the ChatRoom is not found,
a new ChatRoom will be created.jid
- the jid of the user to chat with.public ChatRoom createConferenceRoom(java.lang.String roomName, java.lang.String serviceName)
roomName
- the name of the room.serviceName
- the service name to use (ex.conference.jivesoftware.com)public void activateChat(java.lang.String jid, java.lang.String nickname)
jid
- the jid of the user to chat with.nickname
- the nickname of the user.public boolean chatRoomExists(java.lang.String jid)
ChatRoom
exists.jid
- the jid of the user.public void addMessageFilter(MessageFilter filter)
MessageFilter
.filter
- the MessageFilter.public void removeMessageFilter(MessageFilter filter)
MessageFilter
.filter
- the MessageFilter.public java.util.Collection<MessageFilter> getMessageFilters()
public void addGlobalMessageListener(GlobalMessageListener listener)
GlobalMessageListener
.listener
- the listener.public void removeGlobalMessageListener(GlobalMessageListener listener)
GlobalMessageListener
.listener
- the listener.public void fireGlobalMessageReceievedListeners(ChatRoom chatRoom, org.jivesoftware.smack.packet.Message message)
GlobalMessageListeners
of a new incoming message.chatRoom
- the ChatRoom
where the message was sent to.message
- the Message
public void fireGlobalMessageSentListeners(ChatRoom chatRoom, org.jivesoftware.smack.packet.Message message)
GlobalMessageListeners
of a new message sent.chatRoom
- the ChatRoom
where the message was sent from.message
- the Message
sent.public void filterIncomingMessage(ChatRoom room, org.jivesoftware.smack.packet.Message message)
room
- the room the message belongs to.message
- the message to filter.public void filterOutgoingMessage(ChatRoom room, org.jivesoftware.smack.packet.Message message)
MessageFilter
s about a new outgoing message.room
- the ChatRoom
the message belongs too.message
- the Message
being sent.public void addInvitationListener(RoomInvitationListener listener)
RoomInvitationListener
. A RoomInvitationListener islistener
- the listener.public void removeInvitationListener(RoomInvitationListener listener)
RoomInvitationListener
.listener
- the listener to remove.public java.util.Collection<RoomInvitationListener> getInvitationListeners()
RoomInvitationListener
s.public java.lang.String getDefaultConferenceService()
public void addContactItemHandler(ContactItemHandler handler)
ContactItemHandler
.handler
- the ContactItemHandler to add.public void addChatMessageHandler(ChatMessageHandler handler)
public void removeChatMessageHandler(ChatMessageHandler handler)
public void removeContactItemHandler(ContactItemHandler handler)
ContactItemHandler
.handler
- the ContactItemHandler to remove.public void fireMessageReceived(org.jivesoftware.smack.packet.Message message)
public boolean fireContactItemPresenceChanged(ContactItem item, org.jivesoftware.smack.packet.Presence presence)
ContactItemHandler
s of presence changes.item
- the ContactItem where the presence changed.presence
- the new presence.public boolean fireContactItemDoubleClicked(ContactItem item)
ContactItemHandlers
that a ContactItem
was double-clicked.item
- the ContactItem that was double clicked.public javax.swing.Icon getIconForContactHandler(java.lang.String jid)
ContactItemHandler
.jid
- the jid.public javax.swing.Icon getTabIconForContactHandler(org.jivesoftware.smack.packet.Presence presence)
presence
- the presence.public void composingNotification(java.lang.String from)
public void cancelledNotification(java.lang.String from, org.jivesoftware.smackx.chatstates.ChatState state)
public void addTypingNotification(ChatRoom chatRoom)
chatRoom
- the room where the user is typing.public void removeTypingNotification(ChatRoom chatRoom)
chatRoom
- the room to remove.public boolean containsTypingNotification(ChatRoom chatRoom)
ChatRoom
state is in typing mode.chatRoom
- the ChatRoom to check.public boolean isStaleRoom(ChatRoom chatRoom)
chatRoom
- the ChatRoom.public void addTranscriptWindowInterceptor(TranscriptWindowInterceptor interceptor)
interceptor
- the interceptor.public void removeTranscriptWindowInterceptor(TranscriptWindowInterceptor interceptor)
interceptor
- the interceptor.public java.util.Collection<TranscriptWindowInterceptor> getTranscriptWindowInterceptors()
TranscriptWindowInterceptors
.public void addSparkTabHandler(SparkTabHandler decorator)
ContainerDecorator
. The ContainerDecorator will be added to the top of the stack and will therefore
take priority on notification calls. If all decorators return false, the DefaultChatRoomDecorator
will be used.decorator
- the decorator to add.public void removeSparkTabHandler(SparkTabHandler decorator)
ContainerDecorator
decorator
- the decorator to remove.public void notifySparkTabHandlers(java.awt.Component component)
ContainerDecorator
component
- the component within the tab.public java.util.Collection<ContactItem> getSelectedContactItems()
ContactList
.ContactItem
in the ContactList.public void handleURIMapping(java.lang.String arguments)
arguments
- the arguments passed into Spark.public void chatCreated(org.jivesoftware.smack.chat.Chat chat, boolean isLocal)
chatCreated
in interface org.jivesoftware.smack.chat.ChatManagerListener