aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/xmpp/MessagePacket.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-02 17:53:34 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-02 17:53:34 +0100
commit3d9294684c739cc54de8dfa08ad22097ca8a1811 (patch)
tree28f5bd5b6f5dfa7c955db5a0b8ac25fc8bcfd443 /src/de/gultsch/chat/xmpp/MessagePacket.java
parentbbdaf5b0bd7c42729aeba12f3b4ea4cabc794c4f (diff)
tls is no optional
Diffstat (limited to 'src/de/gultsch/chat/xmpp/MessagePacket.java')
-rw-r--r--src/de/gultsch/chat/xmpp/MessagePacket.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/de/gultsch/chat/xmpp/MessagePacket.java b/src/de/gultsch/chat/xmpp/MessagePacket.java
index de486a5d..ab0c05c3 100644
--- a/src/de/gultsch/chat/xmpp/MessagePacket.java
+++ b/src/de/gultsch/chat/xmpp/MessagePacket.java
@@ -4,6 +4,8 @@ import de.gultsch.chat.xml.Element;
public class MessagePacket extends Element {
public static final int TYPE_CHAT = 0;
+ public static final int TYPE_UNKNOWN = 1;
+ public static final int TYPE_NO = 2;
private MessagePacket(String name) {
super(name);
@@ -22,7 +24,12 @@ public class MessagePacket extends Element {
}
public String getBody() {
- return this.findChild("body").getContent();
+ Element body = this.findChild("body");
+ if (body!=null) {
+ return body.getContent();
+ } else {
+ return null;
+ }
}
public void setTo(String to) {
@@ -50,4 +57,16 @@ public class MessagePacket extends Element {
break;
}
}
+
+ public int getType() {
+ String type = getAttribute("type");
+ if (type==null) {
+ return TYPE_NO;
+ }
+ if (type.equals("chat")) {
+ return TYPE_CHAT;
+ } else {
+ return TYPE_UNKNOWN;
+ }
+ }
}