rename JingleConnection to JingleFileTransferConnection; use ID tuple to identify sessions
This commit is contained in:
parent
75f753e957
commit
23ebb6ae80
|
@ -1353,7 +1353,7 @@ public class XmppConnectionService extends Service {
|
||||||
|| message.getConversation().getMode() == Conversation.MODE_MULTI) {
|
|| message.getConversation().getMode() == Conversation.MODE_MULTI) {
|
||||||
mHttpConnectionManager.createNewUploadConnection(message, delay);
|
mHttpConnectionManager.createNewUploadConnection(message, delay);
|
||||||
} else {
|
} else {
|
||||||
mJingleConnectionManager.createNewConnection(message);
|
mJingleConnectionManager.startJingleFileTransfer(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ import eu.siacs.conversations.utils.TimeframeUtils;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
||||||
import eu.siacs.conversations.xmpp.jingle.JingleConnection;
|
import eu.siacs.conversations.xmpp.jingle.JingleFileTransferConnection;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
import static eu.siacs.conversations.ui.XmppActivity.EXTRA_ACCOUNT;
|
import static eu.siacs.conversations.ui.XmppActivity.EXTRA_ACCOUNT;
|
||||||
|
@ -1051,7 +1051,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
final boolean deleted = m.isDeleted();
|
final boolean deleted = m.isDeleted();
|
||||||
final boolean encrypted = m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED
|
final boolean encrypted = m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED
|
||||||
|| m.getEncryption() == Message.ENCRYPTION_PGP;
|
|| m.getEncryption() == Message.ENCRYPTION_PGP;
|
||||||
final boolean receiving = m.getStatus() == Message.STATUS_RECEIVED && (t instanceof JingleConnection || t instanceof HttpDownloadConnection);
|
final boolean receiving = m.getStatus() == Message.STATUS_RECEIVED && (t instanceof JingleFileTransferConnection || t instanceof HttpDownloadConnection);
|
||||||
activity.getMenuInflater().inflate(R.menu.message_context, menu);
|
activity.getMenuInflater().inflate(R.menu.message_context, menu);
|
||||||
menu.setHeaderTitle(R.string.message_options);
|
menu.setHeaderTitle(R.string.message_options);
|
||||||
MenuItem openWith = menu.findItem(R.id.open_with);
|
MenuItem openWith = menu.findItem(R.id.open_with);
|
||||||
|
|
|
@ -29,6 +29,7 @@ public final class Namespace {
|
||||||
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_S5B = "urn:xmpp:jingle:transports:s5b:1";
|
||||||
public static final String JINGLE_TRANSPORTS_IBB = "urn:xmpp:jingle:transports:ibb:1";
|
public static final String JINGLE_TRANSPORTS_IBB = "urn:xmpp:jingle:transports:ibb:1";
|
||||||
|
public static final String IBB = "http://jabber.org/protocol/ibb";
|
||||||
public static final String PING = "urn:xmpp:ping";
|
public static final String PING = "urn:xmpp:ping";
|
||||||
public static final String PUSH = "urn:xmpp:push:0";
|
public static final String PUSH = "urn:xmpp:push:0";
|
||||||
public static final String COMMANDS = "http://jabber.org/protocol/commands";
|
public static final String COMMANDS = "http://jabber.org/protocol/commands";
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package eu.siacs.conversations.xmpp.jingle;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
import eu.siacs.conversations.entities.Message;
|
||||||
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
|
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
|
||||||
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
|
public abstract class AbstractJingleConnection {
|
||||||
|
|
||||||
|
protected final JingleConnectionManager jingleConnectionManager;
|
||||||
|
protected final XmppConnectionService xmppConnectionService;
|
||||||
|
protected final Id id;
|
||||||
|
|
||||||
|
public AbstractJingleConnection(final JingleConnectionManager jingleConnectionManager, final Id id) {
|
||||||
|
this.jingleConnectionManager = jingleConnectionManager;
|
||||||
|
this.xmppConnectionService = jingleConnectionManager.getXmppConnectionService();
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract void deliverPacket(JinglePacket jinglePacket);
|
||||||
|
|
||||||
|
public Id getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class Id {
|
||||||
|
public final Account account;
|
||||||
|
public final Jid counterPart;
|
||||||
|
public final String sessionId;
|
||||||
|
|
||||||
|
private Id(final Account account, final Jid counterPart, final String sessionId) {
|
||||||
|
Preconditions.checkNotNull(counterPart);
|
||||||
|
Preconditions.checkArgument(counterPart.isFullJid());
|
||||||
|
this.account = account;
|
||||||
|
this.counterPart = counterPart;
|
||||||
|
this.sessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Id of(Account account, JinglePacket jinglePacket) {
|
||||||
|
return new Id(account, jinglePacket.getFrom(), jinglePacket.getSessionId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Id of(Message message) {
|
||||||
|
return new Id(
|
||||||
|
message.getConversation().getAccount(),
|
||||||
|
message.getCounterpart(),
|
||||||
|
JingleConnectionManager.nextRandomId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Id id = (Id) o;
|
||||||
|
return Objects.equal(account.getJid(), id.account.getJid()) &&
|
||||||
|
Objects.equal(counterPart, id.counterPart) &&
|
||||||
|
Objects.equal(sessionId, id.sessionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(account.getJid(), counterPart, sessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.siacs.conversations.xmpp.jingle;
|
package eu.siacs.conversations.xmpp.jingle;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import com.google.common.base.Preconditions;
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
@ -15,40 +15,33 @@ import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.entities.Transferable;
|
import eu.siacs.conversations.entities.Transferable;
|
||||||
import eu.siacs.conversations.services.AbstractConnectionManager;
|
import eu.siacs.conversations.services.AbstractConnectionManager;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.xml.Namespace;
|
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
import eu.siacs.conversations.xml.Namespace;
|
||||||
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
||||||
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
|
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class JingleConnectionManager extends AbstractConnectionManager {
|
public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
private List<JingleConnection> connections = new CopyOnWriteArrayList<>();
|
private Map<AbstractJingleConnection.Id, AbstractJingleConnection> connections = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private HashMap<Jid, JingleCandidate> primaryCandidates = new HashMap<>();
|
private HashMap<Jid, JingleCandidate> primaryCandidates = new HashMap<>();
|
||||||
|
|
||||||
@SuppressLint("TrulyRandom")
|
|
||||||
private SecureRandom random = new SecureRandom();
|
|
||||||
|
|
||||||
public JingleConnectionManager(XmppConnectionService service) {
|
public JingleConnectionManager(XmppConnectionService service) {
|
||||||
super(service);
|
super(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deliverPacket(Account account, JinglePacket packet) {
|
public void deliverPacket(final Account account, final JinglePacket packet) {
|
||||||
if (packet.isAction("session-initiate")) {
|
final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, packet);
|
||||||
JingleConnection connection = new JingleConnection(this);
|
if (packet.isAction("session-initiate")) { //TODO check that id doesn't exist yet
|
||||||
|
JingleFileTransferConnection connection = new JingleFileTransferConnection(this, id);
|
||||||
connection.init(account, packet);
|
connection.init(account, packet);
|
||||||
connections.add(connection);
|
connections.put(id, connection);
|
||||||
|
} else {
|
||||||
|
final AbstractJingleConnection abstractJingleConnection = connections.get(id);
|
||||||
|
if (abstractJingleConnection != null) {
|
||||||
|
abstractJingleConnection.deliverPacket(packet);
|
||||||
} else {
|
} else {
|
||||||
for (JingleConnection connection : connections) {
|
|
||||||
if (connection.getAccount() == account
|
|
||||||
&& connection.getSessionId().equals(
|
|
||||||
packet.getSessionId())
|
|
||||||
&& connection.getCounterPart().equals(packet.getFrom())) {
|
|
||||||
connection.deliverPacket(packet);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.d(Config.LOGTAG, "unable to route jingle packet: " + packet);
|
Log.d(Config.LOGTAG, "unable to route jingle packet: " + packet);
|
||||||
IqPacket response = packet.generateResponse(IqPacket.TYPE.ERROR);
|
IqPacket response = packet.generateResponse(IqPacket.TYPE.ERROR);
|
||||||
Element error = response.addChild("error");
|
Element error = response.addChild("error");
|
||||||
|
@ -59,30 +52,26 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
account.getXmppConnection().sendIqPacket(response, null);
|
account.getXmppConnection().sendIqPacket(response, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public JingleConnection createNewConnection(Message message) {
|
public void startJingleFileTransfer(final Message message) {
|
||||||
Transferable old = message.getTransferable();
|
Preconditions.checkArgument(message.isFileOrImage(), "Message is not of type file or image");
|
||||||
|
final Transferable old = message.getTransferable();
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
old.cancel();
|
old.cancel();
|
||||||
}
|
}
|
||||||
JingleConnection connection = new JingleConnection(this);
|
final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(message);
|
||||||
|
final JingleFileTransferConnection connection = new JingleFileTransferConnection(this, id);
|
||||||
mXmppConnectionService.markMessage(message, Message.STATUS_WAITING);
|
mXmppConnectionService.markMessage(message, Message.STATUS_WAITING);
|
||||||
connection.init(message);
|
connection.init(message);
|
||||||
this.connections.add(connection);
|
this.connections.put(id, connection);
|
||||||
return connection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleConnection createNewConnection(final JinglePacket packet) {
|
void finishConnection(final AbstractJingleConnection connection) {
|
||||||
JingleConnection connection = new JingleConnection(this);
|
this.connections.remove(connection.getId());
|
||||||
this.connections.add(connection);
|
|
||||||
return connection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishConnection(JingleConnection connection) {
|
void getPrimaryCandidate(final Account account, final boolean initiator, final OnPrimaryCandidateFound listener) {
|
||||||
this.connections.remove(connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getPrimaryCandidate(final Account account, final boolean initiator, final OnPrimaryCandidateFound listener) {
|
|
||||||
if (Config.DISABLE_PROXY_LOOKUP) {
|
if (Config.DISABLE_PROXY_LOOKUP) {
|
||||||
listener.onPrimaryCandidateFound(false, null);
|
listener.onPrimaryCandidateFound(false, null);
|
||||||
return;
|
return;
|
||||||
|
@ -97,7 +86,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
Element streamhost = packet.query().findChild("streamhost", Namespace.BYTE_STREAMS);
|
final Element streamhost = packet.query().findChild("streamhost", Namespace.BYTE_STREAMS);
|
||||||
final String host = streamhost == null ? null : streamhost.getAttribute("host");
|
final String host = streamhost == null ? null : streamhost.getAttribute("host");
|
||||||
final String port = streamhost == null ? null : streamhost.getAttribute("port");
|
final String port = streamhost == null ? null : streamhost.getAttribute("port");
|
||||||
if (host != null && port != null) {
|
if (host != null && port != null) {
|
||||||
|
@ -112,7 +101,6 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
listener.onPrimaryCandidateFound(true, candidate);
|
listener.onPrimaryCandidateFound(true, candidate);
|
||||||
} catch (final NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
listener.onPrimaryCandidateFound(false, null);
|
listener.onPrimaryCandidateFound(false, null);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
listener.onPrimaryCandidateFound(false, null);
|
listener.onPrimaryCandidateFound(false, null);
|
||||||
|
@ -129,31 +117,30 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String nextRandomId() {
|
static String nextRandomId() {
|
||||||
return new BigInteger(50, random).toString(32);
|
return UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deliverIbbPacket(Account account, IqPacket packet) {
|
public void deliverIbbPacket(Account account, IqPacket packet) {
|
||||||
String sid = null;
|
String sid = null;
|
||||||
Element payload = null;
|
Element payload = null;
|
||||||
if (packet.hasChild("open", "http://jabber.org/protocol/ibb")) {
|
if (packet.hasChild("open", Namespace.IBB)) {
|
||||||
payload = packet.findChild("open", "http://jabber.org/protocol/ibb");
|
payload = packet.findChild("open", Namespace.IBB);
|
||||||
sid = payload.getAttribute("sid");
|
sid = payload.getAttribute("sid");
|
||||||
} else if (packet.hasChild("data", "http://jabber.org/protocol/ibb")) {
|
} else if (packet.hasChild("data", Namespace.IBB)) {
|
||||||
payload = packet.findChild("data", "http://jabber.org/protocol/ibb");
|
payload = packet.findChild("data", Namespace.IBB);
|
||||||
sid = payload.getAttribute("sid");
|
sid = payload.getAttribute("sid");
|
||||||
} else if (packet.hasChild("close", "http://jabber.org/protocol/ibb")) {
|
} else if (packet.hasChild("close", Namespace.IBB)) {
|
||||||
payload = packet.findChild("close", "http://jabber.org/protocol/ibb");
|
payload = packet.findChild("close", Namespace.IBB);
|
||||||
sid = payload.getAttribute("sid");
|
sid = payload.getAttribute("sid");
|
||||||
}
|
}
|
||||||
if (sid != null) {
|
if (sid != null) {
|
||||||
for (JingleConnection connection : connections) {
|
for (final AbstractJingleConnection connection : this.connections.values()) {
|
||||||
if (connection.getAccount() == account
|
if (connection instanceof JingleFileTransferConnection) {
|
||||||
&& connection.hasTransportId(sid)) {
|
final JingleFileTransferConnection fileTransfer = (JingleFileTransferConnection) connection;
|
||||||
JingleTransport transport = connection.getTransport();
|
final JingleTransport transport = fileTransfer.getTransport();
|
||||||
if (transport instanceof JingleInBandTransport) {
|
if (transport instanceof JingleInBandTransport) {
|
||||||
JingleInBandTransport inbandTransport = (JingleInBandTransport) transport;
|
((JingleInBandTransport) transport).deliverPayload(packet, payload);
|
||||||
inbandTransport.deliverPayload(packet, payload);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,10 +151,10 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelInTransmission() {
|
public void cancelInTransmission() {
|
||||||
for (JingleConnection connection : this.connections) {
|
for (AbstractJingleConnection connection : this.connections.values()) {
|
||||||
if (connection.getJingleStatus() == JingleConnection.JINGLE_STATUS_TRANSMITTING) {
|
/*if (connection.getJingleStatus() == JingleFileTransferConnection.JINGLE_STATUS_TRANSMITTING) {
|
||||||
connection.abort("connectivity-error");
|
connection.abort("connectivity-error");
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.siacs.conversations.xmpp.jingle;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -41,27 +42,22 @@ import eu.siacs.conversations.xmpp.jingle.stanzas.Reason;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class JingleConnection implements Transferable {
|
public class JingleFileTransferConnection extends AbstractJingleConnection implements Transferable {
|
||||||
|
|
||||||
|
private static final int JINGLE_STATUS_TRANSMITTING = 5;
|
||||||
private static final String JET_OMEMO_CIPHER = "urn:xmpp:ciphers:aes-128-gcm-nopadding";
|
private static final String JET_OMEMO_CIPHER = "urn:xmpp:ciphers:aes-128-gcm-nopadding";
|
||||||
|
|
||||||
private static final int JINGLE_STATUS_INITIATED = 0;
|
private static final int JINGLE_STATUS_INITIATED = 0;
|
||||||
private static final int JINGLE_STATUS_ACCEPTED = 1;
|
private static final int JINGLE_STATUS_ACCEPTED = 1;
|
||||||
private static final int JINGLE_STATUS_FINISHED = 4;
|
private static final int JINGLE_STATUS_FINISHED = 4;
|
||||||
static final int JINGLE_STATUS_TRANSMITTING = 5;
|
|
||||||
private static final int JINGLE_STATUS_FAILED = 99;
|
private static final int JINGLE_STATUS_FAILED = 99;
|
||||||
private static final int JINGLE_STATUS_OFFERED = -1;
|
private static final int JINGLE_STATUS_OFFERED = -1;
|
||||||
private JingleConnectionManager mJingleConnectionManager;
|
|
||||||
private XmppConnectionService mXmppConnectionService;
|
|
||||||
private Content.Version ftVersion = Content.Version.FT_3;
|
private Content.Version ftVersion = Content.Version.FT_3;
|
||||||
|
|
||||||
private int ibbBlockSize = 8192;
|
private int ibbBlockSize = 8192;
|
||||||
|
|
||||||
private int mJingleStatus = JINGLE_STATUS_OFFERED;
|
private int mJingleStatus = JINGLE_STATUS_OFFERED; //migrate to enum
|
||||||
private int mStatus = Transferable.STATUS_UNKNOWN;
|
private int mStatus = Transferable.STATUS_UNKNOWN;
|
||||||
private Message message;
|
private Message message;
|
||||||
private String sessionId;
|
|
||||||
private Account account;
|
|
||||||
private Jid initiator;
|
private Jid initiator;
|
||||||
private Jid responder;
|
private Jid responder;
|
||||||
private List<JingleCandidate> candidates = new ArrayList<>();
|
private List<JingleCandidate> candidates = new ArrayList<>();
|
||||||
|
@ -109,32 +105,32 @@ public class JingleConnection implements Transferable {
|
||||||
public void onFileTransmitted(DownloadableFile file) {
|
public void onFileTransmitted(DownloadableFile file) {
|
||||||
if (responding()) {
|
if (responding()) {
|
||||||
if (expectedHash.length > 0 && !Arrays.equals(expectedHash, file.getSha1Sum())) {
|
if (expectedHash.length > 0 && !Arrays.equals(expectedHash, file.getSha1Sum())) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": hashes did not match");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": hashes did not match");
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": file transmitted(). we are responding");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": file transmitted(). we are responding");
|
||||||
sendSuccess();
|
sendSuccess();
|
||||||
mXmppConnectionService.getFileBackend().updateFileParams(message);
|
xmppConnectionService.getFileBackend().updateFileParams(message);
|
||||||
mXmppConnectionService.databaseBackend.createMessage(message);
|
xmppConnectionService.databaseBackend.createMessage(message);
|
||||||
mXmppConnectionService.markMessage(message, Message.STATUS_RECEIVED);
|
xmppConnectionService.markMessage(message, Message.STATUS_RECEIVED);
|
||||||
if (acceptedAutomatically) {
|
if (acceptedAutomatically) {
|
||||||
message.markUnread();
|
message.markUnread();
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
account.getPgpDecryptionService().decrypt(message, true);
|
id.account.getPgpDecryptionService().decrypt(message, true);
|
||||||
} else {
|
} else {
|
||||||
mXmppConnectionService.getFileBackend().updateMediaScanner(file, () -> JingleConnection.this.mXmppConnectionService.getNotificationService().push(message));
|
xmppConnectionService.getFileBackend().updateMediaScanner(file, () -> JingleFileTransferConnection.this.xmppConnectionService.getNotificationService().push(message));
|
||||||
|
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "successfully transmitted file:" + file.getAbsolutePath() + " (" + CryptoHelper.bytesToHex(file.getSha1Sum()) + ")");
|
Log.d(Config.LOGTAG, "successfully transmitted file:" + file.getAbsolutePath() + " (" + CryptoHelper.bytesToHex(file.getSha1Sum()) + ")");
|
||||||
return;
|
return;
|
||||||
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
account.getPgpDecryptionService().decrypt(message, true);
|
id.account.getPgpDecryptionService().decrypt(message, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ftVersion == Content.Version.FT_5) { //older Conversations will break when receiving a session-info
|
if (ftVersion == Content.Version.FT_5) { //older Conversations will break when receiving a session-info
|
||||||
sendHash();
|
sendHash();
|
||||||
}
|
}
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
account.getPgpDecryptionService().decrypt(message, false);
|
id.account.getPgpDecryptionService().decrypt(message, false);
|
||||||
}
|
}
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
||||||
file.delete();
|
file.delete();
|
||||||
|
@ -142,14 +138,14 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "successfully transmitted file:" + file.getAbsolutePath() + " (" + CryptoHelper.bytesToHex(file.getSha1Sum()) + ")");
|
Log.d(Config.LOGTAG, "successfully transmitted file:" + file.getAbsolutePath() + " (" + CryptoHelper.bytesToHex(file.getSha1Sum()) + ")");
|
||||||
if (message.getEncryption() != Message.ENCRYPTION_PGP) {
|
if (message.getEncryption() != Message.ENCRYPTION_PGP) {
|
||||||
mXmppConnectionService.getFileBackend().updateMediaScanner(file);
|
xmppConnectionService.getFileBackend().updateMediaScanner(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileTransferAborted() {
|
public void onFileTransferAborted() {
|
||||||
JingleConnection.this.sendSessionTerminate("connectivity-error");
|
JingleFileTransferConnection.this.sendSessionTerminate("connectivity-error");
|
||||||
JingleConnection.this.fail();
|
JingleFileTransferConnection.this.fail();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private OnTransportConnected onIbbTransportConnected = new OnTransportConnected() {
|
private OnTransportConnected onIbbTransportConnected = new OnTransportConnected() {
|
||||||
|
@ -160,16 +156,16 @@ public class JingleConnection implements Transferable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void established() {
|
public void established() {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ibb transport connected. sending file");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ibb transport connected. sending file");
|
||||||
mJingleStatus = JINGLE_STATUS_TRANSMITTING;
|
mJingleStatus = JINGLE_STATUS_TRANSMITTING;
|
||||||
JingleConnection.this.transport.send(file, onFileTransmissionStatusChanged);
|
JingleFileTransferConnection.this.transport.send(file, onFileTransmissionStatusChanged);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private OnProxyActivated onProxyActivated = new OnProxyActivated() {
|
private OnProxyActivated onProxyActivated = new OnProxyActivated() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
if (initiator.equals(account.getJid())) {
|
if (initiator.equals(id.account.getJid())) {
|
||||||
Log.d(Config.LOGTAG, "we were initiating. sending file");
|
Log.d(Config.LOGTAG, "we were initiating. sending file");
|
||||||
transport.send(file, onFileTransmissionStatusChanged);
|
transport.send(file, onFileTransmissionStatusChanged);
|
||||||
} else {
|
} else {
|
||||||
|
@ -180,7 +176,7 @@ public class JingleConnection implements Transferable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": proxy activation failed");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": proxy activation failed");
|
||||||
proxyActivationFailed = true;
|
proxyActivationFailed = true;
|
||||||
if (initiating()) {
|
if (initiating()) {
|
||||||
sendFallbackToIbb();
|
sendFallbackToIbb();
|
||||||
|
@ -188,18 +184,28 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public JingleConnection(JingleConnectionManager mJingleConnectionManager) {
|
public JingleFileTransferConnection(JingleConnectionManager jingleConnectionManager, Id id) {
|
||||||
this.mJingleConnectionManager = mJingleConnectionManager;
|
super(jingleConnectionManager, id);
|
||||||
this.mXmppConnectionService = mJingleConnectionManager
|
}
|
||||||
.getXmppConnectionService();
|
|
||||||
|
private static long parseLong(final Element element, final long l) {
|
||||||
|
final String input = element == null ? null : element.getContent();
|
||||||
|
if (input == null) {
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Long.parseLong(input);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return l;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean responding() {
|
private boolean responding() {
|
||||||
return responder != null && responder.equals(account.getJid());
|
return responder != null && responder.equals(id.account.getJid());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean initiating() {
|
private boolean initiating() {
|
||||||
return initiator.equals(account.getJid());
|
return initiator.equals(id.account.getJid());
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream getFileInputStream() {
|
InputStream getFileInputStream() {
|
||||||
|
@ -211,25 +217,19 @@ public class JingleConnection implements Transferable {
|
||||||
Log.d(Config.LOGTAG, "file object was not assigned");
|
Log.d(Config.LOGTAG, "file object was not assigned");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
this.file.getParentFile().mkdirs();
|
final File parent = this.file.getParentFile();
|
||||||
this.file.createNewFile();
|
if (parent != null && parent.mkdirs()) {
|
||||||
|
Log.d(Config.LOGTAG,"created parent directories for file "+file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
if (this.file.createNewFile()) {
|
||||||
|
Log.d(Config.LOGTAG,"created output file "+file.getAbsolutePath());
|
||||||
|
}
|
||||||
this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file, false, true);
|
this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file, false, true);
|
||||||
return this.mFileOutputStream;
|
return this.mFileOutputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSessionId() {
|
@Override
|
||||||
return this.sessionId;
|
void deliverPacket(final JinglePacket packet) {
|
||||||
}
|
|
||||||
|
|
||||||
public Account getAccount() {
|
|
||||||
return this.account;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Jid getCounterPart() {
|
|
||||||
return this.message.getCounterpart();
|
|
||||||
}
|
|
||||||
|
|
||||||
void deliverPacket(JinglePacket packet) {
|
|
||||||
if (packet.isAction("session-terminate")) {
|
if (packet.isAction("session-terminate")) {
|
||||||
Reason reason = packet.getReason();
|
Reason reason = packet.getReason();
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
|
@ -289,7 +289,7 @@ public class JingleConnection implements Transferable {
|
||||||
final Element error = response.addChild("error").setAttribute("type", "cancel");
|
final Element error = response.addChild("error").setAttribute("type", "cancel");
|
||||||
error.addChild("not-acceptable", "urn:ietf:params:xml:ns:xmpp-stanzas");
|
error.addChild("not-acceptable", "urn:ietf:params:xml:ns:xmpp-stanzas");
|
||||||
}
|
}
|
||||||
mXmppConnectionService.sendIqPacket(account, response, null);
|
xmppConnectionService.sendIqPacket(id.account, response, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void respondToIqWithOutOfOrder(final IqPacket packet) {
|
private void respondToIqWithOutOfOrder(final IqPacket packet) {
|
||||||
|
@ -297,7 +297,7 @@ public class JingleConnection implements Transferable {
|
||||||
final Element error = response.addChild("error").setAttribute("type", "wait");
|
final Element error = response.addChild("error").setAttribute("type", "wait");
|
||||||
error.addChild("unexpected-request", "urn:ietf:params:xml:ns:xmpp-stanzas");
|
error.addChild("unexpected-request", "urn:ietf:params:xml:ns:xmpp-stanzas");
|
||||||
error.addChild("out-of-order", "urn:xmpp:jingle:errors:1");
|
error.addChild("out-of-order", "urn:xmpp:jingle:errors:1");
|
||||||
mXmppConnectionService.sendIqPacket(account, response, null);
|
xmppConnectionService.sendIqPacket(id.account, response, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(final Message message) {
|
public void init(final Message message) {
|
||||||
|
@ -318,24 +318,22 @@ public class JingleConnection implements Transferable {
|
||||||
private void init(Message message, XmppAxolotlMessage xmppAxolotlMessage) {
|
private void init(Message message, XmppAxolotlMessage xmppAxolotlMessage) {
|
||||||
this.mXmppAxolotlMessage = xmppAxolotlMessage;
|
this.mXmppAxolotlMessage = xmppAxolotlMessage;
|
||||||
this.contentCreator = "initiator";
|
this.contentCreator = "initiator";
|
||||||
this.contentName = this.mJingleConnectionManager.nextRandomId();
|
this.contentName = JingleConnectionManager.nextRandomId();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.account = message.getConversation().getAccount();
|
|
||||||
final List<String> remoteFeatures = getRemoteFeatures();
|
final List<String> remoteFeatures = getRemoteFeatures();
|
||||||
upgradeNamespace(remoteFeatures);
|
upgradeNamespace(remoteFeatures);
|
||||||
this.initialTransport = remoteFeatures.contains(Namespace.JINGLE_TRANSPORTS_S5B) ? Transport.SOCKS : Transport.IBB;
|
this.initialTransport = remoteFeatures.contains(Namespace.JINGLE_TRANSPORTS_S5B) ? Transport.SOCKS : Transport.IBB;
|
||||||
this.remoteSupportsOmemoJet = remoteFeatures.contains(Namespace.JINGLE_ENCRYPTED_TRANSPORT_OMEMO);
|
this.remoteSupportsOmemoJet = remoteFeatures.contains(Namespace.JINGLE_ENCRYPTED_TRANSPORT_OMEMO);
|
||||||
this.message.setTransferable(this);
|
this.message.setTransferable(this);
|
||||||
this.mStatus = Transferable.STATUS_UPLOADING;
|
this.mStatus = Transferable.STATUS_UPLOADING;
|
||||||
this.initiator = this.account.getJid();
|
this.initiator = this.id.account.getJid();
|
||||||
this.responder = this.message.getCounterpart();
|
this.responder = this.id.counterPart;
|
||||||
this.sessionId = this.mJingleConnectionManager.nextRandomId();
|
this.transportId = JingleConnectionManager.nextRandomId();
|
||||||
this.transportId = this.mJingleConnectionManager.nextRandomId();
|
|
||||||
if (this.initialTransport == Transport.IBB) {
|
if (this.initialTransport == Transport.IBB) {
|
||||||
this.sendInitRequest();
|
this.sendInitRequest();
|
||||||
} else {
|
} else {
|
||||||
gatherAndConnectDirectCandidates();
|
gatherAndConnectDirectCandidates();
|
||||||
this.mJingleConnectionManager.getPrimaryCandidate(account, initiating(), (success, candidate) -> {
|
this.jingleConnectionManager.getPrimaryCandidate(id.account, initiating(), (success, candidate) -> {
|
||||||
if (success) {
|
if (success) {
|
||||||
final JingleSocks5Transport socksConnection = new JingleSocks5Transport(this, candidate);
|
final JingleSocks5Transport socksConnection = new JingleSocks5Transport(this, candidate);
|
||||||
connections.put(candidate.getCid(), socksConnection);
|
connections.put(candidate.getCid(), socksConnection);
|
||||||
|
@ -367,10 +365,10 @@ public class JingleConnection implements Transferable {
|
||||||
private void gatherAndConnectDirectCandidates() {
|
private void gatherAndConnectDirectCandidates() {
|
||||||
final List<JingleCandidate> directCandidates;
|
final List<JingleCandidate> directCandidates;
|
||||||
if (Config.USE_DIRECT_JINGLE_CANDIDATES) {
|
if (Config.USE_DIRECT_JINGLE_CANDIDATES) {
|
||||||
if (account.isOnion() || mXmppConnectionService.useTorToConnect()) {
|
if (id.account.isOnion() || xmppConnectionService.useTorToConnect()) {
|
||||||
directCandidates = Collections.emptyList();
|
directCandidates = Collections.emptyList();
|
||||||
} else {
|
} else {
|
||||||
directCandidates = DirectConnectionUtils.getLocalCandidates(account.getJid());
|
directCandidates = DirectConnectionUtils.getLocalCandidates(id.account.getJid());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
directCandidates = Collections.emptyList();
|
directCandidates = Collections.emptyList();
|
||||||
|
@ -391,10 +389,10 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getRemoteFeatures() {
|
private List<String> getRemoteFeatures() {
|
||||||
Jid jid = this.message.getCounterpart();
|
final Jid jid = this.id.counterPart;
|
||||||
String resource = jid != null ? jid.getResource() : null;
|
String resource = jid != null ? jid.getResource() : null;
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
Presence presence = this.account.getRoster().getContact(jid).getPresences().getPresences().get(resource);
|
Presence presence = this.id.account.getRoster().getContact(jid).getPresences().getPresences().get(resource);
|
||||||
ServiceDiscoveryResult result = presence != null ? presence.getServiceDiscoveryResult() : null;
|
ServiceDiscoveryResult result = presence != null ? presence.getServiceDiscoveryResult() : null;
|
||||||
return result == null ? Collections.emptyList() : result.getFeatures();
|
return result == null ? Collections.emptyList() : result.getFeatures();
|
||||||
} else {
|
} else {
|
||||||
|
@ -402,22 +400,19 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Account account, JinglePacket packet) {
|
public void init(Account account, JinglePacket packet) { //should move to deliverPacket
|
||||||
this.mJingleStatus = JINGLE_STATUS_INITIATED;
|
this.mJingleStatus = JINGLE_STATUS_INITIATED;
|
||||||
Conversation conversation = this.mXmppConnectionService
|
Conversation conversation = this.xmppConnectionService
|
||||||
.findOrCreateConversation(account,
|
.findOrCreateConversation(account,
|
||||||
packet.getFrom().asBareJid(), false, false);
|
packet.getFrom().asBareJid(), false, false);
|
||||||
this.message = new Message(conversation, "", Message.ENCRYPTION_NONE);
|
this.message = new Message(conversation, "", Message.ENCRYPTION_NONE);
|
||||||
this.message.setStatus(Message.STATUS_RECEIVED);
|
this.message.setStatus(Message.STATUS_RECEIVED);
|
||||||
this.mStatus = Transferable.STATUS_OFFER;
|
this.mStatus = Transferable.STATUS_OFFER;
|
||||||
this.message.setTransferable(this);
|
this.message.setTransferable(this);
|
||||||
final Jid from = packet.getFrom();
|
this.message.setCounterpart(this.id.counterPart);
|
||||||
this.message.setCounterpart(from);
|
this.initiator = this.id.counterPart;
|
||||||
this.account = account;
|
this.responder = this.id.account.getJid();
|
||||||
this.initiator = packet.getFrom();
|
final Content content = packet.getJingleContent();
|
||||||
this.responder = this.account.getJid();
|
|
||||||
this.sessionId = packet.getSessionId();
|
|
||||||
Content content = packet.getJingleContent();
|
|
||||||
this.contentCreator = content.getAttribute("creator");
|
this.contentCreator = content.getAttribute("creator");
|
||||||
this.initialTransport = content.hasSocks5Transport() ? Transport.SOCKS : Transport.IBB;
|
this.initialTransport = content.hasSocks5Transport() ? Transport.SOCKS : Transport.IBB;
|
||||||
this.contentName = content.getAttribute("name");
|
this.contentName = content.getAttribute("name");
|
||||||
|
@ -459,7 +454,7 @@ public class JingleConnection implements Transferable {
|
||||||
if (encrypted == null) {
|
if (encrypted == null) {
|
||||||
final Element security = content.findChild("security", Namespace.JINGLE_ENCRYPTED_TRANSPORT);
|
final Element security = content.findChild("security", Namespace.JINGLE_ENCRYPTED_TRANSPORT);
|
||||||
if (security != null && AxolotlService.PEP_PREFIX.equals(security.getAttribute("type"))) {
|
if (security != null && AxolotlService.PEP_PREFIX.equals(security.getAttribute("type"))) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received jingle file offer with JET");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received jingle file offer with JET");
|
||||||
encrypted = security.findChild("encrypted", AxolotlService.PEP_PREFIX);
|
encrypted = security.findChild("encrypted", AxolotlService.PEP_PREFIX);
|
||||||
remoteIsUsingJet = true;
|
remoteIsUsingJet = true;
|
||||||
}
|
}
|
||||||
|
@ -490,10 +485,10 @@ public class JingleConnection implements Transferable {
|
||||||
long size = parseLong(fileSize, 0);
|
long size = parseLong(fileSize, 0);
|
||||||
message.setBody(Long.toString(size));
|
message.setBody(Long.toString(size));
|
||||||
conversation.add(message);
|
conversation.add(message);
|
||||||
mJingleConnectionManager.updateConversationUi(true);
|
jingleConnectionManager.updateConversationUi(true);
|
||||||
this.file = this.mXmppConnectionService.getFileBackend().getFile(message, false);
|
this.file = this.xmppConnectionService.getFileBackend().getFile(message, false);
|
||||||
if (mXmppAxolotlMessage != null) {
|
if (mXmppAxolotlMessage != null) {
|
||||||
XmppAxolotlMessage.XmppAxolotlKeyTransportMessage transportMessage = account.getAxolotlService().processReceivingKeyTransportMessage(mXmppAxolotlMessage, false);
|
XmppAxolotlMessage.XmppAxolotlKeyTransportMessage transportMessage = id.account.getAxolotlService().processReceivingKeyTransportMessage(mXmppAxolotlMessage, false);
|
||||||
if (transportMessage != null) {
|
if (transportMessage != null) {
|
||||||
message.setEncryption(Message.ENCRYPTION_AXOLOTL);
|
message.setEncryption(Message.ENCRYPTION_AXOLOTL);
|
||||||
this.file.setKey(transportMessage.getKey());
|
this.file.setKey(transportMessage.getKey());
|
||||||
|
@ -511,11 +506,11 @@ public class JingleConnection implements Transferable {
|
||||||
|
|
||||||
respondToIq(packet, true);
|
respondToIq(packet, true);
|
||||||
|
|
||||||
if (account.getRoster().getContact(from).showInContactList()
|
if (id.account.getRoster().getContact(id.counterPart).showInContactList()
|
||||||
&& mJingleConnectionManager.hasStoragePermission()
|
&& jingleConnectionManager.hasStoragePermission()
|
||||||
&& size < this.mJingleConnectionManager.getAutoAcceptFileSize()
|
&& size < this.jingleConnectionManager.getAutoAcceptFileSize()
|
||||||
&& mXmppConnectionService.isDataSaverDisabled()) {
|
&& xmppConnectionService.isDataSaverDisabled()) {
|
||||||
Log.d(Config.LOGTAG, "auto accepting file from " + from);
|
Log.d(Config.LOGTAG, "auto accepting file from " + id.counterPart);
|
||||||
this.acceptedAutomatically = true;
|
this.acceptedAutomatically = true;
|
||||||
this.sendAccept();
|
this.sendAccept();
|
||||||
} else {
|
} else {
|
||||||
|
@ -524,9 +519,9 @@ public class JingleConnection implements Transferable {
|
||||||
"not auto accepting new file offer with size: "
|
"not auto accepting new file offer with size: "
|
||||||
+ size
|
+ size
|
||||||
+ " allowed size:"
|
+ " allowed size:"
|
||||||
+ this.mJingleConnectionManager
|
+ this.jingleConnectionManager
|
||||||
.getAutoAcceptFileSize());
|
.getAutoAcceptFileSize());
|
||||||
this.mXmppConnectionService.getNotificationService().push(message);
|
this.xmppConnectionService.getNotificationService().push(message);
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "receiving file: expecting size of " + this.file.getExpectedSize());
|
Log.d(Config.LOGTAG, "receiving file: expecting size of " + this.file.getExpectedSize());
|
||||||
return;
|
return;
|
||||||
|
@ -535,24 +530,12 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long parseLong(final Element element, final long l) {
|
|
||||||
final String input = element == null ? null : element.getContent();
|
|
||||||
if (input == null) {
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Long.parseLong(input);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendInitRequest() {
|
private void sendInitRequest() {
|
||||||
JinglePacket packet = this.bootstrapPacket("session-initiate");
|
JinglePacket packet = this.bootstrapPacket("session-initiate");
|
||||||
Content content = new Content(this.contentCreator, this.contentName);
|
Content content = new Content(this.contentCreator, this.contentName);
|
||||||
if (message.isFileOrImage()) {
|
if (message.isFileOrImage()) {
|
||||||
content.setTransportId(this.transportId);
|
content.setTransportId(this.transportId);
|
||||||
this.file = this.mXmppConnectionService.getFileBackend().getFile(message, false);
|
this.file = this.xmppConnectionService.getFileBackend().getFile(message, false);
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
|
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
|
||||||
this.file.setKey(mXmppAxolotlMessage.getInnerKey());
|
this.file.setKey(mXmppAxolotlMessage.getInnerKey());
|
||||||
this.file.setIv(mXmppAxolotlMessage.getIV());
|
this.file.setIv(mXmppAxolotlMessage.getIV());
|
||||||
|
@ -561,7 +544,7 @@ public class JingleConnection implements Transferable {
|
||||||
this.file.setExpectedSize(file.getSize() + (this.remoteSupportsOmemoJet ? 0 : 16));
|
this.file.setExpectedSize(file.getSize() + (this.remoteSupportsOmemoJet ? 0 : 16));
|
||||||
final Element file = content.setFileOffer(this.file, false, this.ftVersion);
|
final Element file = content.setFileOffer(this.file, false, this.ftVersion);
|
||||||
if (remoteSupportsOmemoJet) {
|
if (remoteSupportsOmemoJet) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": remote announced support for JET");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": remote announced support for JET");
|
||||||
final Element security = new Element("security", Namespace.JINGLE_ENCRYPTED_TRANSPORT);
|
final Element security = new Element("security", Namespace.JINGLE_ENCRYPTED_TRANSPORT);
|
||||||
security.setAttribute("name", this.contentName);
|
security.setAttribute("name", this.contentName);
|
||||||
security.setAttribute("cipher", JET_OMEMO_CIPHER);
|
security.setAttribute("cipher", JET_OMEMO_CIPHER);
|
||||||
|
@ -585,19 +568,19 @@ public class JingleConnection implements Transferable {
|
||||||
content.setTransportId(this.transportId);
|
content.setTransportId(this.transportId);
|
||||||
if (this.initialTransport == Transport.IBB) {
|
if (this.initialTransport == Transport.IBB) {
|
||||||
content.ibbTransport().setAttribute("block-size", Integer.toString(this.ibbBlockSize));
|
content.ibbTransport().setAttribute("block-size", Integer.toString(this.ibbBlockSize));
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": sending IBB offer");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending IBB offer");
|
||||||
} else {
|
} else {
|
||||||
final List<Element> candidates = getCandidatesAsElements();
|
final List<Element> candidates = getCandidatesAsElements();
|
||||||
Log.d(Config.LOGTAG, String.format("%s: sending S5B offer with %d candidates", account.getJid().asBareJid(), candidates.size()));
|
Log.d(Config.LOGTAG, String.format("%s: sending S5B offer with %d candidates", id.account.getJid().asBareJid(), candidates.size()));
|
||||||
content.socks5transport().setChildren(candidates);
|
content.socks5transport().setChildren(candidates);
|
||||||
}
|
}
|
||||||
packet.setContent(content);
|
packet.setContent(content);
|
||||||
this.sendJinglePacket(packet, (account, response) -> {
|
this.sendJinglePacket(packet, (account, response) -> {
|
||||||
if (response.getType() == IqPacket.TYPE.RESULT) {
|
if (response.getType() == IqPacket.TYPE.RESULT) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": other party received offer");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": other party received offer");
|
||||||
if (mJingleStatus == JINGLE_STATUS_OFFERED) {
|
if (mJingleStatus == JINGLE_STATUS_OFFERED) {
|
||||||
mJingleStatus = JINGLE_STATUS_INITIATED;
|
mJingleStatus = JINGLE_STATUS_INITIATED;
|
||||||
mXmppConnectionService.markMessage(message, Message.STATUS_OFFERED);
|
xmppConnectionService.markMessage(message, Message.STATUS_OFFERED);
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "received ack for offer when status was " + mJingleStatus);
|
Log.d(Config.LOGTAG, "received ack for offer when status was " + mJingleStatus);
|
||||||
}
|
}
|
||||||
|
@ -628,7 +611,7 @@ public class JingleConnection implements Transferable {
|
||||||
private void sendAccept() {
|
private void sendAccept() {
|
||||||
mJingleStatus = JINGLE_STATUS_ACCEPTED;
|
mJingleStatus = JINGLE_STATUS_ACCEPTED;
|
||||||
this.mStatus = Transferable.STATUS_DOWNLOADING;
|
this.mStatus = Transferable.STATUS_DOWNLOADING;
|
||||||
this.mJingleConnectionManager.updateConversationUi(true);
|
this.jingleConnectionManager.updateConversationUi(true);
|
||||||
if (initialTransport == Transport.SOCKS) {
|
if (initialTransport == Transport.SOCKS) {
|
||||||
sendAcceptSocks();
|
sendAcceptSocks();
|
||||||
} else {
|
} else {
|
||||||
|
@ -638,7 +621,7 @@ public class JingleConnection implements Transferable {
|
||||||
|
|
||||||
private void sendAcceptSocks() {
|
private void sendAcceptSocks() {
|
||||||
gatherAndConnectDirectCandidates();
|
gatherAndConnectDirectCandidates();
|
||||||
this.mJingleConnectionManager.getPrimaryCandidate(this.account, initiating(), (success, candidate) -> {
|
this.jingleConnectionManager.getPrimaryCandidate(this.id.account, initiating(), (success, candidate) -> {
|
||||||
final JinglePacket packet = bootstrapPacket("session-accept");
|
final JinglePacket packet = bootstrapPacket("session-accept");
|
||||||
final Content content = new Content(contentCreator, contentName);
|
final Content content = new Content(contentCreator, contentName);
|
||||||
content.setFileOffer(fileOffer, ftVersion);
|
content.setFileOffer(fileOffer, ftVersion);
|
||||||
|
@ -692,34 +675,34 @@ public class JingleConnection implements Transferable {
|
||||||
private JinglePacket bootstrapPacket(String action) {
|
private JinglePacket bootstrapPacket(String action) {
|
||||||
JinglePacket packet = new JinglePacket();
|
JinglePacket packet = new JinglePacket();
|
||||||
packet.setAction(action);
|
packet.setAction(action);
|
||||||
packet.setFrom(account.getJid());
|
packet.setFrom(id.account.getJid());
|
||||||
packet.setTo(this.message.getCounterpart());
|
packet.setTo(id.counterPart);
|
||||||
packet.setSessionId(this.sessionId);
|
packet.setSessionId(this.id.sessionId);
|
||||||
packet.setInitiator(this.initiator);
|
packet.setInitiator(this.initiator);
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendJinglePacket(JinglePacket packet) {
|
private void sendJinglePacket(JinglePacket packet) {
|
||||||
mXmppConnectionService.sendIqPacket(account, packet, responseListener);
|
xmppConnectionService.sendIqPacket(id.account, packet, responseListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendJinglePacket(JinglePacket packet, OnIqPacketReceived callback) {
|
private void sendJinglePacket(JinglePacket packet, OnIqPacketReceived callback) {
|
||||||
mXmppConnectionService.sendIqPacket(account, packet, callback);
|
xmppConnectionService.sendIqPacket(id.account, packet, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void receiveAccept(JinglePacket packet) {
|
private void receiveAccept(JinglePacket packet) {
|
||||||
if (responding()) {
|
if (responding()) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order session-accept (we were responding)");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received out of order session-accept (we were responding)");
|
||||||
respondToIqWithOutOfOrder(packet);
|
respondToIqWithOutOfOrder(packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.mJingleStatus != JINGLE_STATUS_INITIATED) {
|
if (this.mJingleStatus != JINGLE_STATUS_INITIATED) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order session-accept");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received out of order session-accept");
|
||||||
respondToIqWithOutOfOrder(packet);
|
respondToIqWithOutOfOrder(packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.mJingleStatus = JINGLE_STATUS_ACCEPTED;
|
this.mJingleStatus = JINGLE_STATUS_ACCEPTED;
|
||||||
mXmppConnectionService.markMessage(message, Message.STATUS_UNSEND);
|
xmppConnectionService.markMessage(message, Message.STATUS_UNSEND);
|
||||||
Content content = packet.getJingleContent();
|
Content content = packet.getJingleContent();
|
||||||
if (content.hasSocks5Transport()) {
|
if (content.hasSocks5Transport()) {
|
||||||
respondToIq(packet, true);
|
respondToIq(packet, true);
|
||||||
|
@ -734,7 +717,7 @@ public class JingleConnection implements Transferable {
|
||||||
this.ibbBlockSize = bs;
|
this.ibbBlockSize = bs;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to parse block size in session-accept");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to parse block size in session-accept");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
respondToIq(packet, true);
|
respondToIq(packet, true);
|
||||||
|
@ -769,7 +752,7 @@ public class JingleConnection implements Transferable {
|
||||||
respondToIq(packet, true);
|
respondToIq(packet, true);
|
||||||
onProxyActivated.failed();
|
onProxyActivated.failed();
|
||||||
} else if (content.socks5transport().hasChild("candidate-error")) {
|
} else if (content.socks5transport().hasChild("candidate-error")) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received candidate error");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received candidate error");
|
||||||
respondToIq(packet, true);
|
respondToIq(packet, true);
|
||||||
this.receivedCandidate = true;
|
this.receivedCandidate = true;
|
||||||
if (mJingleStatus == JINGLE_STATUS_ACCEPTED && this.sentCandidate) {
|
if (mJingleStatus == JINGLE_STATUS_ACCEPTED && this.sentCandidate) {
|
||||||
|
@ -808,21 +791,21 @@ public class JingleConnection implements Transferable {
|
||||||
final JingleSocks5Transport connection = chooseConnection();
|
final JingleSocks5Transport connection = chooseConnection();
|
||||||
this.transport = connection;
|
this.transport = connection;
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not find suitable candidate");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": could not find suitable candidate");
|
||||||
this.disconnectSocks5Connections();
|
this.disconnectSocks5Connections();
|
||||||
if (initiating()) {
|
if (initiating()) {
|
||||||
this.sendFallbackToIbb();
|
this.sendFallbackToIbb();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final JingleCandidate candidate = connection.getCandidate();
|
final JingleCandidate candidate = connection.getCandidate();
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": elected candidate " + candidate.getHost() + ":" + candidate.getPort());
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": elected candidate " + candidate.getHost() + ":" + candidate.getPort());
|
||||||
this.mJingleStatus = JINGLE_STATUS_TRANSMITTING;
|
this.mJingleStatus = JINGLE_STATUS_TRANSMITTING;
|
||||||
if (connection.needsActivation()) {
|
if (connection.needsActivation()) {
|
||||||
if (connection.getCandidate().isOurs()) {
|
if (connection.getCandidate().isOurs()) {
|
||||||
final String sid;
|
final String sid;
|
||||||
if (ftVersion == Content.Version.FT_3) {
|
if (ftVersion == Content.Version.FT_3) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": use session ID instead of transport ID to activate proxy");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": use session ID instead of transport ID to activate proxy");
|
||||||
sid = getSessionId();
|
sid = id.sessionId;
|
||||||
} else {
|
} else {
|
||||||
sid = getTransportId();
|
sid = getTransportId();
|
||||||
}
|
}
|
||||||
|
@ -834,10 +817,10 @@ public class JingleConnection implements Transferable {
|
||||||
activation.query("http://jabber.org/protocol/bytestreams")
|
activation.query("http://jabber.org/protocol/bytestreams")
|
||||||
.setAttribute("sid", sid);
|
.setAttribute("sid", sid);
|
||||||
activation.query().addChild("activate")
|
activation.query().addChild("activate")
|
||||||
.setContent(this.getCounterPart().toString());
|
.setContent(this.id.counterPart.toEscapedString());
|
||||||
mXmppConnectionService.sendIqPacket(account, activation, (account, response) -> {
|
xmppConnectionService.sendIqPacket(this.id.account, activation, (account, response) -> {
|
||||||
if (response.getType() != IqPacket.TYPE.RESULT) {
|
if (response.getType() != IqPacket.TYPE.RESULT) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + response.toString());
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": " + response.toString());
|
||||||
sendProxyError();
|
sendProxyError();
|
||||||
onProxyActivated.failed();
|
onProxyActivated.failed();
|
||||||
} else {
|
} else {
|
||||||
|
@ -904,15 +887,15 @@ public class JingleConnection implements Transferable {
|
||||||
this.mJingleStatus = JINGLE_STATUS_FINISHED;
|
this.mJingleStatus = JINGLE_STATUS_FINISHED;
|
||||||
this.message.setStatus(Message.STATUS_RECEIVED);
|
this.message.setStatus(Message.STATUS_RECEIVED);
|
||||||
this.message.setTransferable(null);
|
this.message.setTransferable(null);
|
||||||
this.mXmppConnectionService.updateMessage(message, false);
|
this.xmppConnectionService.updateMessage(message, false);
|
||||||
this.mJingleConnectionManager.finishConnection(this);
|
this.jingleConnectionManager.finishConnection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendFallbackToIbb() {
|
private void sendFallbackToIbb() {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": sending fallback to ibb");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending fallback to ibb");
|
||||||
JinglePacket packet = this.bootstrapPacket("transport-replace");
|
JinglePacket packet = this.bootstrapPacket("transport-replace");
|
||||||
Content content = new Content(this.contentCreator, this.contentName);
|
Content content = new Content(this.contentCreator, this.contentName);
|
||||||
this.transportId = this.mJingleConnectionManager.nextRandomId();
|
this.transportId = this.jingleConnectionManager.nextRandomId();
|
||||||
content.setTransportId(this.transportId);
|
content.setTransportId(this.transportId);
|
||||||
content.ibbTransport().setAttribute("block-size",
|
content.ibbTransport().setAttribute("block-size",
|
||||||
Integer.toString(this.ibbBlockSize));
|
Integer.toString(this.ibbBlockSize));
|
||||||
|
@ -923,18 +906,18 @@ public class JingleConnection implements Transferable {
|
||||||
|
|
||||||
private void receiveFallbackToIbb(JinglePacket packet) {
|
private void receiveFallbackToIbb(JinglePacket packet) {
|
||||||
if (initiating()) {
|
if (initiating()) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order transport-replace (we were initiating)");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received out of order transport-replace (we were initiating)");
|
||||||
respondToIqWithOutOfOrder(packet);
|
respondToIqWithOutOfOrder(packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean validState = mJingleStatus == JINGLE_STATUS_ACCEPTED || (proxyActivationFailed && mJingleStatus == JINGLE_STATUS_TRANSMITTING);
|
final boolean validState = mJingleStatus == JINGLE_STATUS_ACCEPTED || (proxyActivationFailed && mJingleStatus == JINGLE_STATUS_TRANSMITTING);
|
||||||
if (!validState) {
|
if (!validState) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order transport-replace");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received out of order transport-replace");
|
||||||
respondToIqWithOutOfOrder(packet);
|
respondToIqWithOutOfOrder(packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.proxyActivationFailed = false; //fallback received; now we no longer need to accept another one;
|
this.proxyActivationFailed = false; //fallback received; now we no longer need to accept another one;
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": receiving fallback to ibb");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": receiving fallback to ibb");
|
||||||
final String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size");
|
final String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size");
|
||||||
if (receivedBlockSize != null) {
|
if (receivedBlockSize != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -943,7 +926,7 @@ public class JingleConnection implements Transferable {
|
||||||
this.ibbBlockSize = bs;
|
this.ibbBlockSize = bs;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to parse block size in transport-replace");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to parse block size in transport-replace");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.transportId = packet.getJingleContent().getTransportId();
|
this.transportId = packet.getJingleContent().getTransportId();
|
||||||
|
@ -961,7 +944,7 @@ public class JingleConnection implements Transferable {
|
||||||
if (initiating()) {
|
if (initiating()) {
|
||||||
this.sendJinglePacket(answer, (account, response) -> {
|
this.sendJinglePacket(answer, (account, response) -> {
|
||||||
if (response.getType() == IqPacket.TYPE.RESULT) {
|
if (response.getType() == IqPacket.TYPE.RESULT) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + " recipient ACKed our transport-accept. creating ibb");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + " recipient ACKed our transport-accept. creating ibb");
|
||||||
transport.connect(onIbbTransportConnected);
|
transport.connect(onIbbTransportConnected);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -973,13 +956,13 @@ public class JingleConnection implements Transferable {
|
||||||
|
|
||||||
private void receiveTransportAccept(JinglePacket packet) {
|
private void receiveTransportAccept(JinglePacket packet) {
|
||||||
if (responding()) {
|
if (responding()) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order transport-accept (we were responding)");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received out of order transport-accept (we were responding)");
|
||||||
respondToIqWithOutOfOrder(packet);
|
respondToIqWithOutOfOrder(packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean validState = mJingleStatus == JINGLE_STATUS_ACCEPTED || (proxyActivationFailed && mJingleStatus == JINGLE_STATUS_TRANSMITTING);
|
final boolean validState = mJingleStatus == JINGLE_STATUS_ACCEPTED || (proxyActivationFailed && mJingleStatus == JINGLE_STATUS_TRANSMITTING);
|
||||||
if (!validState) {
|
if (!validState) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order transport-accept");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received out of order transport-accept");
|
||||||
respondToIqWithOutOfOrder(packet);
|
respondToIqWithOutOfOrder(packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -995,13 +978,13 @@ public class JingleConnection implements Transferable {
|
||||||
this.ibbBlockSize = bs;
|
this.ibbBlockSize = bs;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to parse block size in transport-accept");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to parse block size in transport-accept");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.transport = new JingleInBandTransport(this, this.transportId, this.ibbBlockSize);
|
this.transport = new JingleInBandTransport(this, this.transportId, this.ibbBlockSize);
|
||||||
|
|
||||||
if (sid == null || !sid.equals(this.transportId)) {
|
if (sid == null || !sid.equals(this.transportId)) {
|
||||||
Log.w(Config.LOGTAG, String.format("%s: sid in transport-accept (%s) did not match our sid (%s) ", account.getJid().asBareJid(), sid, transportId));
|
Log.w(Config.LOGTAG, String.format("%s: sid in transport-accept (%s) did not match our sid (%s) ", id.account.getJid().asBareJid(), sid, transportId));
|
||||||
}
|
}
|
||||||
respondToIq(packet, true);
|
respondToIq(packet, true);
|
||||||
//might be receive instead if we are not initiating
|
//might be receive instead if we are not initiating
|
||||||
|
@ -1009,7 +992,7 @@ public class JingleConnection implements Transferable {
|
||||||
this.transport.connect(onIbbTransportConnected);
|
this.transport.connect(onIbbTransportConnected);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received invalid transport-accept");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received invalid transport-accept");
|
||||||
respondToIq(packet, false);
|
respondToIq(packet, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1017,15 +1000,15 @@ public class JingleConnection implements Transferable {
|
||||||
private void receiveSuccess() {
|
private void receiveSuccess() {
|
||||||
if (initiating()) {
|
if (initiating()) {
|
||||||
this.mJingleStatus = JINGLE_STATUS_FINISHED;
|
this.mJingleStatus = JINGLE_STATUS_FINISHED;
|
||||||
this.mXmppConnectionService.markMessage(this.message, Message.STATUS_SEND_RECEIVED);
|
this.xmppConnectionService.markMessage(this.message, Message.STATUS_SEND_RECEIVED);
|
||||||
this.disconnectSocks5Connections();
|
this.disconnectSocks5Connections();
|
||||||
if (this.transport instanceof JingleInBandTransport) {
|
if (this.transport instanceof JingleInBandTransport) {
|
||||||
this.transport.disconnect();
|
this.transport.disconnect();
|
||||||
}
|
}
|
||||||
this.message.setTransferable(null);
|
this.message.setTransferable(null);
|
||||||
this.mJingleConnectionManager.finishConnection(this);
|
this.jingleConnectionManager.finishConnection(this);
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received session-terminate/success while responding");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received session-terminate/success while responding");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,15 +1024,15 @@ public class JingleConnection implements Transferable {
|
||||||
this.transport.disconnect();
|
this.transport.disconnect();
|
||||||
}
|
}
|
||||||
sendSessionTerminate(reason);
|
sendSessionTerminate(reason);
|
||||||
this.mJingleConnectionManager.finishConnection(this);
|
this.jingleConnectionManager.finishConnection(this);
|
||||||
if (responding()) {
|
if (responding()) {
|
||||||
this.message.setTransferable(new TransferablePlaceholder(cancelled ? Transferable.STATUS_CANCELLED : Transferable.STATUS_FAILED));
|
this.message.setTransferable(new TransferablePlaceholder(cancelled ? Transferable.STATUS_CANCELLED : Transferable.STATUS_FAILED));
|
||||||
if (this.file != null) {
|
if (this.file != null) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
this.mJingleConnectionManager.updateConversationUi(true);
|
this.jingleConnectionManager.updateConversationUi(true);
|
||||||
} else {
|
} else {
|
||||||
this.mXmppConnectionService.markMessage(this.message, Message.STATUS_SEND_FAILED, cancelled ? Message.ERROR_MESSAGE_CANCELLED : null);
|
this.xmppConnectionService.markMessage(this.message, Message.STATUS_SEND_FAILED, cancelled ? Message.ERROR_MESSAGE_CANCELLED : null);
|
||||||
this.message.setTransferable(null);
|
this.message.setTransferable(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1072,15 +1055,15 @@ public class JingleConnection implements Transferable {
|
||||||
if (this.file != null) {
|
if (this.file != null) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
this.mJingleConnectionManager.updateConversationUi(true);
|
this.jingleConnectionManager.updateConversationUi(true);
|
||||||
} else {
|
} else {
|
||||||
this.mXmppConnectionService.markMessage(this.message,
|
this.xmppConnectionService.markMessage(this.message,
|
||||||
Message.STATUS_SEND_FAILED,
|
Message.STATUS_SEND_FAILED,
|
||||||
cancelled ? Message.ERROR_MESSAGE_CANCELLED : errorMessage);
|
cancelled ? Message.ERROR_MESSAGE_CANCELLED : errorMessage);
|
||||||
this.message.setTransferable(null);
|
this.message.setTransferable(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.mJingleConnectionManager.finishConnection(this);
|
this.jingleConnectionManager.finishConnection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendSessionTerminate(String reason) {
|
private void sendSessionTerminate(String reason) {
|
||||||
|
@ -1168,7 +1151,7 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendCandidateError() {
|
private void sendCandidateError() {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": sending candidate error");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending candidate error");
|
||||||
JinglePacket packet = bootstrapPacket("transport-info");
|
JinglePacket packet = bootstrapPacket("transport-info");
|
||||||
Content content = new Content(this.contentCreator, this.contentName);
|
Content content = new Content(this.contentCreator, this.contentName);
|
||||||
content.setTransportId(this.transportId);
|
content.setTransportId(this.transportId);
|
||||||
|
@ -1221,7 +1204,7 @@ public class JingleConnection implements Transferable {
|
||||||
|
|
||||||
void updateProgress(int i) {
|
void updateProgress(int i) {
|
||||||
this.mProgress = i;
|
this.mProgress = i;
|
||||||
mJingleConnectionManager.updateConversationUi(false);
|
jingleConnectionManager.updateConversationUi(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTransportId() {
|
public String getTransportId() {
|
||||||
|
@ -1241,7 +1224,7 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
if (account.getStatus() == Account.State.ONLINE) {
|
if (id.account.getStatus() == Account.State.ONLINE) {
|
||||||
if (mJingleStatus == JINGLE_STATUS_INITIATED) {
|
if (mJingleStatus == JINGLE_STATUS_INITIATED) {
|
||||||
new Thread(this::sendAccept).start();
|
new Thread(this::sendAccept).start();
|
||||||
}
|
}
|
||||||
|
@ -1271,7 +1254,7 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractConnectionManager getConnectionManager() {
|
public AbstractConnectionManager getConnectionManager() {
|
||||||
return this.mJingleConnectionManager;
|
return this.jingleConnectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OnProxyActivated {
|
interface OnProxyActivated {
|
|
@ -33,7 +33,7 @@ public class JingleInBandTransport extends JingleTransport {
|
||||||
private boolean connected = true;
|
private boolean connected = true;
|
||||||
|
|
||||||
private DownloadableFile file;
|
private DownloadableFile file;
|
||||||
private final JingleConnection connection;
|
private final JingleFileTransferConnection connection;
|
||||||
|
|
||||||
private InputStream fileInputStream = null;
|
private InputStream fileInputStream = null;
|
||||||
private InputStream innerInputStream = null;
|
private InputStream innerInputStream = null;
|
||||||
|
@ -60,10 +60,10 @@ public class JingleInBandTransport extends JingleTransport {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
JingleInBandTransport(final JingleConnection connection, final String sid, final int blockSize) {
|
JingleInBandTransport(final JingleFileTransferConnection connection, final String sid, final int blockSize) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.account = connection.getAccount();
|
this.account = connection.getId().account;
|
||||||
this.counterpart = connection.getCounterPart();
|
this.counterpart = connection.getId().counterPart;
|
||||||
this.blockSize = blockSize;
|
this.blockSize = blockSize;
|
||||||
this.sessionId = sid;
|
this.sessionId = sid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,9 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
private static final int SOCKET_TIMEOUT_PROXY = 5000;
|
private static final int SOCKET_TIMEOUT_PROXY = 5000;
|
||||||
|
|
||||||
private final JingleCandidate candidate;
|
private final JingleCandidate candidate;
|
||||||
private final JingleConnection connection;
|
private final JingleFileTransferConnection connection;
|
||||||
private final String destination;
|
private final String destination;
|
||||||
|
private final Account account;
|
||||||
private OutputStream outputStream;
|
private OutputStream outputStream;
|
||||||
private InputStream inputStream;
|
private InputStream inputStream;
|
||||||
private boolean isEstablished = false;
|
private boolean isEstablished = false;
|
||||||
|
@ -40,7 +41,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
private ServerSocket serverSocket;
|
private ServerSocket serverSocket;
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
|
|
||||||
JingleSocks5Transport(JingleConnection jingleConnection, JingleCandidate candidate) {
|
JingleSocks5Transport(JingleFileTransferConnection jingleConnection, JingleCandidate candidate) {
|
||||||
final MessageDigest messageDigest;
|
final MessageDigest messageDigest;
|
||||||
try {
|
try {
|
||||||
messageDigest = MessageDigest.getInstance("SHA-1");
|
messageDigest = MessageDigest.getInstance("SHA-1");
|
||||||
|
@ -49,19 +50,20 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
}
|
}
|
||||||
this.candidate = candidate;
|
this.candidate = candidate;
|
||||||
this.connection = jingleConnection;
|
this.connection = jingleConnection;
|
||||||
|
this.account = jingleConnection.getId().account;
|
||||||
final StringBuilder destBuilder = new StringBuilder();
|
final StringBuilder destBuilder = new StringBuilder();
|
||||||
if (jingleConnection.getFtVersion() == Content.Version.FT_3) {
|
if (this.connection.getFtVersion() == Content.Version.FT_3) {
|
||||||
Log.d(Config.LOGTAG, this.connection.getAccount().getJid().asBareJid() + ": using session Id instead of transport Id for proxy destination");
|
Log.d(Config.LOGTAG, this.account.getJid().asBareJid() + ": using session Id instead of transport Id for proxy destination");
|
||||||
destBuilder.append(jingleConnection.getSessionId());
|
destBuilder.append(this.connection.getId().sessionId);
|
||||||
} else {
|
} else {
|
||||||
destBuilder.append(jingleConnection.getTransportId());
|
destBuilder.append(this.connection.getTransportId());
|
||||||
}
|
}
|
||||||
if (candidate.isOurs()) {
|
if (candidate.isOurs()) {
|
||||||
destBuilder.append(jingleConnection.getAccount().getJid());
|
destBuilder.append(this.account.getJid());
|
||||||
destBuilder.append(jingleConnection.getCounterPart());
|
destBuilder.append(this.connection.getId().counterPart);
|
||||||
} else {
|
} else {
|
||||||
destBuilder.append(jingleConnection.getCounterPart());
|
destBuilder.append(this.connection.getId().counterPart);
|
||||||
destBuilder.append(jingleConnection.getAccount().getJid());
|
destBuilder.append(this.account.getJid());
|
||||||
}
|
}
|
||||||
messageDigest.reset();
|
messageDigest.reset();
|
||||||
this.destination = CryptoHelper.bytesToHex(messageDigest.digest(destBuilder.toString().getBytes()));
|
this.destination = CryptoHelper.bytesToHex(messageDigest.digest(destBuilder.toString().getBytes()));
|
||||||
|
@ -130,7 +132,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
responseHeader = new byte[]{0x05, 0x00, 0x00, 0x03};
|
responseHeader = new byte[]{0x05, 0x00, 0x00, 0x03};
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG,connection.getAccount().getJid().asBareJid()+": destination mismatch. received "+receivedDestination+" (expected "+this.destination+")");
|
Log.d(Config.LOGTAG,this.account.getJid().asBareJid()+": destination mismatch. received "+receivedDestination+" (expected "+this.destination+")");
|
||||||
responseHeader = new byte[]{0x05, 0x04, 0x00, 0x03};
|
responseHeader = new byte[]{0x05, 0x04, 0x00, 0x03};
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +143,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
outputStream.write(response.array());
|
outputStream.write(response.array());
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
if (success) {
|
if (success) {
|
||||||
Log.d(Config.LOGTAG,connection.getAccount().getJid().asBareJid()+": successfully processed connection to candidate "+candidate.getHost()+":"+candidate.getPort());
|
Log.d(Config.LOGTAG,this.account.getJid().asBareJid()+": successfully processed connection to candidate "+candidate.getHost()+":"+candidate.getPort());
|
||||||
socket.setSoTimeout(0);
|
socket.setSoTimeout(0);
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
this.inputStream = inputStream;
|
this.inputStream = inputStream;
|
||||||
|
@ -160,7 +162,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
final int timeout = candidate.getType() == JingleCandidate.TYPE_DIRECT ? SOCKET_TIMEOUT_DIRECT : SOCKET_TIMEOUT_PROXY;
|
final int timeout = candidate.getType() == JingleCandidate.TYPE_DIRECT ? SOCKET_TIMEOUT_DIRECT : SOCKET_TIMEOUT_PROXY;
|
||||||
try {
|
try {
|
||||||
final boolean useTor = connection.getAccount().isOnion() || connection.getConnectionManager().getXmppConnectionService().useTorToConnect();
|
final boolean useTor = this.account.isOnion() || connection.getConnectionManager().getXmppConnectionService().useTorToConnect();
|
||||||
if (useTor) {
|
if (useTor) {
|
||||||
socket = SocksSocketFactory.createSocketOverTor(candidate.getHost(), candidate.getPort());
|
socket = SocksSocketFactory.createSocketOverTor(candidate.getHost(), candidate.getPort());
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,7 +187,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
public void send(final DownloadableFile file, final OnFileTransmissionStatusChanged callback) {
|
public void send(final DownloadableFile file, final OnFileTransmissionStatusChanged callback) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
InputStream fileInputStream = null;
|
InputStream fileInputStream = null;
|
||||||
final PowerManager.WakeLock wakeLock = connection.getConnectionManager().createWakeLock("jingle_send_" + connection.getSessionId());
|
final PowerManager.WakeLock wakeLock = connection.getConnectionManager().createWakeLock("jingle_send_" + connection.getId().sessionId);
|
||||||
long transmitted = 0;
|
long transmitted = 0;
|
||||||
try {
|
try {
|
||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
|
@ -193,7 +195,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
digest.reset();
|
digest.reset();
|
||||||
fileInputStream = connection.getFileInputStream();
|
fileInputStream = connection.getFileInputStream();
|
||||||
if (fileInputStream == null) {
|
if (fileInputStream == null) {
|
||||||
Log.d(Config.LOGTAG, connection.getAccount().getJid().asBareJid() + ": could not create input stream");
|
Log.d(Config.LOGTAG, this.account.getJid().asBareJid() + ": could not create input stream");
|
||||||
callback.onFileTransferAborted();
|
callback.onFileTransferAborted();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +215,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
callback.onFileTransmitted(file);
|
callback.onFileTransmitted(file);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
final Account account = connection.getAccount();
|
final Account account = this.account;
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid()+": failed sending file after "+transmitted+"/"+file.getExpectedSize()+" ("+ socket.getInetAddress()+":"+socket.getPort()+")", e);
|
Log.d(Config.LOGTAG, account.getJid().asBareJid()+": failed sending file after "+transmitted+"/"+file.getExpectedSize()+" ("+ socket.getInetAddress()+":"+socket.getPort()+")", e);
|
||||||
callback.onFileTransferAborted();
|
callback.onFileTransferAborted();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -227,7 +229,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
public void receive(final DownloadableFile file, final OnFileTransmissionStatusChanged callback) {
|
public void receive(final DownloadableFile file, final OnFileTransmissionStatusChanged callback) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
OutputStream fileOutputStream = null;
|
OutputStream fileOutputStream = null;
|
||||||
final PowerManager.WakeLock wakeLock = connection.getConnectionManager().createWakeLock("jingle_receive_" + connection.getSessionId());
|
final PowerManager.WakeLock wakeLock = connection.getConnectionManager().createWakeLock("jingle_receive_" + connection.getId().sessionId);
|
||||||
try {
|
try {
|
||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-1");
|
MessageDigest digest = MessageDigest.getInstance("SHA-1");
|
||||||
|
@ -237,7 +239,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
fileOutputStream = connection.getFileOutputStream();
|
fileOutputStream = connection.getFileOutputStream();
|
||||||
if (fileOutputStream == null) {
|
if (fileOutputStream == null) {
|
||||||
callback.onFileTransferAborted();
|
callback.onFileTransferAborted();
|
||||||
Log.d(Config.LOGTAG, connection.getAccount().getJid().asBareJid() + ": could not create output stream");
|
Log.d(Config.LOGTAG, this.account.getJid().asBareJid() + ": could not create output stream");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double size = file.getExpectedSize();
|
double size = file.getExpectedSize();
|
||||||
|
@ -248,7 +250,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
count = inputStream.read(buffer);
|
count = inputStream.read(buffer);
|
||||||
if (count == -1) {
|
if (count == -1) {
|
||||||
callback.onFileTransferAborted();
|
callback.onFileTransferAborted();
|
||||||
Log.d(Config.LOGTAG, connection.getAccount().getJid().asBareJid() + ": file ended prematurely with " + remainingSize + " bytes remaining");
|
Log.d(Config.LOGTAG, this.account.getJid().asBareJid() + ": file ended prematurely with " + remainingSize + " bytes remaining");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
fileOutputStream.write(buffer, 0, count);
|
fileOutputStream.write(buffer, 0, count);
|
||||||
|
@ -262,7 +264,7 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||||
file.setSha1Sum(digest.digest());
|
file.setSha1Sum(digest.digest());
|
||||||
callback.onFileTransmitted(file);
|
callback.onFileTransmitted(file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(Config.LOGTAG, connection.getAccount().getJid().asBareJid() + ": " + e.getMessage());
|
Log.d(Config.LOGTAG, this.account.getJid().asBareJid() + ": " + e.getMessage());
|
||||||
callback.onFileTransferAborted();
|
callback.onFileTransferAborted();
|
||||||
} finally {
|
} finally {
|
||||||
WakeLockHelper.release(wakeLock);
|
WakeLockHelper.release(wakeLock);
|
||||||
|
|
|
@ -6,6 +6,10 @@ import eu.siacs.conversations.xml.Namespace;
|
||||||
|
|
||||||
public class Content extends Element {
|
public class Content extends Element {
|
||||||
|
|
||||||
|
|
||||||
|
//refactor to getDescription and getTransport
|
||||||
|
//return either FileTransferDescription or GenericDescription or RtpDescription (all extend Description interface)
|
||||||
|
|
||||||
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"),
|
||||||
|
|
|
@ -7,11 +7,15 @@ import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class JinglePacket extends IqPacket {
|
public class JinglePacket extends IqPacket {
|
||||||
|
|
||||||
|
|
||||||
|
//get rid of that BS and set/get directly
|
||||||
Content content = null;
|
Content content = null;
|
||||||
Reason reason = null;
|
Reason reason = null;
|
||||||
Element checksum = null;
|
Element checksum = null;
|
||||||
Element jingle = new Element("jingle");
|
Element jingle = new Element("jingle");
|
||||||
|
|
||||||
|
//get rid of what ever that is; maybe throw illegal state to ensure we are only calling setContent etc
|
||||||
@Override
|
@Override
|
||||||
public Element addChild(Element child) {
|
public Element addChild(Element child) {
|
||||||
if ("jingle".equals(child.getName())) {
|
if ("jingle".equals(child.getName())) {
|
||||||
|
@ -33,7 +37,7 @@ public class JinglePacket extends IqPacket {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JinglePacket setContent(Content content) {
|
public JinglePacket setContent(Content content) { //take content interface
|
||||||
this.content = content;
|
this.content = content;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -45,19 +49,20 @@ public class JinglePacket extends IqPacket {
|
||||||
return this.content;
|
return this.content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Reason getReason() {
|
||||||
|
return this.reason;
|
||||||
|
}
|
||||||
|
|
||||||
public JinglePacket setReason(Reason reason) {
|
public JinglePacket setReason(Reason reason) {
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Reason getReason() {
|
|
||||||
return this.reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Element getChecksum() {
|
public Element getChecksum() {
|
||||||
return this.checksum;
|
return this.checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//should be unnecessary if we set and get directly
|
||||||
private void build() {
|
private void build() {
|
||||||
this.children.clear();
|
this.children.clear();
|
||||||
this.jingle.clearChildren();
|
this.jingle.clearChildren();
|
||||||
|
@ -89,14 +94,15 @@ public class JinglePacket extends IqPacket {
|
||||||
return super.toString();
|
return super.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAction(String action) {
|
//use enum for action
|
||||||
this.jingle.setAttribute("action", action);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAction() {
|
public String getAction() {
|
||||||
return this.jingle.getAttribute("action");
|
return this.jingle.getAttribute("action");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAction(String action) {
|
||||||
|
this.jingle.setAttribute("action", action);
|
||||||
|
}
|
||||||
|
|
||||||
public void setInitiator(final Jid initiator) {
|
public void setInitiator(final Jid initiator) {
|
||||||
this.jingle.setAttribute("initiator", initiator.toString());
|
this.jingle.setAttribute("initiator", initiator.toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue