use ibb if other party doesn’t annouce s5b feature
This commit is contained in:
parent
fe6c981ae2
commit
9fc1ead74f
|
@ -101,7 +101,7 @@ public final class Config {
|
||||||
|
|
||||||
|
|
||||||
public static final boolean DISABLE_PROXY_LOOKUP = false; //useful to debug ibb
|
public static final boolean DISABLE_PROXY_LOOKUP = false; //useful to debug ibb
|
||||||
public static final boolean DISABLE_HTTP_UPLOAD = false;
|
public static final boolean DISABLE_HTTP_UPLOAD = true;
|
||||||
public static final boolean EXTENDED_SM_LOGGING = false; // log stanza counts
|
public static final boolean EXTENDED_SM_LOGGING = false; // log stanza counts
|
||||||
public static final boolean BACKGROUND_STANZA_LOGGING = false; //log all stanzas that were received while the app is in background
|
public static final boolean BACKGROUND_STANZA_LOGGING = false; //log all stanzas that were received while the app is in background
|
||||||
public static final boolean RESET_ATTEMPT_COUNT_ON_NETWORK_CHANGE = true; //setting to true might increase power consumption
|
public static final boolean RESET_ATTEMPT_COUNT_ON_NETWORK_CHANGE = true; //setting to true might increase power consumption
|
||||||
|
|
|
@ -27,8 +27,8 @@ public abstract class AbstractGenerator {
|
||||||
Content.Version.FT_3.getNamespace(),
|
Content.Version.FT_3.getNamespace(),
|
||||||
Content.Version.FT_4.getNamespace(),
|
Content.Version.FT_4.getNamespace(),
|
||||||
Content.Version.FT_5.getNamespace(),
|
Content.Version.FT_5.getNamespace(),
|
||||||
"urn:xmpp:jingle:transports:s5b:1",
|
Namespace.JINGLE_TRANSPORTS_S5B,
|
||||||
"urn:xmpp:jingle:transports:ibb:1",
|
Namespace.JINGLE_TRANSPORTS_IBB,
|
||||||
"http://jabber.org/protocol/muc",
|
"http://jabber.org/protocol/muc",
|
||||||
"jabber:x:conference",
|
"jabber:x:conference",
|
||||||
Namespace.OOB,
|
Namespace.OOB,
|
||||||
|
|
|
@ -25,4 +25,6 @@ public final class Namespace {
|
||||||
public static final String BOOKMARKS = "storage:bookmarks";
|
public static final String BOOKMARKS = "storage:bookmarks";
|
||||||
public static final String SYNCHRONIZATION = "im.quicksy.synchronization:0";
|
public static final String SYNCHRONIZATION = "im.quicksy.synchronization:0";
|
||||||
public static final String AVATAR_CONVERSION = "urn:xmpp:pep-vcard-conversion:0";
|
public static final String AVATAR_CONVERSION = "urn:xmpp:pep-vcard-conversion:0";
|
||||||
|
public static final String JINGLE_TRANSPORTS_S5B = "urn:xmpp:jingle:transports:s5b:1";
|
||||||
|
public static final String JINGLE_TRANSPORTS_IBB = "urn:xmpp:jingle:transports:ibb:1";
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -154,6 +154,7 @@ public class JingleInbandTransport extends JingleTransport {
|
||||||
if (count == -1) {
|
if (count == -1) {
|
||||||
sendClose();
|
sendClose();
|
||||||
file.setSha1Sum(digest.digest());
|
file.setSha1Sum(digest.digest());
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": sendNextBlock() count was -1");
|
||||||
this.onFileTransmissionStatusChanged.onFileTransmitted(file);
|
this.onFileTransmissionStatusChanged.onFileTransmitted(file);
|
||||||
fileInputStream.close();
|
fileInputStream.close();
|
||||||
return;
|
return;
|
||||||
|
@ -181,6 +182,7 @@ public class JingleInbandTransport extends JingleTransport {
|
||||||
} else {
|
} else {
|
||||||
sendClose();
|
sendClose();
|
||||||
file.setSha1Sum(digest.digest());
|
file.setSha1Sum(digest.digest());
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": sendNextBlock() remaining size");
|
||||||
this.onFileTransmissionStatusChanged.onFileTransmitted(file);
|
this.onFileTransmissionStatusChanged.onFileTransmitted(file);
|
||||||
fileInputStream.close();
|
fileInputStream.close();
|
||||||
}
|
}
|
||||||
|
@ -204,6 +206,7 @@ public class JingleInbandTransport extends JingleTransport {
|
||||||
file.setSha1Sum(digest.digest());
|
file.setSha1Sum(digest.digest());
|
||||||
fileOutputStream.flush();
|
fileOutputStream.flush();
|
||||||
fileOutputStream.close();
|
fileOutputStream.close();
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": receive next block nothing remaining");
|
||||||
this.onFileTransmissionStatusChanged.onFileTransmitted(file);
|
this.onFileTransmissionStatusChanged.onFileTransmitted(file);
|
||||||
} else {
|
} else {
|
||||||
connection.updateProgress((int) ((((double) (this.fileSize - this.remainingSize)) / this.fileSize) * 100));
|
connection.updateProgress((int) ((((double) (this.fileSize - this.remainingSize)) / this.fileSize) * 100));
|
||||||
|
|
|
@ -2,132 +2,129 @@ package eu.siacs.conversations.xmpp.jingle.stanzas;
|
||||||
|
|
||||||
import eu.siacs.conversations.entities.DownloadableFile;
|
import eu.siacs.conversations.entities.DownloadableFile;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
import eu.siacs.conversations.xml.Namespace;
|
||||||
|
|
||||||
public class Content extends Element {
|
public class Content extends Element {
|
||||||
|
|
||||||
public enum Version {
|
public enum Version {
|
||||||
FT_3("urn:xmpp:jingle:apps:file-transfer:3"),
|
FT_3("urn:xmpp:jingle:apps:file-transfer:3"),
|
||||||
FT_4("urn:xmpp:jingle:apps:file-transfer:4"),
|
FT_4("urn:xmpp:jingle:apps:file-transfer:4"),
|
||||||
FT_5("urn:xmpp:jingle:apps:file-transfer:5");
|
FT_5("urn:xmpp:jingle:apps:file-transfer:5");
|
||||||
|
|
||||||
private final String namespace;
|
private final String namespace;
|
||||||
|
|
||||||
Version(String namespace) {
|
Version(String namespace) {
|
||||||
this.namespace = namespace;
|
this.namespace = namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
return namespace;
|
return namespace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String transportId;
|
private String transportId;
|
||||||
|
|
||||||
public Content() {
|
public Content() {
|
||||||
super("content");
|
super("content");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Content(String creator, String name) {
|
public Content(String creator, String name) {
|
||||||
super("content");
|
super("content");
|
||||||
this.setAttribute("creator", creator);
|
this.setAttribute("creator", creator);
|
||||||
this.setAttribute("senders", creator);
|
this.setAttribute("senders", creator);
|
||||||
this.setAttribute("name", name);
|
this.setAttribute("name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Version getVersion() {
|
public Version getVersion() {
|
||||||
if (hasChild("description", Version.FT_3.namespace)) {
|
if (hasChild("description", Version.FT_3.namespace)) {
|
||||||
return Version.FT_3;
|
return Version.FT_3;
|
||||||
} else if (hasChild("description" , Version.FT_4.namespace)) {
|
} else if (hasChild("description", Version.FT_4.namespace)) {
|
||||||
return Version.FT_4;
|
return Version.FT_4;
|
||||||
} else if (hasChild("description" , Version.FT_5.namespace)) {
|
} else if (hasChild("description", Version.FT_5.namespace)) {
|
||||||
return Version.FT_5;
|
return Version.FT_5;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransportId(String sid) {
|
public void setTransportId(String sid) {
|
||||||
this.transportId = sid;
|
this.transportId = sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element setFileOffer(DownloadableFile actualFile, boolean otr, Version version) {
|
public Element setFileOffer(DownloadableFile actualFile, boolean otr, Version version) {
|
||||||
Element description = this.addChild("description", version.namespace);
|
Element description = this.addChild("description", version.namespace);
|
||||||
Element file;
|
Element file;
|
||||||
if (version == Version.FT_3) {
|
if (version == Version.FT_3) {
|
||||||
Element offer = description.addChild("offer");
|
Element offer = description.addChild("offer");
|
||||||
file = offer.addChild("file");
|
file = offer.addChild("file");
|
||||||
} else {
|
} else {
|
||||||
file = description.addChild("file");
|
file = description.addChild("file");
|
||||||
}
|
}
|
||||||
file.addChild("size").setContent(Long.toString(actualFile.getExpectedSize()));
|
file.addChild("size").setContent(Long.toString(actualFile.getExpectedSize()));
|
||||||
if (otr) {
|
if (otr) {
|
||||||
file.addChild("name").setContent(actualFile.getName() + ".otr");
|
file.addChild("name").setContent(actualFile.getName() + ".otr");
|
||||||
} else {
|
} else {
|
||||||
file.addChild("name").setContent(actualFile.getName());
|
file.addChild("name").setContent(actualFile.getName());
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element getFileOffer(Version version) {
|
public Element getFileOffer(Version version) {
|
||||||
Element description = this.findChild("description", version.namespace);
|
Element description = this.findChild("description", version.namespace);
|
||||||
if (description == null) {
|
if (description == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (version == Version.FT_3) {
|
if (version == Version.FT_3) {
|
||||||
Element offer = description.findChild("offer");
|
Element offer = description.findChild("offer");
|
||||||
if (offer == null) {
|
if (offer == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return offer.findChild("file");
|
return offer.findChild("file");
|
||||||
} else {
|
} else {
|
||||||
return description.findChild("file");
|
return description.findChild("file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileOffer(Element fileOffer, Version version) {
|
public void setFileOffer(Element fileOffer, Version version) {
|
||||||
Element description = this.addChild("description", version.namespace);
|
Element description = this.addChild("description", version.namespace);
|
||||||
if (version == Version.FT_3) {
|
if (version == Version.FT_3) {
|
||||||
description.addChild("offer").addChild(fileOffer);
|
description.addChild("offer").addChild(fileOffer);
|
||||||
} else {
|
} else {
|
||||||
description.addChild(fileOffer);
|
description.addChild(fileOffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTransportId() {
|
public String getTransportId() {
|
||||||
if (hasSocks5Transport()) {
|
if (hasSocks5Transport()) {
|
||||||
this.transportId = socks5transport().getAttribute("sid");
|
this.transportId = socks5transport().getAttribute("sid");
|
||||||
} else if (hasIbbTransport()) {
|
} else if (hasIbbTransport()) {
|
||||||
this.transportId = ibbTransport().getAttribute("sid");
|
this.transportId = ibbTransport().getAttribute("sid");
|
||||||
}
|
}
|
||||||
return this.transportId;
|
return this.transportId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element socks5transport() {
|
public Element socks5transport() {
|
||||||
Element transport = this.findChild("transport",
|
Element transport = this.findChild("transport", Namespace.JINGLE_TRANSPORTS_S5B);
|
||||||
"urn:xmpp:jingle:transports:s5b:1");
|
if (transport == null) {
|
||||||
if (transport == null) {
|
transport = this.addChild("transport", Namespace.JINGLE_TRANSPORTS_S5B);
|
||||||
transport = this.addChild("transport",
|
transport.setAttribute("sid", this.transportId);
|
||||||
"urn:xmpp:jingle:transports:s5b:1");
|
}
|
||||||
transport.setAttribute("sid", this.transportId);
|
return transport;
|
||||||
}
|
}
|
||||||
return transport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Element ibbTransport() {
|
public Element ibbTransport() {
|
||||||
Element transport = this.findChild("transport",
|
Element transport = this.findChild("transport", Namespace.JINGLE_TRANSPORTS_IBB);
|
||||||
"urn:xmpp:jingle:transports:ibb:1");
|
if (transport == null) {
|
||||||
if (transport == null) {
|
transport = this.addChild("transport", Namespace.JINGLE_TRANSPORTS_IBB);
|
||||||
transport = this.addChild("transport",
|
transport.setAttribute("sid", this.transportId);
|
||||||
"urn:xmpp:jingle:transports:ibb:1");
|
}
|
||||||
transport.setAttribute("sid", this.transportId);
|
return transport;
|
||||||
}
|
}
|
||||||
return transport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSocks5Transport() {
|
public boolean hasSocks5Transport() {
|
||||||
return this.hasChild("transport", "urn:xmpp:jingle:transports:s5b:1");
|
return this.hasChild("transport", Namespace.JINGLE_TRANSPORTS_S5B);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasIbbTransport() {
|
public boolean hasIbbTransport() {
|
||||||
return this.hasChild("transport", "urn:xmpp:jingle:transports:ibb:1");
|
return this.hasChild("transport", Namespace.JINGLE_TRANSPORTS_IBB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue