From 3cfb4a0cd6c91c7e6077d17b80089c4332d0fd99 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 3 May 2014 15:24:19 +0200 Subject: [PATCH 1/6] added restart button to openkeychain dialog --- res/values/strings.xml | 2 +- .../conversations/services/XmppConnectionService.java | 1 + src/eu/siacs/conversations/ui/XmppActivity.java | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index f4b7d5fa1..fa41b7b81 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -80,7 +80,7 @@ Send unencrypted Decrpytion failed. Maybe you don’t have the proper private key. OpenKeychain - Conversations utilizes a third party called OpenKeychain to encrypt and decrypt messages and to mange your public keys.\n\nOpenKeychain is licensed under GPLv3 and available on F-Droid and Google Play.\n\nTo use openPGP please install the app and then restart Conversations. + Conversations utilizes a third party app called OpenKeychain to encrypt and decrypt messages and to mange your public keys.\n\nOpenKeychain is licensed under GPLv3 and available on F-Droid and Google Play.\n\n(Please restart Conversations afterwards.) Restart Install diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 157b8175c..70d5fc03a 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -619,6 +619,7 @@ public class XmppConnectionService extends Service { @Override public void onDestroy() { + Log.d(LOGTAG,"stopping service"); super.onDestroy(); for (Account account : accounts) { if (account.getXmppConnection() != null) { diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java index 1f9c678a1..70c4614d5 100644 --- a/src/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/eu/siacs/conversations/ui/XmppActivity.java @@ -95,8 +95,12 @@ public abstract class XmppActivity extends Activity { @Override public void onClick(DialogInterface dialog, int which) { - // TODO Auto-generated method stub - + if (xmppConnectionServiceBound) { + unbindService(mConnection); + xmppConnectionServiceBound = false; + } + stopService(new Intent(XmppActivity.this, XmppConnectionService.class)); + finish(); } }); builder.setPositiveButton(getString(R.string.install), new OnClickListener() { @@ -106,6 +110,7 @@ public abstract class XmppActivity extends Activity { Uri uri = Uri.parse("market://details?id=org.sufficientlysecure.keychain"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); + finish(); } }); builder.create().show(); From 4893d8030b049747e220d58edccb2fd00f3f1bce Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 3 May 2014 17:04:41 +0200 Subject: [PATCH 2/6] removed unnecessary files --- res/values-sw600dp/dimens.xml | 8 -------- res/values-sw720dp-land/dimens.xml | 9 --------- res/values-v11/styles.xml | 11 ----------- res/values-v14/styles.xml | 12 ------------ 4 files changed, 40 deletions(-) delete mode 100644 res/values-sw600dp/dimens.xml delete mode 100644 res/values-sw720dp-land/dimens.xml delete mode 100644 res/values-v11/styles.xml delete mode 100644 res/values-v14/styles.xml diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml deleted file mode 100644 index 44f01db75..000000000 --- a/res/values-sw600dp/dimens.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml deleted file mode 100644 index 61e3fa8fb..000000000 --- a/res/values-sw720dp-land/dimens.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - 128dp - - diff --git a/res/values-v11/styles.xml b/res/values-v11/styles.xml deleted file mode 100644 index 3c02242ad..000000000 --- a/res/values-v11/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml deleted file mode 100644 index a91fd0372..000000000 --- a/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - From be2f7e047a488d5ca7de04dfa5437c290882274e Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 3 May 2014 17:06:54 +0200 Subject: [PATCH 3/6] more cleanup in res files --- res/values/dimens.xml | 7 ------- res/values/styles.xml | 36 +++++++++--------------------------- 2 files changed, 9 insertions(+), 34 deletions(-) delete mode 100644 res/values/dimens.xml diff --git a/res/values/dimens.xml b/res/values/dimens.xml deleted file mode 100644 index 55c1e5908..000000000 --- a/res/values/dimens.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - 16dp - 16dp - - diff --git a/res/values/styles.xml b/res/values/styles.xml index 20cfcf1d9..1468283ed 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -1,24 +1,6 @@ - - - - - - - - - - - - + + + + \ No newline at end of file From 4822d4dce7c8110c76dece28ccc2b3dd98698b97 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 3 May 2014 17:07:37 +0200 Subject: [PATCH 4/6] allow roster pushes only from bare jid or null --- .../conversations/services/XmppConnectionService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 70d5fc03a..d554c5041 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -377,12 +377,14 @@ public class XmppConnectionService extends Service { @Override public void onIqPacketReceived(Account account, IqPacket packet) { - if (packet.hasChild("query")) { - Element query = packet.findChild("query"); - String xmlns = query.getAttribute("xmlns"); - if ((xmlns != null) && (xmlns.equals("jabber:iq:roster"))) { + if (packet.hasChild("query","jabber:iq:roster")) { + String from = packet.getFrom(); + if ((from==null)||(from.equals(account.getJid()))) { + Element query = packet.findChild("query"); processRosterItems(account, query); mergePhoneContactsWithRoster(null); + } else { + Log.d(LOGTAG,"unauthorized roster push from: "+from); } } else if (packet .hasChild("open", "http://jabber.org/protocol/ibb") From 2df57f38a066c5a3c26a0fe799ad81b7ef3958cd Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 3 May 2014 17:42:44 +0200 Subject: [PATCH 5/6] properly reply to iq requests. reply to disco --- .../services/XmppConnectionService.java | 17 ++++++++++++++++- .../conversations/xmpp/stanzas/IqPacket.java | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index d554c5041..15c828a7c 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -392,8 +392,23 @@ public class XmppConnectionService extends Service { .hasChild("data", "http://jabber.org/protocol/ibb")) { XmppConnectionService.this.mJingleConnectionManager .deliverIbbPacket(account, packet); + } else if (packet.hasChild("query","http://jabber.org/protocol/disco#info")) { + IqPacket iqResponse = packet.generateRespone(IqPacket.TYPE_RESULT); + Element query = iqResponse.addChild("query", "http://jabber.org/protocol/disco#info"); + query.addChild("feature").setAttribute("var", "urn:xmpp:jingle:1"); + query.addChild("feature").setAttribute("var", "urn:xmpp:jingle:apps:file-transfer:3"); + query.addChild("feature").setAttribute("var", "urn:xmpp:jingle:transports:s5b:1"); + query.addChild("feature").setAttribute("var", "urn:xmpp:jingle:transports:ibb:1"); + Log.d(LOGTAG,"replying to disco from "+packet.getFrom()+"with: "+iqResponse); + account.getXmppConnection().sendIqPacket(iqResponse, null); } else { - Log.d(LOGTAG, "iq packet arrived " + packet.toString()); + if ((packet.getType() == IqPacket.TYPE_GET)||(packet.getType() == IqPacket.TYPE_SET)) { + IqPacket response = packet.generateRespone(IqPacket.TYPE_ERROR); + Element error = response.addChild("error"); + error.setAttribute("type","cancel"); + error.addChild("feature-not-implemented","urn:ietf:params:xml:ns:xmpp-stanzas"); + account.getXmppConnection().sendIqPacket(response, null); + } } } }; diff --git a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java index 9e2884540..48e5c0ecd 100644 --- a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java +++ b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java @@ -26,6 +26,9 @@ public class IqPacket extends AbstractStanza { case TYPE_RESULT: this.setAttribute("type", "result"); break; + case TYPE_ERROR: + this.setAttribute("type", "error"); + break; default: break; } From f7033cb7e06740576d23e1f8fbf473db337e13fe Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 3 May 2014 18:47:53 +0200 Subject: [PATCH 6/6] content name and creator are properly set --- .../services/XmppConnectionService.java | 1 - .../xmpp/jingle/JingleConnection.java | 21 ++++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 15c828a7c..06ba34ab6 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -399,7 +399,6 @@ public class XmppConnectionService extends Service { query.addChild("feature").setAttribute("var", "urn:xmpp:jingle:apps:file-transfer:3"); query.addChild("feature").setAttribute("var", "urn:xmpp:jingle:transports:s5b:1"); query.addChild("feature").setAttribute("var", "urn:xmpp:jingle:transports:ibb:1"); - Log.d(LOGTAG,"replying to disco from "+packet.getFrom()+"with: "+iqResponse); account.getXmppConnection().sendIqPacket(iqResponse, null); } else { if ((packet.getType() == IqPacket.TYPE_GET)||(packet.getType() == IqPacket.TYPE_SET)) { diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index bcf75c0c1..3a20b87fb 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -52,6 +52,9 @@ public class JingleConnection { private Element fileOffer; private JingleFile file = null; + private String contentName; + private String contentCreator; + private boolean receivedCandidate = false; private boolean sentCandidate = false; @@ -160,6 +163,8 @@ public class JingleConnection { } public void init(Message message) { + this.contentCreator = "initiator"; + this.contentName = this.mJingleConnectionManager.nextRandomId(); this.message = message; this.account = message.getConversation().getAccount(); this.initiator = this.account.getFullJid(); @@ -215,6 +220,8 @@ public class JingleConnection { this.responder = this.account.getFullJid(); this.sessionId = packet.getSessionId(); Content content = packet.getJingleContent(); + this.contentCreator = content.getAttribute("creator"); + this.contentName = content.getAttribute("name"); this.transportId = content.getTransportId(); this.mergeCandidates(JingleCandidate.parse(content.socks5transport().getChildren())); this.fileOffer = packet.getJingleContent().getFileOffer(); @@ -263,10 +270,8 @@ public class JingleConnection { private void sendInitRequest() { JinglePacket packet = this.bootstrapPacket("session-initiate"); - Content content = new Content(); + Content content = new Content(this.contentCreator,this.contentName); if (message.getType() == Message.TYPE_IMAGE) { - content.setAttribute("creator", "initiator"); - content.setAttribute("name", "a-file-offer"); content.setTransportId(this.transportId); this.file = this.mXmppConnectionService.getFileBackend().getJingleFile(message); content.setFileOffer(this.file); @@ -295,7 +300,7 @@ public class JingleConnection { @Override public void onPrimaryCandidateFound(boolean success,final JingleCandidate candidate) { final JinglePacket packet = bootstrapPacket("session-accept"); - final Content content = new Content(); + final Content content = new Content(contentCreator,contentName); content.setFileOffer(fileOffer); content.setTransportId(transportId); if ((success)&&(!equalCandidateExists(candidate))) { @@ -499,7 +504,7 @@ public class JingleConnection { private void sendFallbackToIbb() { JinglePacket packet = this.bootstrapPacket("transport-replace"); - Content content = new Content("initiator","a-file-offer"); + Content content = new Content(this.contentCreator,this.contentName); this.transportId = this.mJingleConnectionManager.nextRandomId(); content.setTransportId(this.transportId); content.ibbTransport().setAttribute("block-size",""+this.ibbBlockSize); @@ -613,7 +618,7 @@ public class JingleConnection { private void sendProxyActivated(String cid) { JinglePacket packet = bootstrapPacket("transport-info"); - Content content = new Content("inititaor","a-file-offer"); + Content content = new Content(this.contentCreator,this.contentName); content.setTransportId(this.transportId); content.socks5transport().addChild("activated").setAttribute("cid", cid); packet.setContent(content); @@ -622,7 +627,7 @@ public class JingleConnection { private void sendCandidateUsed(final String cid) { JinglePacket packet = bootstrapPacket("transport-info"); - Content content = new Content("initiator","a-file-offer"); + Content content = new Content(this.contentCreator,this.contentName); content.setTransportId(this.transportId); content.socks5transport().addChild("candidate-used").setAttribute("cid", cid); packet.setContent(content); @@ -635,7 +640,7 @@ public class JingleConnection { private void sendCandidateError() { JinglePacket packet = bootstrapPacket("transport-info"); - Content content = new Content("initiator","a-file-offer"); + Content content = new Content(this.contentCreator,this.contentName); content.setTransportId(this.transportId); content.socks5transport().addChild("candidate-error"); packet.setContent(content);