use modern Java in XmppConnection

This commit is contained in:
Daniel Gultsch 2024-02-09 11:23:05 +01:00
parent 0f34444b99
commit 03dc15158b
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -1162,8 +1162,7 @@ public class XmppConnection implements Runnable {
+ mStanzaQueue.keyAt(i)); + mStanzaQueue.keyAt(i));
} }
final AbstractAcknowledgeableStanza stanza = mStanzaQueue.valueAt(i); final AbstractAcknowledgeableStanza stanza = mStanzaQueue.valueAt(i);
if (stanza instanceof MessagePacket && acknowledgedListener != null) { if (stanza instanceof MessagePacket packet && acknowledgedListener != null) {
final MessagePacket packet = (MessagePacket) stanza;
final String id = packet.getId(); final String id = packet.getId();
final Jid to = packet.getTo(); final Jid to = packet.getTo();
if (id != null && to != null) { if (id != null && to != null) {
@ -1846,8 +1845,10 @@ public class XmppConnection implements Runnable {
resetAttemptCount(true); resetAttemptCount(true);
resetStreamId(); resetStreamId();
clearIqCallbacks(); clearIqCallbacks();
synchronized (this.mStanzaQueue) {
this.stanzasSent = 0; this.stanzasSent = 0;
mStanzaQueue.clear(); this.mStanzaQueue.clear();
}
this.redirectionUrl = null; this.redirectionUrl = null;
synchronized (this.disco) { synchronized (this.disco) {
disco.clear(); disco.clear();
@ -2332,8 +2333,7 @@ public class XmppConnection implements Runnable {
synchronized (this.mStanzaQueue) { synchronized (this.mStanzaQueue) {
for (int i = 0; i < mStanzaQueue.size(); ++i) { for (int i = 0; i < mStanzaQueue.size(); ++i) {
final AbstractAcknowledgeableStanza stanza = mStanzaQueue.valueAt(i); final AbstractAcknowledgeableStanza stanza = mStanzaQueue.valueAt(i);
if (stanza instanceof MessagePacket) { if (stanza instanceof MessagePacket packet) {
final MessagePacket packet = (MessagePacket) stanza;
final String id = packet.getId(); final String id = packet.getId();
final Jid to = packet.getTo(); final Jid to = packet.getTo();
mXmppConnectionService.markMessage( mXmppConnectionService.markMessage(
@ -2458,9 +2458,7 @@ public class XmppConnection implements Runnable {
+ " do not write stanza to unbound stream " + " do not write stanza to unbound stream "
+ packet.toString()); + packet.toString());
} }
if (packet instanceof AbstractAcknowledgeableStanza) { if (packet instanceof AbstractAcknowledgeableStanza stanza) {
AbstractAcknowledgeableStanza stanza = (AbstractAcknowledgeableStanza) packet;
if (this.mStanzaQueue.size() != 0) { if (this.mStanzaQueue.size() != 0) {
int currentHighestKey = this.mStanzaQueue.keyAt(this.mStanzaQueue.size() - 1); int currentHighestKey = this.mStanzaQueue.keyAt(this.mStanzaQueue.size() - 1);
if (currentHighestKey != stanzasSent) { if (currentHighestKey != stanzasSent) {
@ -2860,11 +2858,6 @@ public class XmppConnection implements Runnable {
&& pepPublishOptions(); && pepPublishOptions();
} }
public boolean avatarConversion() {
return hasDiscoFeature(account.getJid().asBareJid(), Namespace.AVATAR_CONVERSION)
&& pepPublishOptions();
}
public boolean blocking() { public boolean blocking() {
return hasDiscoFeature(account.getDomain(), Namespace.BLOCKING); return hasDiscoFeature(account.getDomain(), Namespace.BLOCKING);
} }