summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-12 10:52:03 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-12 10:52:03 (GMT)
commitedd726abb1d0f7532218efbb8067a75a313e9e98 (patch)
tree7eec4f7912a59bb9a383a61c2c96616d5b5847b6 /Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
parent6e9fb4e4a3aeee8c40617a4dda6e5e0892ceebad (diff)
downloadswift-contrib-edd726abb1d0f7532218efbb8067a75a313e9e98.zip
swift-contrib-edd726abb1d0f7532218efbb8067a75a313e9e98.tar.bz2
Improved whiteboard session handling
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;
+ }
+ }
}