summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-11-16 19:32:48 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-11-16 19:32:48 (GMT)
commit2c5ef44b56d9c45254ea331a53fb6d8fe6efe7d1 (patch)
treee6e63729cbde4a894627a381af8dd6c4f7557a78
parent999f19158672bd6c91fa274a9f8e968b84f8a931 (diff)
downloadswift-contrib-2c5ef44b56d9c45254ea331a53fb6d8fe6efe7d1.zip
swift-contrib-2c5ef44b56d9c45254ea331a53fb6d8fe6efe7d1.tar.bz2
Added In-band-registration unsubscribe support to Swiften.
-rw-r--r--Swiften/Elements/InBandRegistrationPayload.h12
-rw-r--r--Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.cpp3
-rw-r--r--Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp4
3 files changed, 17 insertions, 2 deletions
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())));
}