summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp16
-rw-r--r--Swiften/Serializer/XML/XMLElement.h7
-rw-r--r--Swiften/Serializer/XML/XMLTextNode.h3
3 files changed, 20 insertions, 6 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
index 19a6b6e..8975818 100644
--- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
@@ -10,6 +10,7 @@
#include "Swiften/Serializer/XML/XMLElement.h"
#include "Swiften/Serializer/XML/XMLTextNode.h"
+#include "Swiften/StringCodecs/Hexify.h"
namespace Swift {
@@ -49,7 +50,20 @@ String VCardSerializer::serializePayload(boost::shared_ptr<VCard> vcard) const
nickElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getNickname())));
queryElement.addNode(nickElement);
}
- // TODO
+ if (!vcard->getPhoto().isEmpty() || !vcard->getPhotoType().isEmpty()) {
+ XMLElement::ref photoElement(new XMLElement("PHOTO"));
+ if (!vcard->getPhotoType().isEmpty()) {
+ XMLElement::ref typeElement(new XMLElement("TYPE"));
+ typeElement->addNode(XMLTextNode::ref(new XMLTextNode(vcard->getPhotoType())));
+ photoElement->addNode(typeElement);
+ }
+ if (!vcard->getPhoto().isEmpty()) {
+ XMLElement::ref binvalElement(new XMLElement("BINVAL"));
+ binvalElement->addNode(XMLTextNode::ref(new XMLTextNode(Hexify::hexify(vcard->getPhoto()))));
+ photoElement->addNode(binvalElement);
+ }
+ queryElement.addNode(photoElement);
+ }
return queryElement.serialize();
}
diff --git a/Swiften/Serializer/XML/XMLElement.h b/Swiften/Serializer/XML/XMLElement.h
index 373a939..8447ab1 100644
--- a/Swiften/Serializer/XML/XMLElement.h
+++ b/Swiften/Serializer/XML/XMLElement.h
@@ -4,18 +4,18 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_XMLElement_H
-#define SWIFTEN_XMLElement_H
+#pragma once
#include <boost/shared_ptr.hpp>
#include <vector>
#include <map>
#include "Swiften/Base/String.h"
+#include "Swiften/Base/Shared.h"
#include "Swiften/Serializer/XML/XMLNode.h"
namespace Swift {
- class XMLElement : public XMLNode {
+ class XMLElement : public XMLNode, public Shared<XMLElement> {
public:
XMLElement(const String& tag, const String& xmlns = "");
@@ -30,4 +30,3 @@ namespace Swift {
std::vector< boost::shared_ptr<XMLNode> > childNodes_;
};
}
-#endif
diff --git a/Swiften/Serializer/XML/XMLTextNode.h b/Swiften/Serializer/XML/XMLTextNode.h
index c1d13ef..e158916 100644
--- a/Swiften/Serializer/XML/XMLTextNode.h
+++ b/Swiften/Serializer/XML/XMLTextNode.h
@@ -7,9 +7,10 @@
#pragma once
#include "Swiften/Serializer/XML/XMLNode.h"
+#include "Swiften/Base/Shared.h"
namespace Swift {
- class XMLTextNode : public XMLNode {
+ class XMLTextNode : public XMLNode, public Shared<XMLTextNode> {
public:
typedef boost::shared_ptr<XMLTextNode> ref;