summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/MessageParser.cpp')
-rw-r--r--Swiften/Parser/MessageParser.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/Swiften/Parser/MessageParser.cpp b/Swiften/Parser/MessageParser.cpp
new file mode 100644
index 0000000..5e83fad
--- /dev/null
+++ b/Swiften/Parser/MessageParser.cpp
@@ -0,0 +1,33 @@
+#include <iostream>
+
+#include "Swiften/Parser/MessageParser.h"
+
+namespace Swift {
+
+MessageParser::MessageParser(PayloadParserFactoryCollection* factories) :
+ GenericStanzaParser<Message>(factories) {
+ getStanzaGeneric()->setType(Message::Normal);
+}
+
+void MessageParser::handleStanzaAttributes(const AttributeMap& attributes) {
+ AttributeMap::const_iterator type = attributes.find("type");
+ if (type != attributes.end()) {
+ if (type->second == "chat") {
+ getStanzaGeneric()->setType(Message::Chat);
+ }
+ else if (type->second == "error") {
+ getStanzaGeneric()->setType(Message::Error);
+ }
+ else if (type->second == "groupchat") {
+ getStanzaGeneric()->setType(Message::Groupchat);
+ }
+ else if (type->second == "headline") {
+ getStanzaGeneric()->setType(Message::Headline);
+ }
+ else {
+ getStanzaGeneric()->setType(Message::Normal);
+ }
+ }
+}
+
+}