aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-09-04 20:37:09 +0200
committerChristian Schneppe <christian@pix-art.de>2017-09-04 20:37:09 +0200
commit9004a0efcff15deb98d37b9ae07f24efa860c8f4 (patch)
treed720a7de657c8b046219d63b7bda3dd152e43cf1 /src/main/java/de/pixart
parent62885d86d3337802a0420bf9fd777c4202e87603 (diff)
fixed jingle state machine being thrown off by iq-result coming after session-accept
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java25
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/Content.java1
2 files changed, 14 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
index 3aaf002c7..d8bb0c21d 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
@@ -48,6 +48,7 @@ public class JingleConnection implements Transferable {
private JingleConnectionManager mJingleConnectionManager;
private XmppConnectionService mXmppConnectionService;
+ private static final int JINGLE_STATUS_OFFERED = -1;
protected static final int JINGLE_STATUS_INITIATED = 0;
protected static final int JINGLE_STATUS_ACCEPTED = 1;
protected static final int JINGLE_STATUS_FINISHED = 4;
@@ -58,7 +59,7 @@ public class JingleConnection implements Transferable {
private int ibbBlockSize = 8192;
- private int mJingleStatus = -1;
+ private int mJingleStatus = JINGLE_STATUS_OFFERED;
private int mStatus = Transferable.STATUS_UNKNOWN;
private Message message;
private String sessionId;
@@ -520,8 +521,12 @@ public class JingleConnection implements Transferable {
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": other party received offer");
- mJingleStatus = JINGLE_STATUS_INITIATED;
- mXmppConnectionService.markMessage(message, Message.STATUS_OFFERED);
+ if (mJingleStatus == JINGLE_STATUS_OFFERED) {
+ mJingleStatus = JINGLE_STATUS_INITIATED;
+ mXmppConnectionService.markMessage(message, Message.STATUS_OFFERED);
+ } else {
+ Log.d(Config.LOGTAG, "received ack for offer when status was " + mJingleStatus);
+ }
} else {
fail(IqParser.extractErrorMessage(packet));
}
@@ -649,8 +654,7 @@ public class JingleConnection implements Transferable {
} else if (content.socks5transport().hasChild("candidate-error")) {
Log.d(Config.LOGTAG, "received candidate error");
this.receivedCandidate = true;
- if ((mJingleStatus == JINGLE_STATUS_ACCEPTED)
- && (this.sentCandidate)) {
+ if (mJingleStatus == JINGLE_STATUS_ACCEPTED && this.sentCandidate) {
this.connect();
}
return true;
@@ -666,12 +670,10 @@ public class JingleConnection implements Transferable {
}
candidate.flagAsUsedByCounterpart();
this.receivedCandidate = true;
- if ((mJingleStatus == JINGLE_STATUS_ACCEPTED)
- && (this.sentCandidate)) {
+ if (mJingleStatus == JINGLE_STATUS_ACCEPTED && this.sentCandidate) {
this.connect();
} else {
- Log.d(Config.LOGTAG,
- "ignoring because file is already in transmission or we haven't sent our candidate yet");
+ Log.d(Config.LOGTAG, "ignoring because file is already in transmission or we haven't sent our candidate yet status=" + mJingleStatus + " sentCandidate=" + Boolean.toString(sentCandidate));
}
return true;
} else {
@@ -1007,8 +1009,7 @@ public class JingleConnection implements Transferable {
JinglePacket packet = bootstrapPacket("transport-info");
Content content = new Content(this.contentCreator, this.contentName);
content.setTransportId(this.transportId);
- content.socks5transport().addChild("candidate-used")
- .setAttribute("cid", cid);
+ content.socks5transport().addChild("candidate-used").setAttribute("cid", cid);
packet.setContent(content);
this.sentCandidate = true;
if ((receivedCandidate) && (mJingleStatus == JINGLE_STATUS_ACCEPTED)) {
@@ -1024,7 +1025,7 @@ public class JingleConnection implements Transferable {
content.socks5transport().addChild("candidate-error");
packet.setContent(content);
this.sentCandidate = true;
- if ((receivedCandidate) && (mJingleStatus == JINGLE_STATUS_ACCEPTED)) {
+ if (receivedCandidate && mJingleStatus == JINGLE_STATUS_ACCEPTED) {
connect();
}
this.sendJinglePacket(packet);
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/Content.java b/src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/Content.java
index d4220083e..a15acee97 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/Content.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/Content.java
@@ -30,6 +30,7 @@ public class Content extends Element {
public Content(String creator, String name) {
super("content");
this.setAttribute("creator", creator);
+ this.setAttribute("senders", creator);
this.setAttribute("name", name);
}