diff options
| author | Tim Robbings <tim.robbings@isode.com> | 2015-01-26 17:33:20 (GMT) | 
|---|---|---|
| committer | Kevin Smith <kevin.smith@isode.com> | 2015-02-17 12:17:35 (GMT) | 
| commit | 55461d1b5f97591b4ab9510896ca1bc5b5e2a71f (patch) | |
| tree | 17c79419d06c6740bb6ff04f6e17a13e7c4533a5 /Swiften/Elements/Form.h | |
| parent | 265b779d6766130afa8f2f166733dc172ba22dca (diff) | |
| download | swift-55461d1b5f97591b4ab9510896ca1bc5b5e2a71f.zip swift-55461d1b5f97591b4ab9510896ca1bc5b5e2a71f.tar.bz2  | |
Swiften XEP-0141 support
Classes to support XEP-0141 data forms layout. This includes <page/>,
<section/>, <reportedref/> and <text/> elements. The form
parser and serializer classes have also been updated to handle these new
elements, with added CPPUnit tests.
Test-information:
Tested using updated CPPUnit tests to check the parsing and serializing of
new elements. All tests complete successfully.
Change-Id: Ibeab22d2834512d06c7f656acd1ef24eea39d650
Diffstat (limited to 'Swiften/Elements/Form.h')
| -rw-r--r-- | Swiften/Elements/Form.h | 89 | 
1 files changed, 71 insertions, 18 deletions
diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h index 42fe7ed..c1d7a5b 100644 --- a/Swiften/Elements/Form.h +++ b/Swiften/Elements/Form.h @@ -1,5 +1,5 @@  /* - * Copyright (c) 2010-2014 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited.   * All rights reserved.   * See the COPYING file for more information.   */ @@ -11,6 +11,8 @@  #include <Swiften/Base/API.h>  #include <Swiften/Elements/Payload.h> +#include <Swiften/Elements/FormPage.h> +#include <Swiften/Elements/FormSection.h>  #include <Swiften/Elements/FormField.h>  #include <Swiften/JID/JID.h> @@ -30,39 +32,90 @@ namespace Swift {  		public:  			Form(Type type = FormType) : type_(type) {} -			/** Add a field to the form. -			 * @param field New field - must not be null. -			 */ -			void addField(boost::shared_ptr<FormField> field) {assert(field);  fields_.push_back(field); } -			const std::vector<boost::shared_ptr<FormField> >& getFields() const { return fields_; } -			void clearFields() { fields_.clear(); } -			void setTitle(const std::string& title) { title_ = title; } -			const std::string& getTitle() const { return title_; } +			void addPage(boost::shared_ptr<FormPage> page) { +				assert(page); +				pages_.push_back(page); +			} -			void setInstructions(const std::string& instructions) { instructions_ = instructions; } -			const std::string& getInstructions() const { return instructions_; } +			const std::vector<boost::shared_ptr<FormPage> >& getPages() const { +				return pages_; +			} -			Type getType() const { return type_; } -			void setType(Type type) { type_ = type; } +			void addField(boost::shared_ptr<FormField> field) { +				assert(field); +				fields_.push_back(field); +			} -			std::string getFormType() const; +			const std::vector<boost::shared_ptr<FormField> >& getFields() const { +				return fields_; +			} -			FormField::ref getField(const std::string& name) const; +			void clearFields() { +				fields_.clear(); +			} -			void addReportedField(FormField::ref field); -			const std::vector<FormField::ref>& getReportedFields() const; -			void clearReportedFields() { reportedFields_.clear(); } +			void addTextElement(boost::shared_ptr<FormText> text) { +				assert(text); +				textElements_.push_back(text); +			} + +			const std::vector<boost::shared_ptr<FormText> >& getTextElements() const { +				return textElements_; +			} + +			void addReportedRef(boost::shared_ptr<FormReportedRef> reportedRef) { +				assert(reportedRef); +				reportedRefs_.push_back(reportedRef); +			} + +			const std::vector<boost::shared_ptr<FormReportedRef> >& getReportedRefs() const { +				return reportedRefs_; +			} + +			void setTitle(const std::string& title) { +				title_ = title; +			} + +			const std::string& getTitle() const { +				return title_; +			} +			void setInstructions(const std::string& instructions) { +				instructions_ = instructions; +			} + +			const std::string& getInstructions() const { +				return instructions_; +			} + +			Type getType() const { +				return type_; +			} + +			void setType(Type type) { +				type_ = type; +			} + +			std::string getFormType() const; +			FormField::ref getField(const std::string& name) const;  			void addItem(const FormItem& item);  			const std::vector<FormItem>& getItems() const;  			void clearItems() { items_.clear(); }  			void clearEmptyTextFields(); +			void addReportedField(FormField::ref field); +			const std::vector<FormField::ref> & getReportedFields() const; +			void clearReportedFields() { reportedFields_.clear(); } +  		private: +			std::vector<boost::shared_ptr<FormReportedRef> >reportedRefs_; +			std::vector<boost::shared_ptr<FormText> > textElements_; +			std::vector<boost::shared_ptr<FormPage> > pages_;  			std::vector<boost::shared_ptr<FormField> > fields_;  			std::vector<boost::shared_ptr<FormField> > reportedFields_;  			std::vector<FormItem> items_; +			boost::shared_ptr<FormReportedRef> reportedRef_;  			std::string title_;  			std::string instructions_;  			Type type_;  | 
 Swift