From 385692ea289a92e61e9241343611edf09f559f04 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 2 Apr 2020 16:29:33 +0200 Subject: [PATCH] route jingle message inits --- .../generator/AbstractGenerator.java | 3 +- .../conversations/parser/MessageParser.java | 32 ++++--- .../eu/siacs/conversations/xml/Namespace.java | 90 ++++++++++--------- .../xmpp/jingle/AbstractJingleConnection.java | 18 ++-- .../xmpp/jingle/JingleConnectionManager.java | 65 ++++++++++---- .../jingle/JingleFileTransferConnection.java | 23 +++-- .../xmpp/jingle/JingleInBandTransport.java | 2 +- .../xmpp/jingle/JingleRtpConnection.java | 6 ++ .../xmpp/jingle/JingleSocks5Transport.java | 5 +- .../xmpp/jingle/stanzas/RtpDescription.java | 4 +- 10 files changed, 151 insertions(+), 97 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java index 7be008491..dbb188593 100644 --- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java @@ -39,7 +39,8 @@ public abstract class AbstractGenerator { Namespace.JINGLE_TRANSPORT_ICE_UDP, Namespace.JINGLE_FEATURE_AUDIO, Namespace.JINGLE_FEATURE_VIDEO, - Namespace.JINGLE_APP_RTP, + Namespace.JINGLE_APPS_RTP, + Namespace.JINGLE_APPS_DTLS, "http://jabber.org/protocol/muc", "jabber:x:conference", diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index a57f0eec8..a53613e28 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -6,6 +6,7 @@ import android.util.Pair; import java.net.URL; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; @@ -50,6 +51,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH); + private static final List JINGLE_MESSAGE_ELEMENT_NAMES = Arrays.asList("accept", "propose", "proceed", "reject", "retract"); + public MessageParser(XmppConnectionService service) { super(service); } @@ -136,7 +139,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece return new Message(conversation, "", Message.ENCRYPTION_AXOLOTL_FAILED, status); } } else { - Log.d(Config.LOGTAG,"ignoring broken session exception because checkForDuplicates failed"); + Log.d(Config.LOGTAG, "ignoring broken session exception because checkForDuplicates failed"); return null; } } catch (NotEncryptedForThisDeviceException e) { @@ -249,13 +252,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece final Jid id = InvalidJid.getNullForInvalid(retract.getAttributeAsJid("id")); if (id != null) { account.removeBookmark(id); - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": deleted bookmark for "+id); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": deleted bookmark for " + id); mXmppConnectionService.processDeletedBookmark(account, id); mXmppConnectionService.updateConversationUi(); } } } else { - Log.d(Config.LOGTAG,account.getJid().asBareJid()+" received pubsub notification for node="+node); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + " received pubsub notification for node=" + node); } } @@ -267,7 +270,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece setNick(account, from, null); } else if (Namespace.BOOKMARKS2.equals(node) && account.getJid().asBareJid().equals(from)) { account.setBookmarks(Collections.emptyMap()); - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": deleted bookmarks node"); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": deleted bookmarks node"); } } @@ -276,7 +279,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece final String node = purge == null ? null : purge.getAttribute("node"); if (Namespace.BOOKMARKS2.equals(node) && account.getJid().asBareJid().equals(from)) { account.setBookmarks(Collections.emptyMap()); - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": purged bookmarks"); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": purged bookmarks"); } } @@ -308,10 +311,10 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece final Element error = packet.findChild("error"); final boolean pingWorthyError = error != null && (error.hasChild("not-acceptable") || error.hasChild("remote-server-timeout") || error.hasChild("remote-server-not-found")); if (pingWorthyError) { - Conversation conversation = mXmppConnectionService.find(account,from); + Conversation conversation = mXmppConnectionService.find(account, from); if (conversation != null && conversation.getMode() == Conversational.MODE_MULTI) { if (conversation.getMucOptions().online()) { - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received ping worthy error for seemingly online muc at "+from); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received ping worthy error for seemingly online muc at " + from); mXmppConnectionService.mucSelfPingAndRejoin(conversation); } } @@ -419,9 +422,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece final Invite invite = extractInvite(packet); if (invite != null) { if (isTypeGroupChat) { - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": ignoring invite to "+invite.jid+" because type=groupchat"); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring invite to " + invite.jid + " because type=groupchat"); } else if (invite.direct && (mucUserElement != null || invite.inviter == null || mXmppConnectionService.isMuc(account, invite.inviter))) { - Log.d(Config.LOGTAG, account.getJid().asBareJid()+": ignoring direct invite to "+invite.jid+" because it was received in MUC"); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring direct invite to " + invite.jid + " because it was received in MUC"); } else { invite.execute(account); return; @@ -504,7 +507,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece final boolean checkedForDuplicates = liveMessage || (serverMsgId != null && remoteMsgId != null && !conversation.possibleDuplicate(serverMsgId, remoteMsgId)); if (origin != null) { - message = parseAxolotlChat(axolotlEncrypted, origin, conversation, status, checkedForDuplicates,query != null); + message = parseAxolotlChat(axolotlEncrypted, origin, conversation, status, checkedForDuplicates, query != null); } else { Message trial = null; for (Jid fallback : fallbacksBySourceId) { @@ -809,6 +812,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } } } + if (!isTypeGroupChat) { + for (Element child : packet.getChildren()) { + if (Namespace.JINGLE_MESSAGE.equals(child.getNamespace()) && JINGLE_MESSAGE_ELEMENT_NAMES.contains(child.getName())) { + mXmppConnectionService.getJingleConnectionManager().deliverMessage(account, packet.getTo(), packet.getFrom(), child); + } + } + } } Element received = packet.findChild("received", "urn:xmpp:chat-markers:0"); @@ -944,7 +954,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece if (jid != null) { Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, jid, true, false); if (conversation.getMucOptions().online()) { - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received invite to "+jid+" but muc is considered to be online"); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received invite to " + jid + " but muc is considered to be online"); mXmppConnectionService.mucSelfPingAndRejoin(conversation); } else { conversation.getMucOptions().setPassword(password); diff --git a/src/main/java/eu/siacs/conversations/xml/Namespace.java b/src/main/java/eu/siacs/conversations/xml/Namespace.java index a15103126..40a89cb07 100644 --- a/src/main/java/eu/siacs/conversations/xml/Namespace.java +++ b/src/main/java/eu/siacs/conversations/xml/Namespace.java @@ -1,48 +1,50 @@ package eu.siacs.conversations.xml; public final class Namespace { - public static final String DISCO_ITEMS = "http://jabber.org/protocol/disco#items"; - public static final String DISCO_INFO = "http://jabber.org/protocol/disco#info"; - public static final String BLOCKING = "urn:xmpp:blocking"; - public static final String ROSTER = "jabber:iq:roster"; - public static final String REGISTER = "jabber:iq:register"; - public static final String BYTE_STREAMS = "http://jabber.org/protocol/bytestreams"; - public static final String HTTP_UPLOAD = "urn:xmpp:http:upload:0"; - public static final String HTTP_UPLOAD_LEGACY = "urn:xmpp:http:upload"; - public static final String STANZA_IDS = "urn:xmpp:sid:0"; - public static final String IDLE = "urn:xmpp:idle:1"; - public static final String DATA = "jabber:x:data"; - public static final String OOB = "jabber:x:oob"; - public static final String SASL = "urn:ietf:params:xml:ns:xmpp-sasl"; - public static final String TLS = "urn:ietf:params:xml:ns:xmpp-tls"; - public static final String PUBSUB = "http://jabber.org/protocol/pubsub"; - public static final String PUBSUB_PUBLISH_OPTIONS = PUBSUB+"#publish-options"; - public static final String PUBSUB_ERROR = PUBSUB+"#errors"; - public static final String PUBSUB_OWNER = PUBSUB+"#owner"; - public static final String NICK = "http://jabber.org/protocol/nick"; - public static final String FLEXIBLE_OFFLINE_MESSAGE_RETRIEVAL = "http://jabber.org/protocol/offline"; - public static final String BIND = "urn:ietf:params:xml:ns:xmpp-bind"; - public static final String P1_S3_FILE_TRANSFER = "p1:s3filetransfer"; - public static final String BOOKMARKS_CONVERSION = "urn:xmpp:bookmarks-conversion:0"; - public static final String BOOKMARKS = "storage:bookmarks"; - public static final String SYNCHRONIZATION = "im.quicksy.synchronization:0"; - public static final String AVATAR_CONVERSION = "urn:xmpp:pep-vcard-conversion:0"; - public static final String 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_TRANSPORT_ICE_UDP = "urn:xmpp:jingle:transports:ice-udp:1"; - public static final String JINGLE_APP_RTP = "urn:xmpp:jingle:apps:rtp:1"; - public static final String JINGLE_FEATURE_AUDIO = "urn:xmpp:jingle:apps:rtp:audio"; - public static final String JINGLE_FEATURE_VIDEO = "urn:xmpp:jingle:apps:rtp:video"; - public static final String IBB = "http://jabber.org/protocol/ibb"; - public static final String PING = "urn:xmpp:ping"; - public static final String PUSH = "urn:xmpp:push:0"; - public static final String COMMANDS = "http://jabber.org/protocol/commands"; - public static final String JINGLE = "urn:xmpp:jingle:1"; - public static final String JINGLE_ENCRYPTED_TRANSPORT = "urn:xmpp:jingle:jet:0"; - public static final String JINGLE_ENCRYPTED_TRANSPORT_OMEMO = "urn:xmpp:jingle:jet-omemo:0"; - public static final String MUC_USER = "http://jabber.org/protocol/muc#user"; - public static final String BOOKMARKS2 = "urn:xmpp:bookmarks:0"; - public static final String BOOKMARKS2_COMPAT = BOOKMARKS2+"#compat"; - public static final String INVITE = "urn:xmpp:invite"; - public static final String PARS = "urn:xmpp:pars:0"; + public static final String DISCO_ITEMS = "http://jabber.org/protocol/disco#items"; + public static final String DISCO_INFO = "http://jabber.org/protocol/disco#info"; + public static final String BLOCKING = "urn:xmpp:blocking"; + public static final String ROSTER = "jabber:iq:roster"; + public static final String REGISTER = "jabber:iq:register"; + public static final String BYTE_STREAMS = "http://jabber.org/protocol/bytestreams"; + public static final String HTTP_UPLOAD = "urn:xmpp:http:upload:0"; + public static final String HTTP_UPLOAD_LEGACY = "urn:xmpp:http:upload"; + public static final String STANZA_IDS = "urn:xmpp:sid:0"; + public static final String IDLE = "urn:xmpp:idle:1"; + public static final String DATA = "jabber:x:data"; + public static final String OOB = "jabber:x:oob"; + public static final String SASL = "urn:ietf:params:xml:ns:xmpp-sasl"; + public static final String TLS = "urn:ietf:params:xml:ns:xmpp-tls"; + public static final String PUBSUB = "http://jabber.org/protocol/pubsub"; + public static final String PUBSUB_PUBLISH_OPTIONS = PUBSUB + "#publish-options"; + public static final String PUBSUB_ERROR = PUBSUB + "#errors"; + public static final String PUBSUB_OWNER = PUBSUB + "#owner"; + public static final String NICK = "http://jabber.org/protocol/nick"; + public static final String FLEXIBLE_OFFLINE_MESSAGE_RETRIEVAL = "http://jabber.org/protocol/offline"; + public static final String BIND = "urn:ietf:params:xml:ns:xmpp-bind"; + public static final String P1_S3_FILE_TRANSFER = "p1:s3filetransfer"; + public static final String BOOKMARKS_CONVERSION = "urn:xmpp:bookmarks-conversion:0"; + public static final String BOOKMARKS = "storage:bookmarks"; + public static final String SYNCHRONIZATION = "im.quicksy.synchronization:0"; + public static final String AVATAR_CONVERSION = "urn:xmpp:pep-vcard-conversion:0"; + public static final String JINGLE = "urn:xmpp:jingle:1"; + public static final String JINGLE_MESSAGE = "urn:xmpp:jingle-message:0"; + public static final String JINGLE_ENCRYPTED_TRANSPORT = "urn:xmpp:jingle:jet:0"; + public static final String JINGLE_ENCRYPTED_TRANSPORT_OMEMO = "urn:xmpp:jingle:jet-omemo:0"; + public static final String JINGLE_TRANSPORTS_S5B = "urn:xmpp:jingle:transports:s5b:1"; + public static final String JINGLE_TRANSPORTS_IBB = "urn:xmpp:jingle:transports:ibb:1"; + public static final String JINGLE_TRANSPORT_ICE_UDP = "urn:xmpp:jingle:transports:ice-udp:1"; + public static final String JINGLE_APPS_RTP = "urn:xmpp:jingle:apps:rtp:1"; + public static final String JINGLE_APPS_DTLS = "urn:xmpp:jingle:apps:dtls:0"; + public static final String JINGLE_FEATURE_AUDIO = "urn:xmpp:jingle:apps:rtp:audio"; + public static final String JINGLE_FEATURE_VIDEO = "urn:xmpp:jingle:apps:rtp:video"; + public static final String IBB = "http://jabber.org/protocol/ibb"; + public static final String PING = "urn:xmpp:ping"; + public static final String PUSH = "urn:xmpp:push:0"; + public static final String COMMANDS = "http://jabber.org/protocol/commands"; + public static final String MUC_USER = "http://jabber.org/protocol/muc#user"; + public static final String BOOKMARKS2 = "urn:xmpp:bookmarks:0"; + public static final String BOOKMARKS2_COMPAT = BOOKMARKS2 + "#compat"; + public static final String INVITE = "urn:xmpp:invite"; + public static final String PARS = "urn:xmpp:pars:0"; } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/AbstractJingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/AbstractJingleConnection.java index 19ad2822a..4b7ecb354 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/AbstractJingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/AbstractJingleConnection.java @@ -30,14 +30,14 @@ public abstract class AbstractJingleConnection { public static class Id { public final Account account; - public final Jid counterPart; + public final Jid with; public final String sessionId; - private Id(final Account account, final Jid counterPart, final String sessionId) { - Preconditions.checkNotNull(counterPart); - Preconditions.checkArgument(counterPart.isFullJid()); + private Id(final Account account, final Jid with, final String sessionId) { + Preconditions.checkNotNull(with); + Preconditions.checkArgument(with.isFullJid()); this.account = account; - this.counterPart = counterPart; + this.with = with; this.sessionId = sessionId; } @@ -45,6 +45,10 @@ public abstract class AbstractJingleConnection { return new Id(account, jinglePacket.getFrom(), jinglePacket.getSessionId()); } + public static Id of(Account account, Jid with, final String sessionId) { + return new Id(account, with, sessionId); + } + public static Id of(Message message) { return new Id( message.getConversation().getAccount(), @@ -59,13 +63,13 @@ public abstract class AbstractJingleConnection { 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(with, id.with) && Objects.equal(sessionId, id.sessionId); } @Override public int hashCode() { - return Objects.hashCode(account.getJid(), counterPart, sessionId); + return Objects.hashCode(account.getJid(), with, sessionId); } } } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index d73968783..74082d03e 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -22,6 +22,7 @@ import eu.siacs.conversations.xmpp.jingle.stanzas.Content; import eu.siacs.conversations.xmpp.jingle.stanzas.FileTransferDescription; import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket; import eu.siacs.conversations.xmpp.stanzas.IqPacket; +import eu.siacs.conversations.xmpp.stanzas.MessagePacket; import rocks.xmpp.addr.Jid; public class JingleConnectionManager extends AbstractConnectionManager { @@ -35,13 +36,16 @@ public class JingleConnectionManager extends AbstractConnectionManager { public void deliverPacket(final Account account, final JinglePacket packet) { final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, packet); - if (packet.getAction() == JinglePacket.Action.SESSION_INITIATE) { //TODO check that id doesn't exist yet + final AbstractJingleConnection existingJingleConnection = connections.get(id); + if (existingJingleConnection != null) { + existingJingleConnection.deliverPacket(packet); + } else if (packet.getAction() == JinglePacket.Action.SESSION_INITIATE) { final Content content = packet.getJingleContent(); final String descriptionNamespace = content == null ? null : content.getDescriptionNamespace(); final AbstractJingleConnection connection; if (FileTransferDescription.NAMESPACES.contains(descriptionNamespace)) { connection = new JingleFileTransferConnection(this, id); - } else if (Namespace.JINGLE_APP_RTP.equals(descriptionNamespace)) { + } else if (Namespace.JINGLE_APPS_RTP.equals(descriptionNamespace)) { connection = new JingleRtpConnection(this, id); } else { //TODO return feature-not-implemented @@ -50,22 +54,53 @@ public class JingleConnectionManager extends AbstractConnectionManager { connections.put(id, connection); connection.deliverPacket(packet); } else { - final AbstractJingleConnection abstractJingleConnection = connections.get(id); - if (abstractJingleConnection != null) { - abstractJingleConnection.deliverPacket(packet); - } else { - Log.d(Config.LOGTAG, "unable to route jingle packet: " + packet); - IqPacket response = packet.generateResponse(IqPacket.TYPE.ERROR); - Element error = response.addChild("error"); - error.setAttribute("type", "cancel"); - error.addChild("item-not-found", - "urn:ietf:params:xml:ns:xmpp-stanzas"); - error.addChild("unknown-session", "urn:xmpp:jingle:errors:1"); - account.getXmppConnection().sendIqPacket(response, null); - } + Log.d(Config.LOGTAG, "unable to route jingle packet: " + packet); + final IqPacket response = packet.generateResponse(IqPacket.TYPE.ERROR); + final Element error = response.addChild("error"); + error.setAttribute("type", "cancel"); + error.addChild("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"); + error.addChild("unknown-session", "urn:xmpp:jingle:errors:1"); + account.getXmppConnection().sendIqPacket(response, null); } } + public void deliverMessage(final Account account, final Jid to, final Jid from, final Element message) { + Preconditions.checkArgument(Namespace.JINGLE_MESSAGE.equals(message.getNamespace())); + final String sessionId = message.getAttribute("id"); + if (sessionId == null) { + return; + } + final Jid with; + if (account.getJid().asBareJid().equals(from.asBareJid())) { + with = to; + } else { + with = from; + } + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received jingle message from " + from + " with=" + with + " " + message); + final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, with, sessionId); + final AbstractJingleConnection existingJingleConnection = connections.get(id); + if (existingJingleConnection != null) { + if (existingJingleConnection instanceof JingleRtpConnection) { + ((JingleRtpConnection) existingJingleConnection).deliveryMessage(to, from, message); + } else { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + existingJingleConnection.getClass().getName() + " does not support jingle messages"); + } + } else if ("propose".equals(message.getName())) { + final Element description = message.findChild("description"); + final String namespace = description == null ? null : description.getNamespace(); + if (Namespace.JINGLE_APPS_RTP.equals(namespace)) { + final JingleRtpConnection rtpConnection = new JingleRtpConnection(this, id); + this.connections.put(id, rtpConnection); + rtpConnection.deliveryMessage(to, from, message); + } else { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to react to proposed " + namespace + " session"); + } + } else { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": retrieved out of order jingle message"); + } + + } + public void startJingleFileTransfer(final Message message) { Preconditions.checkArgument(message.isFileOrImage(), "Message is not of type file or image"); final Transferable old = message.getTransferable(); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java index 97d6a248f..f70bbc575 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java @@ -4,11 +4,7 @@ import android.util.Base64; import android.util.Log; import com.google.common.base.Preconditions; -import com.google.common.base.Predicate; import com.google.common.collect.Collections2; -import com.google.common.collect.Lists; - -import org.checkerframework.checker.nullness.compatqual.NullableDecl; import java.io.File; import java.io.FileInputStream; @@ -351,7 +347,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple this.message.setTransferable(this); this.mStatus = Transferable.STATUS_UPLOADING; this.initiator = this.id.account.getJid(); - this.responder = this.id.counterPart; + this.responder = this.id.with; this.transportId = JingleConnectionManager.nextRandomId(); this.setupDescription(remoteVersion); if (this.initialTransport == IbbTransportInfo.class) { @@ -416,7 +412,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple } private List getRemoteFeatures() { - final Jid jid = this.id.counterPart; + final Jid jid = this.id.with; String resource = jid != null ? jid.getResource() : null; if (resource != null) { Presence presence = this.id.account.getRoster().getContact(jid).getPresences().getPresences().get(resource); @@ -428,14 +424,15 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple } private void init(JinglePacket packet) { //should move to deliverPacket + //TODO if not 'OFFERED' reply with out-of-order this.mJingleStatus = JINGLE_STATUS_INITIATED; - final Conversation conversation = this.xmppConnectionService.findOrCreateConversation(id.account, id.counterPart.asBareJid(), false, false); + final Conversation conversation = this.xmppConnectionService.findOrCreateConversation(id.account, id.with.asBareJid(), false, false); this.message = new Message(conversation, "", Message.ENCRYPTION_NONE); this.message.setStatus(Message.STATUS_RECEIVED); this.mStatus = Transferable.STATUS_OFFER; this.message.setTransferable(this); - this.message.setCounterpart(this.id.counterPart); - this.initiator = this.id.counterPart; + this.message.setCounterpart(this.id.with); + this.initiator = this.id.with; this.responder = this.id.account.getJid(); final Content content = packet.getJingleContent(); final GenericTransportInfo transportInfo = content.getTransport(); @@ -527,11 +524,11 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple respondToIq(packet, true); - if (id.account.getRoster().getContact(id.counterPart).showInContactList() + if (id.account.getRoster().getContact(id.with).showInContactList() && jingleConnectionManager.hasStoragePermission() && size < this.jingleConnectionManager.getAutoAcceptFileSize() && xmppConnectionService.isDataSaverDisabled()) { - Log.d(Config.LOGTAG, "auto accepting file from " + id.counterPart); + Log.d(Config.LOGTAG, "auto accepting file from " + id.with); this.acceptedAutomatically = true; this.sendAccept(); } else { @@ -697,7 +694,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple private JinglePacket bootstrapPacket(JinglePacket.Action action) { final JinglePacket packet = new JinglePacket(action, this.id.sessionId); - packet.setTo(id.counterPart); + packet.setTo(id.with); return packet; } @@ -837,7 +834,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple activation.query("http://jabber.org/protocol/bytestreams") .setAttribute("sid", sid); activation.query().addChild("activate") - .setContent(this.id.counterPart.toEscapedString()); + .setContent(this.id.with.toEscapedString()); xmppConnectionService.sendIqPacket(this.id.account, activation, (account, response) -> { if (response.getType() != IqPacket.TYPE.RESULT) { Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": " + response.toString()); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInBandTransport.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInBandTransport.java index fbc1ad95f..2dc0d9cab 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInBandTransport.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInBandTransport.java @@ -65,7 +65,7 @@ public class JingleInBandTransport extends JingleTransport { JingleInBandTransport(final JingleFileTransferConnection connection, final String sid, final int blockSize) { this.connection = connection; this.account = connection.getId().account; - this.counterpart = connection.getId().counterPart; + this.counterpart = connection.getId().with; this.blockSize = blockSize; this.sessionId = sid; } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index fc7bd14f4..571832650 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -3,7 +3,9 @@ package eu.siacs.conversations.xmpp.jingle; import android.util.Log; import eu.siacs.conversations.Config; +import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket; +import rocks.xmpp.addr.Jid; public class JingleRtpConnection extends AbstractJingleConnection { @@ -16,4 +18,8 @@ public class JingleRtpConnection extends AbstractJingleConnection { void deliverPacket(final JinglePacket jinglePacket) { Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": packet delivered to JingleRtpConnection"); } + + void deliveryMessage(final Jid to, Jid from, Element message) { + Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": delivered message to JingleRtpConnection " + message); + } } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java index 31c40f531..4e7825c42 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java @@ -23,7 +23,6 @@ import eu.siacs.conversations.services.AbstractConnectionManager; import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.SocksSocketFactory; import eu.siacs.conversations.utils.WakeLockHelper; -import eu.siacs.conversations.xmpp.jingle.stanzas.Content; import eu.siacs.conversations.xmpp.jingle.stanzas.FileTransferDescription; public class JingleSocks5Transport extends JingleTransport { @@ -61,9 +60,9 @@ public class JingleSocks5Transport extends JingleTransport { } if (candidate.isOurs()) { destBuilder.append(this.account.getJid()); - destBuilder.append(this.connection.getId().counterPart); + destBuilder.append(this.connection.getId().with); } else { - destBuilder.append(this.connection.getId().counterPart); + destBuilder.append(this.connection.getId().with); destBuilder.append(this.account.getJid()); } messageDigest.reset(); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/RtpDescription.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/RtpDescription.java index 5ecb6fa15..fd66f00ee 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/RtpDescription.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/RtpDescription.java @@ -14,8 +14,8 @@ public class RtpDescription extends GenericDescription { public static RtpDescription upgrade(final Element element) { Preconditions.checkArgument("description".equals(element.getName()), "Name of provided element is not description"); - Preconditions.checkArgument(Namespace.JINGLE_APP_RTP.equals(element.getNamespace()), "Element does not match the jingle rtp namespace"); - final RtpDescription description = new RtpDescription("description", Namespace.JINGLE_APP_RTP); + Preconditions.checkArgument(Namespace.JINGLE_APPS_RTP.equals(element.getNamespace()), "Element does not match the jingle rtp namespace"); + final RtpDescription description = new RtpDescription("description", Namespace.JINGLE_APPS_RTP); description.setAttributes(element.getAttributes()); description.setChildren(element.getChildren()); return description;