2006-11-22 23:55:37 +01:00
|
|
|
/**
|
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2006-11-23 02:51:00 +01:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2006-11-23 02:51:00 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2006-11-22 23:55:37 +01:00
|
|
|
*/
|
2006-11-23 02:51:00 +01:00
|
|
|
|
2015-01-22 13:53:50 +01:00
|
|
|
package org.jivesoftware.smack.chat;
|
2006-11-22 23:55:37 +01:00
|
|
|
|
2011-03-14 02:53:42 +01:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
2014-02-01 23:22:30 +01:00
|
|
|
import java.util.UUID;
|
2011-03-14 02:53:42 +01:00
|
|
|
import java.util.WeakHashMap;
|
2014-12-27 13:38:41 +01:00
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
2011-03-14 02:53:42 +01:00
|
|
|
import java.util.concurrent.CopyOnWriteArraySet;
|
|
|
|
|
2015-01-22 13:53:50 +01:00
|
|
|
import org.jivesoftware.smack.Manager;
|
|
|
|
import org.jivesoftware.smack.MessageListener;
|
|
|
|
import org.jivesoftware.smack.PacketCollector;
|
2015-03-01 10:28:15 +01:00
|
|
|
import org.jivesoftware.smack.StanzaListener;
|
2015-01-22 13:53:50 +01:00
|
|
|
import org.jivesoftware.smack.XMPPConnection;
|
2014-03-19 14:22:20 +01:00
|
|
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
2006-12-05 08:46:29 +01:00
|
|
|
import org.jivesoftware.smack.filter.AndFilter;
|
2015-02-26 18:41:17 +01:00
|
|
|
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
|
2014-03-05 00:00:02 +01:00
|
|
|
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
2014-05-29 16:05:20 +02:00
|
|
|
import org.jivesoftware.smack.filter.MessageTypeFilter;
|
|
|
|
import org.jivesoftware.smack.filter.OrFilter;
|
2015-02-26 18:41:17 +01:00
|
|
|
import org.jivesoftware.smack.filter.StanzaFilter;
|
2006-12-05 08:46:29 +01:00
|
|
|
import org.jivesoftware.smack.filter.ThreadFilter;
|
2006-11-22 23:55:37 +01:00
|
|
|
import org.jivesoftware.smack.packet.Message;
|
2014-02-01 23:22:30 +01:00
|
|
|
import org.jivesoftware.smack.packet.Message.Type;
|
2015-02-05 11:17:27 +01:00
|
|
|
import org.jivesoftware.smack.packet.Stanza;
|
2014-06-01 12:23:13 +02:00
|
|
|
import org.jxmpp.util.XmppStringUtils;
|
2006-11-22 23:55:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The chat manager keeps track of references to all current chats. It will not hold any references
|
2014-02-01 23:22:30 +01:00
|
|
|
* in memory on its own so it is necessary to keep a reference to the chat object itself. To be
|
2006-11-23 02:51:00 +01:00
|
|
|
* made aware of new chats, register a listener by calling {@link #addChatListener(ChatManagerListener)}.
|
2006-11-22 23:55:37 +01:00
|
|
|
*
|
|
|
|
* @author Alexander Wenckus
|
|
|
|
*/
|
2014-03-17 20:46:08 +01:00
|
|
|
public class ChatManager extends Manager{
|
|
|
|
private static final Map<XMPPConnection, ChatManager> INSTANCES = new WeakHashMap<XMPPConnection, ChatManager>();
|
|
|
|
|
2014-03-10 21:48:46 +01:00
|
|
|
/**
|
2014-02-01 23:22:30 +01:00
|
|
|
* Sets the default behaviour for allowing 'normal' messages to be used in chats. As some clients don't set
|
|
|
|
* the message type to chat, the type normal has to be accepted to allow chats with these clients.
|
|
|
|
*/
|
|
|
|
private static boolean defaultIsNormalInclude = true;
|
2014-03-10 21:48:46 +01:00
|
|
|
|
|
|
|
/**
|
2014-02-01 23:22:30 +01:00
|
|
|
* Sets the default behaviour for how to match chats when there is NO thread id in the incoming message.
|
|
|
|
*/
|
|
|
|
private static MatchMode defaultMatchMode = MatchMode.BARE_JID;
|
2014-03-10 21:48:46 +01:00
|
|
|
|
2014-03-17 20:46:08 +01:00
|
|
|
/**
|
|
|
|
* Returns the ChatManager instance associated with a given XMPPConnection.
|
|
|
|
*
|
|
|
|
* @param connection the connection used to look for the proper ServiceDiscoveryManager.
|
|
|
|
* @return the ChatManager associated with a given XMPPConnection.
|
|
|
|
*/
|
|
|
|
public static synchronized ChatManager getInstanceFor(XMPPConnection connection) {
|
|
|
|
ChatManager manager = INSTANCES.get(connection);
|
|
|
|
if (manager == null)
|
|
|
|
manager = new ChatManager(connection);
|
|
|
|
return manager;
|
|
|
|
}
|
|
|
|
|
2006-11-22 23:55:37 +01:00
|
|
|
/**
|
2014-02-01 23:22:30 +01:00
|
|
|
* Defines the different modes under which a match will be attempted with an existing chat when
|
|
|
|
* the incoming message does not have a thread id.
|
2006-11-22 23:55:37 +01:00
|
|
|
*/
|
2014-02-01 23:22:30 +01:00
|
|
|
public enum MatchMode {
|
|
|
|
/**
|
|
|
|
* Will not attempt to match, always creates a new chat.
|
|
|
|
*/
|
|
|
|
NONE,
|
|
|
|
/**
|
|
|
|
* Will match on the JID in the from field of the message.
|
|
|
|
*/
|
|
|
|
SUPPLIED_JID,
|
|
|
|
/**
|
|
|
|
* Will attempt to match on the JID in the from field, and then attempt the base JID if no match was found.
|
|
|
|
* This is the most lenient matching.
|
|
|
|
*/
|
|
|
|
BARE_JID;
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|
2014-05-29 16:05:20 +02:00
|
|
|
|
2015-02-26 18:41:17 +01:00
|
|
|
private final StanzaFilter packetFilter = new OrFilter(MessageTypeFilter.CHAT, new FlexibleStanzaTypeFilter<Message>() {
|
2014-05-29 16:05:20 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean acceptSpecific(Message message) {
|
|
|
|
return normalIncluded ? message.getType() == Type.normal : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-03-10 21:48:46 +01:00
|
|
|
/**
|
2014-02-01 23:22:30 +01:00
|
|
|
* Determines whether incoming messages of type normal can create chats.
|
2006-11-22 23:55:37 +01:00
|
|
|
*/
|
2014-02-01 23:22:30 +01:00
|
|
|
private boolean normalIncluded = defaultIsNormalInclude;
|
2014-03-10 21:48:46 +01:00
|
|
|
|
|
|
|
/**
|
2014-02-01 23:22:30 +01:00
|
|
|
* Determines how incoming message with no thread will be matched to existing chats.
|
2006-11-22 23:55:37 +01:00
|
|
|
*/
|
2014-02-01 23:22:30 +01:00
|
|
|
private MatchMode matchMode = defaultMatchMode;
|
2014-03-10 21:48:46 +01:00
|
|
|
|
2006-11-22 23:55:37 +01:00
|
|
|
/**
|
|
|
|
* Maps thread ID to chat.
|
|
|
|
*/
|
2014-12-27 13:38:41 +01:00
|
|
|
private Map<String, Chat> threadChats = new ConcurrentHashMap<>();
|
2006-11-22 23:55:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps jids to chats
|
|
|
|
*/
|
2014-12-27 13:38:41 +01:00
|
|
|
private Map<String, Chat> jidChats = new ConcurrentHashMap<>();
|
2011-03-14 02:53:42 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps base jids to chats
|
|
|
|
*/
|
2014-12-27 13:38:41 +01:00
|
|
|
private Map<String, Chat> baseJidChats = new ConcurrentHashMap<>();
|
2006-11-22 23:55:37 +01:00
|
|
|
|
2006-11-23 22:10:59 +01:00
|
|
|
private Set<ChatManagerListener> chatManagerListeners
|
|
|
|
= new CopyOnWriteArraySet<ChatManagerListener>();
|
|
|
|
|
2015-02-26 18:41:17 +01:00
|
|
|
private Map<MessageListener, StanzaFilter> interceptors
|
|
|
|
= new WeakHashMap<MessageListener, StanzaFilter>();
|
2006-11-22 23:55:37 +01:00
|
|
|
|
2014-03-17 20:46:08 +01:00
|
|
|
private ChatManager(XMPPConnection connection) {
|
|
|
|
super(connection);
|
2006-11-22 23:55:37 +01:00
|
|
|
|
2014-02-01 23:22:30 +01:00
|
|
|
// Add a listener for all message packets so that we can deliver
|
2006-11-22 23:55:37 +01:00
|
|
|
// messages to the best Chat instance available.
|
2015-03-01 10:28:15 +01:00
|
|
|
connection.addSyncStanzaListener(new StanzaListener() {
|
2015-02-05 11:17:27 +01:00
|
|
|
public void processPacket(Stanza packet) {
|
2006-11-22 23:55:37 +01:00
|
|
|
Message message = (Message) packet;
|
|
|
|
Chat chat;
|
|
|
|
if (message.getThread() == null) {
|
2010-01-12 00:32:21 +01:00
|
|
|
chat = getUserChat(message.getFrom());
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
chat = getThreadChat(message.getThread());
|
|
|
|
}
|
|
|
|
|
|
|
|
if(chat == null) {
|
|
|
|
chat = createChat(message);
|
|
|
|
}
|
2014-03-18 08:44:03 +01:00
|
|
|
// The chat could not be created, abort here
|
|
|
|
if (chat == null)
|
|
|
|
return;
|
2006-11-22 23:55:37 +01:00
|
|
|
deliverMessage(chat, message);
|
|
|
|
}
|
2014-05-29 16:05:20 +02:00
|
|
|
}, packetFilter);
|
2014-03-17 20:46:08 +01:00
|
|
|
INSTANCES.put(connection, this);
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|
|
|
|
|
2014-02-01 23:22:30 +01:00
|
|
|
/**
|
|
|
|
* Determines whether incoming messages of type <i>normal</i> will be used for creating new chats or matching
|
|
|
|
* a message to existing ones.
|
|
|
|
*
|
|
|
|
* @return true if normal is allowed, false otherwise.
|
|
|
|
*/
|
|
|
|
public boolean isNormalIncluded() {
|
|
|
|
return normalIncluded;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether to allow incoming messages of type <i>normal</i> to be used for creating new chats or matching
|
|
|
|
* a message to an existing one.
|
|
|
|
*
|
|
|
|
* @param normalIncluded true to allow normal, false otherwise.
|
|
|
|
*/
|
|
|
|
public void setNormalIncluded(boolean normalIncluded) {
|
|
|
|
this.normalIncluded = normalIncluded;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the current mode for matching messages with <b>NO</b> thread id to existing chats.
|
|
|
|
*
|
|
|
|
* @return The current mode.
|
|
|
|
*/
|
|
|
|
public MatchMode getMatchMode() {
|
|
|
|
return matchMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the mode for matching messages with <b>NO</b> thread id to existing chats.
|
|
|
|
*
|
|
|
|
* @param matchMode The mode to set.
|
|
|
|
*/
|
|
|
|
public void setMatchMode(MatchMode matchMode) {
|
|
|
|
this.matchMode = matchMode;
|
|
|
|
}
|
|
|
|
|
2006-11-22 23:55:37 +01:00
|
|
|
/**
|
|
|
|
* Creates a new chat and returns it.
|
|
|
|
*
|
|
|
|
* @param userJID the user this chat is with.
|
2014-12-30 19:55:15 +01:00
|
|
|
* @return the created chat.
|
|
|
|
*/
|
|
|
|
public Chat createChat(String userJID) {
|
|
|
|
return createChat(userJID, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new chat and returns it.
|
|
|
|
*
|
|
|
|
* @param userJID the user this chat is with.
|
|
|
|
* @param listener the optional listener which will listen for new messages from this chat.
|
2006-11-22 23:55:37 +01:00
|
|
|
* @return the created chat.
|
|
|
|
*/
|
2014-10-12 18:01:19 +02:00
|
|
|
public Chat createChat(String userJID, ChatMessageListener listener) {
|
2014-02-01 23:22:30 +01:00
|
|
|
return createChat(userJID, null, listener);
|
2006-11-28 19:46:40 +01:00
|
|
|
}
|
2006-11-22 23:55:37 +01:00
|
|
|
|
2006-11-28 19:46:40 +01:00
|
|
|
/**
|
|
|
|
* Creates a new chat using the specified thread ID, then returns it.
|
|
|
|
*
|
|
|
|
* @param userJID the jid of the user this chat is with
|
|
|
|
* @param thread the thread of the created chat.
|
2014-12-30 19:55:15 +01:00
|
|
|
* @param listener the optional listener to add to the chat
|
2006-11-28 19:46:40 +01:00
|
|
|
* @return the created chat.
|
|
|
|
*/
|
2014-10-12 18:01:19 +02:00
|
|
|
public Chat createChat(String userJID, String thread, ChatMessageListener listener) {
|
2014-02-01 23:22:30 +01:00
|
|
|
if (thread == null) {
|
2007-03-09 18:27:20 +01:00
|
|
|
thread = nextID();
|
|
|
|
}
|
2006-11-28 19:46:40 +01:00
|
|
|
Chat chat = threadChats.get(thread);
|
|
|
|
if(chat != null) {
|
|
|
|
throw new IllegalArgumentException("ThreadID is already used");
|
|
|
|
}
|
|
|
|
chat = createChat(userJID, thread, true);
|
|
|
|
chat.addMessageListener(listener);
|
2006-11-22 23:55:37 +01:00
|
|
|
return chat;
|
|
|
|
}
|
|
|
|
|
|
|
|
private Chat createChat(String userJID, String threadID, boolean createdLocally) {
|
|
|
|
Chat chat = new Chat(this, userJID, threadID);
|
|
|
|
threadChats.put(threadID, chat);
|
|
|
|
jidChats.put(userJID, chat);
|
2014-11-02 12:12:56 +01:00
|
|
|
baseJidChats.put(XmppStringUtils.parseBareJid(userJID), chat);
|
2006-11-22 23:55:37 +01:00
|
|
|
|
2006-11-23 02:51:00 +01:00
|
|
|
for(ChatManagerListener listener : chatManagerListeners) {
|
2006-11-22 23:55:37 +01:00
|
|
|
listener.chatCreated(chat, createdLocally);
|
|
|
|
}
|
|
|
|
|
|
|
|
return chat;
|
|
|
|
}
|
|
|
|
|
2014-03-17 09:14:17 +01:00
|
|
|
void closeChat(Chat chat) {
|
|
|
|
threadChats.remove(chat.getThreadID());
|
|
|
|
String userJID = chat.getParticipant();
|
|
|
|
jidChats.remove(userJID);
|
2014-11-02 12:12:56 +01:00
|
|
|
baseJidChats.remove(XmppStringUtils.parseBareJid(userJID));
|
2014-03-17 09:14:17 +01:00
|
|
|
}
|
|
|
|
|
2014-03-18 08:44:03 +01:00
|
|
|
/**
|
|
|
|
* Creates a new {@link Chat} based on the message. May returns null if no chat could be
|
|
|
|
* created, e.g. because the message comes without from.
|
|
|
|
*
|
|
|
|
* @param message
|
|
|
|
* @return a Chat or null if none can be created
|
|
|
|
*/
|
2006-11-22 23:55:37 +01:00
|
|
|
private Chat createChat(Message message) {
|
2014-03-18 08:44:03 +01:00
|
|
|
String userJID = message.getFrom();
|
|
|
|
// According to RFC6120 8.1.2.1 4. messages without a 'from' attribute are valid, but they
|
|
|
|
// are of no use in this case for ChatManager
|
|
|
|
if (userJID == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2006-11-22 23:55:37 +01:00
|
|
|
String threadID = message.getThread();
|
2007-03-09 18:27:20 +01:00
|
|
|
if(threadID == null) {
|
|
|
|
threadID = nextID();
|
|
|
|
}
|
2006-11-22 23:55:37 +01:00
|
|
|
|
|
|
|
return createChat(userJID, threadID, false);
|
|
|
|
}
|
|
|
|
|
2011-03-14 02:53:42 +01:00
|
|
|
/**
|
2014-02-01 23:22:30 +01:00
|
|
|
* Try to get a matching chat for the given user JID, based on the {@link MatchMode}.
|
|
|
|
* <li>NONE - return null
|
|
|
|
* <li>SUPPLIED_JID - match the jid in the from field of the message exactly.
|
|
|
|
* <li>BARE_JID - if not match for from field, try the bare jid.
|
2011-03-14 02:53:42 +01:00
|
|
|
*
|
2014-02-01 23:22:30 +01:00
|
|
|
* @param userJID jid in the from field of message.
|
|
|
|
* @return Matching chat, or null if no match found.
|
2011-03-14 02:53:42 +01:00
|
|
|
*/
|
2006-11-22 23:55:37 +01:00
|
|
|
private Chat getUserChat(String userJID) {
|
2014-02-01 23:22:30 +01:00
|
|
|
if (matchMode == MatchMode.NONE) {
|
|
|
|
return null;
|
|
|
|
}
|
2014-03-18 08:44:03 +01:00
|
|
|
// According to RFC6120 8.1.2.1 4. messages without a 'from' attribute are valid, but they
|
|
|
|
// are of no use in this case for ChatManager
|
|
|
|
if (userJID == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2014-02-01 23:22:30 +01:00
|
|
|
Chat match = jidChats.get(userJID);
|
2011-03-14 02:53:42 +01:00
|
|
|
|
2014-02-01 23:22:30 +01:00
|
|
|
if (match == null && (matchMode == MatchMode.BARE_JID)) {
|
2014-11-02 12:12:56 +01:00
|
|
|
match = baseJidChats.get(XmppStringUtils.parseBareJid(userJID));
|
2014-02-01 23:22:30 +01:00
|
|
|
}
|
|
|
|
return match;
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|
|
|
|
|
2007-01-17 20:36:45 +01:00
|
|
|
public Chat getThreadChat(String thread) {
|
2006-11-22 23:55:37 +01:00
|
|
|
return threadChats.get(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a new listener with the ChatManager to recieve events related to chats.
|
|
|
|
*
|
|
|
|
* @param listener the listener.
|
|
|
|
*/
|
2006-11-23 02:51:00 +01:00
|
|
|
public void addChatListener(ChatManagerListener listener) {
|
|
|
|
chatManagerListeners.add(listener);
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a listener, it will no longer be notified of new events related to chats.
|
|
|
|
*
|
|
|
|
* @param listener the listener that is being removed
|
|
|
|
*/
|
2006-11-23 02:51:00 +01:00
|
|
|
public void removeChatListener(ChatManagerListener listener) {
|
|
|
|
chatManagerListeners.remove(listener);
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-29 13:36:56 +01:00
|
|
|
* Returns an unmodifiable set of all chat listeners currently registered with this
|
2006-11-22 23:55:37 +01:00
|
|
|
* manager.
|
|
|
|
*
|
|
|
|
* @return an unmodifiable collection of all chat listeners currently registered with this
|
|
|
|
* manager.
|
|
|
|
*/
|
2014-11-29 13:36:56 +01:00
|
|
|
public Set<ChatManagerListener> getChatListeners() {
|
|
|
|
return Collections.unmodifiableSet(chatManagerListeners);
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void deliverMessage(Chat chat, Message message) {
|
|
|
|
// Here we will run any interceptors
|
|
|
|
chat.deliver(message);
|
|
|
|
}
|
|
|
|
|
2014-03-19 14:22:20 +01:00
|
|
|
void sendMessage(Chat chat, Message message) throws NotConnectedException {
|
2015-02-26 18:41:17 +01:00
|
|
|
for(Map.Entry<MessageListener, StanzaFilter> interceptor : interceptors.entrySet()) {
|
|
|
|
StanzaFilter filter = interceptor.getValue();
|
2006-11-23 22:10:59 +01:00
|
|
|
if(filter != null && filter.accept(message)) {
|
2014-10-12 19:19:44 +02:00
|
|
|
interceptor.getKey().processMessage(message);
|
2006-11-23 22:10:59 +01:00
|
|
|
}
|
|
|
|
}
|
2006-12-05 08:46:29 +01:00
|
|
|
// Ensure that messages being sent have a proper FROM value
|
|
|
|
if (message.getFrom() == null) {
|
2014-03-17 20:46:08 +01:00
|
|
|
message.setFrom(connection().getUser());
|
2006-12-05 08:46:29 +01:00
|
|
|
}
|
2015-03-04 21:44:43 +01:00
|
|
|
connection().sendStanza(message);
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PacketCollector createPacketCollector(Chat chat) {
|
2014-03-17 20:46:08 +01:00
|
|
|
return connection().createPacketCollector(new AndFilter(new ThreadFilter(chat.getThreadID()),
|
2014-03-06 21:05:49 +01:00
|
|
|
FromMatchesFilter.create(chat.getParticipant())));
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|
|
|
|
|
2006-11-23 22:10:59 +01:00
|
|
|
/**
|
|
|
|
* Adds an interceptor which intercepts any messages sent through chats.
|
|
|
|
*
|
2014-10-12 19:19:44 +02:00
|
|
|
* @param messageInterceptor the interceptor.
|
2006-11-23 22:10:59 +01:00
|
|
|
*/
|
2014-10-12 19:19:44 +02:00
|
|
|
public void addOutgoingMessageInterceptor(MessageListener messageInterceptor) {
|
|
|
|
addOutgoingMessageInterceptor(messageInterceptor, null);
|
2006-11-23 22:10:59 +01:00
|
|
|
}
|
|
|
|
|
2015-02-26 18:41:17 +01:00
|
|
|
public void addOutgoingMessageInterceptor(MessageListener messageInterceptor, StanzaFilter filter) {
|
2014-10-12 19:19:44 +02:00
|
|
|
if (messageInterceptor == null) {
|
|
|
|
return;
|
2006-11-23 22:10:59 +01:00
|
|
|
}
|
2014-10-12 19:19:44 +02:00
|
|
|
interceptors.put(messageInterceptor, filter);
|
2006-11-23 22:10:59 +01:00
|
|
|
}
|
2014-02-01 23:22:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a unique id.
|
|
|
|
*
|
|
|
|
* @return the next id.
|
|
|
|
*/
|
|
|
|
private static String nextID() {
|
|
|
|
return UUID.randomUUID().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setDefaultMatchMode(MatchMode mode) {
|
|
|
|
defaultMatchMode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setDefaultIsNormalIncluded(boolean allowNormal) {
|
|
|
|
defaultIsNormalInclude = allowNormal;
|
|
|
|
}
|
2006-11-22 23:55:37 +01:00
|
|
|
}
|