aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xmpp
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-03-27 02:02:59 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-03-27 02:02:59 +0100
commit4864f7200bbdb3e8d45eb7f165d62274f19e2e7b (patch)
tree54da6eeef9f9114dfb9e89c4342bdcee266414e2 /src/eu/siacs/conversations/xmpp
parentf4c9c19ec0f50fa7a80f4aa7dd28269335188f55 (diff)
fixed a couple of muc issues. added jingle listener (which doesn't do anything for now)
Diffstat (limited to 'src/eu/siacs/conversations/xmpp')
-rw-r--r--src/eu/siacs/conversations/xmpp/OnJinglePacketReceived.java8
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java33
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/jingle/Content.java13
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/jingle/JinglePacket.java54
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/jingle/Reason.java13
5 files changed, 113 insertions, 8 deletions
diff --git a/src/eu/siacs/conversations/xmpp/OnJinglePacketReceived.java b/src/eu/siacs/conversations/xmpp/OnJinglePacketReceived.java
new file mode 100644
index 00000000..6705e309
--- /dev/null
+++ b/src/eu/siacs/conversations/xmpp/OnJinglePacketReceived.java
@@ -0,0 +1,8 @@
+package eu.siacs.conversations.xmpp;
+
+import eu.siacs.conversations.entities.Account;
+import eu.siacs.conversations.xmpp.stanzas.jingle.JinglePacket;
+
+public interface OnJinglePacketReceived extends PacketReceived {
+ public void onJinglePacketReceived(Account account, JinglePacket packet);
+}
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index ec5ab1f6..e265b997 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -46,6 +46,7 @@ import eu.siacs.conversations.xmpp.stanzas.AbstractStanza;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
+import eu.siacs.conversations.xmpp.stanzas.jingle.JinglePacket;
import eu.siacs.conversations.xmpp.stanzas.streammgmt.AckPacket;
import eu.siacs.conversations.xmpp.stanzas.streammgmt.EnablePacket;
import eu.siacs.conversations.xmpp.stanzas.streammgmt.RequestPacket;
@@ -86,6 +87,7 @@ public class XmppConnection implements Runnable {
private Hashtable<String, PacketReceived> packetCallbacks = new Hashtable<String, PacketReceived>();
private OnPresencePacketReceived presenceListener = null;
+ private OnJinglePacketReceived jingleListener = null;
private OnIqPacketReceived unregisteredIqListener = null;
private OnMessagePacketReceived messageListener = null;
private OnStatusChanged statusListener = null;
@@ -284,6 +286,10 @@ public class XmppConnection implements Runnable {
while (!nextTag.isEnd(element.getName())) {
if (!nextTag.isNo()) {
Element child = tagReader.readElement(nextTag);
+ if ((packetType == PACKET_IQ)&&("jingle".equals(child.getName()))) {
+ element = new JinglePacket();
+ element.setAttributes(currentTag.getAttributes());
+ }
element.addChild(child);
}
nextTag = tagReader.readTag();
@@ -296,15 +302,22 @@ public class XmppConnection implements Runnable {
private void processIq(Tag currentTag) throws XmlPullParserException,
IOException {
IqPacket packet = (IqPacket) processPacket(currentTag, PACKET_IQ);
- if (packetCallbacks.containsKey(packet.getId())) {
- if (packetCallbacks.get(packet.getId()) instanceof OnIqPacketReceived) {
- ((OnIqPacketReceived) packetCallbacks.get(packet.getId()))
- .onIqPacketReceived(account, packet);
+
+ if (packet instanceof JinglePacket) {
+ if (this.jingleListener !=null) {
+ this.jingleListener.onJinglePacketReceived(account, (JinglePacket) packet);
+ }
+ } else {
+ if (packetCallbacks.containsKey(packet.getId())) {
+ if (packetCallbacks.get(packet.getId()) instanceof OnIqPacketReceived) {
+ ((OnIqPacketReceived) packetCallbacks.get(packet.getId()))
+ .onIqPacketReceived(account, packet);
+ }
+
+ packetCallbacks.remove(packet.getId());
+ } else if (this.unregisteredIqListener != null) {
+ this.unregisteredIqListener.onIqPacketReceived(account, packet);
}
-
- packetCallbacks.remove(packet.getId());
- } else if (this.unregisteredIqListener != null) {
- this.unregisteredIqListener.onIqPacketReceived(account, packet);
}
}
@@ -684,6 +697,10 @@ public class XmppConnection implements Runnable {
OnPresencePacketReceived listener) {
this.presenceListener = listener;
}
+
+ public void setOnJinglePacketReceivedListener(OnJinglePacketReceived listener) {
+ this.jingleListener = listener;
+ }
public void setOnStatusChangedListener(OnStatusChanged listener) {
this.statusListener = listener;
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/jingle/Content.java b/src/eu/siacs/conversations/xmpp/stanzas/jingle/Content.java
new file mode 100644
index 00000000..ebd212b8
--- /dev/null
+++ b/src/eu/siacs/conversations/xmpp/stanzas/jingle/Content.java
@@ -0,0 +1,13 @@
+package eu.siacs.conversations.xmpp.stanzas.jingle;
+
+import eu.siacs.conversations.xml.Element;
+
+public class Content extends Element {
+ private Content(String name) {
+ super(name);
+ }
+
+ public Content() {
+ super("content");
+ }
+}
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/jingle/JinglePacket.java b/src/eu/siacs/conversations/xmpp/stanzas/jingle/JinglePacket.java
new file mode 100644
index 00000000..51c60d1f
--- /dev/null
+++ b/src/eu/siacs/conversations/xmpp/stanzas/jingle/JinglePacket.java
@@ -0,0 +1,54 @@
+package eu.siacs.conversations.xmpp.stanzas.jingle;
+
+import eu.siacs.conversations.xml.Element;
+import eu.siacs.conversations.xmpp.stanzas.IqPacket;
+
+public class JinglePacket extends IqPacket {
+ Content content = null;
+ Reason reason = null;
+
+ @Override
+ public Element addChild(Element child) {
+ if ("jingle".equals(child.getName())) {
+ Element contentElement = child.findChild("content");
+ if (contentElement!=null) {
+ this.content = new Content();
+ this.content.setChildren(contentElement.getChildren());
+ this.content.setAttributes(contentElement.getAttributes());
+ }
+ Element reasonElement = child.findChild("reason");
+ if (reasonElement!=null) {
+ this.reason = new Reason();
+ this.reason.setChildren(reasonElement.getChildren());
+ this.reason.setAttributes(reasonElement.getAttributes());
+ }
+ this.build();
+ this.findChild("jingle").setAttributes(child.getAttributes());
+ }
+ return child;
+ }
+
+ public JinglePacket setContent(Content content) {
+ this.content = content;
+ this.build();
+ return this;
+ }
+
+ public JinglePacket setReason(Reason reason) {
+ this.reason = reason;
+ this.build();
+ return this;
+ }
+
+ private void build() {
+ this.children.clear();
+ Element jingle = addChild("jingle", "urn:xmpp:jingle:1");
+ if (this.content!=null) {
+ jingle.addChild(this.content);
+ }
+ if (this.reason != null) {
+ jingle.addChild(this.reason);
+ }
+ this.children.add(jingle);
+ }
+}
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/jingle/Reason.java b/src/eu/siacs/conversations/xmpp/stanzas/jingle/Reason.java
new file mode 100644
index 00000000..35b81655
--- /dev/null
+++ b/src/eu/siacs/conversations/xmpp/stanzas/jingle/Reason.java
@@ -0,0 +1,13 @@
+package eu.siacs.conversations.xmpp.stanzas.jingle;
+
+import eu.siacs.conversations.xml.Element;
+
+public class Reason extends Element {
+ private Reason(String name) {
+ super(name);
+ }
+
+ public Reason() {
+ super("reason");
+ }
+}