mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-16 22:05:07 -05:00
use proper, advertised sm namespace
This commit is contained in:
parent
83a23ad3b1
commit
486f198632
@ -74,6 +74,7 @@ public class XmppConnection implements Runnable {
|
|||||||
private List<String> discoItems = new ArrayList<String>();
|
private List<String> discoItems = new ArrayList<String>();
|
||||||
|
|
||||||
private String streamId = null;
|
private String streamId = null;
|
||||||
|
private int smVersion = 3;
|
||||||
|
|
||||||
private int stanzasReceived = 0;
|
private int stanzasReceived = 0;
|
||||||
private int stanzasSent = 0;
|
private int stanzasSent = 0;
|
||||||
@ -241,13 +242,13 @@ public class XmppConnection implements Runnable {
|
|||||||
Element enabled = tagReader.readElement(nextTag);
|
Element enabled = tagReader.readElement(nextTag);
|
||||||
if ("true".equals(enabled.getAttribute("resume"))) {
|
if ("true".equals(enabled.getAttribute("resume"))) {
|
||||||
this.streamId = enabled.getAttribute("id");
|
this.streamId = enabled.getAttribute("id");
|
||||||
Log.d(LOGTAG,account.getJid()+": stream managment enabled (resumable)");
|
Log.d(LOGTAG,account.getJid()+": stream managment("+smVersion+") enabled (resumable)");
|
||||||
} else {
|
} else {
|
||||||
Log.d(LOGTAG,account.getJid()+": stream managment enabled");
|
Log.d(LOGTAG,account.getJid()+": stream managment("+smVersion+") enabled");
|
||||||
}
|
}
|
||||||
this.lastSessionStarted = SystemClock.elapsedRealtime();
|
this.lastSessionStarted = SystemClock.elapsedRealtime();
|
||||||
this.stanzasReceived = 0;
|
this.stanzasReceived = 0;
|
||||||
RequestPacket r = new RequestPacket();
|
RequestPacket r = new RequestPacket(smVersion);
|
||||||
tagWriter.writeStanzaAsync(r);
|
tagWriter.writeStanzaAsync(r);
|
||||||
} else if (nextTag.isStart("resumed")) {
|
} else if (nextTag.isStart("resumed")) {
|
||||||
tagReader.readElement(nextTag);
|
tagReader.readElement(nextTag);
|
||||||
@ -256,7 +257,7 @@ public class XmppConnection implements Runnable {
|
|||||||
Log.d(LOGTAG,account.getJid()+": session resumed");
|
Log.d(LOGTAG,account.getJid()+": session resumed");
|
||||||
} else if (nextTag.isStart("r")) {
|
} else if (nextTag.isStart("r")) {
|
||||||
tagReader.readElement(nextTag);
|
tagReader.readElement(nextTag);
|
||||||
AckPacket ack = new AckPacket(this.stanzasReceived);
|
AckPacket ack = new AckPacket(this.stanzasReceived,smVersion);
|
||||||
//Log.d(LOGTAG,ack.toString());
|
//Log.d(LOGTAG,ack.toString());
|
||||||
tagWriter.writeStanzaAsync(ack);
|
tagWriter.writeStanzaAsync(ack);
|
||||||
} else if (nextTag.isStart("a")) {
|
} else if (nextTag.isStart("a")) {
|
||||||
@ -531,8 +532,8 @@ public class XmppConnection implements Runnable {
|
|||||||
} else if (mechanisms.contains("DIGEST-MD5")) {
|
} else if (mechanisms.contains("DIGEST-MD5")) {
|
||||||
sendSaslAuthDigestMd5();
|
sendSaslAuthDigestMd5();
|
||||||
}
|
}
|
||||||
} else if (this.streamFeatures.hasChild("sm") && streamId != null) {
|
} else if (this.streamFeatures.hasChild("sm","urn:xmpp:sm:"+smVersion) && streamId != null) {
|
||||||
ResumePacket resume = new ResumePacket(this.streamId,stanzasReceived);
|
ResumePacket resume = new ResumePacket(this.streamId,stanzasReceived,smVersion);
|
||||||
this.tagWriter.writeStanzaAsync(resume);
|
this.tagWriter.writeStanzaAsync(resume);
|
||||||
} else if (this.streamFeatures.hasChild("bind") && shouldBind) {
|
} else if (this.streamFeatures.hasChild("bind") && shouldBind) {
|
||||||
sendBindRequest();
|
sendBindRequest();
|
||||||
@ -633,9 +634,13 @@ public class XmppConnection implements Runnable {
|
|||||||
String resource = packet.findChild("bind").findChild("jid")
|
String resource = packet.findChild("bind").findChild("jid")
|
||||||
.getContent().split("/")[1];
|
.getContent().split("/")[1];
|
||||||
account.setResource(resource);
|
account.setResource(resource);
|
||||||
if (streamFeatures.hasChild("sm")) {
|
if (streamFeatures.hasChild("sm","urn:xmpp:sm:3")) {
|
||||||
String xmlns = streamFeatures.findChild("sm").getAttribute("xmlns");
|
smVersion = 3;
|
||||||
EnablePacket enable = new EnablePacket(xmlns);
|
EnablePacket enable = new EnablePacket(smVersion);
|
||||||
|
tagWriter.writeStanzaAsync(enable);
|
||||||
|
} else if (streamFeatures.hasChild("sm","urn:xmpp:sm:2")) {
|
||||||
|
smVersion = 2;
|
||||||
|
EnablePacket enable = new EnablePacket(smVersion);
|
||||||
tagWriter.writeStanzaAsync(enable);
|
tagWriter.writeStanzaAsync(enable);
|
||||||
}
|
}
|
||||||
sendInitialPresence();
|
sendInitialPresence();
|
||||||
@ -765,7 +770,7 @@ public class XmppConnection implements Runnable {
|
|||||||
|
|
||||||
public void sendPing() {
|
public void sendPing() {
|
||||||
if (streamFeatures.hasChild("sm")) {
|
if (streamFeatures.hasChild("sm")) {
|
||||||
tagWriter.writeStanzaAsync(new RequestPacket());
|
tagWriter.writeStanzaAsync(new RequestPacket(smVersion));
|
||||||
} else {
|
} else {
|
||||||
IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
|
IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
|
||||||
iq.setFrom(account.getFullJid());
|
iq.setFrom(account.getFullJid());
|
||||||
@ -849,7 +854,7 @@ public class XmppConnection implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void r() {
|
public void r() {
|
||||||
this.tagWriter.writeStanzaAsync(new RequestPacket());
|
this.tagWriter.writeStanzaAsync(new RequestPacket(smVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getReceivedStanzas() {
|
public int getReceivedStanzas() {
|
||||||
|
@ -4,9 +4,9 @@ import eu.siacs.conversations.xmpp.stanzas.AbstractStanza;
|
|||||||
|
|
||||||
public class AckPacket extends AbstractStanza {
|
public class AckPacket extends AbstractStanza {
|
||||||
|
|
||||||
public AckPacket(int sequence) {
|
public AckPacket(int sequence, int smVersion) {
|
||||||
super("a");
|
super("a");
|
||||||
this.setAttribute("xmlns","urn:xmpp:sm:3");
|
this.setAttribute("xmlns","urn:xmpp:sm:"+smVersion);
|
||||||
this.setAttribute("h", ""+sequence);
|
this.setAttribute("h", ""+sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,15 +4,9 @@ import eu.siacs.conversations.xmpp.stanzas.AbstractStanza;
|
|||||||
|
|
||||||
public class EnablePacket extends AbstractStanza {
|
public class EnablePacket extends AbstractStanza {
|
||||||
|
|
||||||
public EnablePacket() {
|
public EnablePacket(int smVersion) {
|
||||||
super("enable");
|
super("enable");
|
||||||
this.setAttribute("xmlns","urn:xmpp:sm:3");
|
this.setAttribute("xmlns","urn:xmpp:sm:"+smVersion);
|
||||||
this.setAttribute("resume", "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnablePacket(String xmlns) {
|
|
||||||
super("enable");
|
|
||||||
this.setAttribute("xmlns",xmlns);
|
|
||||||
this.setAttribute("resume", "true");
|
this.setAttribute("resume", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@ import eu.siacs.conversations.xmpp.stanzas.AbstractStanza;
|
|||||||
|
|
||||||
public class RequestPacket extends AbstractStanza {
|
public class RequestPacket extends AbstractStanza {
|
||||||
|
|
||||||
public RequestPacket() {
|
public RequestPacket(int smVersion) {
|
||||||
super("r");
|
super("r");
|
||||||
this.setAttribute("xmlns","urn:xmpp:sm:3");
|
this.setAttribute("xmlns","urn:xmpp:sm:"+smVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import eu.siacs.conversations.xmpp.stanzas.AbstractStanza;
|
|||||||
|
|
||||||
public class ResumePacket extends AbstractStanza {
|
public class ResumePacket extends AbstractStanza {
|
||||||
|
|
||||||
public ResumePacket(String id, int sequence) {
|
public ResumePacket(String id, int sequence, int smVersion) {
|
||||||
super("resume");
|
super("resume");
|
||||||
this.setAttribute("xmlns","urn:xmpp:sm:3");
|
this.setAttribute("xmlns","urn:xmpp:sm:"+smVersion);
|
||||||
this.setAttribute("previd", id);
|
this.setAttribute("previd", id);
|
||||||
this.setAttribute("h", ""+sequence);
|
this.setAttribute("h", ""+sequence);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user