mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 18:29:45 +02:00
Deprecate Chat API, introduce new Chat API
Also add (From|To)TypeFilter and update/fix the documentation in a few places.
This commit is contained in:
parent
b0fef6ffcb
commit
d47463a533
22 changed files with 612 additions and 113 deletions
|
@ -36,7 +36,9 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
* sender.
|
||||
*
|
||||
* @author Matt Tucker
|
||||
* @deprecated use <code>org.jivesoftware.smack.chat2.Chat</code> from <code>smack-extensions</code> instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class Chat {
|
||||
|
||||
private ChatManager chatManager;
|
||||
|
|
|
@ -52,7 +52,9 @@ import org.jxmpp.jid.EntityJid;
|
|||
* made aware of new chats, register a listener by calling {@link #addChatListener(ChatManagerListener)}.
|
||||
*
|
||||
* @author Alexander Wenckus
|
||||
* @deprecated use <code>org.jivesoftware.smack.chat2.ChatManager</code> from <code>smack-extensions</code> instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class ChatManager extends Manager{
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ChatManager.class.getName());
|
||||
|
|
|
@ -30,5 +30,6 @@ public interface ChatManagerListener {
|
|||
* @param chat the chat that was created.
|
||||
* @param createdLocally true if the chat was created by the local user and false if it wasn't.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
void chatCreated(Chat chat, boolean createdLocally);
|
||||
}
|
||||
|
|
|
@ -20,5 +20,6 @@ package org.jivesoftware.smack.chat;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
|
||||
public interface ChatMessageListener {
|
||||
@SuppressWarnings("deprecation")
|
||||
void processMessage(Chat chat, Message message);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.chat.ChatManager.MatchMode;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Message.Type;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -35,6 +34,7 @@ import org.junit.Test;
|
|||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ChatConnectionTest {
|
||||
|
||||
private DummyConnection dc;
|
||||
|
@ -46,7 +46,7 @@ public class ChatConnectionTest {
|
|||
public void setUp() throws Exception {
|
||||
// Defaults
|
||||
ChatManager.setDefaultIsNormalIncluded(true);
|
||||
ChatManager.setDefaultMatchMode(MatchMode.BARE_JID);
|
||||
ChatManager.setDefaultMatchMode(ChatManager.MatchMode.BARE_JID);
|
||||
|
||||
dc = DummyConnection.newConnectedDummyConnection();
|
||||
cm = ChatManager.getInstanceFor(dc);
|
||||
|
@ -77,14 +77,14 @@ public class ChatConnectionTest {
|
|||
|
||||
@Test
|
||||
public void validateDefaultSetMatchModeNone() {
|
||||
ChatManager.setDefaultMatchMode(MatchMode.NONE);
|
||||
assertEquals(MatchMode.NONE, ChatManager.getInstanceFor(new DummyConnection()).getMatchMode());
|
||||
ChatManager.setDefaultMatchMode(ChatManager.MatchMode.NONE);
|
||||
assertEquals(ChatManager.MatchMode.NONE, ChatManager.getInstanceFor(new DummyConnection()).getMatchMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateDefaultSetMatchModeEntityBareJid() {
|
||||
ChatManager.setDefaultMatchMode(MatchMode.BARE_JID);
|
||||
assertEquals(MatchMode.BARE_JID, ChatManager.getInstanceFor(new DummyConnection()).getMatchMode());
|
||||
ChatManager.setDefaultMatchMode(ChatManager.MatchMode.BARE_JID);
|
||||
assertEquals(ChatManager.MatchMode.BARE_JID, ChatManager.getInstanceFor(new DummyConnection()).getMatchMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -138,7 +138,7 @@ public class ChatConnectionTest {
|
|||
// No thread behaviour
|
||||
@Test
|
||||
public void chatMatchedOnJIDWhenNoThreadBareMode() {
|
||||
// MatchMode.BARE_JID is the default, so setting required.
|
||||
// ChatManager.MatchMode.BARE_JID is the default, so setting required.
|
||||
TestMessageListener msgListener = new TestMessageListener();
|
||||
TestChatManagerListener listener = new TestChatManagerListener(msgListener);
|
||||
cm.addChatListener(listener);
|
||||
|
@ -162,7 +162,7 @@ public class ChatConnectionTest {
|
|||
public void chatMatchedOnJIDWhenNoThreadJidMode() {
|
||||
TestMessageListener msgListener = new TestMessageListener();
|
||||
TestChatManagerListener listener = new TestChatManagerListener(msgListener);
|
||||
cm.setMatchMode(MatchMode.SUPPLIED_JID);
|
||||
cm.setMatchMode(ChatManager.MatchMode.SUPPLIED_JID);
|
||||
cm.addChatListener(listener);
|
||||
Stanza incomingChat = createChatPacket(null, true);
|
||||
processServerMessage(incomingChat);
|
||||
|
@ -188,7 +188,7 @@ public class ChatConnectionTest {
|
|||
public void chatMatchedOnJIDWhenNoThreadNoneMode() {
|
||||
TestMessageListener msgListener = new TestMessageListener();
|
||||
TestChatManagerListener listener = new TestChatManagerListener(msgListener);
|
||||
cm.setMatchMode(MatchMode.NONE);
|
||||
cm.setMatchMode(ChatManager.MatchMode.NONE);
|
||||
cm.addChatListener(listener);
|
||||
Stanza incomingChat = createChatPacket(null, true);
|
||||
processServerMessage(incomingChat);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue