summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-04-12 18:35:30 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-04-18 19:11:42 (GMT)
commit509973e7e5978c2225fb89a10a1e2343fce21e7b (patch)
treed8ea2cdc00d42f709103a1a1c0b7777c192e71a7 /Swiften/Parser
parente0578b8fc582d431cce61ecac833ecf7031f6e75 (diff)
downloadswift-509973e7e5978c2225fb89a10a1e2343fce21e7b.zip
swift-509973e7e5978c2225fb89a10a1e2343fce21e7b.tar.bz2
Small tweaks to the roster item exchange payload.
Diffstat (limited to 'Swiften/Parser')
-rw-r--r--Swiften/Parser/PayloadParsers/RosterItemExchangeParser.cpp14
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp22
2 files changed, 18 insertions, 18 deletions
diff --git a/Swiften/Parser/PayloadParsers/RosterItemExchangeParser.cpp b/Swiften/Parser/PayloadParsers/RosterItemExchangeParser.cpp
index 7d59cc3..ff2a73b 100644
--- a/Swiften/Parser/PayloadParsers/RosterItemExchangeParser.cpp
+++ b/Swiften/Parser/PayloadParsers/RosterItemExchangeParser.cpp
@@ -19,22 +19,22 @@ void RosterItemExchangeParser::handleStartElement(const std::string& element, co
currentItem_ = RosterItemExchangePayload::Item();
- currentItem_.jid = JID(attributes.getAttribute("jid"));
- currentItem_.name = attributes.getAttribute("name");
+ currentItem_.setJID(JID(attributes.getAttribute("jid")));
+ currentItem_.setName(attributes.getAttribute("name"));
std::string action = attributes.getAttribute("action");
if (action == "add") {
- currentItem_.action = RosterItemExchangePayload::Add;
+ currentItem_.setAction(RosterItemExchangePayload::Item::Add);
}
else if (action == "modify") {
- currentItem_.action = RosterItemExchangePayload::Modify;
+ currentItem_.setAction(RosterItemExchangePayload::Item::Modify);
}
else if (action == "delete") {
- currentItem_.action = RosterItemExchangePayload::Delete;
+ currentItem_.setAction(RosterItemExchangePayload::Item::Delete);
}
else {
// Add is default action according to XEP
- currentItem_.action = RosterItemExchangePayload::Add;
+ currentItem_.setAction(RosterItemExchangePayload::Item::Add);
}
}
}
@@ -56,7 +56,7 @@ void RosterItemExchangeParser::handleEndElement(const std::string& element, cons
}
else if (level_ == ItemLevel) {
if (element == "group") {
- currentItem_.groups.push_back(currentText_);
+ currentItem_.addGroup(currentText_);
}
}
}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp
index ceba45f..9533e15 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp
@@ -35,17 +35,17 @@ class RosterItemExchangeParserTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
- CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), items[0].jid);
- CPPUNIT_ASSERT_EQUAL(std::string("Foo @ Bar"), items[0].name);
- CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Add, items[0].action);
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items[0].groups.size());
- CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].groups[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].groups[1]);
-
- CPPUNIT_ASSERT_EQUAL(JID("baz@blo.com"), items[1].jid);
- CPPUNIT_ASSERT_EQUAL(std::string("Baz"), items[1].name);
- CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Modify, items[1].action);
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), items[1].groups.size());
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), items[0].getJID());
+ CPPUNIT_ASSERT_EQUAL(std::string("Foo @ Bar"), items[0].getName());
+ CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Item::Add, items[0].getAction());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items[0].getGroups().size());
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]);
+
+ CPPUNIT_ASSERT_EQUAL(JID("baz@blo.com"), items[1].getJID());
+ CPPUNIT_ASSERT_EQUAL(std::string("Baz"), items[1].getName());
+ CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Item::Modify, items[1].getAction());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), items[1].getGroups().size());
}
};