include senders in jingle file offer

This commit is contained in:
Daniel Gultsch 2020-05-11 11:09:18 +02:00
parent 90526efbd4
commit b845c601d0
1 changed files with 20 additions and 2 deletions

View File

@ -78,6 +78,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
private String contentName; private String contentName;
private Content.Creator contentCreator; private Content.Creator contentCreator;
private Content.Senders contentSenders;
private Class<? extends GenericTransportInfo> initialTransport; private Class<? extends GenericTransportInfo> initialTransport;
private boolean remoteSupportsOmemoJet; private boolean remoteSupportsOmemoJet;
@ -339,6 +340,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
private void init(final Message message, final XmppAxolotlMessage xmppAxolotlMessage) { private void init(final Message message, final XmppAxolotlMessage xmppAxolotlMessage) {
this.mXmppAxolotlMessage = xmppAxolotlMessage; this.mXmppAxolotlMessage = xmppAxolotlMessage;
this.contentCreator = Content.Creator.INITIATOR; this.contentCreator = Content.Creator.INITIATOR;
this.contentSenders = Content.Senders.INITIATOR;
this.contentName = JingleConnectionManager.nextRandomId(); this.contentName = JingleConnectionManager.nextRandomId();
this.message = message; this.message = message;
final List<String> remoteFeatures = getRemoteFeatures(); final List<String> remoteFeatures = getRemoteFeatures();
@ -436,6 +438,13 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
final Content content = packet.getJingleContent(); final Content content = packet.getJingleContent();
final GenericTransportInfo transportInfo = content.getTransport(); final GenericTransportInfo transportInfo = content.getTransport();
this.contentCreator = content.getCreator(); this.contentCreator = content.getCreator();
Content.Senders senders;
try {
senders = content.getSenders();
} catch (final Exception e) {
senders = Content.Senders.INITIATOR;
}
this.contentSenders = senders;
this.contentName = content.getAttribute("name"); this.contentName = content.getAttribute("name");
if (transportInfo instanceof S5BTransportInfo) { if (transportInfo instanceof S5BTransportInfo) {
@ -571,6 +580,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
private void sendInitRequest() { private void sendInitRequest() {
final JinglePacket packet = this.bootstrapPacket(JinglePacket.Action.SESSION_INITIATE); final JinglePacket packet = this.bootstrapPacket(JinglePacket.Action.SESSION_INITIATE);
final Content content = new Content(this.contentCreator, this.contentName); final Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL && remoteSupportsOmemoJet) { if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL && remoteSupportsOmemoJet) {
Log.d(Config.LOGTAG, id.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);
@ -645,6 +655,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
this.jingleConnectionManager.getPrimaryCandidate(this.id.account, isInitiator(), (success, candidate) -> { this.jingleConnectionManager.getPrimaryCandidate(this.id.account, isInitiator(), (success, candidate) -> {
final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_ACCEPT); final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_ACCEPT);
final Content content = new Content(contentCreator, contentName); final Content content = new Content(contentCreator, contentName);
content.setSenders(this.contentSenders);
content.setDescription(this.description); content.setDescription(this.description);
if (success && candidate != null && !equalCandidateExists(candidate)) { if (success && candidate != null && !equalCandidateExists(candidate)) {
final JingleSocks5Transport socksConnection = new JingleSocks5Transport(this, candidate); final JingleSocks5Transport socksConnection = new JingleSocks5Transport(this, candidate);
@ -684,6 +695,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
this.transport = new JingleInBandTransport(this, this.transportId, this.ibbBlockSize); this.transport = new JingleInBandTransport(this, this.transportId, this.ibbBlockSize);
final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_ACCEPT); final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_ACCEPT);
final Content content = new Content(contentCreator, contentName); final Content content = new Content(contentCreator, contentName);
content.setSenders(this.contentSenders);
content.setDescription(this.description); content.setDescription(this.description);
content.setTransport(new IbbTransportInfo(this.transportId, this.ibbBlockSize)); content.setTransport(new IbbTransportInfo(this.transportId, this.ibbBlockSize));
packet.addJingleContent(content); packet.addJingleContent(content);
@ -909,8 +921,9 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
private void sendFallbackToIbb() { private void sendFallbackToIbb() {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending fallback to ibb"); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending fallback to ibb");
JinglePacket packet = this.bootstrapPacket(JinglePacket.Action.TRANSPORT_REPLACE); final JinglePacket packet = this.bootstrapPacket(JinglePacket.Action.TRANSPORT_REPLACE);
Content content = new Content(this.contentCreator, this.contentName); final Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
this.transportId = JingleConnectionManager.nextRandomId(); this.transportId = JingleConnectionManager.nextRandomId();
content.setTransport(new IbbTransportInfo(this.transportId, this.ibbBlockSize)); content.setTransport(new IbbTransportInfo(this.transportId, this.ibbBlockSize));
packet.addJingleContent(content); packet.addJingleContent(content);
@ -944,6 +957,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
final JinglePacket answer = bootstrapPacket(JinglePacket.Action.TRANSPORT_ACCEPT); final JinglePacket answer = bootstrapPacket(JinglePacket.Action.TRANSPORT_ACCEPT);
final Content content = new Content(contentCreator, contentName); final Content content = new Content(contentCreator, contentName);
content.setSenders(this.contentSenders);
content.setTransport(new IbbTransportInfo(this.transportId, this.ibbBlockSize)); content.setTransport(new IbbTransportInfo(this.transportId, this.ibbBlockSize));
answer.addJingleContent(content); answer.addJingleContent(content);
@ -1123,6 +1137,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
private void sendProxyActivated(String cid) { private void sendProxyActivated(String cid) {
final JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO); final JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO);
final Content content = new Content(this.contentCreator, this.contentName); final Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
content.setTransport(new S5BTransportInfo(this.transportId, new Element("activated").setAttribute("cid", cid))); content.setTransport(new S5BTransportInfo(this.transportId, new Element("activated").setAttribute("cid", cid)));
packet.addJingleContent(content); packet.addJingleContent(content);
this.sendJinglePacket(packet); this.sendJinglePacket(packet);
@ -1131,6 +1146,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
private void sendProxyError() { private void sendProxyError() {
final JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO); final JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO);
final Content content = new Content(this.contentCreator, this.contentName); final Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
content.setTransport(new S5BTransportInfo(this.transportId, new Element("proxy-error"))); content.setTransport(new S5BTransportInfo(this.transportId, new Element("proxy-error")));
packet.addJingleContent(content); packet.addJingleContent(content);
this.sendJinglePacket(packet); this.sendJinglePacket(packet);
@ -1139,6 +1155,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
private void sendCandidateUsed(final String cid) { private void sendCandidateUsed(final String cid) {
JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO); JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO);
final Content content = new Content(this.contentCreator, this.contentName); final Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
content.setTransport(new S5BTransportInfo(this.transportId, new Element("candidate-used").setAttribute("cid", cid))); content.setTransport(new S5BTransportInfo(this.transportId, new Element("candidate-used").setAttribute("cid", cid)));
packet.addJingleContent(content); packet.addJingleContent(content);
this.sentCandidate = true; this.sentCandidate = true;
@ -1152,6 +1169,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending candidate error"); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending candidate error");
JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO); JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO);
Content content = new Content(this.contentCreator, this.contentName); Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
content.setTransport(new S5BTransportInfo(this.transportId, new Element("candidate-error"))); content.setTransport(new S5BTransportInfo(this.transportId, new Element("candidate-error")));
packet.addJingleContent(content); packet.addJingleContent(content);
this.sentCandidate = true; this.sentCandidate = true;