track offline message queue

This commit is contained in:
Daniel Gultsch 2024-01-19 16:01:07 +01:00
parent ef5508e5b1
commit 32da5853d7
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
2 changed files with 25 additions and 0 deletions

View file

@ -371,14 +371,19 @@ public class XmppConnectionService extends Service {
}
final boolean flexible = account.getXmppConnection().getFeatures().flexibleOfflineMessageRetrieval();
final boolean catchup = getMessageArchiveService().inCatchup(account);
final boolean trackOfflineMessageRetrieval;
if (flexible && catchup && account.getXmppConnection().isMamPreferenceAlways()) {
trackOfflineMessageRetrieval = false;
sendIqPacket(account, mIqGenerator.purgeOfflineMessages(), (acc, packet) -> {
if (packet.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, acc.getJid().asBareJid() + ": successfully purged offline messages");
}
});
} else {
trackOfflineMessageRetrieval = true;
}
sendPresence(account);
account.getXmppConnection().trackOfflineMessageRetrieval(trackOfflineMessageRetrieval);
if (mPushManagementService.available(account)) {
mPushManagementService.registerPushTokenOnServer(account);
}

View file

@ -165,6 +165,7 @@ public class XmppConnection implements Runnable {
private boolean inSmacksSession = false;
private boolean quickStartInProgress = false;
private boolean isBound = false;
private boolean offlineMessagesRetrieved = false;
private Element streamFeatures;
private Element boundStreamFeatures;
private StreamId streamId = null;
@ -2200,6 +2201,7 @@ public class XmppConnection implements Runnable {
}
private void finalizeBind() {
this.offlineMessagesRetrieved = false;
if (bindListener != null) {
bindListener.onBind(account);
}
@ -2727,6 +2729,24 @@ public class XmppConnection implements Runnable {
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 {
@Override
public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket) {