aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/xmpp/MessagePacket.java
diff options
context:
space:
mode:
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 de486a5da..ab0c05c3d 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;
+ }
+ }
}