summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParsers/RosterParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/RosterParser.cpp148
1 files changed, 74 insertions, 74 deletions
diff --git a/Swiften/Parser/PayloadParsers/RosterParser.cpp b/Swiften/Parser/PayloadParsers/RosterParser.cpp
index b35d598..0cb47d3 100644
--- a/Swiften/Parser/PayloadParsers/RosterParser.cpp
+++ b/Swiften/Parser/PayloadParsers/RosterParser.cpp
@@ -16,89 +16,89 @@ RosterParser::RosterParser() : level_(TopLevel), inItem_(false), unknownContentP
}
void RosterParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
- if (level_ == TopLevel) {
- boost::optional<std::string> ver = attributes.getAttributeValue("ver");
- if (ver) {
- getPayloadInternal()->setVersion(*ver);
- }
- }
- else if (level_ == PayloadLevel) {
- if (element == "item") {
- inItem_ = true;
- currentItem_ = RosterItemPayload();
+ if (level_ == TopLevel) {
+ boost::optional<std::string> ver = attributes.getAttributeValue("ver");
+ if (ver) {
+ getPayloadInternal()->setVersion(*ver);
+ }
+ }
+ else if (level_ == PayloadLevel) {
+ if (element == "item") {
+ inItem_ = true;
+ currentItem_ = RosterItemPayload();
- currentItem_.setJID(JID(attributes.getAttribute("jid")));
- currentItem_.setName(attributes.getAttribute("name"));
+ currentItem_.setJID(JID(attributes.getAttribute("jid")));
+ currentItem_.setName(attributes.getAttribute("name"));
- std::string subscription = attributes.getAttribute("subscription");
- if (subscription == "both") {
- currentItem_.setSubscription(RosterItemPayload::Both);
- }
- else if (subscription == "to") {
- currentItem_.setSubscription(RosterItemPayload::To);
- }
- else if (subscription == "from") {
- currentItem_.setSubscription(RosterItemPayload::From);
- }
- else if (subscription == "remove") {
- currentItem_.setSubscription(RosterItemPayload::Remove);
- }
- else {
- currentItem_.setSubscription(RosterItemPayload::None);
- }
+ std::string subscription = attributes.getAttribute("subscription");
+ if (subscription == "both") {
+ currentItem_.setSubscription(RosterItemPayload::Both);
+ }
+ else if (subscription == "to") {
+ currentItem_.setSubscription(RosterItemPayload::To);
+ }
+ else if (subscription == "from") {
+ currentItem_.setSubscription(RosterItemPayload::From);
+ }
+ else if (subscription == "remove") {
+ currentItem_.setSubscription(RosterItemPayload::Remove);
+ }
+ else {
+ currentItem_.setSubscription(RosterItemPayload::None);
+ }
- if (attributes.getAttribute("ask") == "subscribe") {
- currentItem_.setSubscriptionRequested();
- }
- }
- }
- else if (level_ == ItemLevel) {
- if (element == "group") {
- currentText_ = "";
- }
- else {
- assert(!unknownContentParser_);
- unknownContentParser_ = new SerializingParser();
- unknownContentParser_->handleStartElement(element, ns, attributes);
- }
- }
- else if (unknownContentParser_) {
- unknownContentParser_->handleStartElement(element, ns, attributes);
- }
- ++level_;
+ if (attributes.getAttribute("ask") == "subscribe") {
+ currentItem_.setSubscriptionRequested();
+ }
+ }
+ }
+ else if (level_ == ItemLevel) {
+ if (element == "group") {
+ currentText_ = "";
+ }
+ else {
+ assert(!unknownContentParser_);
+ unknownContentParser_ = new SerializingParser();
+ unknownContentParser_->handleStartElement(element, ns, attributes);
+ }
+ }
+ else if (unknownContentParser_) {
+ unknownContentParser_->handleStartElement(element, ns, attributes);
+ }
+ ++level_;
}
void RosterParser::handleEndElement(const std::string& element, const std::string& ns) {
- --level_;
- if (level_ == PayloadLevel) {
- if (inItem_) {
- getPayloadInternal()->addItem(currentItem_);
- inItem_ = false;
- }
- }
- else if (level_ == ItemLevel) {
- if (unknownContentParser_) {
- unknownContentParser_->handleEndElement(element, ns);
- currentItem_.addUnknownContent(unknownContentParser_->getResult());
- delete unknownContentParser_;
- unknownContentParser_ = NULL;
- }
- else if (element == "group") {
- currentItem_.addGroup(currentText_);
- }
- }
- else if (unknownContentParser_) {
- unknownContentParser_->handleEndElement(element, ns);
- }
+ --level_;
+ if (level_ == PayloadLevel) {
+ if (inItem_) {
+ getPayloadInternal()->addItem(currentItem_);
+ inItem_ = false;
+ }
+ }
+ else if (level_ == ItemLevel) {
+ if (unknownContentParser_) {
+ unknownContentParser_->handleEndElement(element, ns);
+ currentItem_.addUnknownContent(unknownContentParser_->getResult());
+ delete unknownContentParser_;
+ unknownContentParser_ = NULL;
+ }
+ else if (element == "group") {
+ currentItem_.addGroup(currentText_);
+ }
+ }
+ else if (unknownContentParser_) {
+ unknownContentParser_->handleEndElement(element, ns);
+ }
}
void RosterParser::handleCharacterData(const std::string& data) {
- if (unknownContentParser_) {
- unknownContentParser_->handleCharacterData(data);
- }
- else {
- currentText_ += data;
- }
+ if (unknownContentParser_) {
+ unknownContentParser_->handleCharacterData(data);
+ }
+ else {
+ currentText_ += data;
+ }
}
}