diff options
author | Beriain <beriain@bitmessage.ch> | 2014-05-13 16:46:03 +0200 |
---|---|---|
committer | Beriain <beriain@bitmessage.ch> | 2014-05-13 16:46:03 +0200 |
commit | 8d27d0c44a4c35ce4606628eb5a280df4b1a8c5b (patch) | |
tree | d5d45d67e14e707446fd0a427cc8f00fc58e8685 /src/eu | |
parent | 1150f47addba09889fd64fd6d59d98c115ea71cf (diff) | |
parent | 7e667319607aa5ed9fd2a2aa1573c40ffae3a613 (diff) |
Merge https://github.com/siacs/Conversations into development
Diffstat (limited to 'src/eu')
4 files changed, 52 insertions, 26 deletions
diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java index eaa9b8ee..06179bc6 100644 --- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -173,7 +173,7 @@ public class ContactDetailsActivity extends XmppActivity { if (contact.getSubscriptionOption(Contact.Subscription.FROM)) { send.setChecked(true); } else { - send.setText("Preemptively grant subscription request"); + send.setText(R.string.preemptively_grant); if (contact .getSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT)) { send.setChecked(true); @@ -184,7 +184,7 @@ public class ContactDetailsActivity extends XmppActivity { if (contact.getSubscriptionOption(Contact.Subscription.TO)) { receive.setChecked(true); } else { - receive.setText("Ask for presence updates"); + receive.setText(R.string.ask_for_presence_updates); askAgain.setVisibility(View.VISIBLE); askAgain.setOnClickListener(new OnClickListener() { diff --git a/src/eu/siacs/conversations/xml/TagWriter.java b/src/eu/siacs/conversations/xml/TagWriter.java index 40d5b328..ef1e8555 100644 --- a/src/eu/siacs/conversations/xml/TagWriter.java +++ b/src/eu/siacs/conversations/xml/TagWriter.java @@ -23,8 +23,12 @@ public class TagWriter { } try { AbstractStanza output = writeQueue.take(); - outputStream.write(output.toString()); - outputStream.flush(); + if (outputStream==null) { + shouldStop = true; + } else { + outputStream.write(output.toString()); + outputStream.flush(); + } } catch (IOException e) { shouldStop = true; } catch (InterruptedException e) { diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index 3c9120ec..8f88688a 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -135,7 +135,7 @@ public class JingleConnection { } public void deliverPacket(JinglePacket packet) { - + boolean returnResult = true; if (packet.isAction("session-terminate")) { Reason reason = packet.getReason(); if (reason!=null) { @@ -143,26 +143,37 @@ public class JingleConnection { this.receiveCancel(); } else if (reason.hasChild("success")) { this.receiveSuccess(); + } else { + this.receiveCancel(); } } else { - Log.d("xmppService","remote terminated for no reason"); this.receiveCancel(); } - } else if (packet.isAction("session-accept")) { - receiveAccept(packet); + } else if (packet.isAction("session-accept")) { + returnResult = receiveAccept(packet); } else if (packet.isAction("transport-info")) { - receiveTransportInfo(packet); + returnResult = receiveTransportInfo(packet); } else if (packet.isAction("transport-replace")) { if (packet.getJingleContent().hasIbbTransport()) { - this.receiveFallbackToIbb(packet); + returnResult = this.receiveFallbackToIbb(packet); } else { + returnResult = false; Log.d("xmppService","trying to fallback to something unknown"+packet.toString()); } } else if (packet.isAction("transport-accept")) { - this.receiveTransportAccept(packet); + returnResult = this.receiveTransportAccept(packet); } else { Log.d("xmppService","packet arrived in connection. action was "+packet.getAction()); + returnResult = false; } + IqPacket response; + if (returnResult) { + response = packet.generateRespone(IqPacket.TYPE_RESULT); + + } else { + response = packet.generateRespone(IqPacket.TYPE_ERROR); + } + account.getXmppConnection().sendIqPacket(response, null); } public void init(Message message) { @@ -356,17 +367,16 @@ public class JingleConnection { account.getXmppConnection().sendIqPacket(packet,responseListener); } - private void receiveAccept(JinglePacket packet) { + private boolean receiveAccept(JinglePacket packet) { Content content = packet.getJingleContent(); mergeCandidates(JingleCandidate.parse(content.socks5transport().getChildren())); this.status = STATUS_ACCEPTED; mXmppConnectionService.markMessage(message, Message.STATUS_UNSEND); this.connectNextCandidate(); - IqPacket response = packet.generateRespone(IqPacket.TYPE_RESULT); - account.getXmppConnection().sendIqPacket(response, null); + return true; } - private void receiveTransportInfo(JinglePacket packet) { + private boolean receiveTransportInfo(JinglePacket packet) { Content content = packet.getJingleContent(); if (content.hasSocks5Transport()) { if (content.socks5transport().hasChild("activated")) { @@ -383,14 +393,17 @@ public class JingleConnection { this.sendCancel(); } } - } else if (content.socks5transport().hasChild("activated")) { + return true; + } else if (content.socks5transport().hasChild("proxy-error")) { onProxyActivated.failed(); + return true; } else if (content.socks5transport().hasChild("candidate-error")) { Log.d("xmppService","received candidate error"); this.receivedCandidate = true; if ((status == STATUS_ACCEPTED)&&(this.sentCandidate)) { this.connect(); } + return true; } else if (content.socks5transport().hasChild("candidate-used")){ String cid = content.socks5transport().findChild("candidate-used").getAttribute("cid"); if (cid!=null) { @@ -403,16 +416,16 @@ public class JingleConnection { } else { Log.d("xmppService","ignoring because file is already in transmission or we havent sent our candidate yet"); } + return true; } else { - Log.d("xmppService","couldn't read used candidate"); + return false; } } else { - Log.d("xmppService","empty transport"); + return false; } + } else { + return true; } - - IqPacket response = packet.generateRespone(IqPacket.TYPE_RESULT); - account.getXmppConnection().sendIqPacket(response, null); } private void connect() { @@ -502,6 +515,7 @@ public class JingleConnection { this.disconnect(); this.status = STATUS_FINISHED; this.mXmppConnectionService.markMessage(this.message, Message.STATUS_RECIEVED); + this.mJingleConnectionManager.finishConnection(this); } private void sendFallbackToIbb() { @@ -514,7 +528,7 @@ public class JingleConnection { this.sendJinglePacket(packet); } - private void receiveFallbackToIbb(JinglePacket packet) { + private boolean receiveFallbackToIbb(JinglePacket packet) { String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size"); if (receivedBlockSize!=null) { int bs = Integer.parseInt(receivedBlockSize); @@ -531,9 +545,10 @@ public class JingleConnection { content.ibbTransport().setAttribute("block-size", ""+this.ibbBlockSize); answer.setContent(content); this.sendJinglePacket(answer); + return true; } - private void receiveTransportAccept(JinglePacket packet) { + private boolean receiveTransportAccept(JinglePacket packet) { if (packet.getJingleContent().hasIbbTransport()) { String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size"); if (receivedBlockSize!=null) { @@ -555,8 +570,9 @@ public class JingleConnection { JingleConnection.this.transport.send(file, onFileTransmitted); } }); + return true; } else { - Log.d("xmppService","invalid transport accept"); + return false; } } @@ -564,12 +580,14 @@ public class JingleConnection { this.status = STATUS_FINISHED; this.mXmppConnectionService.markMessage(this.message, Message.STATUS_SEND); this.disconnect(); + this.mJingleConnectionManager.finishConnection(this); } private void receiveCancel() { this.disconnect(); this.status = STATUS_CANCELED; this.mXmppConnectionService.markMessage(this.message, Message.STATUS_SEND_REJECTED); + this.mJingleConnectionManager.finishConnection(this); } private void sendCancel() { diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index 2fa1a6be..a277b74c 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -51,15 +51,19 @@ public class JingleConnectionManager { public JingleConnection createNewConnection(Message message) { JingleConnection connection = new JingleConnection(this); connection.init(message); - connections.add(connection); + this.connections.add(connection); return connection; } public JingleConnection createNewConnection(JinglePacket packet) { JingleConnection connection = new JingleConnection(this); - connections.add(connection); + this.connections.add(connection); return connection; } + + public void finishConnection(JingleConnection connection) { + this.connections.remove(connection); + } public XmppConnectionService getXmppConnectionService() { return this.xmppConnectionService; |