diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-03-28 15:46:49 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-03-28 15:46:49 (GMT) |
commit | f53a1ef582494458301b97bf6e546be52d7ff7e8 (patch) | |
tree | 7571b5cbcbd8a8f1dd1c966c9045b6cb69f0e295 /Swiften/Parser/PresenceParser.cpp | |
parent | 638345680d72ca6acaf123f2c8c1c391f696e371 (diff) | |
download | swift-contrib-f53a1ef582494458301b97bf6e546be52d7ff7e8.zip swift-contrib-f53a1ef582494458301b97bf6e546be52d7ff7e8.tar.bz2 |
Moving submodule contents back.
Diffstat (limited to 'Swiften/Parser/PresenceParser.cpp')
-rw-r--r-- | Swiften/Parser/PresenceParser.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Swiften/Parser/PresenceParser.cpp b/Swiften/Parser/PresenceParser.cpp new file mode 100644 index 0000000..72cdd4c --- /dev/null +++ b/Swiften/Parser/PresenceParser.cpp @@ -0,0 +1,45 @@ +#include <iostream> + +#include "Swiften/Parser/PresenceParser.h" + +namespace Swift { + +PresenceParser::PresenceParser(PayloadParserFactoryCollection* factories) : + GenericStanzaParser<Presence>(factories) { +} + +void PresenceParser::handleStanzaAttributes(const AttributeMap& attributes) { + AttributeMap::const_iterator type = attributes.find("type"); + if (type != attributes.end()) { + if (type->second == "unavailable") { + getStanzaGeneric()->setType(Presence::Unavailable); + } + else if (type->second == "probe") { + getStanzaGeneric()->setType(Presence::Probe); + } + else if (type->second == "subscribe") { + getStanzaGeneric()->setType(Presence::Subscribe); + } + else if (type->second == "subscribed") { + getStanzaGeneric()->setType(Presence::Subscribed); + } + else if (type->second == "unsubscribe") { + getStanzaGeneric()->setType(Presence::Unsubscribe); + } + else if (type->second == "unsubscribed") { + getStanzaGeneric()->setType(Presence::Unsubscribed); + } + else if (type->second == "error") { + getStanzaGeneric()->setType(Presence::Error); + } + else { + std::cerr << "Unknown Presence type: " << type->second << std::endl; + getStanzaGeneric()->setType(Presence::Available); + } + } + else { + getStanzaGeneric()->setType(Presence::Available); + } +} + +} |