diff options
Diffstat (limited to 'Swiften/Serializer')
10 files changed, 31 insertions, 23 deletions
diff --git a/Swiften/Serializer/AuthChallengeSerializer.cpp b/Swiften/Serializer/AuthChallengeSerializer.cpp index 18d190d..6848ad1 100644 --- a/Swiften/Serializer/AuthChallengeSerializer.cpp +++ b/Swiften/Serializer/AuthChallengeSerializer.cpp @@ -8,6 +8,7 @@ #include <Swiften/Elements/AuthChallenge.h> #include <Swiften/StringCodecs/Base64.h> +#include <Swiften/Base/ByteArray.h> namespace Swift { @@ -17,13 +18,13 @@ AuthChallengeSerializer::AuthChallengeSerializer() { std::string AuthChallengeSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthChallenge> authChallenge(boost::dynamic_pointer_cast<AuthChallenge>(element)); std::string value; - boost::optional<ByteArray> message = authChallenge->getValue(); + boost::optional<std::vector<unsigned char> > message = authChallenge->getValue(); if (message) { - if ((*message).isEmpty()) { + if ((*message).empty()) { value = "="; } else { - value = Base64::encode(*message); + value = Base64::encode(ByteArray(*message)); } } return "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</challenge>"; diff --git a/Swiften/Serializer/AuthRequestSerializer.cpp b/Swiften/Serializer/AuthRequestSerializer.cpp index 4ba3e47..415a0ff 100644 --- a/Swiften/Serializer/AuthRequestSerializer.cpp +++ b/Swiften/Serializer/AuthRequestSerializer.cpp @@ -8,6 +8,7 @@ #include <Swiften/Elements/AuthRequest.h> #include <Swiften/StringCodecs/Base64.h> +#include <Swiften/Base/ByteArray.h> namespace Swift { @@ -17,13 +18,13 @@ AuthRequestSerializer::AuthRequestSerializer() { std::string AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthRequest> authRequest(boost::dynamic_pointer_cast<AuthRequest>(element)); std::string value; - boost::optional<ByteArray> message = authRequest->getMessage(); + boost::optional<std::vector<unsigned char> > message = authRequest->getMessage(); if (message) { - if ((*message).isEmpty()) { + if ((*message).empty()) { value = "="; } else { - value = Base64::encode(*message); + value = Base64::encode(ByteArray(*message)); } } return "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">" + value + "</auth>"; diff --git a/Swiften/Serializer/AuthResponseSerializer.cpp b/Swiften/Serializer/AuthResponseSerializer.cpp index 9bd1cc1..0d1872b 100644 --- a/Swiften/Serializer/AuthResponseSerializer.cpp +++ b/Swiften/Serializer/AuthResponseSerializer.cpp @@ -8,6 +8,7 @@ #include <Swiften/Elements/AuthResponse.h> #include <Swiften/StringCodecs/Base64.h> +#include <Swiften/Base/ByteArray.h> namespace Swift { @@ -17,13 +18,13 @@ AuthResponseSerializer::AuthResponseSerializer() { std::string AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthResponse> authResponse(boost::dynamic_pointer_cast<AuthResponse>(element)); std::string value; - boost::optional<ByteArray> message = authResponse->getValue(); + boost::optional<std::vector<unsigned char> > message = authResponse->getValue(); if (message) { - if ((*message).isEmpty()) { + if ((*message).empty()) { value = "="; } else { - value = Base64::encode(*message); + value = Base64::encode(ByteArray(*message)); } } return "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</response>"; diff --git a/Swiften/Serializer/AuthSuccessSerializer.cpp b/Swiften/Serializer/AuthSuccessSerializer.cpp index 518c970..12aab8f 100644 --- a/Swiften/Serializer/AuthSuccessSerializer.cpp +++ b/Swiften/Serializer/AuthSuccessSerializer.cpp @@ -8,6 +8,7 @@ #include <Swiften/Elements/AuthSuccess.h> #include <Swiften/StringCodecs/Base64.h> +#include <Swiften/Base/ByteArray.h> namespace Swift { @@ -17,13 +18,13 @@ AuthSuccessSerializer::AuthSuccessSerializer() { std::string AuthSuccessSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthSuccess> authSuccess(boost::dynamic_pointer_cast<AuthSuccess>(element)); std::string value; - boost::optional<ByteArray> message = authSuccess->getValue(); + boost::optional<std::vector<unsigned char> > message = authSuccess->getValue(); if (message) { - if ((*message).isEmpty()) { + if ((*message).empty()) { value = "="; } else { - value = Base64::encode(*message); + value = Base64::encode(ByteArray(*message)); } } return "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</success>"; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp index 5122d22..3ac1d77 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp @@ -29,7 +29,7 @@ class VCardSerializerTest : public CppUnit::TestFixture vcard->setFamilyName("Wonderland"); vcard->setSuffix("PhD"); vcard->setNickname("DreamGirl"); - vcard->setPhoto("abcdef"); + vcard->setPhoto(createByteArray("abcdef")); vcard->setPhotoType("image/png"); vcard->addUnknownContent("<BDAY>1234</BDAY><MAILER>mutt</MAILER>"); diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp index ab6aa1e..17a6b49 100644 --- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp @@ -87,14 +87,14 @@ std::string VCardSerializer::serializePayload(boost::shared_ptr<VCard> vcard) c nickElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getNickname()))); queryElement.addNode(nickElement); } - if (!vcard->getPhoto().isEmpty() || !vcard->getPhotoType().empty()) { + if (!vcard->getPhoto().empty() || !vcard->getPhotoType().empty()) { XMLElement::ref photoElement(new XMLElement("PHOTO")); if (!vcard->getPhotoType().empty()) { XMLElement::ref typeElement(new XMLElement("TYPE")); typeElement->addNode(XMLTextNode::ref(new XMLTextNode(vcard->getPhotoType()))); photoElement->addNode(typeElement); } - if (!vcard->getPhoto().isEmpty()) { + if (!vcard->getPhoto().empty()) { XMLElement::ref binvalElement(new XMLElement("BINVAL")); binvalElement->addNode(XMLTextNode::ref(new XMLTextNode(Base64::encode(vcard->getPhoto())))); photoElement->addNode(binvalElement); diff --git a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp index f044607..a81620d 100644 --- a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp @@ -9,6 +9,7 @@ #include <Swiften/Serializer/AuthChallengeSerializer.h> #include <Swiften/Elements/AuthChallenge.h> +#include <Swiften/Base/ByteArray.h> using namespace Swift; @@ -23,7 +24,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture { void testSerialize() { AuthChallengeSerializer testling; boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge()); - authChallenge->setValue("foo"); + authChallenge->setValue(createByteArray("foo")); CPPUNIT_ASSERT_EQUAL(std::string( "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" @@ -43,7 +44,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture { void testSerialize_EmptyMessage() { AuthChallengeSerializer testling; boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge()); - authChallenge->setValue(ByteArray()); + authChallenge->setValue(std::vector<unsigned char>()); CPPUNIT_ASSERT_EQUAL(std::string( "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" diff --git a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp index eff2c8e..8270139 100644 --- a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp @@ -9,6 +9,7 @@ #include <Swiften/Serializer/AuthRequestSerializer.h> #include <Swiften/Elements/AuthRequest.h> +#include <Swiften/Base/ByteArray.h> using namespace Swift; @@ -23,7 +24,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture { void testSerialize() { AuthRequestSerializer testling; boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN")); - authRequest->setMessage("foo"); + authRequest->setMessage(createByteArray("foo")); CPPUNIT_ASSERT_EQUAL(std::string( "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" @@ -43,7 +44,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture { void testSerialize_EmptyMessage() { AuthRequestSerializer testling; boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN")); - authRequest->setMessage(ByteArray()); + authRequest->setMessage(std::vector<unsigned char>()); CPPUNIT_ASSERT_EQUAL(std::string( "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" diff --git a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp index f14d184..e790cc3 100644 --- a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp @@ -9,6 +9,7 @@ #include <Swiften/Serializer/AuthResponseSerializer.h> #include <Swiften/Elements/AuthResponse.h> +#include <Swiften/Base/ByteArray.h> using namespace Swift; @@ -23,7 +24,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture { void testSerialize() { AuthResponseSerializer testling; boost::shared_ptr<AuthResponse> authResponse(new AuthResponse()); - authResponse->setValue("foo"); + authResponse->setValue(createByteArray("foo")); CPPUNIT_ASSERT_EQUAL(std::string( "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" @@ -43,7 +44,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture { void testSerialize_EmptyMessage() { AuthResponseSerializer testling; boost::shared_ptr<AuthResponse> authResponse(new AuthResponse()); - authResponse->setValue(ByteArray()); + authResponse->setValue(std::vector<unsigned char>()); CPPUNIT_ASSERT_EQUAL(std::string( "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" diff --git a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp index 0f6987c..a9f6de2 100644 --- a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp @@ -9,6 +9,7 @@ #include <Swiften/Serializer/AuthSuccessSerializer.h> #include <Swiften/Elements/AuthSuccess.h> +#include <Swiften/Base/ByteArray.h> using namespace Swift; @@ -23,7 +24,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture { void testSerialize() { AuthSuccessSerializer testling; boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess()); - authSuccess->setValue("foo"); + authSuccess->setValue(createByteArray("foo")); CPPUNIT_ASSERT_EQUAL(std::string( "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" @@ -43,7 +44,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture { void testSerialize_EmptyMessage() { AuthSuccessSerializer testling; boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess()); - authSuccess->setValue(ByteArray()); + authSuccess->setValue(std::vector<unsigned char>()); CPPUNIT_ASSERT_EQUAL(std::string( "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" |