diff options
author | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-09 14:42:58 +0100 |
---|---|---|
committer | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-09 14:42:58 +0100 |
commit | 0a48f777acefa29443743f68f242136309169ba2 (patch) | |
tree | 80985e1c8f7962bc9a157fd561ea75ed7b34e38e /src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java | |
parent | d9f88c4669b024530301fe9e48d70d42bd56190f (diff) |
code cleanup for jingle proxy discovery
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java | 91 |
1 files changed, 39 insertions, 52 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index fe37596c7..cea4346c4 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -396,58 +396,48 @@ public class JingleConnection implements Downloadable { mJingleStatus = JINGLE_STATUS_ACCEPTED; this.mStatus = Downloadable.STATUS_DOWNLOADING; mXmppConnectionService.updateConversationUi(); - this.mJingleConnectionManager.getPrimaryCandidate(this.account, - new OnPrimaryCandidateFound() { - - @Override - public void onPrimaryCandidateFound(boolean success, - final JingleCandidate candidate) { - final JinglePacket packet = bootstrapPacket("session-accept"); - final Content content = new Content(contentCreator, - contentName); - content.setFileOffer(fileOffer); - content.setTransportId(transportId); - if ((success) && (!equalCandidateExists(candidate))) { - final JingleSocks5Transport socksConnection = new JingleSocks5Transport( - JingleConnection.this, candidate); - connections.put(candidate.getCid(), socksConnection); - socksConnection.connect(new OnTransportConnected() { - - @Override - public void failed() { - Log.d(Config.LOGTAG, - "connection to our own primary candidate failed"); - content.socks5transport().setChildren( - getCandidatesAsElements()); - packet.setContent(content); - sendJinglePacket(packet); - connectNextCandidate(); - } + this.mJingleConnectionManager.getPrimaryCandidate(this.account, new OnPrimaryCandidateFound() { + @Override + public void onPrimaryCandidateFound(boolean success, final JingleCandidate candidate) { + final JinglePacket packet = bootstrapPacket("session-accept"); + final Content content = new Content(contentCreator,contentName); + content.setFileOffer(fileOffer); + content.setTransportId(transportId); + if (success && candidate != null && !equalCandidateExists(candidate)) { + final JingleSocks5Transport socksConnection = new JingleSocks5Transport( + JingleConnection.this, + candidate); + connections.put(candidate.getCid(), socksConnection); + socksConnection.connect(new OnTransportConnected() { - @Override - public void established() { - Log.d(Config.LOGTAG, - "connected to primary candidate"); - mergeCandidate(candidate); - content.socks5transport().setChildren( - getCandidatesAsElements()); - packet.setContent(content); - sendJinglePacket(packet); - connectNextCandidate(); - } - }); - } else { - Log.d(Config.LOGTAG, - "did not find a primary candidate for ourself"); - content.socks5transport().setChildren( - getCandidatesAsElements()); + @Override + public void failed() { + Log.d(Config.LOGTAG,"connection to our own primary candidate failed"); + content.socks5transport().setChildren(getCandidatesAsElements()); packet.setContent(content); sendJinglePacket(packet); connectNextCandidate(); } - } - }); + @Override + public void established() { + Log.d(Config.LOGTAG, "connected to primary candidate"); + mergeCandidate(candidate); + content.socks5transport().setChildren(getCandidatesAsElements()); + packet.setContent(content); + sendJinglePacket(packet); + connectNextCandidate(); + } + }); + } else { + Log.d(Config.LOGTAG,"did not find a primary candidate for ourself"); + content.socks5transport().setChildren(getCandidatesAsElements()); + packet.setContent(content); + sendJinglePacket(packet); + connectNextCandidate(); + } + } + }); } private JinglePacket bootstrapPacket(String action) { @@ -479,16 +469,13 @@ public class JingleConnection implements Downloadable { Content content = packet.getJingleContent(); if (content.hasSocks5Transport()) { if (content.socks5transport().hasChild("activated")) { - if ((this.transport != null) - && (this.transport instanceof JingleSocks5Transport)) { + if ((this.transport != null) && (this.transport instanceof JingleSocks5Transport)) { onProxyActivated.success(); } else { - String cid = content.socks5transport() - .findChild("activated").getAttribute("cid"); + String cid = content.socks5transport().findChild("activated").getAttribute("cid"); Log.d(Config.LOGTAG, "received proxy activated (" + cid + ")prior to choosing our own transport"); - JingleSocks5Transport connection = this.connections - .get(cid); + JingleSocks5Transport connection = this.connections.get(cid); if (connection != null) { connection.setActivated(true); } else { |