summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-08-08 18:41:53 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-08-08 18:41:53 (GMT)
commit19df82042f44c201e5a2821b4fa35465e33a1c90 (patch)
tree1746bddfa31ce2a6488ef5186036a049a255c9da /Swiften/Elements/Form.h
parent4a5a0977f661bf5c7c34ee7aa48b35073a682203 (diff)
downloadswift-contrib-19df82042f44c201e5a2821b4fa35465e33a1c90.zip
swift-contrib-19df82042f44c201e5a2821b4fa35465e33a1c90.tar.bz2
Added XEP-0004 data forms parsing & serializing.
Diffstat (limited to 'Swiften/Elements/Form.h')
-rw-r--r--Swiften/Elements/Form.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h
new file mode 100644
index 0000000..ed77d2b
--- /dev/null
+++ b/Swiften/Elements/Form.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <vector>
+
+#include "Swiften/Elements/Payload.h"
+#include "Swiften/Elements/FormField.h"
+#include "Swiften/Base/String.h"
+#include "Swiften/JID/JID.h"
+
+namespace Swift {
+ /**
+ * XEP-0004 Data form.
+ * For the relevant Fields, the parsers and serialisers protect the API user against
+ * the strange multi-value instead of newline thing by transforming them.
+ */
+ class Form : public Payload {
+ public:
+ enum Type { FormType, SubmitType, CancelType, ResultType };
+
+ public:
+ Form(Type type = FormType) : type_(type) {}
+
+ void addField(boost::shared_ptr<FormField> field) { fields_.push_back(field); }
+ const std::vector<boost::shared_ptr<FormField> >& getFields() const { return fields_; }
+ void setTitle(const String& title) { title_ = title; }
+ const String& getTitle() { return title_; }
+
+ void setInstructions(const String& instructions) { instructions_ = instructions; }
+ const String& getInstructions() { return instructions_; }
+
+ Type getType() { return type_; }
+ void setType(Type type) { type_ = type; }
+
+ private:
+ std::vector<boost::shared_ptr<FormField> > fields_;
+ String title_;
+ String instructions_;
+ Type type_;
+ };
+}