aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBeriain <beriain@bitmessage.ch>2014-05-06 16:56:59 +0200
committerBeriain <beriain@bitmessage.ch>2014-05-06 16:56:59 +0200
commitb8023b4dfc192fe2d019c993f17d417f2b6e91ab (patch)
tree3d812373324e928af943fecfca8e993672149960 /src
parent86887274c7eb77b77417ce9c20a50502fa80fe24 (diff)
parentf7033cb7e06740576d23e1f8fbf473db337e13fe (diff)
Merge https://github.com/siacs/Conversations into development
Diffstat (limited to 'src')
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java27
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java9
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java21
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java3
4 files changed, 45 insertions, 15 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 157b8175..06ba34ab 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")
@@ -390,8 +392,22 @@ 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");
+ 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);
+ }
}
}
};
@@ -619,6 +635,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 1f9c678a..70c4614d 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();
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index bcf75c0c..3a20b87f 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);
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java
index 9e288454..48e5c0ec 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;
}