summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParsers/WhiteboardParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/WhiteboardParser.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
index 94b67e5..4306497 100644
--- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
+++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
@@ -5,19 +5,16 @@
*/
#include <Swiften/Parser/PayloadParsers/WhiteboardParser.h>
+#include <boost/optional.hpp>
namespace Swift {
WhiteboardParser::WhiteboardParser() : level_(0) {
}
+
void WhiteboardParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) {
if (level_ == 0) {
- std::string type = attributes.getAttribute("type");
- if (type.empty()) {
- getPayloadInternal()->setType(WhiteboardPayload::Data);
- }
- else if (type == "request") {
- getPayloadInternal()->setType(WhiteboardPayload::SessionRequest);
- }
+// std::string type = attributes.getAttribute("type");
+ getPayloadInternal()->setType(stringToType(attributes.getAttributeValue("type").get_value_or("")));
}
++level_;
}
@@ -32,4 +29,16 @@ namespace Swift {
void WhiteboardParser::handleCharacterData(const std::string& data) {
data_ += data;
}
+
+ WhiteboardPayload::Type WhiteboardParser::stringToType(const std::string& type) const {
+ if (type.empty()) {
+ return WhiteboardPayload::Data;
+ } else if (type == "session-request") {
+ return WhiteboardPayload::SessionRequest;
+ } else if (type == "session-accept") {
+ return WhiteboardPayload::SessionAccept;
+ } else if (type == "session-terminate") {
+ return WhiteboardPayload::SessionTerminate;
+ }
+ }
}