added timeout to jingle socket

This commit is contained in:
iNPUTmice 2014-07-03 22:55:20 +02:00
parent f33d2497f8
commit 363682065d
2 changed files with 16 additions and 3 deletions

View file

@ -99,6 +99,7 @@ public class JingleConnection {
@Override @Override
public void onFileTransferAborted() { public void onFileTransferAborted() {
JingleConnection.this.sendCancel();
JingleConnection.this.cancel(); JingleConnection.this.cancel();
} }
}; };
@ -280,16 +281,26 @@ public class JingleConnection {
} }
this.file = this.mXmppConnectionService.getFileBackend().getJingleFile(message,false); this.file = this.mXmppConnectionService.getFileBackend().getJingleFile(message,false);
if (message.getEncryption() == Message.ENCRYPTION_OTR) { if (message.getEncryption() == Message.ENCRYPTION_OTR) {
byte[] key = conversation.getSymmetricKey();
if (key==null) {
this.sendCancel();
this.cancel();
return;
} else {
this.file.setKey(conversation.getSymmetricKey()); this.file.setKey(conversation.getSymmetricKey());
} }
}
this.file.setExpectedSize(size); this.file.setExpectedSize(size);
} else { } else {
this.sendCancel();
this.cancel(); this.cancel();
} }
} else { } else {
this.sendCancel();
this.cancel(); this.cancel();
} }
} else { } else {
this.sendCancel();
this.cancel(); this.cancel();
} }
} }
@ -410,6 +421,7 @@ public class JingleConnection {
connection.setActivated(true); connection.setActivated(true);
} else { } else {
Log.d("xmppService","activated connection not found"); Log.d("xmppService","activated connection not found");
this.sendCancel();
this.cancel(); this.cancel();
} }
} }
@ -603,8 +615,7 @@ public class JingleConnection {
this.mJingleConnectionManager.finishConnection(this); this.mJingleConnectionManager.finishConnection(this);
} }
void cancel() { public void cancel() {
this.sendCancel();
this.disconnect(); this.disconnect();
if (this.message!=null) { if (this.message!=null) {
if (this.responder.equals(account.getFullJid())) { if (this.responder.equals(account.getFullJid())) {

View file

@ -5,6 +5,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.Socket; import java.net.Socket;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@ -137,6 +138,7 @@ public class JingleSocks5Transport extends JingleTransport {
MessageDigest digest = MessageDigest.getInstance("SHA-1"); MessageDigest digest = MessageDigest.getInstance("SHA-1");
digest.reset(); digest.reset();
inputStream.skip(45); inputStream.skip(45);
socket.setSoTimeout(30000);
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
file.createNewFile(); file.createNewFile();
OutputStream fileOutputStream = getOutputStream(file); OutputStream fileOutputStream = getOutputStream(file);