mirror of
https://github.com/ChronosX88/Influence.git
synced 2024-11-23 10:02:18 +00:00
Added presence control, MAM for all messages
This commit is contained in:
parent
2a29188fed
commit
0168cc5ad8
@ -82,6 +82,7 @@ dependencies {
|
|||||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||||
implementation 'net.sourceforge.streamsupport:android-retrofuture:1.7.0'
|
implementation 'net.sourceforge.streamsupport:android-retrofuture:1.7.0'
|
||||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||||
|
implementation 'org.igniterealtime.smack:smack-experimental:4.3.3'
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -31,10 +31,12 @@ import org.jivesoftware.smack.XMPPException;
|
|||||||
import org.jivesoftware.smack.chat2.Chat;
|
import org.jivesoftware.smack.chat2.Chat;
|
||||||
import org.jivesoftware.smack.chat2.ChatManager;
|
import org.jivesoftware.smack.chat2.ChatManager;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
import org.jivesoftware.smack.roster.Roster;
|
import org.jivesoftware.smack.roster.Roster;
|
||||||
import org.jivesoftware.smack.roster.RosterEntry;
|
import org.jivesoftware.smack.roster.RosterEntry;
|
||||||
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
||||||
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
|
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
|
||||||
|
import org.jivesoftware.smackx.mam.MamManager;
|
||||||
import org.jivesoftware.smackx.vcardtemp.VCardManager;
|
import org.jivesoftware.smackx.vcardtemp.VCardManager;
|
||||||
import org.jxmpp.jid.EntityBareJid;
|
import org.jxmpp.jid.EntityBareJid;
|
||||||
|
|
||||||
@ -53,6 +55,7 @@ public class XMPPConnection implements ConnectionListener {
|
|||||||
private NetworkHandler networkHandler;
|
private NetworkHandler networkHandler;
|
||||||
private Context context;
|
private Context context;
|
||||||
private Roster roster;
|
private Roster roster;
|
||||||
|
private MamManager mamManager;
|
||||||
|
|
||||||
public enum ConnectionState {
|
public enum ConnectionState {
|
||||||
CONNECTED,
|
CONNECTED,
|
||||||
@ -113,6 +116,16 @@ public class XMPPConnection implements ConnectionListener {
|
|||||||
ReconnectionManager.setEnabledPerDefault(true);
|
ReconnectionManager.setEnabledPerDefault(true);
|
||||||
reconnectionManager.enableAutomaticReconnection();
|
reconnectionManager.enableAutomaticReconnection();
|
||||||
roster = roster.getInstanceFor(connection);
|
roster = roster.getInstanceFor(connection);
|
||||||
|
roster.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
|
||||||
|
mamManager = MamManager.getInstanceFor(connection);
|
||||||
|
try {
|
||||||
|
if(mamManager.isSupported()) {
|
||||||
|
MamManager.getInstanceFor(connection).enableMamForAllMessages();
|
||||||
|
}
|
||||||
|
connection.sendStanza(new Presence(Presence.Type.available));
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import android.os.Looper;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -74,6 +75,13 @@ public class XMPPConnectionService extends Service {
|
|||||||
if(connection != null) {
|
if(connection != null) {
|
||||||
thread.interrupt();
|
thread.interrupt();
|
||||||
thread = null;
|
thread = null;
|
||||||
|
try {
|
||||||
|
connection.getConnection().sendStanza(new Presence(Presence.Type.unavailable));
|
||||||
|
} catch (SmackException.NotConnectedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
connection = null;
|
connection = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user