track offline message queue
This commit is contained in:
parent
ef5508e5b1
commit
32da5853d7
|
@ -371,14 +371,19 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
final boolean flexible = account.getXmppConnection().getFeatures().flexibleOfflineMessageRetrieval();
|
final boolean flexible = account.getXmppConnection().getFeatures().flexibleOfflineMessageRetrieval();
|
||||||
final boolean catchup = getMessageArchiveService().inCatchup(account);
|
final boolean catchup = getMessageArchiveService().inCatchup(account);
|
||||||
|
final boolean trackOfflineMessageRetrieval;
|
||||||
if (flexible && catchup && account.getXmppConnection().isMamPreferenceAlways()) {
|
if (flexible && catchup && account.getXmppConnection().isMamPreferenceAlways()) {
|
||||||
|
trackOfflineMessageRetrieval = false;
|
||||||
sendIqPacket(account, mIqGenerator.purgeOfflineMessages(), (acc, packet) -> {
|
sendIqPacket(account, mIqGenerator.purgeOfflineMessages(), (acc, packet) -> {
|
||||||
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
Log.d(Config.LOGTAG, acc.getJid().asBareJid() + ": successfully purged offline messages");
|
Log.d(Config.LOGTAG, acc.getJid().asBareJid() + ": successfully purged offline messages");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
trackOfflineMessageRetrieval = true;
|
||||||
}
|
}
|
||||||
sendPresence(account);
|
sendPresence(account);
|
||||||
|
account.getXmppConnection().trackOfflineMessageRetrieval(trackOfflineMessageRetrieval);
|
||||||
if (mPushManagementService.available(account)) {
|
if (mPushManagementService.available(account)) {
|
||||||
mPushManagementService.registerPushTokenOnServer(account);
|
mPushManagementService.registerPushTokenOnServer(account);
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,6 +165,7 @@ public class XmppConnection implements Runnable {
|
||||||
private boolean inSmacksSession = false;
|
private boolean inSmacksSession = false;
|
||||||
private boolean quickStartInProgress = false;
|
private boolean quickStartInProgress = false;
|
||||||
private boolean isBound = false;
|
private boolean isBound = false;
|
||||||
|
private boolean offlineMessagesRetrieved = false;
|
||||||
private Element streamFeatures;
|
private Element streamFeatures;
|
||||||
private Element boundStreamFeatures;
|
private Element boundStreamFeatures;
|
||||||
private StreamId streamId = null;
|
private StreamId streamId = null;
|
||||||
|
@ -2200,6 +2201,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finalizeBind() {
|
private void finalizeBind() {
|
||||||
|
this.offlineMessagesRetrieved = false;
|
||||||
if (bindListener != null) {
|
if (bindListener != null) {
|
||||||
bindListener.onBind(account);
|
bindListener.onBind(account);
|
||||||
}
|
}
|
||||||
|
@ -2727,6 +2729,24 @@ public class XmppConnection implements Runnable {
|
||||||
return mXmppConnectionService.getIqGenerator();
|
return mXmppConnectionService.getIqGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void trackOfflineMessageRetrieval(boolean trackOfflineMessageRetrieval) {
|
||||||
|
if (trackOfflineMessageRetrieval) {
|
||||||
|
final IqPacket iqPing = new IqPacket(IqPacket.TYPE.GET);
|
||||||
|
iqPing.addChild("ping", Namespace.PING);
|
||||||
|
this.sendIqPacket(
|
||||||
|
iqPing,
|
||||||
|
(a, response) -> {
|
||||||
|
Log.d(
|
||||||
|
Config.LOGTAG,
|
||||||
|
account.getJid().asBareJid()
|
||||||
|
+ ": received ping response after sending initial presence");
|
||||||
|
XmppConnection.this.offlineMessagesRetrieved = true;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.offlineMessagesRetrieved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class MyKeyManager implements X509KeyManager {
|
private class MyKeyManager implements X509KeyManager {
|
||||||
@Override
|
@Override
|
||||||
public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket) {
|
public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket) {
|
||||||
|
|
Loading…
Reference in a new issue