add models for Chat States + manager
This commit is contained in:
parent
bed6b07bdd
commit
ca0a0c07fc
|
@ -9,6 +9,7 @@ import im.conversations.android.xmpp.manager.AxolotlManager;
|
|||
import im.conversations.android.xmpp.manager.BlockingManager;
|
||||
import im.conversations.android.xmpp.manager.BookmarkManager;
|
||||
import im.conversations.android.xmpp.manager.CarbonsManager;
|
||||
import im.conversations.android.xmpp.manager.ChatStateManager;
|
||||
import im.conversations.android.xmpp.manager.DiscoManager;
|
||||
import im.conversations.android.xmpp.manager.NickManager;
|
||||
import im.conversations.android.xmpp.manager.PepManager;
|
||||
|
@ -29,6 +30,7 @@ public final class Managers {
|
|||
.put(BlockingManager.class, new BlockingManager(context, connection))
|
||||
.put(BookmarkManager.class, new BookmarkManager(context, connection))
|
||||
.put(CarbonsManager.class, new CarbonsManager(context, connection))
|
||||
.put(ChatStateManager.class, new ChatStateManager(context, connection))
|
||||
.put(DiscoManager.class, new DiscoManager(context, connection))
|
||||
.put(NickManager.class, new NickManager(context, connection))
|
||||
.put(PepManager.class, new PepManager(context, connection))
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package im.conversations.android.xmpp.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.siacs.conversations.xmpp.Jid;
|
||||
import im.conversations.android.xmpp.XmppConnection;
|
||||
import im.conversations.android.xmpp.model.state.ChatStateNotification;
|
||||
|
||||
public class ChatStateManager extends AbstractManager{
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ChatStateManager.class);
|
||||
|
||||
public ChatStateManager(Context context, XmppConnection connection) {
|
||||
super(context, connection);
|
||||
}
|
||||
|
||||
public void handle(final Jid from, final ChatStateNotification chatState) {
|
||||
LOGGER.info("Received {} from {}", chatState, from);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package im.conversations.android.xmpp.model.state;
|
||||
|
||||
import im.conversations.android.annotation.XmlElement;
|
||||
|
||||
@XmlElement
|
||||
public class Active extends ChatStateNotification {
|
||||
|
||||
protected Active() {
|
||||
super(Active.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package im.conversations.android.xmpp.model.state;
|
||||
|
||||
import im.conversations.android.xmpp.model.Extension;
|
||||
|
||||
public abstract class ChatStateNotification extends Extension {
|
||||
|
||||
protected ChatStateNotification(Class<? extends Extension> clazz) {
|
||||
super(clazz);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package im.conversations.android.xmpp.model.state;
|
||||
|
||||
import im.conversations.android.annotation.XmlElement;
|
||||
|
||||
@XmlElement
|
||||
public class Composing extends ChatStateNotification {
|
||||
|
||||
protected Composing() {
|
||||
super(Composing.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package im.conversations.android.xmpp.model.state;
|
||||
|
||||
import im.conversations.android.annotation.XmlElement;
|
||||
|
||||
@XmlElement
|
||||
public class Gone extends ChatStateNotification {
|
||||
|
||||
protected Gone() {
|
||||
super(Gone.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package im.conversations.android.xmpp.model.state;
|
||||
|
||||
import im.conversations.android.annotation.XmlElement;
|
||||
|
||||
@XmlElement
|
||||
public class Inactive extends ChatStateNotification {
|
||||
|
||||
protected Inactive() {
|
||||
super(Inactive.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package im.conversations.android.xmpp.model.state;
|
||||
|
||||
import im.conversations.android.annotation.XmlElement;
|
||||
|
||||
@XmlElement
|
||||
public class Paused extends ChatStateNotification {
|
||||
|
||||
protected Paused() {
|
||||
super(Paused.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
@XmlPackage(namespace = Namespace.CHAT_STATES)
|
||||
package im.conversations.android.xmpp.model.state;
|
||||
|
||||
import eu.siacs.conversations.xml.Namespace;
|
||||
import im.conversations.android.annotation.XmlPackage;
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import eu.siacs.conversations.xmpp.Jid;
|
||||
import im.conversations.android.xmpp.XmppConnection;
|
||||
import im.conversations.android.xmpp.manager.CarbonsManager;
|
||||
import im.conversations.android.xmpp.manager.ChatStateManager;
|
||||
import im.conversations.android.xmpp.manager.PubSubManager;
|
||||
import im.conversations.android.xmpp.manager.ReceiptManager;
|
||||
import im.conversations.android.xmpp.model.DeliveryReceiptRequest;
|
||||
|
@ -11,6 +12,8 @@ import im.conversations.android.xmpp.model.carbons.Received;
|
|||
import im.conversations.android.xmpp.model.carbons.Sent;
|
||||
import im.conversations.android.xmpp.model.pubsub.event.Event;
|
||||
import im.conversations.android.xmpp.model.stanza.Message;
|
||||
import im.conversations.android.xmpp.model.state.ChatStateNotification;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -58,6 +61,10 @@ public class MessageProcessor extends XmppConnection.Delegate implements Consume
|
|||
if (isRealtimeProcessor()) {
|
||||
final var requests = message.getExtensions(DeliveryReceiptRequest.class);
|
||||
getManager(ReceiptManager.class).received(from, id, requests);
|
||||
final var chatState = message.getExtension(ChatStateNotification.class);
|
||||
if (chatState != null) {
|
||||
getManager(ChatStateManager.class).handle(from, chatState);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO parse chat states
|
||||
|
|
Loading…
Reference in a new issue