From 2c5ef44b56d9c45254ea331a53fb6d8fe6efe7d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Tue, 16 Nov 2010 20:32:48 +0100
Subject: Added In-band-registration unsubscribe support to Swiften.


diff --git a/Swiften/Elements/InBandRegistrationPayload.h b/Swiften/Elements/InBandRegistrationPayload.h
index 6dafa04..1a293ba 100644
--- a/Swiften/Elements/InBandRegistrationPayload.h
+++ b/Swiften/Elements/InBandRegistrationPayload.h
@@ -18,7 +18,7 @@ namespace Swift {
 		public:
 			typedef boost::shared_ptr<InBandRegistrationPayload> ref;
 
-			InBandRegistrationPayload() : registered(false) {}
+			InBandRegistrationPayload() : registered(false), remove(false) {}
 
 			Form::ref getForm() const { return form; }
 			void setForm(Form::ref f) { form = f; }
@@ -31,6 +31,14 @@ namespace Swift {
 				registered = b;
 			}
 
+			bool isRemove() const {
+				return remove;
+			}
+
+			void setRemove(bool b) {
+				remove = b;
+			}
+
 			const boost::optional<String>& getInstructions() const {
 				return instructions;
 			}
@@ -175,10 +183,10 @@ namespace Swift {
 				this->key = v;
 			}
 
-
 		private:
 			Form::ref form;
 			bool registered;
+			bool remove;
 			boost::optional<String> instructions;
 			boost::optional<String> username;
 			boost::optional<String> nick;
diff --git a/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.cpp b/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.cpp
index 0e1b593..5a9b3d8 100644
--- a/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.cpp
+++ b/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.cpp
@@ -56,6 +56,9 @@ void InBandRegistrationPayloadParser::handleEndElement(const String& element, co
 		else if (element == "registered") {
 			getPayloadInternal()->setRegistered(true);
 		}
+		else if (element == "remove") {
+			getPayloadInternal()->setRemove(true);
+		}
 		else if (element == "instructions") {
 			getPayloadInternal()->setInstructions(currentText);
 		}
diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
index 8e8bcf2..5729df6 100644
--- a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
@@ -25,6 +25,10 @@ String InBandRegistrationPayloadSerializer::serializePayload(boost::shared_ptr<I
 		registerElement.addNode(XMLElement::ref(new XMLElement("registered")));
 	}
 
+	if (registration->isRemove()) {
+		registerElement.addNode(XMLElement::ref(new XMLElement("remove")));
+	}
+
 	if (registration->getInstructions()) {
 		registerElement.addNode(XMLElement::ref(new XMLElement("instructions", "", *registration->getInstructions())));
 	}
-- 
cgit v0.10.2-6-g49f6