diff options
-rw-r--r-- | Swiften/Elements/FormPage.cpp | 14 | ||||
-rw-r--r-- | Swiften/Elements/FormPage.h | 10 | ||||
-rw-r--r-- | Swiften/Elements/FormSection.cpp | 8 | ||||
-rw-r--r-- | Swiften/Elements/FormSection.h | 8 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/FormParser.cpp | 15 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/FormParser.h | 1 | ||||
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/FormSerializer.cpp | 2 |
7 files changed, 25 insertions, 33 deletions
diff --git a/Swiften/Elements/FormPage.cpp b/Swiften/Elements/FormPage.cpp index 1a9bd32..db7979f 100644 --- a/Swiften/Elements/FormPage.cpp +++ b/Swiften/Elements/FormPage.cpp @@ -7,7 +7,7 @@ namespace Swift { -FormPage::FormPage() : xmlns_("http://jabber.org/protocol/xdata-layout") { +FormPage::FormPage() { } FormPage::~FormPage() { @@ -21,11 +21,7 @@ const std::string& FormPage::getLabel() const { return label_; } -const std::string& FormPage::getXMLNS() const { - return xmlns_; -} - -void FormPage::addChildSection(boost::shared_ptr<FormSection>& section) { +void FormPage::addChildSection(boost::shared_ptr<FormSection> section) { childSections_.push_back(section); } @@ -33,7 +29,7 @@ const std::vector<boost::shared_ptr<FormSection> >& FormPage::getChildSections() return childSections_; } -void FormPage::addTextElement(boost::shared_ptr<FormText>& textElement) { +void FormPage::addTextElement(boost::shared_ptr<FormText> textElement) { textElements_.push_back(textElement); } @@ -41,7 +37,7 @@ const std::vector<boost::shared_ptr<FormText> >& FormPage::getTextElements() con return textElements_; } -void FormPage::addReportedRef(boost::shared_ptr<FormReportedRef>& reportedRef) { +void FormPage::addReportedRef(boost::shared_ptr<FormReportedRef> reportedRef) { reportedRefs_.push_back(reportedRef); } @@ -49,7 +45,7 @@ const std::vector<boost::shared_ptr<FormReportedRef> >& FormPage::getReportedRef return reportedRefs_; } -void FormPage::addField(boost::shared_ptr<FormField>& field) { +void FormPage::addField(boost::shared_ptr<FormField> field) { fields_.push_back(field); } diff --git a/Swiften/Elements/FormPage.h b/Swiften/Elements/FormPage.h index e5ecda2..0e66549 100644 --- a/Swiften/Elements/FormPage.h +++ b/Swiften/Elements/FormPage.h @@ -23,20 +23,18 @@ namespace Swift { ~FormPage(); void setLabel(const std::string& label); const std::string& getLabel() const; - const std::string& getXMLNS() const; - void addChildSection(boost::shared_ptr<FormSection>& section); + void addChildSection(boost::shared_ptr<FormSection> section); const std::vector<boost::shared_ptr<FormSection> >& getChildSections() const; - void addTextElement(boost::shared_ptr<FormText>& textElement); + void addTextElement(boost::shared_ptr<FormText> textElement); const std::vector<boost::shared_ptr<FormText> >& getTextElements() const; - void addReportedRef(boost::shared_ptr<FormReportedRef>& reportedRef); + void addReportedRef(boost::shared_ptr<FormReportedRef> reportedRef); const std::vector<boost::shared_ptr<FormReportedRef> >& getReportedRefs() const; - void addField(boost::shared_ptr<FormField>& field); + void addField(boost::shared_ptr<FormField> field); const std::vector<boost::shared_ptr<FormField> >& getFields() const; void addFieldRef(std::string ref); const std::vector<std::string> getFieldRefs() const; private: - std::string xmlns_; std::string label_; std::vector<boost::shared_ptr<FormText> > textElements_; std::vector<boost::shared_ptr<FormSection> > childSections_; diff --git a/Swiften/Elements/FormSection.cpp b/Swiften/Elements/FormSection.cpp index 46005a0..7b254df 100644 --- a/Swiften/Elements/FormSection.cpp +++ b/Swiften/Elements/FormSection.cpp @@ -21,7 +21,7 @@ const std::string& FormSection::getLabel() const { return label_; } -void FormSection::addTextElement(boost::shared_ptr<FormText>& textElement) { +void FormSection::addTextElement(boost::shared_ptr<FormText> textElement) { textElements_.push_back(textElement); } @@ -29,7 +29,7 @@ const std::vector<boost::shared_ptr<FormText> >& FormSection::getTextElements() return textElements_; } -void FormSection::addReportedRef(boost::shared_ptr<FormReportedRef>& reportedRef) { +void FormSection::addReportedRef(boost::shared_ptr<FormReportedRef> reportedRef) { reportedRefs_.push_back(reportedRef); } @@ -37,7 +37,7 @@ const std::vector<boost::shared_ptr<FormReportedRef> >& FormSection::getReported return reportedRefs_; } -void FormSection::addChildSection(boost::shared_ptr<FormSection>& childSection) { +void FormSection::addChildSection(boost::shared_ptr<FormSection> childSection) { childSections_.push_back(childSection); } @@ -45,7 +45,7 @@ const std::vector<boost::shared_ptr<FormSection> >& FormSection::getChildSection return childSections_; } -void FormSection::addField(boost::shared_ptr<FormField>& field) { +void FormSection::addField(boost::shared_ptr<FormField> field) { fields_.push_back(field); } diff --git a/Swiften/Elements/FormSection.h b/Swiften/Elements/FormSection.h index f799062..22af67b 100644 --- a/Swiften/Elements/FormSection.h +++ b/Swiften/Elements/FormSection.h @@ -22,13 +22,13 @@ namespace Swift { ~FormSection(); void setLabel(const std::string& label); const std::string& getLabel() const; - void addTextElement(boost::shared_ptr<FormText>& textElement); + void addTextElement(boost::shared_ptr<FormText> textElement); const std::vector<boost::shared_ptr<FormText> >& getTextElements() const; - void addReportedRef(boost::shared_ptr<FormReportedRef>& reportedRef); + void addReportedRef(boost::shared_ptr<FormReportedRef> reportedRef); const std::vector<boost::shared_ptr<FormReportedRef> >& getReportedRefs() const; - void addChildSection(boost::shared_ptr<FormSection>& childSection); + void addChildSection(boost::shared_ptr<FormSection> childSection); const std::vector<boost::shared_ptr<FormSection> >& getChildSections() const; - void addField(boost::shared_ptr<FormField>& field); + void addField(boost::shared_ptr<FormField> field); const std::vector<boost::shared_ptr<FormField> >& getFields() const; void addFieldRef(std::string ref); const std::vector<std::string> getFieldRefs() const; diff --git a/Swiften/Parser/PayloadParsers/FormParser.cpp b/Swiften/Parser/PayloadParsers/FormParser.cpp index d400c4c..bc48fcb 100644 --- a/Swiften/Parser/PayloadParsers/FormParser.cpp +++ b/Swiften/Parser/PayloadParsers/FormParser.cpp @@ -4,18 +4,17 @@ * See the COPYING file for more information. */ #include <iostream> -#include <Swiften/Parser/PayloadParsers/FormParser.h> #include <map> #include <Swiften/Base/foreach.h> +#include <Swiften/Parser/PayloadParsers/FormParser.h> namespace Swift { -FormParser::FormParser() : level_(TopLevel), parsingItem_(false), parsingReported_(false), parsingOption_(false), parseStarted_(false), hasReportedRef_(false){ +FormParser::FormParser() : level_(TopLevel), parsingItem_(false), parsingReported_(false), parsingOption_(false), hasReportedRef_(false){ } void FormParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level_ == TopLevel) { - parseStarted_ = true; std::string type = attributes.getAttribute("type"); if (type == "form") { getPayloadInternal()->setType(Form::FormType); @@ -191,15 +190,15 @@ void FormParser::handleEndElement(const std::string& element, const std::string& else { if (currentPages_.size() > 0) { foreach (boost::shared_ptr<FormPage> page, currentPages_) { - foreach (std::string pRef, page->getFieldRefs()) { - if (pRef == currentField_->getName()) { + foreach (std::string pageRef, page->getFieldRefs()) { + if (pageRef == currentField_->getName()) { page->addField(currentField_); } } } foreach (boost::shared_ptr<FormSection> section, currentSections_) { - foreach (std::string sRef, section->getFieldRefs()) { - if (sRef == currentField_->getName()) { + foreach (std::string sectionRef, section->getFieldRefs()) { + if (sectionRef == currentField_->getName()) { section->addField(currentField_); } } @@ -219,7 +218,7 @@ void FormParser::handleEndElement(const std::string& element, const std::string& sectionStack_.pop_back(); } else if (sectionStack_.size() == 1) { - // Add the remaining section on the stack to it's parent page + // Add the remaining section on the stack to its parent page currentPage_->addChildSection(sectionStack_.at(sectionStack_.size()-1)); sectionStack_.pop_back(); } diff --git a/Swiften/Parser/PayloadParsers/FormParser.h b/Swiften/Parser/PayloadParsers/FormParser.h index a3b7556..c8c2294 100644 --- a/Swiften/Parser/PayloadParsers/FormParser.h +++ b/Swiften/Parser/PayloadParsers/FormParser.h @@ -32,7 +32,6 @@ namespace Swift { bool parsingItem_; bool parsingReported_; bool parsingOption_; - bool parseStarted_; bool hasReportedRef_; FormField::ref currentField_; std::vector<FormField::ref> currentFields_; diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp index 633ead6..a4ec52e 100644 --- a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp @@ -101,7 +101,7 @@ boost::shared_ptr<XMLElement> FormSerializer::fieldRefToXML(const std::string& r boost::shared_ptr<XMLElement> FormSerializer::pageToXML(boost::shared_ptr<FormPage> page) const { boost::shared_ptr<XMLElement> pageElement(new XMLElement("page")); - pageElement->setAttribute("xmlns", page->getXMLNS()); + pageElement->setAttribute("xmlns", "http://jabber.org/protocol/xdata-layout"); if (!page->getLabel().empty()) { pageElement->setAttribute("label", page->getLabel()); } |