diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-06-03 18:11:02 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-06-03 18:11:02 (GMT) |
commit | c3fa606c7ac060c4929e7082e0e24531b093112f (patch) | |
tree | 394cf72c0b43fa706319592dfdb1438335b6116a /Swiften/Serializer/AuthResponseSerializer.cpp | |
parent | 8406d818fcb2a511b1e4264a10fd9069ec020d72 (diff) | |
download | swift-contrib-c3fa606c7ac060c4929e7082e0e24531b093112f.zip swift-contrib-c3fa606c7ac060c4929e7082e0e24531b093112f.tar.bz2 |
Distinguish an empty SASL message from no SASL message.
Diffstat (limited to 'Swiften/Serializer/AuthResponseSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/AuthResponseSerializer.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Swiften/Serializer/AuthResponseSerializer.cpp b/Swiften/Serializer/AuthResponseSerializer.cpp index ffa3963..d2d5616 100644 --- a/Swiften/Serializer/AuthResponseSerializer.cpp +++ b/Swiften/Serializer/AuthResponseSerializer.cpp @@ -14,9 +14,18 @@ namespace Swift { AuthResponseSerializer::AuthResponseSerializer() { } -String AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const { - boost::shared_ptr<AuthResponse> authRequest(boost::dynamic_pointer_cast<AuthResponse>(element)); - String value = (authRequest->getValue().isEmpty() ? "=" : Base64::encode(authRequest->getValue())); +String AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const { + boost::shared_ptr<AuthResponse> authResponse(boost::dynamic_pointer_cast<AuthResponse>(element)); + String value; + boost::optional<ByteArray> message = authResponse->getValue(); + if (message) { + if ((*message).isEmpty()) { + value = "="; + } + else { + value = Base64::encode(*message); + } + } return "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</response>"; } |