summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-05-18 16:22:06 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-05-18 16:50:18 (GMT)
commit8472194d716e0e3b95a66bf5be45c246ee79d0af (patch)
treeb9f473e0e606b012ee5013e85d2cf5e7523b7029 /Swiften/Serializer
parentb1b3b8f88517ad8b14795cc8a6265962d2935be3 (diff)
downloadswift-8472194d716e0e3b95a66bf5be45c246ee79d0af.zip
swift-8472194d716e0e3b95a66bf5be45c246ee79d0af.tar.bz2
Propagate use of SafeByteArray down to the connection.
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/AuthChallengeSerializer.cpp2
-rw-r--r--Swiften/Serializer/AuthChallengeSerializer.h2
-rw-r--r--Swiften/Serializer/AuthFailureSerializer.h2
-rw-r--r--Swiften/Serializer/AuthRequestSerializer.cpp7
-rw-r--r--Swiften/Serializer/AuthRequestSerializer.h2
-rw-r--r--Swiften/Serializer/AuthResponseSerializer.cpp7
-rw-r--r--Swiften/Serializer/AuthResponseSerializer.h2
-rw-r--r--Swiften/Serializer/AuthSuccessSerializer.cpp2
-rw-r--r--Swiften/Serializer/AuthSuccessSerializer.h2
-rw-r--r--Swiften/Serializer/ComponentHandshakeSerializer.cpp2
-rw-r--r--Swiften/Serializer/ComponentHandshakeSerializer.h2
-rw-r--r--Swiften/Serializer/CompressFailureSerializer.h2
-rw-r--r--Swiften/Serializer/CompressRequestSerializer.cpp2
-rw-r--r--Swiften/Serializer/CompressRequestSerializer.h2
-rw-r--r--Swiften/Serializer/ElementSerializer.h4
-rw-r--r--Swiften/Serializer/EnableStreamManagementSerializer.h2
-rw-r--r--Swiften/Serializer/GenericElementSerializer.h2
-rw-r--r--Swiften/Serializer/StanzaAckRequestSerializer.h2
-rw-r--r--Swiften/Serializer/StanzaAckSerializer.h2
-rw-r--r--Swiften/Serializer/StanzaSerializer.cpp2
-rw-r--r--Swiften/Serializer/StanzaSerializer.h2
-rw-r--r--Swiften/Serializer/StartTLSFailureSerializer.h2
-rw-r--r--Swiften/Serializer/StartTLSRequestSerializer.h2
-rw-r--r--Swiften/Serializer/StreamErrorSerializer.cpp2
-rw-r--r--Swiften/Serializer/StreamErrorSerializer.h2
-rw-r--r--Swiften/Serializer/StreamFeaturesSerializer.cpp2
-rw-r--r--Swiften/Serializer/StreamFeaturesSerializer.h2
-rw-r--r--Swiften/Serializer/StreamManagementEnabledSerializer.cpp2
-rw-r--r--Swiften/Serializer/StreamManagementEnabledSerializer.h2
-rw-r--r--Swiften/Serializer/StreamManagementFailedSerializer.h2
-rw-r--r--Swiften/Serializer/StreamResumeSerializer.cpp2
-rw-r--r--Swiften/Serializer/StreamResumeSerializer.h2
-rw-r--r--Swiften/Serializer/StreamResumedSerializer.cpp2
-rw-r--r--Swiften/Serializer/StreamResumedSerializer.h2
-rw-r--r--Swiften/Serializer/TLSProceedSerializer.h2
-rw-r--r--Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp7
-rw-r--r--Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp7
-rw-r--r--Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp7
-rw-r--r--Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp7
-rw-r--r--Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp4
-rw-r--r--Swiften/Serializer/XMPPSerializer.cpp6
-rw-r--r--Swiften/Serializer/XMPPSerializer.h2
42 files changed, 64 insertions, 58 deletions
diff --git a/Swiften/Serializer/AuthChallengeSerializer.cpp b/Swiften/Serializer/AuthChallengeSerializer.cpp
index 6848ad1..445059d 100644
--- a/Swiften/Serializer/AuthChallengeSerializer.cpp
+++ b/Swiften/Serializer/AuthChallengeSerializer.cpp
@@ -15,7 +15,7 @@ namespace Swift {
AuthChallengeSerializer::AuthChallengeSerializer() {
}
-std::string AuthChallengeSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeString AuthChallengeSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<AuthChallenge> authChallenge(boost::dynamic_pointer_cast<AuthChallenge>(element));
std::string value;
boost::optional<std::vector<unsigned char> > message = authChallenge->getValue();
diff --git a/Swiften/Serializer/AuthChallengeSerializer.h b/Swiften/Serializer/AuthChallengeSerializer.h
index 5f04c4c..6254fac 100644
--- a/Swiften/Serializer/AuthChallengeSerializer.h
+++ b/Swiften/Serializer/AuthChallengeSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
AuthChallengeSerializer();
- virtual std::string serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/AuthFailureSerializer.h b/Swiften/Serializer/AuthFailureSerializer.h
index ef63697..5f01f09 100644
--- a/Swiften/Serializer/AuthFailureSerializer.h
+++ b/Swiften/Serializer/AuthFailureSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
AuthFailureSerializer() : GenericElementSerializer<AuthFailure>() {
}
- virtual std::string serialize(boost::shared_ptr<Element>) const {
+ virtual SafeString serialize(boost::shared_ptr<Element>) const {
return XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-sasl").serialize();
}
};
diff --git a/Swiften/Serializer/AuthRequestSerializer.cpp b/Swiften/Serializer/AuthRequestSerializer.cpp
index 33bdd77..e38dc85 100644
--- a/Swiften/Serializer/AuthRequestSerializer.cpp
+++ b/Swiften/Serializer/AuthRequestSerializer.cpp
@@ -8,15 +8,16 @@
#include <Swiften/Elements/AuthRequest.h>
#include <Swiften/StringCodecs/Base64.h>
-#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/SafeByteArray.h>
#include <Swiften/Base/SafeString.h>
+#include <Swiften/Base/Concat.h>
namespace Swift {
AuthRequestSerializer::AuthRequestSerializer() {
}
-std::string AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeString AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<AuthRequest> authRequest(boost::dynamic_pointer_cast<AuthRequest>(element));
SafeString value;
boost::optional<SafeByteArray> message = authRequest->getMessage();
@@ -28,7 +29,7 @@ std::string AuthRequestSerializer::serialize(boost::shared_ptr<Element> element)
value = Base64::encode(*message);
}
}
- return "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">" + value.toString() + "</auth>";
+ return concat(SafeString("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">"), value, SafeString("</auth>"));
}
}
diff --git a/Swiften/Serializer/AuthRequestSerializer.h b/Swiften/Serializer/AuthRequestSerializer.h
index d817b0c..0d812d6 100644
--- a/Swiften/Serializer/AuthRequestSerializer.h
+++ b/Swiften/Serializer/AuthRequestSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
AuthRequestSerializer();
- virtual std::string serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/AuthResponseSerializer.cpp b/Swiften/Serializer/AuthResponseSerializer.cpp
index cfdcc99..5b166b7 100644
--- a/Swiften/Serializer/AuthResponseSerializer.cpp
+++ b/Swiften/Serializer/AuthResponseSerializer.cpp
@@ -8,15 +8,16 @@
#include <Swiften/Elements/AuthResponse.h>
#include <Swiften/StringCodecs/Base64.h>
-#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/SafeByteArray.h>
#include <Swiften/Base/SafeString.h>
+#include <Swiften/Base/Concat.h>
namespace Swift {
AuthResponseSerializer::AuthResponseSerializer() {
}
-std::string AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeString AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<AuthResponse> authResponse(boost::dynamic_pointer_cast<AuthResponse>(element));
SafeString value;
boost::optional<SafeByteArray> message = authResponse->getValue();
@@ -28,7 +29,7 @@ std::string AuthResponseSerializer::serialize(boost::shared_ptr<Element> element
value = Base64::encode(*message);
}
}
- return "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value.toString() + "</response>";
+ return concat(SafeString("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"), value, SafeString("</response>"));
}
}
diff --git a/Swiften/Serializer/AuthResponseSerializer.h b/Swiften/Serializer/AuthResponseSerializer.h
index f3734c0..bb4866f 100644
--- a/Swiften/Serializer/AuthResponseSerializer.h
+++ b/Swiften/Serializer/AuthResponseSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
AuthResponseSerializer();
- virtual std::string serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/AuthSuccessSerializer.cpp b/Swiften/Serializer/AuthSuccessSerializer.cpp
index 12aab8f..b7cae47 100644
--- a/Swiften/Serializer/AuthSuccessSerializer.cpp
+++ b/Swiften/Serializer/AuthSuccessSerializer.cpp
@@ -15,7 +15,7 @@ namespace Swift {
AuthSuccessSerializer::AuthSuccessSerializer() {
}
-std::string AuthSuccessSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeString AuthSuccessSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<AuthSuccess> authSuccess(boost::dynamic_pointer_cast<AuthSuccess>(element));
std::string value;
boost::optional<std::vector<unsigned char> > message = authSuccess->getValue();
diff --git a/Swiften/Serializer/AuthSuccessSerializer.h b/Swiften/Serializer/AuthSuccessSerializer.h
index d681f5a..5516c0d 100644
--- a/Swiften/Serializer/AuthSuccessSerializer.h
+++ b/Swiften/Serializer/AuthSuccessSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
AuthSuccessSerializer();
- virtual std::string serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.cpp b/Swiften/Serializer/ComponentHandshakeSerializer.cpp
index 4eef395..c60492d 100644
--- a/Swiften/Serializer/ComponentHandshakeSerializer.cpp
+++ b/Swiften/Serializer/ComponentHandshakeSerializer.cpp
@@ -13,7 +13,7 @@ namespace Swift {
ComponentHandshakeSerializer::ComponentHandshakeSerializer() {
}
-std::string ComponentHandshakeSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeString ComponentHandshakeSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<ComponentHandshake> handshake(boost::dynamic_pointer_cast<ComponentHandshake>(element));
return "<handshake>" + handshake->getData() + "</handshake>";
}
diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.h b/Swiften/Serializer/ComponentHandshakeSerializer.h
index fe79962..2d5970e 100644
--- a/Swiften/Serializer/ComponentHandshakeSerializer.h
+++ b/Swiften/Serializer/ComponentHandshakeSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
ComponentHandshakeSerializer();
- virtual std::string serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/CompressFailureSerializer.h b/Swiften/Serializer/CompressFailureSerializer.h
index a5272df..3446670 100644
--- a/Swiften/Serializer/CompressFailureSerializer.h
+++ b/Swiften/Serializer/CompressFailureSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
CompressFailureSerializer() : GenericElementSerializer<CompressFailure>() {
}
- virtual std::string serialize(boost::shared_ptr<Element>) const {
+ virtual SafeString serialize(boost::shared_ptr<Element>) const {
return XMLElement("failure", "http://jabber.org/protocol/compress").serialize();
}
};
diff --git a/Swiften/Serializer/CompressRequestSerializer.cpp b/Swiften/Serializer/CompressRequestSerializer.cpp
index 0c7a4ee..8dc4e50 100644
--- a/Swiften/Serializer/CompressRequestSerializer.cpp
+++ b/Swiften/Serializer/CompressRequestSerializer.cpp
@@ -13,7 +13,7 @@ namespace Swift {
CompressRequestSerializer::CompressRequestSerializer() {
}
-std::string CompressRequestSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeString CompressRequestSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<CompressRequest> compressRequest(boost::dynamic_pointer_cast<CompressRequest>(element));
return "<compress xmlns='http://jabber.org/protocol/compress'><method>" + compressRequest->getMethod() + "</method></compress>";
}
diff --git a/Swiften/Serializer/CompressRequestSerializer.h b/Swiften/Serializer/CompressRequestSerializer.h
index 7cbca68..cd06e1a 100644
--- a/Swiften/Serializer/CompressRequestSerializer.h
+++ b/Swiften/Serializer/CompressRequestSerializer.h
@@ -15,7 +15,7 @@ namespace Swift {
public:
CompressRequestSerializer();
- virtual std::string serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const;
virtual bool canSerialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/ElementSerializer.h b/Swiften/Serializer/ElementSerializer.h
index ed9c781..7109f96 100644
--- a/Swiften/Serializer/ElementSerializer.h
+++ b/Swiften/Serializer/ElementSerializer.h
@@ -8,7 +8,7 @@
#include <boost/shared_ptr.hpp>
-#include <string>
+#include <Swiften/Base/SafeString.h>
#include <Swiften/Elements/Element.h>
namespace Swift {
@@ -16,7 +16,7 @@ namespace Swift {
public:
virtual ~ElementSerializer();
- virtual std::string serialize(boost::shared_ptr<Element> element) const = 0;
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const = 0;
virtual bool canSerialize(boost::shared_ptr<Element> element) const = 0;
};
}
diff --git a/Swiften/Serializer/EnableStreamManagementSerializer.h b/Swiften/Serializer/EnableStreamManagementSerializer.h
index dc9710e..35df0c1 100644
--- a/Swiften/Serializer/EnableStreamManagementSerializer.h
+++ b/Swiften/Serializer/EnableStreamManagementSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
EnableStreamManagementSerializer() : GenericElementSerializer<EnableStreamManagement>() {
}
- virtual std::string serialize(boost::shared_ptr<Element>) const {
+ virtual SafeString serialize(boost::shared_ptr<Element>) const {
return XMLElement("enable", "urn:xmpp:sm:2").serialize();
}
};
diff --git a/Swiften/Serializer/GenericElementSerializer.h b/Swiften/Serializer/GenericElementSerializer.h
index 903c205..c8abdf3 100644
--- a/Swiften/Serializer/GenericElementSerializer.h
+++ b/Swiften/Serializer/GenericElementSerializer.h
@@ -14,7 +14,7 @@ namespace Swift {
template<typename T>
class GenericElementSerializer : public ElementSerializer {
public:
- virtual std::string serialize(boost::shared_ptr<Element> element) const = 0;
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const = 0;
virtual bool canSerialize(boost::shared_ptr<Element> element) const {
return boost::dynamic_pointer_cast<T>(element);
diff --git a/Swiften/Serializer/StanzaAckRequestSerializer.h b/Swiften/Serializer/StanzaAckRequestSerializer.h
index 96598e9..dbcb27a 100644
--- a/Swiften/Serializer/StanzaAckRequestSerializer.h
+++ b/Swiften/Serializer/StanzaAckRequestSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
StanzaAckRequestSerializer() : GenericElementSerializer<StanzaAckRequest>() {
}
- virtual std::string serialize(boost::shared_ptr<Element>) const {
+ virtual SafeString serialize(boost::shared_ptr<Element>) const {
return XMLElement("r", "urn:xmpp:sm:2").serialize();
}
};
diff --git a/Swiften/Serializer/StanzaAckSerializer.h b/Swiften/Serializer/StanzaAckSerializer.h
index b417789..91bbb8d 100644
--- a/Swiften/Serializer/StanzaAckSerializer.h
+++ b/Swiften/Serializer/StanzaAckSerializer.h
@@ -19,7 +19,7 @@ namespace Swift {
StanzaAckSerializer() : GenericElementSerializer<StanzaAck>() {
}
- virtual std::string serialize(boost::shared_ptr<Element> element) const {
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const {
StanzaAck::ref stanzaAck(boost::dynamic_pointer_cast<StanzaAck>(element));
assert(stanzaAck->isValid());
XMLElement result("a", "urn:xmpp:sm:2");
diff --git a/Swiften/Serializer/StanzaSerializer.cpp b/Swiften/Serializer/StanzaSerializer.cpp
index ab87416..c34ecae 100644
--- a/Swiften/Serializer/StanzaSerializer.cpp
+++ b/Swiften/Serializer/StanzaSerializer.cpp
@@ -22,7 +22,7 @@ namespace Swift {
StanzaSerializer::StanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers) : tag_(tag), payloadSerializers_(payloadSerializers) {
}
-std::string StanzaSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeString StanzaSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<Stanza> stanza(boost::dynamic_pointer_cast<Stanza>(element));
XMLElement stanzaElement(tag_);
diff --git a/Swiften/Serializer/StanzaSerializer.h b/Swiften/Serializer/StanzaSerializer.h
index e273651..5726562 100644
--- a/Swiften/Serializer/StanzaSerializer.h
+++ b/Swiften/Serializer/StanzaSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
public:
StanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers);
- virtual std::string serialize(boost::shared_ptr<Element>) const;
+ virtual SafeString serialize(boost::shared_ptr<Element>) const;
virtual void setStanzaSpecificAttributes(boost::shared_ptr<Element>, XMLElement&) const = 0;
private:
diff --git a/Swiften/Serializer/StartTLSFailureSerializer.h b/Swiften/Serializer/StartTLSFailureSerializer.h
index 1844bca..6f3f24c 100644
--- a/Swiften/Serializer/StartTLSFailureSerializer.h
+++ b/Swiften/Serializer/StartTLSFailureSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
StartTLSFailureSerializer() : GenericElementSerializer<StartTLSFailure>() {
}
- virtual std::string serialize(boost::shared_ptr<Element>) const {
+ virtual SafeString serialize(boost::shared_ptr<Element>) const {
return XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-tls").serialize();
}
};
diff --git a/Swiften/Serializer/StartTLSRequestSerializer.h b/Swiften/Serializer/StartTLSRequestSerializer.h
index 1e1d54c..d5fa046 100644
--- a/Swiften/Serializer/StartTLSRequestSerializer.h
+++ b/Swiften/Serializer/StartTLSRequestSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
StartTLSRequestSerializer() : GenericElementSerializer<StartTLSRequest>() {
}
- virtual std::string serialize(boost::shared_ptr<Element>) const {
+ virtual SafeString serialize(boost::shared_ptr<Element>) const {
return XMLElement("starttls", "urn:ietf:params:xml:ns:xmpp-tls").serialize();
}
};
diff --git a/Swiften/Serializer/StreamErrorSerializer.cpp b/Swiften/Serializer/StreamErrorSerializer.cpp
index 11f8a30..e95ee37 100644
--- a/Swiften/Serializer/StreamErrorSerializer.cpp
+++ b/Swiften/Serializer/StreamErrorSerializer.cpp
@@ -15,7 +15,7 @@ namespace Swift {
StreamErrorSerializer::StreamErrorSerializer() : GenericElementSerializer<StreamError>() {
}
-std::string StreamErrorSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeString StreamErrorSerializer::serialize(boost::shared_ptr<Element> element) const {
StreamError::ref error = boost::dynamic_pointer_cast<StreamError>(element);
XMLElement errorElement("error", "http://etherx.jabber.org/streams");
diff --git a/Swiften/Serializer/StreamErrorSerializer.h b/Swiften/Serializer/StreamErrorSerializer.h
index 9d4f60c..2115324 100644
--- a/Swiften/Serializer/StreamErrorSerializer.h
+++ b/Swiften/Serializer/StreamErrorSerializer.h
@@ -14,6 +14,6 @@ namespace Swift {
public:
StreamErrorSerializer();
- virtual std::string serialize(boost::shared_ptr<Element> error) const;
+ virtual SafeString serialize(boost::shared_ptr<Element> error) const;
};
}
diff --git a/Swiften/Serializer/StreamFeaturesSerializer.cpp b/Swiften/Serializer/StreamFeaturesSerializer.cpp
index c42d262..3c500e3 100644
--- a/Swiften/Serializer/StreamFeaturesSerializer.cpp
+++ b/Swiften/Serializer/StreamFeaturesSerializer.cpp
@@ -17,7 +17,7 @@ namespace Swift {
StreamFeaturesSerializer::StreamFeaturesSerializer() {
}
-std::string StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeString StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<StreamFeatures> streamFeatures(boost::dynamic_pointer_cast<StreamFeatures>(element));
XMLElement streamFeaturesElement("stream:features");
diff --git a/Swiften/Serializer/StreamFeaturesSerializer.h b/Swiften/Serializer/StreamFeaturesSerializer.h
index fafc92b..0e8a6d2 100644
--- a/Swiften/Serializer/StreamFeaturesSerializer.h
+++ b/Swiften/Serializer/StreamFeaturesSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
StreamFeaturesSerializer();
- virtual std::string serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeString serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/StreamManagementEnabledSerializer.cpp b/Swiften/Serializer/StreamManagementEnabledSerializer.cpp
index 02cf948..c19b86f 100644
--- a/Swiften/Serializer/StreamManagementEnabledSerializer.cpp
+++ b/Swiften/Serializer/StreamManagementEnabledSerializer.cpp
@@ -16,7 +16,7 @@ using namespace Swift;
StreamManagementEnabledSerializer::StreamManagementEnabledSerializer() : GenericElementSerializer<StreamManagementEnabled>() {
}
-std::string StreamManagementEnabledSerializer::serialize(boost::shared_ptr<Element> el) const {
+SafeString StreamManagementEnabledSerializer::serialize(boost::shared_ptr<Element> el) const {
boost::shared_ptr<StreamManagementEnabled> e(boost::dynamic_pointer_cast<StreamManagementEnabled>(el));
XMLElement element("enabled", "urn:xmpp:sm:2");
if (!e->getResumeID().empty()) {
diff --git a/Swiften/Serializer/StreamManagementEnabledSerializer.h b/Swiften/Serializer/StreamManagementEnabledSerializer.h
index 6a27457..0ea976a 100644
--- a/Swiften/Serializer/StreamManagementEnabledSerializer.h
+++ b/Swiften/Serializer/StreamManagementEnabledSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
StreamManagementEnabledSerializer();
- virtual std::string serialize(boost::shared_ptr<Element>) const;
+ virtual SafeString serialize(boost::shared_ptr<Element>) const;
};
}
diff --git a/Swiften/Serializer/StreamManagementFailedSerializer.h b/Swiften/Serializer/StreamManagementFailedSerializer.h
index 731cf4b..034366e 100644
--- a/Swiften/Serializer/StreamManagementFailedSerializer.h
+++ b/Swiften/Serializer/StreamManagementFailedSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
StreamManagementFailedSerializer() : GenericElementSerializer<StreamManagementFailed>() {
}
- virtual std::string serialize(boost::shared_ptr<Element>) const {
+ virtual SafeString serialize(boost::shared_ptr<Element>) const {
return XMLElement("failed", "urn:xmpp:sm:2").serialize();
}
};
diff --git a/Swiften/Serializer/StreamResumeSerializer.cpp b/Swiften/Serializer/StreamResumeSerializer.cpp
index a7a2e3b..01877a9 100644
--- a/Swiften/Serializer/StreamResumeSerializer.cpp
+++ b/Swiften/Serializer/StreamResumeSerializer.cpp
@@ -17,7 +17,7 @@ using namespace Swift;
StreamResumeSerializer::StreamResumeSerializer() : GenericElementSerializer<StreamResume>() {
}
-std::string StreamResumeSerializer::serialize(boost::shared_ptr<Element> el) const {
+SafeString StreamResumeSerializer::serialize(boost::shared_ptr<Element> el) const {
boost::shared_ptr<StreamResume> e(boost::dynamic_pointer_cast<StreamResume>(el));
XMLElement element("resume", "urn:xmpp:sm:2");
element.setAttribute("previd", e->getResumeID());
diff --git a/Swiften/Serializer/StreamResumeSerializer.h b/Swiften/Serializer/StreamResumeSerializer.h
index 6ea7365..965485f 100644
--- a/Swiften/Serializer/StreamResumeSerializer.h
+++ b/Swiften/Serializer/StreamResumeSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
StreamResumeSerializer();
- virtual std::string serialize(boost::shared_ptr<Element>) const;
+ virtual SafeString serialize(boost::shared_ptr<Element>) const;
};
}
diff --git a/Swiften/Serializer/StreamResumedSerializer.cpp b/Swiften/Serializer/StreamResumedSerializer.cpp
index d3beafb..06006b8 100644
--- a/Swiften/Serializer/StreamResumedSerializer.cpp
+++ b/Swiften/Serializer/StreamResumedSerializer.cpp
@@ -17,7 +17,7 @@ using namespace Swift;
StreamResumedSerializer::StreamResumedSerializer() : GenericElementSerializer<StreamResumed>() {
}
-std::string StreamResumedSerializer::serialize(boost::shared_ptr<Element> el) const {
+SafeString StreamResumedSerializer::serialize(boost::shared_ptr<Element> el) const {
boost::shared_ptr<StreamResumed> e(boost::dynamic_pointer_cast<StreamResumed>(el));
XMLElement element("resumed", "urn:xmpp:sm:2");
element.setAttribute("previd", e->getResumeID());
diff --git a/Swiften/Serializer/StreamResumedSerializer.h b/Swiften/Serializer/StreamResumedSerializer.h
index 38d846f..24d5f86 100644
--- a/Swiften/Serializer/StreamResumedSerializer.h
+++ b/Swiften/Serializer/StreamResumedSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
StreamResumedSerializer();
- virtual std::string serialize(boost::shared_ptr<Element>) const;
+ virtual SafeString serialize(boost::shared_ptr<Element>) const;
};
}
diff --git a/Swiften/Serializer/TLSProceedSerializer.h b/Swiften/Serializer/TLSProceedSerializer.h
index d6ca99f..95ee211 100644
--- a/Swiften/Serializer/TLSProceedSerializer.h
+++ b/Swiften/Serializer/TLSProceedSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
TLSProceedSerializer() : GenericElementSerializer<TLSProceed>() {
}
- virtual std::string serialize(boost::shared_ptr<Element>) const {
+ virtual SafeString serialize(boost::shared_ptr<Element>) const {
return XMLElement("proceed", "urn:ietf:params:xml:ns:xmpp-tls").serialize();
}
};
diff --git a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
index a81620d..2dcadcd 100644
--- a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
@@ -10,6 +10,7 @@
#include <Swiften/Serializer/AuthChallengeSerializer.h>
#include <Swiften/Elements/AuthChallenge.h>
#include <Swiften/Base/ByteArray.h>
+#include <QA/Checker/IO.h>
using namespace Swift;
@@ -26,7 +27,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
authChallenge->setValue(createByteArray("foo"));
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"Zm9v"
"</challenge>"), testling.serialize(authChallenge));
@@ -36,7 +37,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture {
AuthChallengeSerializer testling;
boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"</challenge>"), testling.serialize(authChallenge));
}
@@ -46,7 +47,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
authChallenge->setValue(std::vector<unsigned char>());
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"="
"</challenge>"), testling.serialize(authChallenge));
diff --git a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
index d5c0a09..7d7b1be 100644
--- a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
@@ -10,6 +10,7 @@
#include <Swiften/Serializer/AuthRequestSerializer.h>
#include <Swiften/Elements/AuthRequest.h>
#include <Swiften/Base/ByteArray.h>
+#include <QA/Checker/IO.h>
using namespace Swift;
@@ -26,7 +27,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
authRequest->setMessage(createSafeByteArray("foo"));
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
"Zm9v"
"</auth>"), testling.serialize(authRequest));
@@ -36,7 +37,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture {
AuthRequestSerializer testling;
boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
"</auth>"), testling.serialize(authRequest));
}
@@ -46,7 +47,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
authRequest->setMessage(SafeByteArray());
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
"="
"</auth>"), testling.serialize(authRequest));
diff --git a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
index 8887b27..3be1185 100644
--- a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
@@ -10,6 +10,7 @@
#include <Swiften/Serializer/AuthResponseSerializer.h>
#include <Swiften/Elements/AuthResponse.h>
#include <Swiften/Base/ByteArray.h>
+#include <QA/Checker/IO.h>
using namespace Swift;
@@ -26,7 +27,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
authResponse->setValue(createSafeByteArray("foo"));
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"Zm9v"
"</response>"), testling.serialize(authResponse));
@@ -36,7 +37,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture {
AuthResponseSerializer testling;
boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"</response>"), testling.serialize(authResponse));
}
@@ -46,7 +47,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
authResponse->setValue(SafeByteArray());
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"="
"</response>"), testling.serialize(authResponse));
diff --git a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
index a9f6de2..b8646c0 100644
--- a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
@@ -10,6 +10,7 @@
#include <Swiften/Serializer/AuthSuccessSerializer.h>
#include <Swiften/Elements/AuthSuccess.h>
#include <Swiften/Base/ByteArray.h>
+#include <QA/Checker/IO.h>
using namespace Swift;
@@ -26,7 +27,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
authSuccess->setValue(createByteArray("foo"));
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"Zm9v"
"</success>"), testling.serialize(authSuccess));
@@ -36,7 +37,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture {
AuthSuccessSerializer testling;
boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"</success>"), testling.serialize(authSuccess));
}
@@ -46,7 +47,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
authSuccess->setValue(std::vector<unsigned char>());
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"="
"</success>"), testling.serialize(authSuccess));
diff --git a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
index 5b9412b..b30a774 100644
--- a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
@@ -9,6 +9,8 @@
#include <Swiften/Serializer/StreamFeaturesSerializer.h>
#include <Swiften/Elements/StreamFeatures.h>
+#include <QA/Checker/IO.h>
+
using namespace Swift;
@@ -34,7 +36,7 @@ class StreamFeaturesSerializerTest : public CppUnit::TestFixture
streamFeatures->setHasStreamManagement();
streamFeatures->setHasRosterVersioning();
- CPPUNIT_ASSERT_EQUAL(std::string(
+ CPPUNIT_ASSERT_EQUAL(SafeString(
"<stream:features>"
"<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
"<compression xmlns=\"http://jabber.org/features/compress\">"
diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp
index 19a30ce..054175d 100644
--- a/Swiften/Serializer/XMPPSerializer.cpp
+++ b/Swiften/Serializer/XMPPSerializer.cpp
@@ -83,10 +83,8 @@ std::string XMPPSerializer::serializeHeader(const ProtocolHeader& header) const
return result;
}
-std::string XMPPSerializer::serializeElement(boost::shared_ptr<Element> element) const {
- std::vector< boost::shared_ptr<ElementSerializer> >::const_iterator i = std::find_if(
- serializers_.begin(), serializers_.end(),
- boost::bind(&ElementSerializer::canSerialize, _1, element));
+SafeString XMPPSerializer::serializeElement(boost::shared_ptr<Element> element) const {
+ std::vector< boost::shared_ptr<ElementSerializer> >::const_iterator i = std::find_if(serializers_.begin(), serializers_.end(), boost::bind(&ElementSerializer::canSerialize, _1, element));
if (i != serializers_.end()) {
return (*i)->serialize(element);
}
diff --git a/Swiften/Serializer/XMPPSerializer.h b/Swiften/Serializer/XMPPSerializer.h
index 003d33b..58274a8 100644
--- a/Swiften/Serializer/XMPPSerializer.h
+++ b/Swiften/Serializer/XMPPSerializer.h
@@ -24,7 +24,7 @@ namespace Swift {
XMPPSerializer(PayloadSerializerCollection*, StreamType type);
std::string serializeHeader(const ProtocolHeader&) const;
- std::string serializeElement(boost::shared_ptr<Element> stanza) const;
+ SafeString serializeElement(boost::shared_ptr<Element> stanza) const;
std::string serializeFooter() const;
private: