aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xmpp/jingle/SocksConnection.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-04-17 14:52:10 +0200
committerAndreas Straub <andy@strb.org>2014-04-18 00:17:34 +0200
commit07cf07ad58b9e99d9b63da1e00529c4e3bda721f (patch)
treea1dc28f88ce193f9d6e7ae84dac344d64570d0b2 /src/eu/siacs/conversations/xmpp/jingle/SocksConnection.java
parent8006931f80fcba014c141bc726307ceea782f4fe (diff)
lot of cleanup in jingle part
Diffstat (limited to 'src/eu/siacs/conversations/xmpp/jingle/SocksConnection.java')
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/SocksConnection.java42
1 files changed, 14 insertions, 28 deletions
diff --git a/src/eu/siacs/conversations/xmpp/jingle/SocksConnection.java b/src/eu/siacs/conversations/xmpp/jingle/SocksConnection.java
index affbb5f3..197b9424 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/SocksConnection.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/SocksConnection.java
@@ -19,29 +19,20 @@ import android.util.Log;
import android.widget.Button;
public class SocksConnection {
- private Socket socket;
- private String host;
- private String jid;
- private String cid;
- private int port;
- private boolean isProxy = false;
+ private JingleCandidate candidate;
private String destination;
private OutputStream outputStream;
private InputStream inputStream;
private boolean isEstablished = false;
+ protected Socket socket;
- public SocksConnection(JingleConnection jingleConnection, Element candidate, boolean initating) {
- this.cid = candidate.getAttribute("cid");
- this.host = candidate.getAttribute("host");
- this.port = Integer.parseInt(candidate.getAttribute("port"));
- String type = candidate.getAttribute("type");
- this.jid = candidate.getAttribute("jid");
- this.isProxy = "proxy".equalsIgnoreCase(type);
+ public SocksConnection(JingleConnection jingleConnection, JingleCandidate candidate) {
+ this.candidate = candidate;
try {
MessageDigest mDigest = MessageDigest.getInstance("SHA-1");
StringBuilder destBuilder = new StringBuilder();
destBuilder.append(jingleConnection.getSessionId());
- if (initating) {
+ if (candidate.isOurs()) {
destBuilder.append(jingleConnection.getAccountJid());
destBuilder.append(jingleConnection.getCounterPart());
} else {
@@ -62,7 +53,7 @@ public class SocksConnection {
@Override
public void run() {
try {
- socket = new Socket(host, port);
+ socket = new Socket(candidate.getHost(), candidate.getPort());
inputStream = socket.getInputStream();
outputStream = socket.getOutputStream();
byte[] login = { 0x05, 0x01, 0x00 };
@@ -78,8 +69,7 @@ public class SocksConnection {
inputStream.read(result);
int status = result[1];
if (status == 0) {
- Log.d("xmppService", "established connection with "+host + ":" + port
- + "/" + destination);
+ Log.d("xmppService", "established connection with "+candidate.getHost()+":"+candidate.getPort()+ "/" + destination);
isEstablished = true;
callback.established();
} else {
@@ -193,24 +183,16 @@ public class SocksConnection {
}
public boolean isProxy() {
- return this.isProxy;
- }
-
- public String getJid() {
- return this.jid;
- }
-
- public String getCid() {
- return this.cid;
+ return this.candidate.getType() == JingleCandidate.TYPE_PROXY;
}
public void disconnect() {
if (this.socket!=null) {
try {
this.socket.close();
- Log.d("xmppService","cloesd socket with "+this.host);
+ Log.d("xmppService","cloesd socket with "+candidate.getHost()+":"+candidate.getPort());
} catch (IOException e) {
- Log.d("xmppService","error closing socket with "+this.host);
+ Log.d("xmppService","error closing socket with "+candidate.getHost()+":"+candidate.getPort());
}
}
}
@@ -218,4 +200,8 @@ public class SocksConnection {
public boolean isEstablished() {
return this.isEstablished;
}
+
+ public JingleCandidate getCandidate() {
+ return this.candidate;
+ }
}