diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/xmpp/chatstate')
-rw-r--r-- | src/main/java/de/pixart/messenger/xmpp/chatstate/ChatState.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/chatstate/ChatState.java b/src/main/java/de/pixart/messenger/xmpp/chatstate/ChatState.java new file mode 100644 index 000000000..c3117455c --- /dev/null +++ b/src/main/java/de/pixart/messenger/xmpp/chatstate/ChatState.java @@ -0,0 +1,32 @@ +package de.pixart.messenger.xmpp.chatstate; + +import de.pixart.messenger.xml.Element; + +public enum ChatState { + + ACTIVE, INACTIVE, GONE, COMPOSING, PAUSED; + + public static ChatState parse(Element element) { + final String NAMESPACE = "http://jabber.org/protocol/chatstates"; + if (element.hasChild("active",NAMESPACE)) { + return ACTIVE; + } else if (element.hasChild("inactive",NAMESPACE)) { + return INACTIVE; + } else if (element.hasChild("composing",NAMESPACE)) { + return COMPOSING; + } else if (element.hasChild("gone",NAMESPACE)) { + return GONE; + } else if (element.hasChild("paused",NAMESPACE)) { + return PAUSED; + } else { + return null; + } + } + + public static Element toElement(ChatState state) { + final String NAMESPACE = "http://jabber.org/protocol/chatstates"; + final Element element = new Element(state.toString().toLowerCase()); + element.setAttribute("xmlns",NAMESPACE); + return element; + } +} |