diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp | 5 | ||||
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp | 22 |
2 files changed, 27 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp index dcc51b9..f5923dc 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp @@ -10,6 +10,8 @@ #include "Swiften/Base/foreach.h" #include "Swiften/Serializer/XML/XMLElement.h" +#include "Swiften/Serializer/XML/XMLRawTextNode.h" +#include "Swiften/Serializer/PayloadSerializers/FormSerializer.h" namespace Swift { @@ -36,6 +38,9 @@ String DiscoInfoSerializer::serializePayload(boost::shared_ptr<DiscoInfo> discoI featureElement->setAttribute("var", feature); queryElement.addNode(featureElement); } + foreach(const Form::ref extension, discoInfo->getExtensions()) { + queryElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(extension)))); + } return queryElement.serialize(); } diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp index 6a81298..c67fcdb 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp @@ -15,6 +15,7 @@ class DiscoInfoSerializerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(DiscoInfoSerializerTest); CPPUNIT_TEST(testSerialize); + CPPUNIT_TEST(testSerialize_Form); CPPUNIT_TEST_SUITE_END(); public: @@ -39,6 +40,27 @@ class DiscoInfoSerializerTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(discoInfo)); } + + void testSerialize_Form() { + DiscoInfoSerializer testling; + boost::shared_ptr<DiscoInfo> discoInfo(new DiscoInfo()); + discoInfo->addFeature("http://jabber.org/protocol/caps"); + discoInfo->addFeature("http://jabber.org/protocol/disco#info"); + boost::shared_ptr<Form> form(new Form(Form::FormType)); + form->setTitle("Bot Configuration"); + discoInfo->addExtension(form); + + String expectedResult = + "<query xmlns=\"http://jabber.org/protocol/disco#info\">" + "<feature var=\"http://jabber.org/protocol/caps\"/>" + "<feature var=\"http://jabber.org/protocol/disco#info\"/>" + "<x type=\"form\" xmlns=\"jabber:x:data\">" + "<title>Bot Configuration</title>" + "</x>" + "</query>"; + + CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(discoInfo)); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoSerializerTest); |