diff options
Diffstat (limited to 'Swiften/Elements')
-rw-r--r-- | Swiften/Elements/Bytestreams.h | 6 | ||||
-rw-r--r-- | Swiften/Elements/DiscoInfo.cpp | 3 | ||||
-rw-r--r-- | Swiften/Elements/DiscoInfo.h | 3 | ||||
-rw-r--r-- | Swiften/Elements/Form.h | 6 | ||||
-rw-r--r-- | Swiften/Elements/IBB.h | 12 | ||||
-rw-r--r-- | Swiften/Elements/JingleFileTransferFileInfo.h | 2 | ||||
-rw-r--r-- | Swiften/Elements/PubSubItem.cpp | 5 | ||||
-rw-r--r-- | Swiften/Elements/PubSubItem.h | 18 | ||||
-rw-r--r-- | Swiften/Elements/PubSubItems.h | 1 | ||||
-rw-r--r-- | Swiften/Elements/ReferencePayload.cpp | 63 | ||||
-rw-r--r-- | Swiften/Elements/ReferencePayload.h | 62 | ||||
-rw-r--r-- | Swiften/Elements/S5BProxyRequest.h | 4 | ||||
-rw-r--r-- | Swiften/Elements/SecurityLabel.h | 1 | ||||
-rw-r--r-- | Swiften/Elements/StanzaAck.cpp | 8 | ||||
-rw-r--r-- | Swiften/Elements/StanzaAck.h | 4 | ||||
-rw-r--r-- | Swiften/Elements/StreamError.h | 2 | ||||
-rw-r--r-- | Swiften/Elements/StreamInitiationFileInfo.h | 2 |
17 files changed, 168 insertions, 34 deletions
diff --git a/Swiften/Elements/Bytestreams.h b/Swiften/Elements/Bytestreams.h index ca30922..599ed46 100644 --- a/Swiften/Elements/Bytestreams.h +++ b/Swiften/Elements/Bytestreams.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -22,11 +22,11 @@ namespace Swift { typedef std::shared_ptr<Bytestreams> ref; struct StreamHost { - StreamHost(const std::string& host = "", const JID& jid = JID(), int port = -1) : host(host), jid(jid), port(port) {} + StreamHost(const std::string& host = "", const JID& jid = JID(), unsigned short port = 0) : host(host), jid(jid), port(port) {} std::string host; JID jid; - int port; + unsigned short port; }; Bytestreams() {} diff --git a/Swiften/Elements/DiscoInfo.cpp b/Swiften/Elements/DiscoInfo.cpp index 11f0623..701ed40 100644 --- a/Swiften/Elements/DiscoInfo.cpp +++ b/Swiften/Elements/DiscoInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -26,6 +26,7 @@ const std::string DiscoInfo::MessageDeliveryReceiptsFeature = std::string("urn:x const std::string DiscoInfo::WhiteboardFeature = std::string("http://swift.im/whiteboard"); const std::string DiscoInfo::BlockingCommandFeature = std::string("urn:xmpp:blocking"); const std::string DiscoInfo::MessageCarbonsFeature = std::string("urn:xmpp:carbons:2"); +const std::string DiscoInfo::ReferencesFeature = std::string("urn:xmpp:references:0"); bool DiscoInfo::Identity::operator<(const Identity& other) const { if (category_ == other.category_) { diff --git a/Swiften/Elements/DiscoInfo.h b/Swiften/Elements/DiscoInfo.h index c8009ee..713eaba 100644 --- a/Swiften/Elements/DiscoInfo.h +++ b/Swiften/Elements/DiscoInfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -37,6 +37,7 @@ namespace Swift { static const std::string WhiteboardFeature; static const std::string BlockingCommandFeature; static const std::string MessageCarbonsFeature; + static const std::string ReferencesFeature; class Identity { public: diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h index 899fb93..827e497 100644 --- a/Swiften/Elements/Form.h +++ b/Swiften/Elements/Form.h @@ -89,6 +89,9 @@ namespace Swift { return instructions_; } + /** Returns the Form::Type enum (ie. ResultType, CancelType etc.). + * NOT to be confused with Form::getFormType(). + */ Type getType() const { return type_; } @@ -97,6 +100,9 @@ namespace Swift { type_ = type; } + /** Returns the value of the field FORM_TYPE + * NOT to be confused with Form::getType(). + */ std::string getFormType() const; FormField::ref getField(const std::string& name) const; void addItem(const FormItem& item); diff --git a/Swiften/Elements/IBB.h b/Swiften/Elements/IBB.h index bd0b661..6ebe66e 100644 --- a/Swiften/Elements/IBB.h +++ b/Swiften/Elements/IBB.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -28,10 +28,10 @@ namespace Swift { MessageStanza }; - IBB(Action action = Open, const std::string& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(-1), sequenceNumber(-1) { + IBB(Action action = Open, const std::string& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(0), sequenceNumber(-1) { } - static IBB::ref createIBBOpen(const std::string& streamID, int blockSize) { + static IBB::ref createIBBOpen(const std::string& streamID, unsigned int blockSize) { IBB::ref result = std::make_shared<IBB>(Open, streamID); result->setBlockSize(blockSize); return result; @@ -80,11 +80,11 @@ namespace Swift { this->data = data; } - int getBlockSize() const { + unsigned int getBlockSize() const { return blockSize; } - void setBlockSize(int blockSize) { + void setBlockSize(unsigned int blockSize) { this->blockSize = blockSize; } @@ -101,7 +101,7 @@ namespace Swift { std::string streamID; std::vector<unsigned char> data; StanzaType stanzaType; - int blockSize; + unsigned int blockSize; int sequenceNumber; }; } diff --git a/Swiften/Elements/JingleFileTransferFileInfo.h b/Swiften/Elements/JingleFileTransferFileInfo.h index 9fd8756..0e8ccd4 100644 --- a/Swiften/Elements/JingleFileTransferFileInfo.h +++ b/Swiften/Elements/JingleFileTransferFileInfo.h @@ -36,7 +36,7 @@ namespace Swift { public: void setName(const std::string& name) { - name_ = name;; + name_ = name; } const std::string& getName() const { diff --git a/Swiften/Elements/PubSubItem.cpp b/Swiften/Elements/PubSubItem.cpp index 4dc0907..b5f17cc 100644 --- a/Swiften/Elements/PubSubItem.cpp +++ b/Swiften/Elements/PubSubItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Isode Limited. + * Copyright (c) 2013-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,5 +11,8 @@ using namespace Swift; PubSubItem::PubSubItem() { } +PubSubItem::PubSubItem(const std::string& id) : id_(id) { +} + PubSubItem::~PubSubItem() { } diff --git a/Swiften/Elements/PubSubItem.h b/Swiften/Elements/PubSubItem.h index ba13150..161b733 100644 --- a/Swiften/Elements/PubSubItem.h +++ b/Swiften/Elements/PubSubItem.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017 Isode Limited. + * Copyright (c) 2013-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -18,32 +18,32 @@ namespace Swift { public: PubSubItem(); + PubSubItem(const std::string& id); virtual ~PubSubItem(); const std::vector< std::shared_ptr<Payload> >& getData() const { - return data; + return data_; } void setData(const std::vector< std::shared_ptr<Payload> >& value) { - this->data = value ; + this->data_ = value ; } void addData(std::shared_ptr<Payload> value) { - this->data.push_back(value); + this->data_.push_back(value); } const std::string& getID() const { - return id; + return id_; } void setID(const std::string& value) { - this->id = value ; + this->id_ = value ; } - private: - std::vector< std::shared_ptr<Payload> > data; - std::string id; + std::vector< std::shared_ptr<Payload> > data_; + std::string id_; }; } diff --git a/Swiften/Elements/PubSubItems.h b/Swiften/Elements/PubSubItems.h index c60adca..c8b7f53 100644 --- a/Swiften/Elements/PubSubItems.h +++ b/Swiften/Elements/PubSubItems.h @@ -61,7 +61,6 @@ namespace Swift { this->subscriptionID = value ; } - private: std::string node; std::vector< std::shared_ptr<PubSubItem> > items; diff --git a/Swiften/Elements/ReferencePayload.cpp b/Swiften/Elements/ReferencePayload.cpp new file mode 100644 index 0000000..288f28f --- /dev/null +++ b/Swiften/Elements/ReferencePayload.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <Swiften/Elements/ReferencePayload.h> + +namespace Swift { + +ReferencePayload::ReferencePayload() + : type_(Type::Data) { +} + +const ReferencePayload::Type& ReferencePayload::getType() const { + return type_; +} + +void ReferencePayload::setType(const ReferencePayload::Type& type) { + type_ = type; +} + +const boost::optional<std::string>& ReferencePayload::getUri() const { + return uri_; +} + +void ReferencePayload::setUri(const boost::optional<std::string>& uri) { + uri_ = uri; +} + +const boost::optional<std::string>& ReferencePayload::getBegin() const { + return begin_; +} + +void ReferencePayload::setBegin(const boost::optional<std::string>& begin) { + begin_ = begin; +} + +const boost::optional<std::string>& ReferencePayload::getEnd() const { + return end_; +} + +void ReferencePayload::setEnd(const boost::optional<std::string>& end) { + end_ = end; +} + +const boost::optional<std::string>& ReferencePayload::getAnchor() const { + return anchor_; +} + +void ReferencePayload::setAnchor(const boost::optional<std::string>& anchor) { + anchor_ = anchor; +} + +const std::vector<std::shared_ptr<Payload>>& ReferencePayload::getPayloads() const { + return payloads_; +} + +void ReferencePayload::addPayload(const std::shared_ptr<Payload>& payload) { + payloads_.push_back(payload); +} + +} diff --git a/Swiften/Elements/ReferencePayload.h b/Swiften/Elements/ReferencePayload.h new file mode 100644 index 0000000..b9a394e --- /dev/null +++ b/Swiften/Elements/ReferencePayload.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <string> +#include <vector> + +#include <boost/optional.hpp> + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/Payload.h> + +namespace Swift { + /** + * reference from XEP-0372 + */ + class SWIFTEN_API ReferencePayload : public Payload { + + public: + + typedef std::shared_ptr<ReferencePayload> ref; + + enum class Type { + Data, + Mention, + PubSub, + Unknown + }; + + ReferencePayload(); + + const Type& getType() const; + const boost::optional<std::string>& getUri() const; + const boost::optional<std::string>& getBegin() const; + const boost::optional<std::string>& getEnd() const; + const boost::optional<std::string>& getAnchor() const; + + const std::vector<std::shared_ptr<Payload>>& getPayloads() const; + + void setType(const Type& type); + void setUri(const boost::optional<std::string>& uri); + void setBegin(const boost::optional<std::string>& begin); + void setEnd(const boost::optional<std::string>& end); + void setAnchor(const boost::optional<std::string>& anchor); + + void addPayload(const std::shared_ptr<Payload>& payload); + + private: + + Type type_; + boost::optional<std::string> uri_; + boost::optional<std::string> begin_; + boost::optional<std::string> end_; + boost::optional<std::string> anchor_; + + std::vector<std::shared_ptr<Payload>> payloads_; + }; +} diff --git a/Swiften/Elements/S5BProxyRequest.h b/Swiften/Elements/S5BProxyRequest.h index e3f5206..2fecae4 100644 --- a/Swiften/Elements/S5BProxyRequest.h +++ b/Swiften/Elements/S5BProxyRequest.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -30,7 +30,7 @@ public: public: struct StreamHost { std::string host; - int port; + unsigned short port; JID jid; }; diff --git a/Swiften/Elements/SecurityLabel.h b/Swiften/Elements/SecurityLabel.h index 0f0311e..fcaa610 100644 --- a/Swiften/Elements/SecurityLabel.h +++ b/Swiften/Elements/SecurityLabel.h @@ -15,6 +15,7 @@ namespace Swift { class SWIFTEN_API SecurityLabel : public Payload { public: + using ref = std::shared_ptr<SecurityLabel>; SecurityLabel(); diff --git a/Swiften/Elements/StanzaAck.cpp b/Swiften/Elements/StanzaAck.cpp index bd0b78d..dda97f5 100644 --- a/Swiften/Elements/StanzaAck.cpp +++ b/Swiften/Elements/StanzaAck.cpp @@ -1,19 +1,17 @@ /* - * Copyright (c) 2013 Isode Limited. + * Copyright (c) 2013-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Elements/StanzaAck.h> -#include <boost/numeric/conversion/cast.hpp> - using namespace Swift; StanzaAck::~StanzaAck() { } -void StanzaAck::setHandledStanzasCount(int i) { - handledStanzasCount = boost::numeric_cast<unsigned int>(i); +void StanzaAck::setHandledStanzasCount(unsigned int i) { + handledStanzasCount = i; valid = true; } diff --git a/Swiften/Elements/StanzaAck.h b/Swiften/Elements/StanzaAck.h index 68f0a2f..f664aca 100644 --- a/Swiften/Elements/StanzaAck.h +++ b/Swiften/Elements/StanzaAck.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -24,7 +24,7 @@ namespace Swift { return handledStanzasCount; } - void setHandledStanzasCount(int i); + void setHandledStanzasCount(unsigned int i); bool isValid() const { return valid; diff --git a/Swiften/Elements/StreamError.h b/Swiften/Elements/StreamError.h index aa294fd..6dda15c 100644 --- a/Swiften/Elements/StreamError.h +++ b/Swiften/Elements/StreamError.h @@ -27,7 +27,6 @@ namespace Swift { ImproperAddressing, InternalServerError, InvalidFrom, - InvalidID, InvalidNamespace, InvalidXML, NotAuthorized, @@ -41,6 +40,7 @@ namespace Swift { SystemShutdown, UndefinedCondition, UnsupportedEncoding, + UnsupportedFeature, UnsupportedStanzaType, UnsupportedVersion }; diff --git a/Swiften/Elements/StreamInitiationFileInfo.h b/Swiften/Elements/StreamInitiationFileInfo.h index f2dc5b9..773814f 100644 --- a/Swiften/Elements/StreamInitiationFileInfo.h +++ b/Swiften/Elements/StreamInitiationFileInfo.h @@ -26,7 +26,7 @@ public: name(name), description(description), size(size), hash(hash), date(date), algo(algo), supportsRangeRequests(false), rangeOffset(0) {} void setName(const std::string& name) { - this->name = name;; + this->name = name; } const std::string& getName() const { |