summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp')
-rw-r--r--Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp108
1 files changed, 108 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
new file mode 100644
index 0000000..8e8bcf2
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h"
+
+#include <boost/shared_ptr.hpp>
+
+#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 {
+
+InBandRegistrationPayloadSerializer::InBandRegistrationPayloadSerializer() {
+}
+
+String InBandRegistrationPayloadSerializer::serializePayload(boost::shared_ptr<InBandRegistrationPayload> registration) const {
+ XMLElement registerElement("query", "jabber:iq:register");
+
+ if (registration->isRegistered()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("registered")));
+ }
+
+ if (registration->getInstructions()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("instructions", "", *registration->getInstructions())));
+ }
+
+
+ if (registration->getUsername()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("username", "", *registration->getUsername())));
+ }
+
+ if (registration->getNick()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("nick", "", *registration->getNick())));
+ }
+
+ if (registration->getPassword()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("password", "", *registration->getPassword())));
+ }
+
+ if (registration->getName()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("name", "", *registration->getName())));
+ }
+
+ if (registration->getFirst()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("first", "", *registration->getFirst())));
+ }
+
+ if (registration->getLast()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("last", "", *registration->getLast())));
+ }
+
+ if (registration->getEMail()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("email", "", *registration->getEMail())));
+ }
+
+ if (registration->getAddress()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("address", "", *registration->getAddress())));
+ }
+
+ if (registration->getCity()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("city", "", *registration->getCity())));
+ }
+
+ if (registration->getState()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("state", "", *registration->getState())));
+ }
+
+ if (registration->getZip()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("zip", "", *registration->getZip())));
+ }
+
+ if (registration->getPhone()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("phone", "", *registration->getPhone())));
+ }
+
+ if (registration->getURL()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("url", "", *registration->getURL())));
+ }
+
+ if (registration->getDate()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("date", "", *registration->getDate())));
+ }
+
+ if (registration->getMisc()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("misc", "", *registration->getMisc())));
+ }
+
+ if (registration->getText()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("text", "", *registration->getText())));
+ }
+
+ if (registration->getKey()) {
+ registerElement.addNode(XMLElement::ref(new XMLElement("key", "", *registration->getKey())));
+ }
+
+ if (Form::ref form = registration->getForm()) {
+ registerElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(form))));
+ }
+
+ return registerElement.serialize();
+}
+
+}