diff options
Diffstat (limited to 'Swiften')
284 files changed, 4215 insertions, 1239 deletions
diff --git a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp index 8aca98e..3e5e9e6 100644 --- a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp +++ b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp @@ -48,8 +48,8 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture { public: void setUp() { - avatarProvider1 = std::unique_ptr<DummyAvatarProvider>(new DummyAvatarProvider()); - avatarProvider2 = std::unique_ptr<DummyAvatarProvider>(new DummyAvatarProvider()); + avatarProvider1 = std::make_unique<DummyAvatarProvider>(); + avatarProvider2 = std::make_unique<DummyAvatarProvider>(); user1 = JID("user1@bar.com/bla"); user2 = JID("user2@foo.com/baz"); avatarHash1 = "ABCDEFG"; diff --git a/Swiften/Base/Algorithm.h b/Swiften/Base/Algorithm.h index 108dbe3..ee761b7 100644 --- a/Swiften/Base/Algorithm.h +++ b/Swiften/Base/Algorithm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014 Isode Limited. + * Copyright (c) 2011-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -160,4 +160,28 @@ namespace Swift { return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin(), pred); } + + /** + * Ranges + */ + template <typename T> + class range_t { + public: + range_t(T b, T e) : b_(b), e_(e) {} + + T begin() { + return b_; + } + T end() { + return e_; + } + private: + T b_; + T e_; + }; + + template <typename T> + range_t<T> range(T b, T e) { + return range_t<T>(b, e); + } } diff --git a/Swiften/Base/LRUCache.h b/Swiften/Base/LRUCache.h index e4e652f..1f92612 100644 --- a/Swiften/Base/LRUCache.h +++ b/Swiften/Base/LRUCache.h @@ -19,9 +19,9 @@ namespace Swift { /** - * The \ref LRUCache templaged class implements a lookup cache which removes + * The \ref LRUCache template class implements a lookup cache which removes * the least recently used cached item from the cache, if the cache size hits - * the \ref MAX_SIZE limit. + * the \p MAX_SIZE limit. * * An example use is a cache for entity capabilities hash to DiscoInfo. */ @@ -32,9 +32,9 @@ public: public: /** - * Inserts the key/value pair in the front of the cache. If the \ref key + * Inserts the key/value pair in the front of the cache. If the \p key * already exists in the cache, it is moved to the front instead. If - * afterwards, the cahe size exceeds the \ref MAX_SIZE limit, the least + * afterwards, the cahe size exceeds the \p MAX_SIZE limit, the least * recently item is removed from the cache. */ void insert(const KEY_TYPE& key, VALUE_TYPE value) { @@ -48,11 +48,11 @@ public: } /** - * Looks up a cache entry based on the provided \ref key and moves it back + * Looks up a cache entry based on the provided \p key and moves it back * to the front of the cache. If there is no cache entry for the provided - * \ref key, an uninitialized \ref boost::optional is returned. - * If the optional \ref missFunction is provided, it is called on a cache miss. - * If the \ref missFunction returns an initialized \ref boost::optional, the + * \p key, an uninitialized \p boost::optional is returned. + * If the optional \p missFunction is provided, it is called on a cache miss. + * If the \p missFunction returns an initialized \p boost::optional, the * value is inserted in the cache. */ boost::optional<VALUE_TYPE> get(const KEY_TYPE& key, cacheMissFunction missFunction = cacheMissFunction()) { diff --git a/Swiften/Base/Override.h b/Swiften/Base/Override.h deleted file mode 100644 index 2806aae..0000000 --- a/Swiften/Base/Override.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2012 Isode Limited. - * All rights reserved. - * See the COPYING file for more information. - */ - -#pragma once - -#if defined(__clang__) -# if __has_feature(cxx_override_control) || __has_extension(cxx_override_control) -# define SWIFTEN_OVERRIDE override -# else -# define SWIFTEN_OVERRIDE -# endif - -#elif defined(__GNUC__) -# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) && defined(__GXX_EXPERIMENTAL_CXX0X__) -# define SWIFTEN_OVERRIDE override -# else -# define SWIFTEN_OVERRIDE -# endif - -#elif defined(_MSC_VER) -// Actually, 1700 is the first version that supports the C++11 override, but -// older versions apparently support a similar keyword. -# if _MSC_VER >= 1400 -# define SWIFTEN_OVERRIDE override -# else -# define SWIFTEN_OVERRIDE -# endif - -#else -# define SWIFTEN_OVERRIDE -#endif diff --git a/Swiften/Base/SimpleIDGenerator.h b/Swiften/Base/SimpleIDGenerator.h index ff645b1..09e01de 100644 --- a/Swiften/Base/SimpleIDGenerator.h +++ b/Swiften/Base/SimpleIDGenerator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <Swiften/Base/API.h> #include <Swiften/Base/IDGenerator.h> -#include <Swiften/Base/Override.h> namespace Swift { @@ -22,9 +21,9 @@ namespace Swift { class SWIFTEN_API SimpleIDGenerator : public IDGenerator { public: SimpleIDGenerator(); - ~SimpleIDGenerator(); + ~SimpleIDGenerator() override; - std::string generateID() SWIFTEN_OVERRIDE; + std::string generateID() override; private: std::string currentID; diff --git a/Swiften/Base/StdRandomGenerator.h b/Swiften/Base/StdRandomGenerator.h index 4cc5e95..159d361 100644 --- a/Swiften/Base/StdRandomGenerator.h +++ b/Swiften/Base/StdRandomGenerator.h @@ -9,7 +9,6 @@ #include <random> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Base/RandomGenerator.h> namespace Swift { @@ -17,7 +16,7 @@ namespace Swift { public: StdRandomGenerator(); - int generateRandomInteger(int max) SWIFTEN_OVERRIDE; + int generateRandomInteger(int max) override; private: std::mt19937 generator; diff --git a/Swiften/Client/ClientXMLTracer.cpp b/Swiften/Client/ClientXMLTracer.cpp index e205f41..e1b9e0c 100644 --- a/Swiften/Client/ClientXMLTracer.cpp +++ b/Swiften/Client/ClientXMLTracer.cpp @@ -16,9 +16,9 @@ namespace Swift { ClientXMLTracer::ClientXMLTracer(CoreClient* client, bool bosh) : bosh_(bosh) { #ifdef SWIFTEN_PLATFORM_WIN32 - beautifier_ = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + beautifier_ = std::make_unique<XMLBeautifier>(true, false); #else - beautifier_ = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, true)); + beautifier_ = std::make_unique<XMLBeautifier>(true, true); #endif onDataReadConnection_ = client->onDataRead.connect(boost::bind(&ClientXMLTracer::printData, this, '<', _1)); onDataWrittenConnection_ = client->onDataWritten.connect(boost::bind(&ClientXMLTracer::printData, this, '>', _1)); diff --git a/Swiften/Client/UnitTest/XMLBeautifierTest.cpp b/Swiften/Client/UnitTest/XMLBeautifierTest.cpp index 0188634..2eac086 100644 --- a/Swiften/Client/UnitTest/XMLBeautifierTest.cpp +++ b/Swiften/Client/UnitTest/XMLBeautifierTest.cpp @@ -15,7 +15,7 @@ namespace { } TEST(XMLBeautifierTest, testBeautify) { - auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + auto beautifier = std::make_unique<XMLBeautifier>(true, false); ASSERT_EQ(FULL_FORMATTED_OUTPUT, beautifier->beautify("<list><el>aqq</el><el>bzz</el></list>")); ASSERT_TRUE(beautifier->wasReset()); @@ -26,7 +26,7 @@ TEST(XMLBeautifierTest, testBeautify) { } TEST(XMLBeautifierTest, testBeautifyMultipleChunks) { - auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + auto beautifier = std::make_unique<XMLBeautifier>(true, false); auto result = beautifier->beautify("<list><el>aqq</el>"); ASSERT_TRUE(beautifier->wasReset()); @@ -40,7 +40,7 @@ TEST(XMLBeautifierTest, testBeautifyMultipleChunks) { } TEST(XMLBeautifierTest, testBeautifyMultipleChunksMiddleElement) { - auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + auto beautifier = std::make_unique<XMLBeautifier>(true, false); auto result = beautifier->beautify("<l"); ASSERT_TRUE(beautifier->wasReset()); @@ -54,7 +54,7 @@ TEST(XMLBeautifierTest, testBeautifyMultipleChunksMiddleElement) { } TEST(XMLBeautifierTest, testBeautifyInvalidMultipleChunks) { - auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + auto beautifier = std::make_unique<XMLBeautifier>(true, false); ASSERT_EQ(std::string("<list>\n <el>aqq"), beautifier->beautify("<list><el>aqq<")); ASSERT_TRUE(beautifier->wasReset()); diff --git a/Swiften/Crypto/CommonCryptoCryptoProvider.cpp b/Swiften/Crypto/CommonCryptoCryptoProvider.cpp index 9fbdb2a..d4257e0 100644 --- a/Swiften/Crypto/CommonCryptoCryptoProvider.cpp +++ b/Swiften/Crypto/CommonCryptoCryptoProvider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -27,18 +27,18 @@ namespace { } } - ~SHA1Hash() { + virtual ~SHA1Hash() override { } - virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const ByteArray& data) override { return updateInternal(data); } - virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const SafeByteArray& data) override { return updateInternal(data); } - virtual std::vector<unsigned char> getHash() SWIFTEN_OVERRIDE { + virtual std::vector<unsigned char> getHash() override { assert(!finalized); std::vector<unsigned char> result(CC_SHA1_DIGEST_LENGTH); CC_SHA1_Final(vecptr(result), &context); @@ -68,18 +68,18 @@ namespace { } } - ~MD5Hash() { + virtual ~MD5Hash() override { } - virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const ByteArray& data) override { return updateInternal(data); } - virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const SafeByteArray& data) override { return updateInternal(data); } - virtual std::vector<unsigned char> getHash() SWIFTEN_OVERRIDE { + virtual std::vector<unsigned char> getHash() override { assert(!finalized); std::vector<unsigned char> result(CC_MD5_DIGEST_LENGTH); CC_MD5_Final(vecptr(result), &context); diff --git a/Swiften/Crypto/CommonCryptoCryptoProvider.h b/Swiften/Crypto/CommonCryptoCryptoProvider.h index 8fa7fa6..7d1675f 100644 --- a/Swiften/Crypto/CommonCryptoCryptoProvider.h +++ b/Swiften/Crypto/CommonCryptoCryptoProvider.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,19 +7,18 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Crypto/CryptoProvider.h> namespace Swift { class SWIFTEN_API CommonCryptoCryptoProvider : public CryptoProvider { public: CommonCryptoCryptoProvider(); - ~CommonCryptoCryptoProvider(); + virtual ~CommonCryptoCryptoProvider() override; - virtual Hash* createSHA1() SWIFTEN_OVERRIDE; - virtual Hash* createMD5() SWIFTEN_OVERRIDE; - virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE; - virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE; - virtual bool isMD5AllowedForCrypto() const SWIFTEN_OVERRIDE; + virtual Hash* createSHA1() override; + virtual Hash* createMD5() override; + virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) override; + virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) override; + virtual bool isMD5AllowedForCrypto() const override; }; } diff --git a/Swiften/Crypto/OpenSSLCryptoProvider.cpp b/Swiften/Crypto/OpenSSLCryptoProvider.cpp index c785041..b46cb2a 100644 --- a/Swiften/Crypto/OpenSSLCryptoProvider.cpp +++ b/Swiften/Crypto/OpenSSLCryptoProvider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -31,15 +31,15 @@ namespace { ~SHA1Hash() { } - virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const ByteArray& data) override { return updateInternal(data); } - virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const SafeByteArray& data) override { return updateInternal(data); } - virtual std::vector<unsigned char> getHash() SWIFTEN_OVERRIDE { + virtual std::vector<unsigned char> getHash() override { assert(!finalized); std::vector<unsigned char> result(SHA_DIGEST_LENGTH); SHA1_Final(vecptr(result), &context); @@ -72,15 +72,15 @@ namespace { ~MD5Hash() { } - virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const ByteArray& data) override { return updateInternal(data); } - virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const SafeByteArray& data) override { return updateInternal(data); } - virtual std::vector<unsigned char> getHash() SWIFTEN_OVERRIDE { + virtual std::vector<unsigned char> getHash() override { assert(!finalized); std::vector<unsigned char> result(MD5_DIGEST_LENGTH); MD5_Final(vecptr(result), &context); diff --git a/Swiften/Crypto/OpenSSLCryptoProvider.h b/Swiften/Crypto/OpenSSLCryptoProvider.h index 6e0c01b..e4ee97d 100644 --- a/Swiften/Crypto/OpenSSLCryptoProvider.h +++ b/Swiften/Crypto/OpenSSLCryptoProvider.h @@ -1,24 +1,23 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Crypto/CryptoProvider.h> namespace Swift { class OpenSSLCryptoProvider : public CryptoProvider { public: OpenSSLCryptoProvider(); - ~OpenSSLCryptoProvider(); + virtual ~OpenSSLCryptoProvider() override; - virtual Hash* createSHA1() SWIFTEN_OVERRIDE; - virtual Hash* createMD5() SWIFTEN_OVERRIDE; - virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE; - virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE; - virtual bool isMD5AllowedForCrypto() const SWIFTEN_OVERRIDE; + virtual Hash* createSHA1() override; + virtual Hash* createMD5() override; + virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) override; + virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) override; + virtual bool isMD5AllowedForCrypto() const override; }; } diff --git a/Swiften/Crypto/WindowsCryptoProvider.cpp b/Swiften/Crypto/WindowsCryptoProvider.cpp index 513941f..c784283 100644 --- a/Swiften/Crypto/WindowsCryptoProvider.cpp +++ b/Swiften/Crypto/WindowsCryptoProvider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -43,11 +43,11 @@ namespace { CryptDestroyHash(hash); } - virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const ByteArray& data) override { return updateInternal(data); } - virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const SafeByteArray& data) override { return updateInternal(data); } @@ -123,11 +123,11 @@ namespace { CryptDestroyHash(hash); } - virtual Hash& update(const ByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const ByteArray& data) override { return updateInternal(data); } - virtual Hash& update(const SafeByteArray& data) SWIFTEN_OVERRIDE { + virtual Hash& update(const SafeByteArray& data) override { return updateInternal(data); } diff --git a/Swiften/Crypto/WindowsCryptoProvider.h b/Swiften/Crypto/WindowsCryptoProvider.h index f446027..d0c982e 100644 --- a/Swiften/Crypto/WindowsCryptoProvider.h +++ b/Swiften/Crypto/WindowsCryptoProvider.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <boost/noncopyable.hpp> -#include <Swiften/Base/Override.h> #include <Swiften/Crypto/CryptoProvider.h> namespace Swift { @@ -19,11 +18,11 @@ namespace Swift { WindowsCryptoProvider(); virtual ~WindowsCryptoProvider(); - virtual Hash* createSHA1() SWIFTEN_OVERRIDE; - virtual Hash* createMD5() SWIFTEN_OVERRIDE; - virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE; - virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) SWIFTEN_OVERRIDE; - virtual bool isMD5AllowedForCrypto() const SWIFTEN_OVERRIDE; + virtual Hash* createSHA1() override; + virtual Hash* createMD5() override; + virtual ByteArray getHMACSHA1(const SafeByteArray& key, const ByteArray& data) override; + virtual ByteArray getHMACSHA1(const ByteArray& key, const ByteArray& data) override; + virtual bool isMD5AllowedForCrypto() const override; private: struct Private; diff --git a/Swiften/Disco/UnitTest/CapsManagerTest.cpp b/Swiften/Disco/UnitTest/CapsManagerTest.cpp index 153e821..5f1aaf4 100644 --- a/Swiften/Disco/UnitTest/CapsManagerTest.cpp +++ b/Swiften/Disco/UnitTest/CapsManagerTest.cpp @@ -47,9 +47,9 @@ class CapsManagerTest : public CppUnit::TestFixture { public: void setUp() { crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); - stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel()); - iqRouter = std::unique_ptr<IQRouter>(new IQRouter(stanzaChannel.get())); - storage = std::unique_ptr<CapsMemoryStorage>(new CapsMemoryStorage()); + stanzaChannel = std::make_unique<DummyStanzaChannel>(); + iqRouter = std::make_unique<IQRouter>(stanzaChannel.get()); + storage = std::make_unique<CapsMemoryStorage>(); user1 = JID("user1@bar.com/bla"); discoInfo1 = std::make_shared<DiscoInfo>(); discoInfo1->addFeature("http://swift.im/feature1"); diff --git a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp index 8c59741..6548485 100644 --- a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp +++ b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp @@ -37,8 +37,8 @@ class EntityCapsManagerTest : public CppUnit::TestFixture { void setUp() { crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); - stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel()); - capsProvider = std::unique_ptr<DummyCapsProvider>(new DummyCapsProvider()); + stanzaChannel = std::make_unique<DummyStanzaChannel>(); + capsProvider = std::make_unique<DummyCapsProvider>(); user1 = JID("user1@bar.com/bla"); discoInfo1 = std::make_shared<DiscoInfo>(); diff --git a/Swiften/Elements/ContainerPayload.h b/Swiften/Elements/ContainerPayload.h index 3da04b7..033575a 100644 --- a/Swiften/Elements/ContainerPayload.h +++ b/Swiften/Elements/ContainerPayload.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <vector> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { 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/IsodeIQDelegation.h b/Swiften/Elements/IsodeIQDelegation.h index 39655ce..074a06d 100644 --- a/Swiften/Elements/IsodeIQDelegation.h +++ b/Swiften/Elements/IsodeIQDelegation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Forwarded.h> #include <Swiften/Elements/Payload.h> diff --git a/Swiften/Elements/MIXJoin.h b/Swiften/Elements/MIXJoin.h index 2d82adc..ecd7b12 100644 --- a/Swiften/Elements/MIXJoin.h +++ b/Swiften/Elements/MIXJoin.h @@ -8,12 +8,12 @@ #include <memory> #include <string> +#include <unordered_set> #include <boost/optional.hpp> #include <Swiften/Base/API.h> #include <Swiften/Elements/Payload.h> -#include <Swiften/Elements/MIXSubscribe.h> #include <Swiften/Elements/Form.h> #include <Swiften/JID/JID.h> @@ -31,7 +31,7 @@ namespace Swift { return channel_; } - void setChannel(const JID& channel) { + void setChannel(JID channel) { channel_ = channel; } @@ -39,20 +39,24 @@ namespace Swift { return jid_; } - void setJID(const JID& jid) { + void setJID(JID jid) { jid_ = jid; } - const std::vector<MIXSubscribe::ref>& getSubscriptions() const { + const std::unordered_set<std::string>& getSubscriptions() const { return subscribeItems_; } - void setSubscriptions(const std::vector<MIXSubscribe::ref>& value) { - subscribeItems_ = value ; + void setSubscriptions(std::unordered_set<std::string> values) { + subscribeItems_ = values ; } - void addSubscription(MIXSubscribe::ref value) { - subscribeItems_.push_back(value); + void addSubscription(std::string value) { + subscribeItems_.insert(value); + } + + bool hasSubscription(const std::string& value) const { + return std::find(subscribeItems_.begin(), subscribeItems_.end(), value) != subscribeItems_.end(); } void setForm(std::shared_ptr<Form> form) { @@ -66,7 +70,7 @@ namespace Swift { private: boost::optional<JID> jid_; boost::optional<JID> channel_; - std::vector<MIXSubscribe::ref> subscribeItems_; + std::unordered_set<std::string> subscribeItems_; std::shared_ptr<Form> form_; // FIXME: MIXInvitation to be implemented. boost::optional<MIXInvitation> invitation_; }; diff --git a/Swiften/Elements/MIXLeave.h b/Swiften/Elements/MIXLeave.h new file mode 100644 index 0000000..76ca09d --- /dev/null +++ b/Swiften/Elements/MIXLeave.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <memory> + +#include <boost/optional.hpp> + +#include <Swiften/Base/API.h> +#include <Swiften/JID/JID.h> +#include <Swiften/Elements/Payload.h> + +namespace Swift { + class SWIFTEN_API MIXLeave : public Payload { + public: + using ref = std::shared_ptr<MIXLeave>; + + public: + + MIXLeave() {} + + const boost::optional<JID>& getChannel() const { + return channel_; + } + + void setChannel(const JID& channel) { + channel_ = channel; + } + + private: + boost::optional<JID> channel_; + }; +} diff --git a/Swiften/Elements/MIXPayload.h b/Swiften/Elements/MIXPayload.h new file mode 100644 index 0000000..3989c18 --- /dev/null +++ b/Swiften/Elements/MIXPayload.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <memory> +#include <string> + +#include <boost/optional.hpp> + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/Payload.h> +#include <Swiften/JID/JID.h> + +namespace Swift { + class SWIFTEN_API MIXPayload : public Payload { + public: + using ref = std::shared_ptr<MIXPayload>; + + public: + + MIXPayload() {} + + const boost::optional<std::string>& getNick() const { + return nick_; + } + + void setNick(const std::string& nick) { + nick_ = nick; + } + + const boost::optional<JID>& getJID() const { + return jid_; + } + + void setJID(const JID& jid) { + jid_ = jid; + } + + const boost::optional<std::string>& getSubmissionID() const { + return submissionId_; + } + + void setSubmissionID(const std::string& submissionId) { + submissionId_ = submissionId; + } + + private: + boost::optional<JID> jid_; + boost::optional<std::string> nick_; + boost::optional<std::string> submissionId_; + }; +} diff --git a/Swiften/Elements/MIXSubscribe.h b/Swiften/Elements/MIXRegisterNick.h index eaf1aa9..3bd8c4a 100644 --- a/Swiften/Elements/MIXSubscribe.h +++ b/Swiften/Elements/MIXRegisterNick.h @@ -9,30 +9,27 @@ #include <memory> #include <string> -#include <boost/optional.hpp> - #include <Swiften/Base/API.h> #include <Swiften/Elements/Payload.h> namespace Swift { - class SWIFTEN_API MIXSubscribe : public Payload { - + class SWIFTEN_API MIXRegisterNick : public Payload { public: - using ref = std::shared_ptr<MIXSubscribe>; + using ref = std::shared_ptr<MIXRegisterNick>; public: - MIXSubscribe() {} + MIXRegisterNick() {} - const std::string& getNode() const { - return node_; + const std::string& getNick() const { + return nick_; } - void setNode(const std::string& node) { - node_ = node; + void setNick(const std::string& nick) { + nick_ = nick; } private: - std::string node_; + std::string nick_; }; } diff --git a/Swiften/Elements/MIXSetNick.h b/Swiften/Elements/MIXSetNick.h new file mode 100644 index 0000000..94c5a3b --- /dev/null +++ b/Swiften/Elements/MIXSetNick.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <memory> +#include <string> + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/Payload.h> + +namespace Swift { + class SWIFTEN_API MIXSetNick : public Payload { + public: + using ref = std::shared_ptr<MIXSetNick>; + + public: + + MIXSetNick() {} + + const std::string& getNick() const { + return nick_; + } + + void setNick(const std::string& nick) { + nick_ = nick; + } + + private: + std::string nick_; + }; +} diff --git a/Swiften/Elements/MIXUpdateSubscription.h b/Swiften/Elements/MIXUpdateSubscription.h new file mode 100644 index 0000000..dc6ed27 --- /dev/null +++ b/Swiften/Elements/MIXUpdateSubscription.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <memory> +#include <unordered_set> + +#include <boost/optional.hpp> + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/Payload.h> +#include <Swiften/JID/JID.h> + +namespace Swift { + class SWIFTEN_API MIXUpdateSubscription : public Payload { + + public: + using ref = std::shared_ptr<MIXUpdateSubscription>; + + public: + + MIXUpdateSubscription() {} + + const boost::optional<JID>& getJID() const { + return jid_; + } + + void setJID(JID jid) { + jid_ = jid; + } + + const std::unordered_set<std::string>& getSubscriptions() const { + return subscribeItems_; + } + + void setSubscriptions(std::unordered_set<std::string> values) { + subscribeItems_ = values ; + } + + void addSubscription(std::string value) { + subscribeItems_.insert(value); + } + + bool hasSubscription(const std::string& value) const { + return std::find(subscribeItems_.begin(), subscribeItems_.end(), value) != subscribeItems_.end(); + } + + private: + boost::optional<JID> jid_; + std::unordered_set<std::string> subscribeItems_; + }; +} diff --git a/Swiften/Elements/PubSub.h b/Swiften/Elements/PubSub.h index d62c54e..47b8c3f 100644 --- a/Swiften/Elements/PubSub.h +++ b/Swiften/Elements/PubSub.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/ContainerPayload.h> #include <Swiften/Elements/PubSubPayload.h> diff --git a/Swiften/Elements/PubSubAffiliation.h b/Swiften/Elements/PubSubAffiliation.h index b19e84b..058ef88 100644 --- a/Swiften/Elements/PubSubAffiliation.h +++ b/Swiften/Elements/PubSubAffiliation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/PubSubAffiliations.h b/Swiften/Elements/PubSubAffiliations.h index c7e22ce..f3a6dda 100644 --- a/Swiften/Elements/PubSubAffiliations.h +++ b/Swiften/Elements/PubSubAffiliations.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,7 +13,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubAffiliation.h> #include <Swiften/Elements/PubSubPayload.h> diff --git a/Swiften/Elements/PubSubConfigure.h b/Swiften/Elements/PubSubConfigure.h index 8442198..88a1ea9 100644 --- a/Swiften/Elements/PubSubConfigure.h +++ b/Swiften/Elements/PubSubConfigure.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Form.h> #include <Swiften/Elements/Payload.h> diff --git a/Swiften/Elements/PubSubCreate.h b/Swiften/Elements/PubSubCreate.h index 5ece36e..ac6b987 100644 --- a/Swiften/Elements/PubSubCreate.h +++ b/Swiften/Elements/PubSubCreate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubConfigure.h> #include <Swiften/Elements/PubSubPayload.h> diff --git a/Swiften/Elements/PubSubDefault.h b/Swiften/Elements/PubSubDefault.h index 08482b4..aa058ac 100644 --- a/Swiften/Elements/PubSubDefault.h +++ b/Swiften/Elements/PubSubDefault.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubPayload.h> diff --git a/Swiften/Elements/PubSubEvent.h b/Swiften/Elements/PubSubEvent.h index 8f02258..561f731 100644 --- a/Swiften/Elements/PubSubEvent.h +++ b/Swiften/Elements/PubSubEvent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/ContainerPayload.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubEventPayload.h> diff --git a/Swiften/Elements/PubSubEventAssociate.h b/Swiften/Elements/PubSubEventAssociate.h index 5d963a0..b7bb839 100644 --- a/Swiften/Elements/PubSubEventAssociate.h +++ b/Swiften/Elements/PubSubEventAssociate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/PubSubEventCollection.h b/Swiften/Elements/PubSubEventCollection.h index 61056e2..367fe02 100644 --- a/Swiften/Elements/PubSubEventCollection.h +++ b/Swiften/Elements/PubSubEventCollection.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -12,7 +12,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubEventAssociate.h> #include <Swiften/Elements/PubSubEventDisassociate.h> diff --git a/Swiften/Elements/PubSubEventConfiguration.h b/Swiften/Elements/PubSubEventConfiguration.h index 6c5305d..e529014 100644 --- a/Swiften/Elements/PubSubEventConfiguration.h +++ b/Swiften/Elements/PubSubEventConfiguration.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Form.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubEventPayload.h> diff --git a/Swiften/Elements/PubSubEventDelete.h b/Swiften/Elements/PubSubEventDelete.h index 787dce0..f899d4e 100644 --- a/Swiften/Elements/PubSubEventDelete.h +++ b/Swiften/Elements/PubSubEventDelete.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubEventPayload.h> #include <Swiften/Elements/PubSubEventRedirect.h> diff --git a/Swiften/Elements/PubSubEventDisassociate.h b/Swiften/Elements/PubSubEventDisassociate.h index 826b1f4..415ac29 100644 --- a/Swiften/Elements/PubSubEventDisassociate.h +++ b/Swiften/Elements/PubSubEventDisassociate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/PubSubEventItem.h b/Swiften/Elements/PubSubEventItem.h index 50e8757..defdbf4 100644 --- a/Swiften/Elements/PubSubEventItem.h +++ b/Swiften/Elements/PubSubEventItem.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,7 +13,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/PubSubEventItems.h b/Swiften/Elements/PubSubEventItems.h index 48fd340..aade826 100644 --- a/Swiften/Elements/PubSubEventItems.h +++ b/Swiften/Elements/PubSubEventItems.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include <vector> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubEventItem.h> #include <Swiften/Elements/PubSubEventPayload.h> diff --git a/Swiften/Elements/PubSubEventPurge.h b/Swiften/Elements/PubSubEventPurge.h index 743cc25..647598d 100644 --- a/Swiften/Elements/PubSubEventPurge.h +++ b/Swiften/Elements/PubSubEventPurge.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubEventPayload.h> diff --git a/Swiften/Elements/PubSubEventRedirect.h b/Swiften/Elements/PubSubEventRedirect.h index e0e351f..063cf8c 100644 --- a/Swiften/Elements/PubSubEventRedirect.h +++ b/Swiften/Elements/PubSubEventRedirect.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/PubSubEventRetract.h b/Swiften/Elements/PubSubEventRetract.h index b0aea96..19e02c9 100644 --- a/Swiften/Elements/PubSubEventRetract.h +++ b/Swiften/Elements/PubSubEventRetract.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/PubSubEventSubscription.h b/Swiften/Elements/PubSubEventSubscription.h index 0b8297c..37e8b74 100644 --- a/Swiften/Elements/PubSubEventSubscription.h +++ b/Swiften/Elements/PubSubEventSubscription.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -12,7 +12,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubEventPayload.h> #include <Swiften/JID/JID.h> diff --git a/Swiften/Elements/PubSubItem.h b/Swiften/Elements/PubSubItem.h index d424ae4..ba13150 100644 --- a/Swiften/Elements/PubSubItem.h +++ b/Swiften/Elements/PubSubItem.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include <vector> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/PubSubItems.h b/Swiften/Elements/PubSubItems.h index 9903075..c60adca 100644 --- a/Swiften/Elements/PubSubItems.h +++ b/Swiften/Elements/PubSubItems.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,7 +13,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubItem.h> #include <Swiften/Elements/PubSubPayload.h> diff --git a/Swiften/Elements/PubSubOptions.h b/Swiften/Elements/PubSubOptions.h index 2b312a7..80a3b03 100644 --- a/Swiften/Elements/PubSubOptions.h +++ b/Swiften/Elements/PubSubOptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -12,7 +12,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Form.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubPayload.h> diff --git a/Swiften/Elements/PubSubOwnerAffiliation.h b/Swiften/Elements/PubSubOwnerAffiliation.h index a8c1d91..77886d1 100644 --- a/Swiften/Elements/PubSubOwnerAffiliation.h +++ b/Swiften/Elements/PubSubOwnerAffiliation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/JID/JID.h> diff --git a/Swiften/Elements/PubSubOwnerAffiliations.h b/Swiften/Elements/PubSubOwnerAffiliations.h index f1085bb..2434d4e 100644 --- a/Swiften/Elements/PubSubOwnerAffiliations.h +++ b/Swiften/Elements/PubSubOwnerAffiliations.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include <vector> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubOwnerAffiliation.h> #include <Swiften/Elements/PubSubOwnerPayload.h> diff --git a/Swiften/Elements/PubSubOwnerConfigure.h b/Swiften/Elements/PubSubOwnerConfigure.h index 7dcf792..2b84753 100644 --- a/Swiften/Elements/PubSubOwnerConfigure.h +++ b/Swiften/Elements/PubSubOwnerConfigure.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -12,7 +12,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Form.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubOwnerPayload.h> diff --git a/Swiften/Elements/PubSubOwnerDefault.h b/Swiften/Elements/PubSubOwnerDefault.h index 322f47a..a17d9f3 100644 --- a/Swiften/Elements/PubSubOwnerDefault.h +++ b/Swiften/Elements/PubSubOwnerDefault.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Form.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubOwnerPayload.h> diff --git a/Swiften/Elements/PubSubOwnerDelete.h b/Swiften/Elements/PubSubOwnerDelete.h index 7cc5d79..a222e85 100644 --- a/Swiften/Elements/PubSubOwnerDelete.h +++ b/Swiften/Elements/PubSubOwnerDelete.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubOwnerPayload.h> #include <Swiften/Elements/PubSubOwnerRedirect.h> diff --git a/Swiften/Elements/PubSubOwnerPubSub.h b/Swiften/Elements/PubSubOwnerPubSub.h index f3474cf..9989cde 100644 --- a/Swiften/Elements/PubSubOwnerPubSub.h +++ b/Swiften/Elements/PubSubOwnerPubSub.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/ContainerPayload.h> #include <Swiften/Elements/PubSubOwnerPayload.h> diff --git a/Swiften/Elements/PubSubOwnerPurge.h b/Swiften/Elements/PubSubOwnerPurge.h index aca48e1..3631bd9 100644 --- a/Swiften/Elements/PubSubOwnerPurge.h +++ b/Swiften/Elements/PubSubOwnerPurge.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubOwnerPayload.h> diff --git a/Swiften/Elements/PubSubOwnerRedirect.h b/Swiften/Elements/PubSubOwnerRedirect.h index c481f98..f7deca8 100644 --- a/Swiften/Elements/PubSubOwnerRedirect.h +++ b/Swiften/Elements/PubSubOwnerRedirect.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/PubSubOwnerSubscription.h b/Swiften/Elements/PubSubOwnerSubscription.h index 6a3fcc1..cf2edd9 100644 --- a/Swiften/Elements/PubSubOwnerSubscription.h +++ b/Swiften/Elements/PubSubOwnerSubscription.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/JID/JID.h> diff --git a/Swiften/Elements/PubSubOwnerSubscriptions.h b/Swiften/Elements/PubSubOwnerSubscriptions.h index ec5aa17..d7cd8df 100644 --- a/Swiften/Elements/PubSubOwnerSubscriptions.h +++ b/Swiften/Elements/PubSubOwnerSubscriptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include <vector> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubOwnerPayload.h> #include <Swiften/Elements/PubSubOwnerSubscription.h> diff --git a/Swiften/Elements/PubSubPublish.h b/Swiften/Elements/PubSubPublish.h index dff099b..2d6d5bb 100644 --- a/Swiften/Elements/PubSubPublish.h +++ b/Swiften/Elements/PubSubPublish.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include <vector> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubItem.h> #include <Swiften/Elements/PubSubPayload.h> diff --git a/Swiften/Elements/PubSubSubscribe.h b/Swiften/Elements/PubSubSubscribe.h index a4c0b68..aaaca38 100644 --- a/Swiften/Elements/PubSubSubscribe.h +++ b/Swiften/Elements/PubSubSubscribe.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -12,7 +12,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubOptions.h> #include <Swiften/Elements/PubSubPayload.h> diff --git a/Swiften/Elements/PubSubSubscribeOptions.h b/Swiften/Elements/PubSubSubscribeOptions.h index c837787..1521427 100644 --- a/Swiften/Elements/PubSubSubscribeOptions.h +++ b/Swiften/Elements/PubSubSubscribeOptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/PubSubSubscription.h b/Swiften/Elements/PubSubSubscription.h index e2b527f..9645ebb 100644 --- a/Swiften/Elements/PubSubSubscription.h +++ b/Swiften/Elements/PubSubSubscription.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -12,7 +12,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubPayload.h> #include <Swiften/Elements/PubSubSubscribeOptions.h> diff --git a/Swiften/Elements/PubSubSubscriptions.h b/Swiften/Elements/PubSubSubscriptions.h index 441e6c1..f721bd5 100644 --- a/Swiften/Elements/PubSubSubscriptions.h +++ b/Swiften/Elements/PubSubSubscriptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,7 +13,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubPayload.h> #include <Swiften/Elements/PubSubSubscription.h> diff --git a/Swiften/Elements/PubSubUnsubscribe.h b/Swiften/Elements/PubSubUnsubscribe.h index 305af9a..c0c25bd 100644 --- a/Swiften/Elements/PubSubUnsubscribe.h +++ b/Swiften/Elements/PubSubUnsubscribe.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/PubSubPayload.h> #include <Swiften/JID/JID.h> diff --git a/Swiften/Elements/SecurityLabel.h b/Swiften/Elements/SecurityLabel.h index 748c65e..fcaa610 100644 --- a/Swiften/Elements/SecurityLabel.h +++ b/Swiften/Elements/SecurityLabel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,12 +10,12 @@ #include <vector> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { class SWIFTEN_API SecurityLabel : public Payload { public: + using ref = std::shared_ptr<SecurityLabel>; SecurityLabel(); diff --git a/Swiften/Elements/UserLocation.h b/Swiften/Elements/UserLocation.h index 3bdaec6..b59fc5c 100644 --- a/Swiften/Elements/UserLocation.h +++ b/Swiften/Elements/UserLocation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -12,7 +12,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/Elements/UserTune.h b/Swiften/Elements/UserTune.h index 7def9b9..5413085 100644 --- a/Swiften/Elements/UserTune.h +++ b/Swiften/Elements/UserTune.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Payload.h> namespace Swift { diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.h b/Swiften/FileTransfer/DefaultFileTransferTransporter.h index 339232f..1bfe799 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporter.h +++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/ErrorPayload.h> #include <Swiften/FileTransfer/FileTransferTransporter.h> @@ -48,35 +47,35 @@ namespace Swift { CryptoProvider*, IQRouter*, const FileTransferOptions&); - virtual ~DefaultFileTransferTransporter(); + virtual ~DefaultFileTransferTransporter() override; virtual void initialize(); virtual void initialize(const std::string& s5bSessionID); - virtual void startGeneratingLocalCandidates() SWIFTEN_OVERRIDE; - virtual void stopGeneratingLocalCandidates() SWIFTEN_OVERRIDE; + virtual void startGeneratingLocalCandidates() override; + virtual void stopGeneratingLocalCandidates() override; virtual void addRemoteCandidates( - const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string&) SWIFTEN_OVERRIDE; - virtual void startTryingRemoteCandidates() SWIFTEN_OVERRIDE; - virtual void stopTryingRemoteCandidates() SWIFTEN_OVERRIDE; + const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string&) override; + virtual void startTryingRemoteCandidates() override; + virtual void stopTryingRemoteCandidates() override; - virtual void startActivatingProxy(const JID& jid) SWIFTEN_OVERRIDE; - virtual void stopActivatingProxy() SWIFTEN_OVERRIDE; + virtual void startActivatingProxy(const JID& jid) override; + virtual void stopActivatingProxy() override; virtual std::shared_ptr<TransportSession> createIBBSendSession( - const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream>) SWIFTEN_OVERRIDE; + const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream>) override; virtual std::shared_ptr<TransportSession> createIBBReceiveSession( - const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream>) SWIFTEN_OVERRIDE; + const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream>) override; virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( - std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override; virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( - std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override; virtual std::shared_ptr<TransportSession> createLocalCandidateSession( - std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override; virtual std::shared_ptr<TransportSession> createLocalCandidateSession( - std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override; private: void handleLocalCandidatesGenerated(const std::vector<JingleS5BTransportPayload::Candidate>&); diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h b/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h index 3cc3455..fe4f6ea 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h +++ b/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/FileTransfer/FileTransferTransporterFactory.h> namespace Swift { @@ -31,12 +30,12 @@ namespace Swift { TimerFactory*, CryptoProvider*, IQRouter*); - virtual ~DefaultFileTransferTransporterFactory(); + virtual ~DefaultFileTransferTransporterFactory() override; virtual FileTransferTransporter* createInitiatorTransporter( - const JID& initiator, const JID& responder, const FileTransferOptions&) SWIFTEN_OVERRIDE; + const JID& initiator, const JID& responder, const FileTransferOptions&) override; virtual FileTransferTransporter* createResponderTransporter( - const JID& initiator, const JID& responder, const std::string& s5bSessionID, const FileTransferOptions&) SWIFTEN_OVERRIDE; + const JID& initiator, const JID& responder, const std::string& s5bSessionID, const FileTransferOptions&) override; private: SOCKS5BytestreamRegistry* s5bRegistry; diff --git a/Swiften/FileTransfer/FailingTransportSession.h b/Swiften/FileTransfer/FailingTransportSession.h index 6e0e16e..489786b 100644 --- a/Swiften/FileTransfer/FailingTransportSession.h +++ b/Swiften/FileTransfer/FailingTransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,10 +13,10 @@ namespace Swift { class SWIFTEN_API FailingTransportSession : public TransportSession { public: - virtual ~FailingTransportSession(); + virtual ~FailingTransportSession() override; - virtual void start() SWIFTEN_OVERRIDE; - virtual void stop() SWIFTEN_OVERRIDE; + virtual void start() override; + virtual void stop() override; }; } diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.h b/Swiften/FileTransfer/FileTransferManagerImpl.h index 026c8b7..d3d55f0 100644 --- a/Swiften/FileTransfer/FileTransferManagerImpl.h +++ b/Swiften/FileTransfer/FileTransferManagerImpl.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -22,7 +22,6 @@ #include <Swiften/Base/API.h> #include <Swiften/Base/IDGenerator.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/S5BProxyRequest.h> #include <Swiften/FileTransfer/FileTransferManager.h> #include <Swiften/FileTransfer/FileTransferOptions.h> @@ -65,14 +64,14 @@ namespace Swift { NetworkEnvironment* networkEnvironment, NATTraverser* natTraverser, CryptoProvider* crypto); - virtual ~FileTransferManagerImpl(); + virtual ~FileTransferManagerImpl() override; OutgoingFileTransfer::ref createOutgoingFileTransfer( const JID& to, const boost::filesystem::path& filepath, const std::string& description, std::shared_ptr<ReadBytestream> bytestream, - const FileTransferOptions&) SWIFTEN_OVERRIDE; + const FileTransferOptions&) override; OutgoingFileTransfer::ref createOutgoingFileTransfer( const JID& to, const std::string& filename, @@ -80,7 +79,7 @@ namespace Swift { const boost::uintmax_t sizeInBytes, const boost::posix_time::ptime& lastModified, std::shared_ptr<ReadBytestream> bytestream, - const FileTransferOptions&) SWIFTEN_OVERRIDE; + const FileTransferOptions&) override; void start(); void stop(); diff --git a/Swiften/FileTransfer/FileTransferOptions.h b/Swiften/FileTransfer/FileTransferOptions.h index 2bc4ee1..aa9aa97 100644 --- a/Swiften/FileTransfer/FileTransferOptions.h +++ b/Swiften/FileTransfer/FileTransferOptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> namespace Swift { class SWIFTEN_API FileTransferOptions { diff --git a/Swiften/FileTransfer/IBBReceiveTransportSession.h b/Swiften/FileTransfer/IBBReceiveTransportSession.h index 8b304c3..5b1fd8d 100644 --- a/Swiften/FileTransfer/IBBReceiveTransportSession.h +++ b/Swiften/FileTransfer/IBBReceiveTransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,10 +17,10 @@ namespace Swift { class SWIFTEN_API IBBReceiveTransportSession : public TransportSession { public: IBBReceiveTransportSession(std::shared_ptr<IBBReceiveSession> session); - virtual ~IBBReceiveTransportSession(); + virtual ~IBBReceiveTransportSession() override; - virtual void start() SWIFTEN_OVERRIDE; - virtual void stop() SWIFTEN_OVERRIDE; + virtual void start() override; + virtual void stop() override; private: std::shared_ptr<IBBReceiveSession> session; diff --git a/Swiften/FileTransfer/IBBSendTransportSession.h b/Swiften/FileTransfer/IBBSendTransportSession.h index d1e786b..7deaaac 100644 --- a/Swiften/FileTransfer/IBBSendTransportSession.h +++ b/Swiften/FileTransfer/IBBSendTransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,10 +17,10 @@ namespace Swift { class SWIFTEN_API IBBSendTransportSession : public TransportSession { public: IBBSendTransportSession(std::shared_ptr<IBBSendSession> session); - virtual ~IBBSendTransportSession(); + virtual ~IBBSendTransportSession() override; - virtual void start() SWIFTEN_OVERRIDE; - virtual void stop() SWIFTEN_OVERRIDE; + virtual void start() override; + virtual void stop() override; private: std::shared_ptr<IBBSendSession> session; diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.h b/Swiften/FileTransfer/IncomingJingleFileTransfer.h index 7ddf700..f42004d 100644 --- a/Swiften/FileTransfer/IncomingJingleFileTransfer.h +++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.h @@ -13,7 +13,6 @@ #include <Swiften/Base/API.h> #include <Swiften/Base/ByteArray.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/JingleS5BTransportPayload.h> #include <Swiften/FileTransfer/FileTransferOptions.h> #include <Swiften/FileTransfer/IncomingFileTransfer.h> @@ -49,10 +48,10 @@ namespace Swift { FileTransferTransporterFactory*, TimerFactory*, CryptoProvider*); - virtual ~IncomingJingleFileTransfer(); + virtual ~IncomingJingleFileTransfer() override; - virtual void accept(std::shared_ptr<WriteBytestream>, const FileTransferOptions& = FileTransferOptions()) SWIFTEN_OVERRIDE; - virtual void cancel() SWIFTEN_OVERRIDE; + virtual void accept(std::shared_ptr<WriteBytestream>, const FileTransferOptions& = FileTransferOptions()) override; + virtual void cancel() override; private: enum State { @@ -68,44 +67,44 @@ namespace Swift { }; virtual void handleSessionTerminateReceived( - boost::optional<JinglePayload::Reason> reason) SWIFTEN_OVERRIDE; - virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) SWIFTEN_OVERRIDE; + boost::optional<JinglePayload::Reason> reason) override; + virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) override; virtual void handleTransportReplaceReceived( - const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; + const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override; virtual void handleLocalTransportCandidatesGenerated( const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>&, - const std::string& dstAddr) SWIFTEN_OVERRIDE; + const std::string& dstAddr) override; void handleWriteStreamDataReceived(const std::vector<unsigned char>& data); void stopActiveTransport(); void checkCandidateSelected(); - virtual JingleContentID getContentID() const SWIFTEN_OVERRIDE; + virtual JingleContentID getContentID() const override; void checkIfAllDataReceived(); bool verifyData(); void handleWaitOnHashTimerTicked(); void handleTransferFinished(boost::optional<FileTransferError>); private: - virtual void startTransferViaRemoteCandidate() SWIFTEN_OVERRIDE; - virtual void startTransferViaLocalCandidate() SWIFTEN_OVERRIDE; + virtual void startTransferViaRemoteCandidate() override; + virtual void startTransferViaLocalCandidate() override; void checkHashAndTerminate(); void stopAll(); void setState(State state); void setFinishedState(FileTransfer::State::Type, const boost::optional<FileTransferError>& error); - const JID& getSender() const SWIFTEN_OVERRIDE; - const JID& getRecipient() const SWIFTEN_OVERRIDE; + const JID& getSender() const override; + const JID& getRecipient() const override; static FileTransfer::State::Type getExternalState(State state); - virtual bool hasPriorityOnCandidateTie() const SWIFTEN_OVERRIDE; - virtual void fallback() SWIFTEN_OVERRIDE; - virtual void startTransferring(std::shared_ptr<TransportSession>) SWIFTEN_OVERRIDE; - virtual bool isWaitingForPeerProxyActivate() const SWIFTEN_OVERRIDE; - virtual bool isWaitingForLocalProxyActivate() const SWIFTEN_OVERRIDE; - virtual bool isTryingCandidates() const SWIFTEN_OVERRIDE; - virtual std::shared_ptr<TransportSession> createLocalCandidateSession() SWIFTEN_OVERRIDE; - virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() SWIFTEN_OVERRIDE; - virtual void terminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE; + virtual bool hasPriorityOnCandidateTie() const override; + virtual void fallback() override; + virtual void startTransferring(std::shared_ptr<TransportSession>) override; + virtual bool isWaitingForPeerProxyActivate() const override; + virtual bool isWaitingForLocalProxyActivate() const override; + virtual bool isTryingCandidates() const override; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession() override; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() override; + virtual void terminate(JinglePayload::Reason::Type reason) override; private: diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h index 2159063..8c53d16 100644 --- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h +++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,7 +17,6 @@ #include <boost/signals2.hpp> #include <Swiften/Base/IDGenerator.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/JingleS5BTransportPayload.h> #include <Swiften/FileTransfer/FileTransferOptions.h> #include <Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h> diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h index 9fd1d76..6db4e40 100644 --- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h +++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h @@ -17,7 +17,6 @@ #include <boost/optional/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/JingleFileTransferFileInfo.h> #include <Swiften/FileTransfer/FileTransferOptions.h> #include <Swiften/FileTransfer/JingleFileTransfer.h> @@ -46,10 +45,10 @@ namespace Swift { const JingleFileTransferFileInfo&, const FileTransferOptions&, CryptoProvider*); - virtual ~OutgoingJingleFileTransfer(); + virtual ~OutgoingJingleFileTransfer() override; - virtual void start() SWIFTEN_OVERRIDE; - virtual void cancel() SWIFTEN_OVERRIDE; + virtual void start() override; + virtual void cancel() override; private: enum State { @@ -66,34 +65,34 @@ namespace Swift { Finished }; - virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) SWIFTEN_OVERRIDE; - virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleTransportRejectReceived(const JingleContentID &, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void startTransferViaRemoteCandidate() SWIFTEN_OVERRIDE; - virtual void startTransferViaLocalCandidate() SWIFTEN_OVERRIDE; + virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) override; + virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) override; + virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override; + virtual void handleTransportRejectReceived(const JingleContentID &, std::shared_ptr<JingleTransportPayload>) override; + virtual void startTransferViaRemoteCandidate() override; + virtual void startTransferViaLocalCandidate() override; void startTransferringIfCandidateAcknowledged(); - virtual void handleLocalTransportCandidatesGenerated(const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string& dstAddr) SWIFTEN_OVERRIDE; - virtual void handleTransportInfoAcknowledged(const std::string& id) SWIFTEN_OVERRIDE; + virtual void handleLocalTransportCandidatesGenerated(const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string& dstAddr) override; + virtual void handleTransportInfoAcknowledged(const std::string& id) override; - virtual JingleContentID getContentID() const SWIFTEN_OVERRIDE; + virtual JingleContentID getContentID() const override; - virtual void terminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE; + virtual void terminate(JinglePayload::Reason::Type reason) override; - virtual void fallback() SWIFTEN_OVERRIDE; + virtual void fallback() override; void handleTransferFinished(boost::optional<FileTransferError>); void sendSessionInfoHash(); - virtual void startTransferring(std::shared_ptr<TransportSession>) SWIFTEN_OVERRIDE; + virtual void startTransferring(std::shared_ptr<TransportSession>) override; - virtual bool hasPriorityOnCandidateTie() const SWIFTEN_OVERRIDE; - virtual bool isWaitingForPeerProxyActivate() const SWIFTEN_OVERRIDE; - virtual bool isWaitingForLocalProxyActivate() const SWIFTEN_OVERRIDE; - virtual bool isTryingCandidates() const SWIFTEN_OVERRIDE; - virtual std::shared_ptr<TransportSession> createLocalCandidateSession() SWIFTEN_OVERRIDE; - virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() SWIFTEN_OVERRIDE; + virtual bool hasPriorityOnCandidateTie() const override; + virtual bool isWaitingForPeerProxyActivate() const override; + virtual bool isWaitingForLocalProxyActivate() const override; + virtual bool isTryingCandidates() const override; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession() override; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() override; void handleWaitForRemoteTerminationTimeout(); diff --git a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h index c4257f6..c205516 100644 --- a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h +++ b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -18,7 +18,6 @@ #include <queue> #include <vector> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/JingleS5BTransportPayload.h> #include <Swiften/FileTransfer/FileTransferOptions.h> #include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h> diff --git a/Swiften/FileTransfer/S5BTransportSession.h b/Swiften/FileTransfer/S5BTransportSession.h index 3e064fa..fd92f2e 100644 --- a/Swiften/FileTransfer/S5BTransportSession.h +++ b/Swiften/FileTransfer/S5BTransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -35,10 +35,10 @@ class SWIFTEN_API S5BTransportSession : public TransportSession { initialize(); } - virtual ~S5BTransportSession() { + virtual ~S5BTransportSession() override { } - virtual void start() SWIFTEN_OVERRIDE { + virtual void start() override { if (readStream) { session->startSending(readStream); } @@ -47,7 +47,7 @@ class SWIFTEN_API S5BTransportSession : public TransportSession { } } - virtual void stop() SWIFTEN_OVERRIDE { + virtual void stop() override { session->stop(); } diff --git a/Swiften/FileTransfer/TransportSession.h b/Swiften/FileTransfer/TransportSession.h index dc6e59a..2d56517 100644 --- a/Swiften/FileTransfer/TransportSession.h +++ b/Swiften/FileTransfer/TransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <boost/signals2.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/FileTransfer/FileTransferError.h> namespace Swift { diff --git a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h index 03e2476..6119658 100644 --- a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h +++ b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,7 +17,6 @@ #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/filesystem/path.hpp> -#include <Swiften/Base/Override.h> #include <Swiften/FileTransfer/FileTransferManager.h> namespace Swift { @@ -34,7 +33,7 @@ namespace Swift { const boost::filesystem::path&, const std::string&, std::shared_ptr<ReadBytestream>, - const FileTransferOptions&) SWIFTEN_OVERRIDE { + const FileTransferOptions&) override { return OutgoingFileTransfer::ref(); } @@ -45,7 +44,7 @@ namespace Swift { const boost::uintmax_t, const boost::posix_time::ptime&, std::shared_ptr<ReadBytestream>, - const FileTransferOptions&) SWIFTEN_OVERRIDE { + const FileTransferOptions&) override { return OutgoingFileTransfer::ref(); } diff --git a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp index 72b933d..9793b87 100644 --- a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp +++ b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -18,7 +18,6 @@ #include <Swiften/Base/ByteArray.h> #include <Swiften/Base/Log.h> -#include <Swiften/Base/Override.h> #include <Swiften/Client/DummyStanzaChannel.h> #include <Swiften/Crypto/CryptoProvider.h> #include <Swiften/Crypto/PlatformCryptoProvider.h> diff --git a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp index 3f4d20f..a0fe057 100644 --- a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp +++ b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -21,7 +21,6 @@ #include <Swiften/Base/ByteArray.h> #include <Swiften/Base/IDGenerator.h> -#include <Swiften/Base/Override.h> #include <Swiften/Client/DummyStanzaChannel.h> #include <Swiften/Crypto/CryptoProvider.h> #include <Swiften/Crypto/PlatformCryptoProvider.h> diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp index 290dda5..80667b6 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp @@ -59,8 +59,8 @@ public: crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); destination = "092a44d859d19c9eed676b551ee80025903351c2"; randomGen.seed(static_cast<unsigned int>(time(nullptr))); - eventLoop = std::unique_ptr<DummyEventLoop>(new DummyEventLoop()); - timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory()); + eventLoop = std::make_unique<DummyEventLoop>(); + timerFactory = std::make_unique<DummyTimerFactory>(); connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop.get()); //connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1)); //stream1 = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"))); diff --git a/Swiften/IDN/ICUConverter.h b/Swiften/IDN/ICUConverter.h index 0a0b0d3..b0f5d85 100644 --- a/Swiften/IDN/ICUConverter.h +++ b/Swiften/IDN/ICUConverter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,15 +9,14 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/IDN/IDNConverter.h> namespace Swift { class SWIFTEN_API ICUConverter : public IDNConverter { public: - virtual std::string getStringPrepared(const std::string& s, StringPrepProfile profile) SWIFTEN_OVERRIDE; - virtual SafeByteArray getStringPrepared(const SafeByteArray& s, StringPrepProfile profile) SWIFTEN_OVERRIDE; + virtual std::string getStringPrepared(const std::string& s, StringPrepProfile profile) override; + virtual SafeByteArray getStringPrepared(const SafeByteArray& s, StringPrepProfile profile) override; - virtual boost::optional<std::string> getIDNAEncoded(const std::string& s) SWIFTEN_OVERRIDE; + virtual boost::optional<std::string> getIDNAEncoded(const std::string& s) override; }; } diff --git a/Swiften/IDN/LibIDNConverter.h b/Swiften/IDN/LibIDNConverter.h index 3f1d1f7..5553ab3 100644 --- a/Swiften/IDN/LibIDNConverter.h +++ b/Swiften/IDN/LibIDNConverter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,16 +9,15 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/IDN/IDNConverter.h> namespace Swift { class SWIFTEN_API LibIDNConverter : public IDNConverter { public: - virtual std::string getStringPrepared(const std::string& s, StringPrepProfile profile) SWIFTEN_OVERRIDE; - virtual SafeByteArray getStringPrepared(const SafeByteArray& s, StringPrepProfile profile) SWIFTEN_OVERRIDE; + virtual std::string getStringPrepared(const std::string& s, StringPrepProfile profile) override; + virtual SafeByteArray getStringPrepared(const SafeByteArray& s, StringPrepProfile profile) override; - virtual boost::optional<std::string> getIDNAEncoded(const std::string& s) SWIFTEN_OVERRIDE; + virtual boost::optional<std::string> getIDNAEncoded(const std::string& s) override; }; } diff --git a/Swiften/Jingle/AbstractJingleSessionListener.h b/Swiften/Jingle/AbstractJingleSessionListener.h index 590cd14..dd8bd1e 100644 --- a/Swiften/Jingle/AbstractJingleSessionListener.h +++ b/Swiften/Jingle/AbstractJingleSessionListener.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,20 +7,19 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Jingle/JingleSessionListener.h> namespace Swift { class SWIFTEN_API AbstractJingleSessionListener : public JingleSessionListener { public: - virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) SWIFTEN_OVERRIDE; - virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) SWIFTEN_OVERRIDE; - virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleTransportInfoReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleTransportRejectReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleTransportReplaceReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleTransportInfoAcknowledged(const std::string& id) SWIFTEN_OVERRIDE; + virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) override; + virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) override; + virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) override; + virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override; + virtual void handleTransportInfoReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override; + virtual void handleTransportRejectReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override; + virtual void handleTransportReplaceReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override; + virtual void handleTransportInfoAcknowledged(const std::string& id) override; }; } diff --git a/Swiften/Jingle/FakeJingleSession.h b/Swiften/Jingle/FakeJingleSession.h index 6218544..0ed97d5 100644 --- a/Swiften/Jingle/FakeJingleSession.h +++ b/Swiften/Jingle/FakeJingleSession.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -20,7 +20,6 @@ #include <boost/variant.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Base/SimpleIDGenerator.h> #include <Swiften/Elements/JinglePayload.h> #include <Swiften/JID/JID.h> @@ -86,16 +85,16 @@ namespace Swift { typedef std::shared_ptr<FakeJingleSession> ref; FakeJingleSession(const JID& initiator, const std::string& id); - virtual ~FakeJingleSession(); - - virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref) SWIFTEN_OVERRIDE; - virtual void sendTerminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE; - virtual void sendInfo(std::shared_ptr<Payload>) SWIFTEN_OVERRIDE; - virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref = JingleTransportPayload::ref()) SWIFTEN_OVERRIDE; - virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE; - virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE; - virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE; - virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE; + virtual ~FakeJingleSession() override; + + virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref) override; + virtual void sendTerminate(JinglePayload::Reason::Type reason) override; + virtual void sendInfo(std::shared_ptr<Payload>) override; + virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref = JingleTransportPayload::ref()) override; + virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref) override; + virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref) override; + virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref) override; + virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref) override; void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>); void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>); diff --git a/Swiften/MIX/MIX.cpp b/Swiften/MIX/MIX.cpp new file mode 100644 index 0000000..f3e3d69 --- /dev/null +++ b/Swiften/MIX/MIX.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/MIX/MIX.h> + +namespace Swift { + +MIX::~MIX() { +} + +} diff --git a/Swiften/MIX/MIX.h b/Swiften/MIX/MIX.h new file mode 100644 index 0000000..1398a6e --- /dev/null +++ b/Swiften/MIX/MIX.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <memory> +#include <string> +#include <unordered_set> + +#include <boost/signals2.hpp> + +#include <Swiften/Base/API.h> +#include <Swiften/JID/JID.h> +#include <Swiften/Elements/Form.h> +#include <Swiften/Elements/MIXJoin.h> +#include <Swiften/Elements/MIXLeave.h> +#include <Swiften/Elements/MIXUpdateSubscription.h> +#include <Swiften/Elements/MIXUserPreference.h> +#include <Swiften/Elements/ErrorPayload.h> + +namespace Swift { + class SWIFTEN_API MIX { + public: + using ref = std::shared_ptr<MIX>; + + public: + virtual ~MIX(); + + /** + * Join a MIX channel and subscribe to nodes. + */ + virtual void joinChannel(const std::unordered_set<std::string>& nodes) = 0; + + /** + * Join Channel with a set of preferences. + */ + virtual void joinChannelWithPreferences(const std::unordered_set<std::string>& nodes, Form::ref form) = 0; + + /** + * Update subscription of nodes. + */ + virtual void updateSubscription(const std::unordered_set<std::string>& nodes) = 0; + + /** + * Leave a MIX channel and unsubcribe nodes. + */ + virtual void leaveChannel() = 0; + + /** + * Request a configuration form for updating preferences. + */ + virtual void requestPreferencesForm() = 0; + + /** + * Update preferences after requesting preference form. + */ + virtual void updatePreferences(Form::ref form) = 0; + + public: + boost::signals2::signal<void (MIXJoin::ref /* joinResponse */, ErrorPayload::ref /* joinError */)> onJoinResponse; + boost::signals2::signal<void (MIXLeave::ref /* leaveResponse */, ErrorPayload::ref /* leaveError */)> onLeaveResponse; + boost::signals2::signal<void (MIXUpdateSubscription::ref /* updateResponse */, ErrorPayload::ref /* updateError */)> onSubscriptionUpdateResponse; + boost::signals2::signal<void (Form::ref /* preferencesForm */, ErrorPayload::ref /* failedConfiguration */)> onPreferencesFormResponse; + boost::signals2::signal<void (MIXUserPreference::ref /* userPreferenceResponse */, ErrorPayload::ref /* failedUpdate */)> onPreferencesUpdateResponse; + }; +} diff --git a/Swiften/MIX/MIXImpl.cpp b/Swiften/MIX/MIXImpl.cpp new file mode 100644 index 0000000..cd3eb21 --- /dev/null +++ b/Swiften/MIX/MIXImpl.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/MIX/MIXImpl.h> + +#include <Swiften/Client/StanzaChannel.h> +#include <Swiften/Elements/IQ.h> +#include <Swiften/Queries/GenericRequest.h> +#include <Swiften/Queries/IQRouter.h> + +namespace Swift { + +MIXImpl::MIXImpl(const JID& ownJID, const JID& channelJID, IQRouter* iqRouter) : ownJID_(ownJID), channelJID_(channelJID), iqRouter_(iqRouter) { + +} + +MIXImpl::~MIXImpl() { + +} + +void MIXImpl::joinChannel(const std::unordered_set<std::string>& nodes) { + joinChannelWithPreferences(nodes, nullptr); +} + +void MIXImpl::joinChannelWithPreferences(const std::unordered_set<std::string>& nodes, Form::ref form) { + auto joinPayload = std::make_shared<MIXJoin>(); + joinPayload->setChannel(channelJID_); + for (auto node : nodes) { + joinPayload->addSubscription(node); + } + if (form) { + joinPayload->setForm(form); + } + auto request = std::make_shared<GenericRequest<MIXJoin>>(IQ::Set, getJID(), joinPayload, iqRouter_); + request->onResponse.connect(boost::bind(&MIXImpl::handleJoinResponse, this, _1, _2)); + request->send(); +} + +void MIXImpl::handleJoinResponse(MIXJoin::ref payload, ErrorPayload::ref error) { + onJoinResponse(payload, error); +} + +void MIXImpl::updateSubscription(const std::unordered_set<std::string>& nodes) { + auto updateSubscriptionPayload = std::make_shared<MIXUpdateSubscription>(); + updateSubscriptionPayload->setSubscriptions(nodes); + auto request = std::make_shared<GenericRequest<MIXUpdateSubscription>>(IQ::Set, channelJID_, updateSubscriptionPayload, iqRouter_); + request->onResponse.connect(boost::bind(&MIXImpl::handleUpdateSubscriptionResponse, this, _1, _2)); + request->send(); +} + +void MIXImpl::handleUpdateSubscriptionResponse(MIXUpdateSubscription::ref payload, ErrorPayload::ref error) { + onSubscriptionUpdateResponse(payload, error); +} + +void MIXImpl::leaveChannel() { + auto leavePayload = std::make_shared<MIXLeave>(); + leavePayload->setChannel(channelJID_); + auto request = std::make_shared<GenericRequest<MIXLeave>>(IQ::Set, getJID(), leavePayload, iqRouter_); + request->onResponse.connect(boost::bind(&MIXImpl::handleLeaveResponse, this, _1, _2)); + request->send(); +} + +void MIXImpl::handleLeaveResponse(MIXLeave::ref payload, ErrorPayload::ref error) { + onLeaveResponse(payload, error); +} + +void MIXImpl::requestPreferencesForm() { + auto prefPayload = std::make_shared<MIXUserPreference>(); + auto request = std::make_shared<GenericRequest<MIXUserPreference>>(IQ::Get, channelJID_, prefPayload, iqRouter_); + request->onResponse.connect(boost::bind(&MIXImpl::handlePreferencesFormReceived, this, _1, _2)); + request->send(); +} + +void MIXImpl::handlePreferencesFormReceived(MIXUserPreference::ref payload, ErrorPayload::ref error) { + Form::ref form = nullptr; + if (payload) { + form = payload->getData(); + } + onPreferencesFormResponse(form, error); +} + +void MIXImpl::handlePreferencesResultReceived(MIXUserPreference::ref payload, ErrorPayload::ref error) { + onPreferencesUpdateResponse(payload, error); +} + +void MIXImpl::updatePreferences(Form::ref form) { + auto prefPayload = std::make_shared<MIXUserPreference>(); + prefPayload->setData(form); + auto request = std::make_shared<GenericRequest<MIXUserPreference>>(IQ::Set, channelJID_, prefPayload, iqRouter_); + request->onResponse.connect(boost::bind(&MIXImpl::handlePreferencesResultReceived, this, _1, _2)); + request->send(); +} + +} diff --git a/Swiften/MIX/MIXImpl.h b/Swiften/MIX/MIXImpl.h new file mode 100644 index 0000000..58b33f4 --- /dev/null +++ b/Swiften/MIX/MIXImpl.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <Swiften/MIX/MIX.h> + +namespace Swift { + class StanzaChannel; + class IQRouter; + + class SWIFTEN_API MIXImpl : public MIX { + public: + using ref = std::shared_ptr<MIXImpl>; + + public: + MIXImpl(const JID& ownJID, const JID& channelJID, IQRouter* iqRouter); + virtual ~MIXImpl(); + + /** + * Returns the (bare) JID of the user. + */ + virtual JID getJID() const { + return ownJID_.toBare(); + } + + /** + * Returns the JID of MIX channel. + */ + virtual JID getChannelJID() const { + return channelJID_; + } + + virtual void joinChannel(const std::unordered_set<std::string>& nodes) override; + + virtual void joinChannelWithPreferences(const std::unordered_set<std::string>& nodes, Form::ref form) override; + + virtual void updateSubscription(const std::unordered_set<std::string>& nodes) override; + + virtual void leaveChannel() override; + + virtual void requestPreferencesForm() override; + + virtual void updatePreferences(Form::ref form) override; + + private: + void handleJoinResponse(MIXJoin::ref, ErrorPayload::ref); + void handleLeaveResponse(MIXLeave::ref, ErrorPayload::ref); + void handleUpdateSubscriptionResponse(MIXUpdateSubscription::ref, ErrorPayload::ref); + void handlePreferencesFormReceived(MIXUserPreference::ref, ErrorPayload::ref); + void handlePreferencesResultReceived(MIXUserPreference::ref /*payload*/, ErrorPayload::ref error); + + private: + JID ownJID_; + JID channelJID_; + IQRouter* iqRouter_; + }; +} diff --git a/Swiften/MIX/UnitTest/MIXImplTest.cpp b/Swiften/MIX/UnitTest/MIXImplTest.cpp new file mode 100644 index 0000000..05dde17 --- /dev/null +++ b/Swiften/MIX/UnitTest/MIXImplTest.cpp @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <boost/bind.hpp> + +#include <Swiften/Elements/FormField.h> +#include <Swiften/Client/DummyStanzaChannel.h> +#include <Swiften/MIX/MIXImpl.h> +#include <Swiften/Queries/IQRouter.h> + +using namespace Swift; + +class MIXImplTest : public ::testing::Test { + + protected: + void SetUp() { + ownJID_ = JID("hag66@shakespeare.example/UUID-a1j/7533"); + channelJID_ = JID("coven@mix.shakespeare.example"); + channel_ = new DummyStanzaChannel(); + router_ = new IQRouter(channel_); + successfulJoins_ = 0; + } + + void TearDown() { + delete router_; + delete channel_; + } + + MIX::ref createMIXClient() { + auto mix = std::make_shared<MIXImpl>(ownJID_, channelJID_, router_); + mix->onJoinResponse.connect(boost::bind(&MIXImplTest::handleJoin, this, _1, _2)); + mix->onLeaveResponse.connect(boost::bind(&MIXImplTest::handleLeave, this, _1, _2)); + mix->onSubscriptionUpdateResponse.connect(boost::bind(&MIXImplTest::handleSubscriptionUpdate, this, _1, _2)); + mix->onPreferencesFormResponse.connect(boost::bind(&MIXImplTest::handlePreferencesForm, this, _1, _2)); + return mix; + } + + void handleJoin(MIXJoin::ref joinPayload, ErrorPayload::ref error) { + if (joinPayload) { + ASSERT_FALSE(error); + ASSERT_TRUE(joinPayload->getJID()); + ASSERT_EQ(*joinPayload->getJID(), JID("123456#coven@mix.shakespeare.example")); + if (joinPayload->getForm()) { + preferenceForm_ = joinPayload->getForm(); + } + ++successfulJoins_; + subscribedNodes_ = joinPayload->getSubscriptions(); + } + } + + void handleLeave(MIXLeave::ref leavePayload, ErrorPayload::ref error) { + ASSERT_TRUE(leavePayload); + ASSERT_FALSE(error); + ASSERT_EQ(static_cast<int>(0), subscribedNodes_.size()); + } + + void handleSubscriptionUpdate(MIXUpdateSubscription::ref payload, ErrorPayload::ref error) { + ASSERT_TRUE(payload); + ASSERT_FALSE(error); + if (payload) { + for (auto node : payload->getSubscriptions()) { + subscribedNodes_.insert(node); + } + } + } + + void handlePreferencesForm(Form::ref form, ErrorPayload::ref error) { + ASSERT_FALSE(error); + if (form) { + preferenceForm_ = form; + } + } + + IQ::ref createJoinResult(const std::unordered_set<std::string>& nodes, Form::ref form) { + auto joinResultPayload = std::make_shared<MIXJoin>(); + for (auto node : nodes) { + joinResultPayload->addSubscription(node); + } + if (form) { + joinResultPayload->setForm(form); + } + joinResultPayload->setJID(JID("123456#coven@mix.shakespeare.example")); + return IQ::createResult(ownJID_, channel_->sentStanzas[0]->getTo(), channel_->sentStanzas[0]->getID(), joinResultPayload); + } + + IQ::ref createLeaveResult() { + auto leaveResultPayload = std::make_shared<MIXLeave>(); + return IQ::createResult(ownJID_, channel_->sentStanzas[0]->getTo(), channel_->sentStanzas[0]->getID(), leaveResultPayload); + } + + IQ::ref createError() { + return IQ::createError(ownJID_, channel_->sentStanzas[0]->getTo(), channel_->sentStanzas[0]->getID()); + } + + bool hasSubscription(const std::string& value) { + return std::find(subscribedNodes_.begin(), subscribedNodes_.end(), value) != subscribedNodes_.end(); + } + + JID ownJID_; + JID channelJID_; + DummyStanzaChannel* channel_; + IQRouter* router_; + int successfulJoins_; + Form::ref preferenceForm_; + std::unordered_set<std::string> subscribedNodes_; +}; + +TEST_F(MIXImplTest, testJoinError) { + MIX::ref testling = createMIXClient(); + testling->joinChannel(std::unordered_set<std::string>()); + + ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size())); + ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set)); + + auto iq = channel_->getStanzaAtIndex<IQ>(0); + ASSERT_TRUE(iq); + ASSERT_TRUE(iq->getPayload<MIXJoin>()); + ASSERT_FALSE(iq->getPayload<MIXJoin>()->getForm()); + ASSERT_EQ(static_cast<size_t>(0), iq->getPayload<MIXJoin>()->getSubscriptions().size()); + + channel_->onIQReceived(createError()); + ASSERT_EQ(static_cast<int>(0), successfulJoins_); + ASSERT_EQ(static_cast<int>(0), subscribedNodes_.size()); +} + +TEST_F(MIXImplTest, testJoinWithAllSubscriptions) { + MIX::ref testling = createMIXClient(); + std::unordered_set<std::string> nodes; + nodes.insert(std::string("urn:xmpp:mix:nodes:messages")); + nodes.insert(std::string("urn:xmpp:mix:nodes:presence")); + nodes.insert(std::string("urn:xmpp:mix:nodes:participants")); + nodes.insert(std::string("urn:xmpp:mix:nodes:config")); + + testling->joinChannel(nodes); + + ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size())); + ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set)); + + auto iq = channel_->getStanzaAtIndex<IQ>(0); + ASSERT_TRUE(iq); + ASSERT_TRUE(iq->getPayload<MIXJoin>()); + ASSERT_FALSE(iq->getPayload<MIXJoin>()->getForm()); + ASSERT_EQ(static_cast<size_t>(4), iq->getPayload<MIXJoin>()->getSubscriptions().size()); + + channel_->onIQReceived(createJoinResult(nodes, nullptr)); + ASSERT_EQ(static_cast<int>(1), successfulJoins_); + ASSERT_EQ(static_cast<int>(4), subscribedNodes_.size()); +} + +TEST_F(MIXImplTest, testJoinWithSomeSubscriptions) { + MIX::ref testling = createMIXClient(); + std::unordered_set<std::string> nodes; + nodes.insert(std::string("urn:xmpp:mix:nodes:messages")); + nodes.insert(std::string("urn:xmpp:mix:nodes:presence")); + nodes.insert(std::string("urn:xmpp:mix:nodes:participants")); + nodes.insert(std::string("urn:xmpp:mix:nodes:config")); + + testling->joinChannel(nodes); + + ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size())); + ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set)); + + auto iq = channel_->getStanzaAtIndex<IQ>(0); + ASSERT_TRUE(iq); + ASSERT_TRUE(iq->getPayload<MIXJoin>()); + ASSERT_FALSE(iq->getPayload<MIXJoin>()->getForm()); + ASSERT_EQ(static_cast<size_t>(4), iq->getPayload<MIXJoin>()->getSubscriptions().size()); + + std::unordered_set<std::string> subscribedTo; + subscribedTo.insert(std::string("urn:xmpp:mix:nodes:messages")); + + channel_->onIQReceived(createJoinResult(subscribedTo, nullptr)); + ASSERT_EQ(static_cast<int>(1), successfulJoins_); + ASSERT_EQ(static_cast<int>(1), subscribedNodes_.size()); + ASSERT_TRUE(hasSubscription(std::string("urn:xmpp:mix:nodes:messages"))); +} + +TEST_F(MIXImplTest, testLeaveChannel) { + MIX::ref testling = createMIXClient(); + testling->leaveChannel(); + ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size())); + ASSERT_TRUE(channel_->isRequestAtIndex<MIXLeave>(0, ownJID_.toBare(), IQ::Set)); + + auto iq = channel_->getStanzaAtIndex<IQ>(0); + ASSERT_TRUE(iq); + ASSERT_TRUE(iq->getPayload<MIXLeave>()); + ASSERT_TRUE(iq->getPayload<MIXLeave>()->getChannel()); + + channel_->onIQReceived(createLeaveResult()); +} + +TEST_F(MIXImplTest, testUpdateSubscription) { + MIX::ref testling = createMIXClient(); + std::unordered_set<std::string> nodes; + nodes.insert(std::string("urn:xmpp:mix:nodes:messages")); + nodes.insert(std::string("urn:xmpp:mix:nodes:presence")); + + testling->joinChannel(nodes); + + ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size())); + ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set)); + + channel_->onIQReceived(createJoinResult(nodes, nullptr)); + ASSERT_EQ(static_cast<int>(1), successfulJoins_); + ASSERT_EQ(static_cast<int>(2), subscribedNodes_.size()); + + nodes.clear(); + nodes.insert(std::string("urn:xmpp:mix:nodes:participants")); + nodes.insert(std::string("urn:xmpp:mix:nodes:config")); + + testling->updateSubscription(nodes); + + ASSERT_EQ(2, static_cast<int>(channel_->sentStanzas.size())); + ASSERT_TRUE(channel_->isRequestAtIndex<MIXUpdateSubscription>(1, channelJID_, IQ::Set)); + + // fake response + auto subscriptionUpdate = std::make_shared<MIXUpdateSubscription>(); + subscriptionUpdate->setSubscriptions(nodes); + subscriptionUpdate->setJID(JID("hag66@shakespeare.example")); + auto response = IQ::createResult(ownJID_, channel_->sentStanzas[1]->getTo(), channel_->sentStanzas[1]->getID(), subscriptionUpdate); + + channel_->onIQReceived(response); + ASSERT_EQ(static_cast<int>(4), subscribedNodes_.size()); + ASSERT_TRUE(hasSubscription(std::string("urn:xmpp:mix:nodes:participants"))); + ASSERT_TRUE(hasSubscription(std::string("urn:xmpp:mix:nodes:config"))); + ASSERT_TRUE(hasSubscription(std::string("urn:xmpp:mix:nodes:messages"))); +} + +TEST_F(MIXImplTest, testJoinWithPreference) { + MIX::ref testling = createMIXClient(); + std::unordered_set<std::string> nodes; + nodes.insert(std::string("urn:xmpp:mix:nodes:messages")); + nodes.insert(std::string("urn:xmpp:mix:nodes:presence")); + + auto parameters = std::make_shared<Form>(); + parameters->setType(Form::Type::SubmitType); + + auto fieldType = std::make_shared<FormField>(FormField::HiddenType); + fieldType->setName("FORM_TYPE"); + fieldType->addValue("urn:xmpp:mix:0"); + parameters->addField(fieldType); + + auto fieldJIDVisibility = std::make_shared<FormField>(); + fieldJIDVisibility->setName("JID Visibility"); + fieldJIDVisibility->addValue("never"); + parameters->addField(fieldJIDVisibility); + + testling->joinChannelWithPreferences(nodes, parameters); + + ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size())); + ASSERT_TRUE(channel_->isRequestAtIndex<MIXJoin>(0, ownJID_.toBare(), IQ::Set)); + + //fake response + auto responseForm = std::make_shared<Form>(); + responseForm->setType(Form::Type::ResultType); + + auto fieldTypeResponse = std::make_shared<FormField>(FormField::HiddenType); + fieldTypeResponse->setName("FORM_TYPE"); + fieldTypeResponse->addValue("urn:xmpp:mix:0"); + responseForm->addField(fieldTypeResponse); + + auto fieldJIDVisibilityResponse = std::make_shared<FormField>(); + fieldJIDVisibilityResponse->setName("JID Visibility"); + fieldJIDVisibilityResponse->addValue("never"); + responseForm->addField(fieldJIDVisibilityResponse); + + auto fieldprivateMessagesResponse = std::make_shared<FormField>(); + fieldprivateMessagesResponse->setName("Private Messages"); + fieldprivateMessagesResponse->addValue("allow"); + responseForm->addField(fieldprivateMessagesResponse); + + auto vCardResponse = std::make_shared<FormField>(); + vCardResponse->setName("vCard"); + vCardResponse->addValue("block"); + responseForm->addField(vCardResponse); + + channel_->onIQReceived(createJoinResult(nodes, responseForm)); + ASSERT_EQ(static_cast<int>(1), successfulJoins_); + ASSERT_EQ(static_cast<int>(2), subscribedNodes_.size()); + ASSERT_TRUE(preferenceForm_); + + ASSERT_TRUE(preferenceForm_->getField("JID Visibility")); + ASSERT_EQ(std::string("never"), preferenceForm_->getField("JID Visibility")->getTextSingleValue()); +} + +TEST_F(MIXImplTest, preferenceFormRequest) { + MIX::ref testling = createMIXClient(); + testling->requestPreferencesForm(); + + ASSERT_EQ(1, static_cast<int>(channel_->sentStanzas.size())); + ASSERT_TRUE(channel_->isRequestAtIndex<MIXUserPreference>(0, channelJID_, IQ::Get)); + + //fake response + auto responseForm = std::make_shared<Form>(); + responseForm->setType(Form::Type::FormType); + + auto fieldTypeResponse = std::make_shared<FormField>(FormField::HiddenType); + fieldTypeResponse->setName("FORM_TYPE"); + fieldTypeResponse->addValue("urn:xmpp:mix:0"); + responseForm->addField(fieldTypeResponse); + + auto preferenceResponse = std::make_shared<MIXUserPreference>(); + preferenceResponse->setData(responseForm); + + channel_->onIQReceived(IQ::createResult(ownJID_, channel_->sentStanzas[0]->getTo(), channel_->sentStanzas[0]->getID(), preferenceResponse)); + ASSERT_TRUE(preferenceForm_); +} diff --git a/Swiften/Network/BoostNetworkFactories.h b/Swiften/Network/BoostNetworkFactories.h index 72afb04..2bf8d33 100644 --- a/Swiften/Network/BoostNetworkFactories.h +++ b/Swiften/Network/BoostNetworkFactories.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Network/BoostIOServiceThread.h> #include <Swiften/Network/NetworkFactories.h> @@ -24,13 +23,13 @@ namespace Swift { * used for the construction of the BoostIOServiceThread. */ BoostNetworkFactories(EventLoop* eventLoop, std::shared_ptr<boost::asio::io_service> ioService = std::shared_ptr<boost::asio::io_service>()); - virtual ~BoostNetworkFactories(); + virtual ~BoostNetworkFactories() override; - virtual TimerFactory* getTimerFactory() const SWIFTEN_OVERRIDE { + virtual TimerFactory* getTimerFactory() const override { return timerFactory; } - virtual ConnectionFactory* getConnectionFactory() const SWIFTEN_OVERRIDE { + virtual ConnectionFactory* getConnectionFactory() const override { return connectionFactory; } @@ -38,41 +37,41 @@ namespace Swift { return &ioServiceThread; } - DomainNameResolver* getDomainNameResolver() const SWIFTEN_OVERRIDE { + DomainNameResolver* getDomainNameResolver() const override { return domainNameResolver; } - ConnectionServerFactory* getConnectionServerFactory() const SWIFTEN_OVERRIDE { + ConnectionServerFactory* getConnectionServerFactory() const override { return connectionServerFactory; } - NetworkEnvironment* getNetworkEnvironment() const SWIFTEN_OVERRIDE { + NetworkEnvironment* getNetworkEnvironment() const override { return networkEnvironment; } - NATTraverser* getNATTraverser() const SWIFTEN_OVERRIDE { + NATTraverser* getNATTraverser() const override { return natTraverser; } - virtual XMLParserFactory* getXMLParserFactory() const SWIFTEN_OVERRIDE { + virtual XMLParserFactory* getXMLParserFactory() const override { return xmlParserFactory; } - virtual TLSContextFactory* getTLSContextFactory() const SWIFTEN_OVERRIDE; + virtual TLSContextFactory* getTLSContextFactory() const override; - virtual ProxyProvider* getProxyProvider() const SWIFTEN_OVERRIDE { + virtual ProxyProvider* getProxyProvider() const override { return proxyProvider; } - virtual EventLoop* getEventLoop() const SWIFTEN_OVERRIDE { + virtual EventLoop* getEventLoop() const override { return eventLoop; } - virtual IDNConverter* getIDNConverter() const SWIFTEN_OVERRIDE { + virtual IDNConverter* getIDNConverter() const override { return idnConverter; } - virtual CryptoProvider* getCryptoProvider() const SWIFTEN_OVERRIDE { + virtual CryptoProvider* getCryptoProvider() const override { return cryptoProvider; } diff --git a/Swiften/Parser/EnumParser.h b/Swiften/Parser/EnumParser.h index cf17ead..0da765e 100644 --- a/Swiften/Parser/EnumParser.h +++ b/Swiften/Parser/EnumParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,7 +13,6 @@ #include <boost/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> namespace Swift { template<typename T> diff --git a/Swiften/Parser/PayloadParsers/ForwardedParser.h b/Swiften/Parser/PayloadParsers/ForwardedParser.h index f91fda5..c9f13df 100644 --- a/Swiften/Parser/PayloadParsers/ForwardedParser.h +++ b/Swiften/Parser/PayloadParsers/ForwardedParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Forwarded.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -22,9 +21,9 @@ namespace Swift { public: ForwardedParser(PayloadParserFactoryCollection* factories); - virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; enum Level { TopLevel = 0, diff --git a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp index ea7bdbf..43c4ebb 100644 --- a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp +++ b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp @@ -53,9 +53,14 @@ #include <Swiften/Parser/PayloadParsers/MAMResultParser.h> #include <Swiften/Parser/PayloadParsers/MIXParticipantParserFactory.h> #include <Swiften/Parser/PayloadParsers/MIXCreateParser.h> +#include <Swiften/Parser/PayloadParsers/MIXRegisterNickParserFactory.h> +#include <Swiften/Parser/PayloadParsers/MIXSetNickParserFactory.h> #include <Swiften/Parser/PayloadParsers/MIXDestroyParser.h> +#include <Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h> #include <Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h> +#include <Swiften/Parser/PayloadParsers/MIXPayloadParserFactory.h> #include <Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h> +#include <Swiften/Parser/PayloadParsers/MIXLeaveParser.h> #include <Swiften/Parser/PayloadParsers/MUCAdminPayloadParser.h> #include <Swiften/Parser/PayloadParsers/MUCDestroyPayloadParser.h> #include <Swiften/Parser/PayloadParsers/MUCInvitationPayloadParser.h> @@ -135,9 +140,14 @@ FullPayloadParserFactoryCollection::FullPayloadParserFactoryCollection() { factories_.push_back(std::make_shared<ChatStateParserFactory>()); factories_.push_back(std::make_shared<ClientStateParserFactory>()); factories_.push_back(std::make_shared<MIXParticipantParserFactory>()); - factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXDestroyParser> >("destroy", "urn:xmpp:mix:1")); - factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXCreateParser> >("create", "urn:xmpp:mix:1")); - factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXUserPreferenceParser> >("user-preference", "urn:xmpp:mix:1")); + factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXDestroyParser> >("destroy", "urn:xmpp:mix:0")); + factories_.push_back(std::make_shared<MIXRegisterNickParserFactory>()); + factories_.push_back(std::make_shared<MIXSetNickParserFactory>()); + factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXCreateParser> >("create", "urn:xmpp:mix:0")); + factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXUpdateSubscriptionParser> >("update-subscription", "urn:xmpp:mix:0")); + factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXUserPreferenceParser> >("user-preference", "urn:xmpp:mix:0")); + factories_.push_back(std::make_shared<MIXPayloadParserFactory>()); + factories_.push_back(std::make_shared<GenericPayloadParserFactory<MIXLeaveParser> >("leave", "urn:xmpp:mix:0")); factories_.push_back(std::make_shared<MUCUserPayloadParserFactory>(this)); factories_.push_back(std::make_shared<MUCOwnerPayloadParserFactory>(this)); factories_.push_back(std::make_shared<GenericPayloadParserFactory<MUCInvitationPayloadParser> >("x", "jabber:x:conference")); diff --git a/Swiften/Parser/PayloadParsers/IsodeIQDelegationParser.h b/Swiften/Parser/PayloadParsers/IsodeIQDelegationParser.h index eaedd27..af2f061 100644 --- a/Swiften/Parser/PayloadParsers/IsodeIQDelegationParser.h +++ b/Swiften/Parser/PayloadParsers/IsodeIQDelegationParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/IsodeIQDelegation.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API IsodeIQDelegationParser : public GenericPayloadParser<IsodeIQDelegation> { public: IsodeIQDelegationParser(PayloadParserFactoryCollection* parsers); - virtual ~IsodeIQDelegationParser(); + virtual ~IsodeIQDelegationParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/MAMFinParser.h b/Swiften/Parser/PayloadParsers/MAMFinParser.h index f08231e..419d542 100644 --- a/Swiften/Parser/PayloadParsers/MAMFinParser.h +++ b/Swiften/Parser/PayloadParsers/MAMFinParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MAMFin.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,9 +19,9 @@ namespace Swift { public: MAMFinParser(); - virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; enum Level { TopLevel = 0, diff --git a/Swiften/Parser/PayloadParsers/MAMQueryParser.h b/Swiften/Parser/PayloadParsers/MAMQueryParser.h index 7e4b58a..ab062c5 100644 --- a/Swiften/Parser/PayloadParsers/MAMQueryParser.h +++ b/Swiften/Parser/PayloadParsers/MAMQueryParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MAMQuery.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -22,9 +21,9 @@ namespace Swift { public: MAMQueryParser(); - virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; enum Level { TopLevel = 0, diff --git a/Swiften/Parser/PayloadParsers/MAMResultParser.h b/Swiften/Parser/PayloadParsers/MAMResultParser.h index e68e365..f058e15 100644 --- a/Swiften/Parser/PayloadParsers/MAMResultParser.h +++ b/Swiften/Parser/PayloadParsers/MAMResultParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MAMResult.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -22,9 +21,9 @@ namespace Swift { public: MAMResultParser(PayloadParserFactoryCollection* factories); - virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; enum Level { TopLevel = 0, diff --git a/Swiften/Parser/PayloadParsers/MIXCreateParser.h b/Swiften/Parser/PayloadParsers/MIXCreateParser.h index 60e3040..ef123e1 100644 --- a/Swiften/Parser/PayloadParsers/MIXCreateParser.h +++ b/Swiften/Parser/PayloadParsers/MIXCreateParser.h @@ -4,12 +4,17 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MIXCreate.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -19,11 +24,11 @@ namespace Swift { class SWIFTEN_API MIXCreateParser : public GenericPayloadParser<MIXCreate> { public: MIXCreateParser(); - virtual ~MIXCreateParser(); + virtual ~MIXCreateParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level_; diff --git a/Swiften/Parser/PayloadParsers/MIXDestroyParser.h b/Swiften/Parser/PayloadParsers/MIXDestroyParser.h index 3a925de..8cfd91e 100644 --- a/Swiften/Parser/PayloadParsers/MIXDestroyParser.h +++ b/Swiften/Parser/PayloadParsers/MIXDestroyParser.h @@ -4,12 +4,17 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MIXDestroy.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -19,11 +24,11 @@ namespace Swift { class SWIFTEN_API MIXDestroyParser : public GenericPayloadParser<MIXDestroy> { public: MIXDestroyParser(); - virtual ~MIXDestroyParser(); + virtual ~MIXDestroyParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level_; diff --git a/Swiften/Parser/PayloadParsers/MIXJoinParser.cpp b/Swiften/Parser/PayloadParsers/MIXJoinParser.cpp index 2509667..6e72f90 100644 --- a/Swiften/Parser/PayloadParsers/MIXJoinParser.cpp +++ b/Swiften/Parser/PayloadParsers/MIXJoinParser.cpp @@ -9,7 +9,6 @@ #include <boost/optional.hpp> #include <Swiften/Parser/PayloadParserFactory.h> -#include <Swiften/Parser/PayloadParsers/MIXSubscribeParser.h> #include <Swiften/Parser/PayloadParsers/FormParser.h> using namespace Swift; @@ -35,8 +34,10 @@ void MIXJoinParser::handleStartElement(const std::string& element, const std::st } if (level_ == 1) { - if (element == "subscribe" && ns == "urn:xmpp:mix:1") { - currentPayloadParser_ = std::make_shared<MIXSubscribeParser>(); + if (element == "subscribe" && ns == "urn:xmpp:mix:0") { + if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) { + getPayloadInternal()->addSubscription(*attributeValue); + } } if (element == "x" && ns == "jabber:x:data") { currentPayloadParser_ = std::make_shared<FormParser>(); @@ -57,9 +58,6 @@ void MIXJoinParser::handleEndElement(const std::string& element, const std::stri } if (level_ == 1) { - if (element == "subscribe" && ns == "urn:xmpp:mix:1") { - getPayloadInternal()->addSubscription(std::dynamic_pointer_cast<MIXSubscribe>(currentPayloadParser_->getPayload())); - } if (element == "x" && ns == "jabber:x:data") { getPayloadInternal()->setForm(std::dynamic_pointer_cast<Form>(currentPayloadParser_->getPayload())); } diff --git a/Swiften/Parser/PayloadParsers/MIXJoinParser.h b/Swiften/Parser/PayloadParsers/MIXJoinParser.h index c0ded7b..f371d6f 100644 --- a/Swiften/Parser/PayloadParsers/MIXJoinParser.h +++ b/Swiften/Parser/PayloadParsers/MIXJoinParser.h @@ -4,12 +4,17 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MIXJoin.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -19,11 +24,11 @@ namespace Swift { class SWIFTEN_API MIXJoinParser : public GenericPayloadParser<MIXJoin> { public: MIXJoinParser(); - virtual ~MIXJoinParser(); + virtual ~MIXJoinParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level_; diff --git a/Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h b/Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h index 6103c70..8432c61 100644 --- a/Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h +++ b/Swiften/Parser/PayloadParsers/MIXJoinParserFactory.h @@ -17,7 +17,7 @@ namespace Swift { } virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const { - return element == "join" && ns == "urn:xmpp:mix:1"; + return element == "join" && ns == "urn:xmpp:mix:0"; } virtual PayloadParser* createPayloadParser() { diff --git a/Swiften/Parser/PayloadParsers/MIXLeaveParser.cpp b/Swiften/Parser/PayloadParsers/MIXLeaveParser.cpp new file mode 100644 index 0000000..6330925 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXLeaveParser.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Parser/PayloadParsers/MIXLeaveParser.h> + +#include <boost/optional.hpp> + +namespace Swift { + +MIXLeaveParser::MIXLeaveParser() : level_(0) { +} + +MIXLeaveParser::~MIXLeaveParser() { +} + +void MIXLeaveParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) { + if (level_ == 0) { + if (auto attributeValue = attributes.getAttributeValue("channel")) { + if (auto jid = JID::parse(*attributeValue)) { + getPayloadInternal()->setChannel(*jid); + } + } + } + ++level_; +} + +void MIXLeaveParser::handleEndElement(const std::string&, const std::string&) { + --level_; +} + +void MIXLeaveParser::handleCharacterData(const std::string&) { + +} +} diff --git a/Swiften/Parser/PayloadParsers/MIXSubscribeParser.h b/Swiften/Parser/PayloadParsers/MIXLeaveParser.h index eecc0d2..b0798b4 100644 --- a/Swiften/Parser/PayloadParsers/MIXSubscribeParser.h +++ b/Swiften/Parser/PayloadParsers/MIXLeaveParser.h @@ -4,27 +4,30 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> -#include <Swiften/Elements/MIXSubscribe.h> +#include <Swiften/Elements/MIXLeave.h> #include <Swiften/Parser/GenericPayloadParser.h> namespace Swift { - class PayloadParserFactoryCollection; - class PayloadParser; - class SWIFTEN_API MIXSubscribeParser : public GenericPayloadParser<MIXSubscribe> { + class SWIFTEN_API MIXLeaveParser : public GenericPayloadParser<MIXLeave> { public: - MIXSubscribeParser(); - virtual ~MIXSubscribeParser(); + MIXLeaveParser(); + virtual ~MIXLeaveParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level_; diff --git a/Swiften/Parser/PayloadParsers/MIXPayloadParser.cpp b/Swiften/Parser/PayloadParsers/MIXPayloadParser.cpp new file mode 100644 index 0000000..51ef584 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXPayloadParser.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Parser/PayloadParsers/MIXPayloadParser.h> + +namespace Swift { + +void MIXPayloadParser::handleTree(ParserElement::ref root) { + for (const auto& child : root->getAllChildren()) { + if (child->getName() == "nick" && child->getNamespace() == root->getNamespace()) { + getPayloadInternal()->setNick(child->getText()); + } else if (child->getName() == "jid" && child->getNamespace() == root->getNamespace()) { + if (boost::optional<JID> jid = JID::parse(child->getText())) { + getPayloadInternal()->setJID(*jid); + } + } else if (child->getName() == "submission-id" && child->getNamespace() == root->getNamespace()) { + getPayloadInternal()->setSubmissionID(child->getText()); + } + } +} + +} diff --git a/Swiften/Parser/PayloadParsers/MIXPayloadParser.h b/Swiften/Parser/PayloadParsers/MIXPayloadParser.h new file mode 100644 index 0000000..9133e8b --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXPayloadParser.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/MIXPayload.h> +#include <Swiften/Parser/GenericPayloadTreeParser.h> + +namespace Swift { + class SWIFTEN_API MIXPayloadParser : public GenericPayloadTreeParser<MIXPayload> { + public: + MIXPayloadParser() {} + virtual void handleTree(ParserElement::ref root) override; + }; +} diff --git a/Swiften/Parser/PayloadParsers/MIXPayloadParserFactory.h b/Swiften/Parser/PayloadParsers/MIXPayloadParserFactory.h new file mode 100644 index 0000000..8397b78 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXPayloadParserFactory.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Parser/GenericPayloadParserFactory.h> +#include <Swiften/Parser/PayloadParsers/MIXPayloadParser.h> + +namespace Swift { + class SWIFTEN_API MIXPayloadParserFactory : public PayloadParserFactory { + public: + MIXPayloadParserFactory() { + } + + virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const override { + return element == "mix" && ns == "urn:xmpp:mix:0"; + } + + virtual PayloadParser* createPayloadParser() override { + return new MIXPayloadParser(); + } + }; +} diff --git a/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.cpp b/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.cpp new file mode 100644 index 0000000..945e9b2 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.cpp @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h> + +namespace Swift { + +void MIXRegisterNickParser::handleTree(ParserElement::ref root) { + for (const auto& child : root->getAllChildren()) { + if (child->getName() == "nick" && child->getNamespace() == root->getNamespace()) { + getPayloadInternal()->setNick(child->getText()); + } + } +} + +} diff --git a/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h b/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h new file mode 100644 index 0000000..cfb618e --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/MIXRegisterNick.h> +#include <Swiften/Parser/GenericPayloadTreeParser.h> + +namespace Swift { + class SWIFTEN_API MIXRegisterNickParser : public GenericPayloadTreeParser<MIXRegisterNick> { + public: + MIXRegisterNickParser() {} + virtual void handleTree(ParserElement::ref root) override; + }; +} diff --git a/Swiften/Parser/PayloadParsers/MIXRegisterNickParserFactory.h b/Swiften/Parser/PayloadParsers/MIXRegisterNickParserFactory.h new file mode 100644 index 0000000..e03392c --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXRegisterNickParserFactory.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Parser/GenericPayloadParserFactory.h> +#include <Swiften/Parser/PayloadParsers/MIXRegisterNickParser.h> + +namespace Swift { + class SWIFTEN_API MIXRegisterNickParserFactory : public PayloadParserFactory { + public: + MIXRegisterNickParserFactory() { + } + + virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const override { + return element == "register" && ns == "urn:xmpp:mix:0"; + } + + virtual PayloadParser* createPayloadParser() override { + return new MIXRegisterNickParser(); + } + }; +} diff --git a/Swiften/Parser/PayloadParsers/MIXSetNickParser.cpp b/Swiften/Parser/PayloadParsers/MIXSetNickParser.cpp new file mode 100644 index 0000000..34fec70 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXSetNickParser.cpp @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Parser/PayloadParsers/MIXSetNickParser.h> + +namespace Swift { + +void MIXSetNickParser::handleTree(ParserElement::ref root) { + for (const auto& child : root->getAllChildren()) { + if (child->getName() == "nick" && child->getNamespace() == root->getNamespace()) { + getPayloadInternal()->setNick(child->getText()); + } + } +} + +} diff --git a/Swiften/Parser/PayloadParsers/MIXSetNickParser.h b/Swiften/Parser/PayloadParsers/MIXSetNickParser.h new file mode 100644 index 0000000..6d552c8 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXSetNickParser.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/MIXSetNick.h> +#include <Swiften/Parser/GenericPayloadTreeParser.h> + +namespace Swift { + class SWIFTEN_API MIXSetNickParser : public GenericPayloadTreeParser<MIXSetNick> { + public: + MIXSetNickParser() {} + virtual void handleTree(ParserElement::ref root) override; + }; +} diff --git a/Swiften/Parser/PayloadParsers/MIXSetNickParserFactory.h b/Swiften/Parser/PayloadParsers/MIXSetNickParserFactory.h new file mode 100644 index 0000000..e028873 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXSetNickParserFactory.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Parser/GenericPayloadParserFactory.h> +#include <Swiften/Parser/PayloadParsers/MIXSetNickParser.h> + +namespace Swift { + class SWIFTEN_API MIXSetNickParserFactory : public PayloadParserFactory { + public: + MIXSetNickParserFactory() { + } + + virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const override { + return element == "setnick" && ns == "urn:xmpp:mix:0"; + } + + virtual PayloadParser* createPayloadParser() override { + return new MIXSetNickParser(); + } + }; +} diff --git a/Swiften/Parser/PayloadParsers/MIXSubscribeParser.cpp b/Swiften/Parser/PayloadParsers/MIXSubscribeParser.cpp deleted file mode 100644 index 1500716..0000000 --- a/Swiften/Parser/PayloadParsers/MIXSubscribeParser.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2017 Tarun Gupta - * Licensed under the simplified BSD license. - * See Documentation/Licenses/BSD-simplified.txt for more information. - */ - -#include <Swiften/Parser/PayloadParsers/MIXSubscribeParser.h> - -#include <boost/optional.hpp> - -#include <Swiften/Parser/PayloadParserFactory.h> -#include <Swiften/Parser/PayloadParserFactoryCollection.h> - -using namespace Swift; - -MIXSubscribeParser::MIXSubscribeParser() : level_(0) { -} - -MIXSubscribeParser::~MIXSubscribeParser() { -} - -void MIXSubscribeParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) { - if (level_ == 0) { - if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) { - getPayloadInternal()->setNode(*attributeValue); - } - } - ++level_; -} - -void MIXSubscribeParser::handleEndElement(const std::string& , const std::string& ) { - --level_; -} - -void MIXSubscribeParser::handleCharacterData(const std::string& ) { -} diff --git a/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp new file mode 100644 index 0000000..d530e49 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h> + +#include <boost/optional.hpp> + +#include <Swiften/Parser/PayloadParserFactory.h> +#include <Swiften/Parser/PayloadParsers/FormParser.h> + +namespace Swift { + +MIXUpdateSubscriptionParser::MIXUpdateSubscriptionParser() : level_(0) { +} + +MIXUpdateSubscriptionParser::~MIXUpdateSubscriptionParser() { +} + +void MIXUpdateSubscriptionParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { + if (level_ == 0) { + if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("jid")) { + if (boost::optional<JID> jid = JID::parse(*attributeValue)) { + getPayloadInternal()->setJID(*jid); + } + } + } + + if (level_ == 1) { + if (element == "subscribe" && ns == "urn:xmpp:mix:0") { + if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) { + getPayloadInternal()->addSubscription(*attributeValue); + } + } + } + + ++level_; +} + +void MIXUpdateSubscriptionParser::handleEndElement(const std::string&, const std::string&) { + --level_; +} + +void MIXUpdateSubscriptionParser::handleCharacterData(const std::string&) { +} + +} diff --git a/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h new file mode 100644 index 0000000..9975411 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <memory> + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/MIXUpdateSubscription.h> +#include <Swiften/Parser/GenericPayloadParser.h> + +namespace Swift { + class PayloadParser; + + class SWIFTEN_API MIXUpdateSubscriptionParser : public GenericPayloadParser<MIXUpdateSubscription> { + public: + MIXUpdateSubscriptionParser(); + virtual ~MIXUpdateSubscriptionParser(); + + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; + + private: + int level_; + }; +} diff --git a/Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h b/Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h index 505087d..b2a2c10 100644 --- a/Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h +++ b/Swiften/Parser/PayloadParsers/MIXUserPreferenceParser.h @@ -4,12 +4,17 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MIXUserPreference.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -19,11 +24,11 @@ namespace Swift { class SWIFTEN_API MIXUserPreferenceParser : public GenericPayloadParser<MIXUserPreference> { public: MIXUserPreferenceParser(); - virtual ~MIXUserPreferenceParser(); + virtual ~MIXUserPreferenceParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level_; diff --git a/Swiften/Parser/PayloadParsers/PubSubAffiliationParser.h b/Swiften/Parser/PayloadParsers/PubSubAffiliationParser.h index eabe3db..383ceae 100644 --- a/Swiften/Parser/PayloadParsers/PubSubAffiliationParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubAffiliationParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubAffiliation.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubAffiliationParser : public GenericPayloadParser<PubSubAffiliation> { public: PubSubAffiliationParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubAffiliationParser(); + virtual ~PubSubAffiliationParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubAffiliationsParser.h b/Swiften/Parser/PayloadParsers/PubSubAffiliationsParser.h index 2f80dbd..48e3825 100644 --- a/Swiften/Parser/PayloadParsers/PubSubAffiliationsParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubAffiliationsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubAffiliations.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubAffiliationsParser : public GenericPayloadParser<PubSubAffiliations> { public: PubSubAffiliationsParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubAffiliationsParser(); + virtual ~PubSubAffiliationsParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubConfigureParser.h b/Swiften/Parser/PayloadParsers/PubSubConfigureParser.h index 90c2f3e..e53d477 100644 --- a/Swiften/Parser/PayloadParsers/PubSubConfigureParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubConfigureParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubConfigure.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubConfigureParser : public GenericPayloadParser<PubSubConfigure> { public: PubSubConfigureParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubConfigureParser(); + virtual ~PubSubConfigureParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubCreateParser.h b/Swiften/Parser/PayloadParsers/PubSubCreateParser.h index a1ada74..626419c 100644 --- a/Swiften/Parser/PayloadParsers/PubSubCreateParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubCreateParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubCreate.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubCreateParser : public GenericPayloadParser<PubSubCreate> { public: PubSubCreateParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubCreateParser(); + virtual ~PubSubCreateParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubDefaultParser.h b/Swiften/Parser/PayloadParsers/PubSubDefaultParser.h index 01bea7b..08f6b43 100644 --- a/Swiften/Parser/PayloadParsers/PubSubDefaultParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubDefaultParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubDefault.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubDefaultParser : public GenericPayloadParser<PubSubDefault> { public: PubSubDefaultParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubDefaultParser(); + virtual ~PubSubDefaultParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubErrorParser.h b/Swiften/Parser/PayloadParsers/PubSubErrorParser.h index 9c41095..273da82 100644 --- a/Swiften/Parser/PayloadParsers/PubSubErrorParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubErrorParser.h @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubError.h> #include <Swiften/Parser/EnumParser.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -18,11 +17,11 @@ namespace Swift { class SWIFTEN_API PubSubErrorParser : public GenericPayloadParser<PubSubError> { public: PubSubErrorParser(); - virtual ~PubSubErrorParser(); + virtual ~PubSubErrorParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventAssociateParser.h b/Swiften/Parser/PayloadParsers/PubSubEventAssociateParser.h index 4bb9bd9..f4d6327 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventAssociateParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventAssociateParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventAssociate.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventAssociateParser : public GenericPayloadParser<PubSubEventAssociate> { public: PubSubEventAssociateParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventAssociateParser(); + virtual ~PubSubEventAssociateParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventCollectionParser.h b/Swiften/Parser/PayloadParsers/PubSubEventCollectionParser.h index ffdafcf..ffa1deb 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventCollectionParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventCollectionParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventCollection.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventCollectionParser : public GenericPayloadParser<PubSubEventCollection> { public: PubSubEventCollectionParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventCollectionParser(); + virtual ~PubSubEventCollectionParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventConfigurationParser.h b/Swiften/Parser/PayloadParsers/PubSubEventConfigurationParser.h index dddb7a4..6b68d86 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventConfigurationParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventConfigurationParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventConfiguration.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventConfigurationParser : public GenericPayloadParser<PubSubEventConfiguration> { public: PubSubEventConfigurationParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventConfigurationParser(); + virtual ~PubSubEventConfigurationParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventDeleteParser.h b/Swiften/Parser/PayloadParsers/PubSubEventDeleteParser.h index 270430e..54a1913 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventDeleteParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventDeleteParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventDelete.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventDeleteParser : public GenericPayloadParser<PubSubEventDelete> { public: PubSubEventDeleteParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventDeleteParser(); + virtual ~PubSubEventDeleteParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventDisassociateParser.h b/Swiften/Parser/PayloadParsers/PubSubEventDisassociateParser.h index 5f7f1af..6a0a7ce 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventDisassociateParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventDisassociateParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventDisassociate.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventDisassociateParser : public GenericPayloadParser<PubSubEventDisassociate> { public: PubSubEventDisassociateParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventDisassociateParser(); + virtual ~PubSubEventDisassociateParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventItemParser.h b/Swiften/Parser/PayloadParsers/PubSubEventItemParser.h index bd2e72e..e9a986d 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventItemParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventItemParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventItem.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventItemParser : public GenericPayloadParser<PubSubEventItem> { public: PubSubEventItemParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventItemParser(); + virtual ~PubSubEventItemParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventItemsParser.h b/Swiften/Parser/PayloadParsers/PubSubEventItemsParser.h index 34b3669..067a9f7 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventItemsParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventItemsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventItems.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventItemsParser : public GenericPayloadParser<PubSubEventItems> { public: PubSubEventItemsParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventItemsParser(); + virtual ~PubSubEventItemsParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventParser.h b/Swiften/Parser/PayloadParsers/PubSubEventParser.h index 3b231b0..02cf01f 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEvent.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventParser : public GenericPayloadParser<PubSubEvent> { public: PubSubEventParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventParser(); + virtual ~PubSubEventParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventPurgeParser.h b/Swiften/Parser/PayloadParsers/PubSubEventPurgeParser.h index 563283c..1c9e623 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventPurgeParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventPurgeParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventPurge.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventPurgeParser : public GenericPayloadParser<PubSubEventPurge> { public: PubSubEventPurgeParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventPurgeParser(); + virtual ~PubSubEventPurgeParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventRedirectParser.h b/Swiften/Parser/PayloadParsers/PubSubEventRedirectParser.h index 603fbec..be7593e 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventRedirectParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventRedirectParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventRedirect.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventRedirectParser : public GenericPayloadParser<PubSubEventRedirect> { public: PubSubEventRedirectParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventRedirectParser(); + virtual ~PubSubEventRedirectParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventRetractParser.h b/Swiften/Parser/PayloadParsers/PubSubEventRetractParser.h index 141790b..83a8e66 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventRetractParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventRetractParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventRetract.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventRetractParser : public GenericPayloadParser<PubSubEventRetract> { public: PubSubEventRetractParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventRetractParser(); + virtual ~PubSubEventRetractParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubEventSubscriptionParser.h b/Swiften/Parser/PayloadParsers/PubSubEventSubscriptionParser.h index 0d56a20..6f2eeeb 100644 --- a/Swiften/Parser/PayloadParsers/PubSubEventSubscriptionParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubEventSubscriptionParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventSubscription.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubEventSubscriptionParser : public GenericPayloadParser<PubSubEventSubscription> { public: PubSubEventSubscriptionParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubEventSubscriptionParser(); + virtual ~PubSubEventSubscriptionParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubItemParser.h b/Swiften/Parser/PayloadParsers/PubSubItemParser.h index c6e4ccf..cbbd3a5 100644 --- a/Swiften/Parser/PayloadParsers/PubSubItemParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubItemParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubItem.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubItemParser : public GenericPayloadParser<PubSubItem> { public: PubSubItemParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubItemParser(); + virtual ~PubSubItemParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubItemsParser.h b/Swiften/Parser/PayloadParsers/PubSubItemsParser.h index ad6e746..d792e1b 100644 --- a/Swiften/Parser/PayloadParsers/PubSubItemsParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubItemsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubItems.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubItemsParser : public GenericPayloadParser<PubSubItems> { public: PubSubItemsParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubItemsParser(); + virtual ~PubSubItemsParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubOptionsParser.h b/Swiften/Parser/PayloadParsers/PubSubOptionsParser.h index ac14caf..ee11f70 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOptionsParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOptionsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOptions.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOptionsParser : public GenericPayloadParser<PubSubOptions> { public: PubSubOptionsParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOptionsParser(); + virtual ~PubSubOptionsParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationParser.h index 0a6503f..7bb93f1 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerAffiliation.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerAffiliationParser : public GenericPayloadParser<PubSubOwnerAffiliation> { public: PubSubOwnerAffiliationParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerAffiliationParser(); + virtual ~PubSubOwnerAffiliationParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationsParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationsParser.h index 52c7fa9..20df72f 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationsParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerAffiliationsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerAffiliations.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerAffiliationsParser : public GenericPayloadParser<PubSubOwnerAffiliations> { public: PubSubOwnerAffiliationsParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerAffiliationsParser(); + virtual ~PubSubOwnerAffiliationsParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerConfigureParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerConfigureParser.h index 34000fa..f11f357 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerConfigureParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerConfigureParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerConfigure.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerConfigureParser : public GenericPayloadParser<PubSubOwnerConfigure> { public: PubSubOwnerConfigureParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerConfigureParser(); + virtual ~PubSubOwnerConfigureParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerDefaultParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerDefaultParser.h index 528c297..2f80b85 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerDefaultParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerDefaultParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerDefault.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerDefaultParser : public GenericPayloadParser<PubSubOwnerDefault> { public: PubSubOwnerDefaultParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerDefaultParser(); + virtual ~PubSubOwnerDefaultParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerDeleteParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerDeleteParser.h index 99a8c0e..4484329 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerDeleteParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerDeleteParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerDelete.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerDeleteParser : public GenericPayloadParser<PubSubOwnerDelete> { public: PubSubOwnerDeleteParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerDeleteParser(); + virtual ~PubSubOwnerDeleteParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h index 35420f7..cfacc97 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerPubSubParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerPubSub.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerPubSubParser : public GenericPayloadParser<PubSubOwnerPubSub> { public: PubSubOwnerPubSubParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerPubSubParser(); + virtual ~PubSubOwnerPubSubParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerPurgeParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerPurgeParser.h index f85b2bb..8d233b6 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerPurgeParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerPurgeParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerPurge.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerPurgeParser : public GenericPayloadParser<PubSubOwnerPurge> { public: PubSubOwnerPurgeParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerPurgeParser(); + virtual ~PubSubOwnerPurgeParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerRedirectParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerRedirectParser.h index 1197952..ebb6436 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerRedirectParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerRedirectParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerRedirect.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerRedirectParser : public GenericPayloadParser<PubSubOwnerRedirect> { public: PubSubOwnerRedirectParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerRedirectParser(); + virtual ~PubSubOwnerRedirectParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionParser.h index 74a61a2..d68d910 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerSubscription.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerSubscriptionParser : public GenericPayloadParser<PubSubOwnerSubscription> { public: PubSubOwnerSubscriptionParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerSubscriptionParser(); + virtual ~PubSubOwnerSubscriptionParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionsParser.h b/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionsParser.h index 541d225..ca868e6 100644 --- a/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionsParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubOwnerSubscriptionsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerSubscriptions.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubOwnerSubscriptionsParser : public GenericPayloadParser<PubSubOwnerSubscriptions> { public: PubSubOwnerSubscriptionsParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubOwnerSubscriptionsParser(); + virtual ~PubSubOwnerSubscriptionsParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubParser.h b/Swiften/Parser/PayloadParsers/PubSubParser.h index 1f40ca9..5cc50e1 100644 --- a/Swiften/Parser/PayloadParsers/PubSubParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSub.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -22,11 +21,11 @@ namespace Swift { class SWIFTEN_API PubSubParser : public GenericPayloadParser<PubSub> { public: PubSubParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubParser(); + virtual ~PubSubParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubPublishParser.h b/Swiften/Parser/PayloadParsers/PubSubPublishParser.h index ad7dd11..e3b05ff 100644 --- a/Swiften/Parser/PayloadParsers/PubSubPublishParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubPublishParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubPublish.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubPublishParser : public GenericPayloadParser<PubSubPublish> { public: PubSubPublishParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubPublishParser(); + virtual ~PubSubPublishParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubRetractParser.h b/Swiften/Parser/PayloadParsers/PubSubRetractParser.h index 6bea498..aa9bbcc 100644 --- a/Swiften/Parser/PayloadParsers/PubSubRetractParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubRetractParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubRetract.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubRetractParser : public GenericPayloadParser<PubSubRetract> { public: PubSubRetractParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubRetractParser(); + virtual ~PubSubRetractParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubSubscribeOptionsParser.h b/Swiften/Parser/PayloadParsers/PubSubSubscribeOptionsParser.h index 328818b..9deae2d 100644 --- a/Swiften/Parser/PayloadParsers/PubSubSubscribeOptionsParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubSubscribeOptionsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubSubscribeOptions.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubSubscribeOptionsParser : public GenericPayloadParser<PubSubSubscribeOptions> { public: PubSubSubscribeOptionsParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubSubscribeOptionsParser(); + virtual ~PubSubSubscribeOptionsParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubSubscribeParser.h b/Swiften/Parser/PayloadParsers/PubSubSubscribeParser.h index 31221cb..ccd8ac8 100644 --- a/Swiften/Parser/PayloadParsers/PubSubSubscribeParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubSubscribeParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubSubscribe.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubSubscribeParser : public GenericPayloadParser<PubSubSubscribe> { public: PubSubSubscribeParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubSubscribeParser(); + virtual ~PubSubSubscribeParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/PubSubSubscriptionParser.h b/Swiften/Parser/PayloadParsers/PubSubSubscriptionParser.h index 7075a99..3d9be23 100644 --- a/Swiften/Parser/PayloadParsers/PubSubSubscriptionParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubSubscriptionParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubSubscription.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubSubscriptionParser : public GenericPayloadParser<PubSubSubscription> { public: PubSubSubscriptionParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubSubscriptionParser(); + virtual ~PubSubSubscriptionParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubSubscriptionsParser.h b/Swiften/Parser/PayloadParsers/PubSubSubscriptionsParser.h index 2371a56..c7169ae 100644 --- a/Swiften/Parser/PayloadParsers/PubSubSubscriptionsParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubSubscriptionsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubSubscriptions.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubSubscriptionsParser : public GenericPayloadParser<PubSubSubscriptions> { public: PubSubSubscriptionsParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubSubscriptionsParser(); + virtual ~PubSubSubscriptionsParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: PayloadParserFactoryCollection* parsers; diff --git a/Swiften/Parser/PayloadParsers/PubSubUnsubscribeParser.h b/Swiften/Parser/PayloadParsers/PubSubUnsubscribeParser.h index e471130..21d5599 100644 --- a/Swiften/Parser/PayloadParsers/PubSubUnsubscribeParser.h +++ b/Swiften/Parser/PayloadParsers/PubSubUnsubscribeParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubUnsubscribe.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -20,11 +19,11 @@ namespace Swift { class SWIFTEN_API PubSubUnsubscribeParser : public GenericPayloadParser<PubSubUnsubscribe> { public: PubSubUnsubscribeParser(PayloadParserFactoryCollection* parsers); - virtual ~PubSubUnsubscribeParser(); + virtual ~PubSubUnsubscribeParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/ResultSetParser.h b/Swiften/Parser/PayloadParsers/ResultSetParser.h index 819c0a5..edf6f2f 100644 --- a/Swiften/Parser/PayloadParsers/ResultSetParser.h +++ b/Swiften/Parser/PayloadParsers/ResultSetParser.h @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/ResultSet.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -18,9 +17,9 @@ namespace Swift { public: ResultSetParser(); - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; enum Level { TopLevel = 0, diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp index 85c79c6..f48bbc7 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp @@ -14,7 +14,7 @@ using namespace Swift; TEST(MIXCreateParserTest, XEP0369_Example68) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<create xmlns=\"urn:xmpp:mix:1\"/>" + "<create xmlns=\"urn:xmpp:mix:0\"/>" )); auto payload = parser.getPayload<MIXCreate>(); @@ -27,7 +27,7 @@ TEST(MIXCreateParserTest, XEP0369_Example68) { TEST(MIXCreateParserTest, XEP0369_Example66) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>" + "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>" )); auto payload = parser.getPayload<MIXCreate>(); @@ -42,10 +42,10 @@ TEST(MIXCreateParserTest, XEP0369_Example66) { TEST(MIXCreateParserTest, XEP0369_Example67) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:1\">" + "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:0\">" "<x xmlns=\"jabber:x:data\" type=\"result\">" "<field var=\"FORM_TYPE\" type=\"hidden\">" - "<value>urn:xmpp:mix:1</value>" + "<value>urn:xmpp:mix:0</value>" "</field>" "<field var=\"Owner\">" "<value>hecate@shakespeare.lit</value>" diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp index fc2588a..80eb144 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp @@ -14,7 +14,7 @@ using namespace Swift; TEST(MIXDestroyParserTest, XEP0369_Example70) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>" + "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>" )); auto payload = parser.getPayload<MIXDestroy>(); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp index 8e4dff2..5fa321e 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp @@ -14,7 +14,7 @@ using namespace Swift; TEST(MIXDestroyParserTest, XEP0369_Example70) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>" + "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>" )); auto payload = parser.getPayload<MIXDestroy>(); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp index 7a422f4..0ad4589 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp @@ -14,7 +14,7 @@ using namespace Swift; TEST(MIXJoinParserTest, XEP0369_Example22) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<join xmlns=\"urn:xmpp:mix:1\" channel=\"coven@mix.shakespeare.example\">" + "<join xmlns=\"urn:xmpp:mix:0\" channel=\"coven@mix.shakespeare.example\">" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>" @@ -30,18 +30,17 @@ TEST(MIXJoinParserTest, XEP0369_Example22) { ASSERT_FALSE(payload->getJID()); ASSERT_FALSE(payload->getForm()); - const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions(); - ASSERT_EQ(static_cast<size_t>(4), items.size()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:participants"), items[2]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:config"), items[3]->getNode()); + ASSERT_EQ(static_cast<size_t>(4), payload->getSubscriptions().size()); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:participants"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:config"))); } TEST(MIXJoinParserTest, XEP0369_Example23) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<join xmlns=\"urn:xmpp:mix:1\">" + "<join xmlns=\"urn:xmpp:mix:0\">" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>" @@ -56,18 +55,17 @@ TEST(MIXJoinParserTest, XEP0369_Example23) { ASSERT_FALSE(payload->getJID()); ASSERT_FALSE(payload->getForm()); - const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions(); - ASSERT_EQ(static_cast<size_t>(4), items.size()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:participants"), items[2]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:config"), items[3]->getNode()); + ASSERT_EQ(static_cast<size_t>(4), payload->getSubscriptions().size()); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:participants"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:config"))); } TEST(MIXJoinParserTest, XEP0369_Example24) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<join xmlns=\"urn:xmpp:mix:1\" jid=\"123456#coven@mix.shakespeare.example\">" + "<join xmlns=\"urn:xmpp:mix:0\" jid=\"123456#coven@mix.shakespeare.example\">" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>" @@ -83,23 +81,22 @@ TEST(MIXJoinParserTest, XEP0369_Example24) { ASSERT_EQ(JID("123456#coven@mix.shakespeare.example"), *payload->getJID()); ASSERT_FALSE(payload->getForm()); - const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions(); - ASSERT_EQ(static_cast<size_t>(4), items.size()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:participants"), items[2]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:config"), items[3]->getNode()); + ASSERT_EQ(static_cast<size_t>(4), payload->getSubscriptions().size()); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:participants"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:config"))); } TEST(MIXJoinParserTest, XEP0369_Example29) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<join xmlns=\"urn:xmpp:mix:1\">" + "<join xmlns=\"urn:xmpp:mix:0\">" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<x xmlns=\"jabber:x:data\" type=\"submit\">" "<field var=\"FORM_TYPE\" type=\"hidden\">" - "<value>urn:xmpp:mix:1</value>" + "<value>urn:xmpp:mix:0</value>" "</field>" "<field var=\"JID Visibility\">" "<value>never</value>" @@ -112,10 +109,10 @@ TEST(MIXJoinParserTest, XEP0369_Example29) { ASSERT_FALSE(payload->getChannel()); ASSERT_FALSE(payload->getJID()); - const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions(); - ASSERT_EQ(static_cast<size_t>(2), items.size()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode()); + + ASSERT_EQ(static_cast<size_t>(2), payload->getSubscriptions().size()); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence"))); ASSERT_TRUE(payload->getForm()); ASSERT_EQ(Form::Type::SubmitType, payload->getForm()->getType()); @@ -130,12 +127,12 @@ TEST(MIXJoinParserTest, XEP0369_Example29) { TEST(MIXJoinParserTest, XEP0369_Example30) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<join xmlns=\"urn:xmpp:mix:1\" jid=\"hag66@shakespeare.example\">" + "<join xmlns=\"urn:xmpp:mix:0\" jid=\"hag66@shakespeare.example\">" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<x xmlns=\"jabber:x:data\" type=\"result\">" "<field var=\"FORM_TYPE\" type=\"hidden\">" - "<value>urn:xmpp:mix:1</value>" + "<value>urn:xmpp:mix:0</value>" "</field>" "<field var=\"JID Visibility\">" "<value>never</value>" @@ -156,10 +153,9 @@ TEST(MIXJoinParserTest, XEP0369_Example30) { ASSERT_TRUE(payload->getJID()); ASSERT_EQ(JID("hag66@shakespeare.example"), *payload->getJID()); - const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions(); - ASSERT_EQ(static_cast<size_t>(2), items.size()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode()); - ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode()); + ASSERT_EQ(static_cast<size_t>(2), payload->getSubscriptions().size()); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages"))); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence"))); ASSERT_TRUE(payload->getForm()); ASSERT_EQ(Form::Type::ResultType, payload->getForm()->getType()); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp new file mode 100644 index 0000000..0a2839e --- /dev/null +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Elements/MIXLeave.h> +#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h> + +using namespace Swift; + +TEST(MIXLeaveParserTest, XEP0369_Example33) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse("<leave xmlns=\"urn:xmpp:mix:0\" channel=\"coven@mix.shakespeare.example\"/>")); + + auto payload = parser.getPayload<MIXLeave>(); + ASSERT_TRUE(payload); + + ASSERT_TRUE(payload->getChannel()); + ASSERT_EQ(JID("coven@mix.shakespeare.example"), *payload->getChannel()); +} + +TEST(MIXLeaveParserTest, XEP0369_Example34) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse("<leave xmlns=\"urn:xmpp:mix:0\"/>")); + + auto payload = parser.getPayload<MIXLeave>(); + ASSERT_TRUE(payload); + ASSERT_FALSE(payload->getChannel()); +} diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp index 27c02e7..57d4b35 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp @@ -54,6 +54,3 @@ TEST(MIXParticipantParserTest, XEP0369_Example27_ParticipantEmpty) { ASSERT_FALSE(payload->getNick()); ASSERT_FALSE(payload->getJID()); } - - - diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp new file mode 100644 index 0000000..920aca7 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Elements/MIXPayload.h> +#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h> + +using namespace Swift; + +TEST(MIXPayloadParserTest, WithNick) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse( + "<mix xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </mix>" + )); + + auto payload = parser.getPayload<MIXPayload>(); + ASSERT_TRUE(payload); + + ASSERT_TRUE(payload->getNick()); + std::string nick = *payload->getNick(); + ASSERT_EQ("thirdwitch", nick); + + ASSERT_FALSE(payload->getJID()); + ASSERT_FALSE(payload->getSubmissionID()); +} + +TEST(MIXPayloadParserTest, WithJID) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse( + "<mix xmlns=\"urn:xmpp:mix:0\"> <jid>hecate@mix.shakespeare.example</jid> </mix>" + )); + + auto payload = parser.getPayload<MIXPayload>(); + ASSERT_TRUE(payload); + + ASSERT_TRUE(payload->getJID()); + JID jid = *payload->getJID(); + ASSERT_EQ("hecate@mix.shakespeare.example", jid.toString()); + + ASSERT_FALSE(payload->getNick()); + ASSERT_FALSE(payload->getSubmissionID()); +} + +TEST(MIXPayloadParserTest, WithAll) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse( + "<mix xmlns=\"urn:xmpp:mix:0\">" + "<nick>thirdwitch</nick>" + "<jid>hecate@mix.shakespeare.example</jid>" + "<submission-id>92vax143g</submission-id>" + "</mix>" + )); + + auto payload = parser.getPayload<MIXPayload>(); + ASSERT_TRUE(payload); + + ASSERT_TRUE(payload->getNick()); + std::string nick = *payload->getNick(); + ASSERT_EQ("thirdwitch", nick); + + ASSERT_TRUE(payload->getJID()); + JID jid = *payload->getJID(); + ASSERT_EQ("hecate@mix.shakespeare.example", jid.toString()); + + ASSERT_TRUE(payload->getSubmissionID()); + std::string subID = *payload->getSubmissionID(); + ASSERT_EQ("92vax143g", subID); +} + +TEST(MIXPayloadParserTest, Empty) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse( + "<mix xmlns=\"urn:xmpp:mix:0\"/>" + )); + + auto payload = parser.getPayload<MIXPayload>(); + ASSERT_TRUE(payload); + ASSERT_FALSE(payload->getNick()); + ASSERT_FALSE(payload->getJID()); + ASSERT_FALSE(payload->getSubmissionID()); +} diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp new file mode 100644 index 0000000..d0539fd --- /dev/null +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Elements/MIXRegisterNick.h> +#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h> + +using namespace Swift; + +TEST(MIXRegisterNickParserTest, WithNick) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse( + "<register xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </register>" + )); + + auto payload = parser.getPayload<MIXRegisterNick>(); + ASSERT_TRUE(payload); + ASSERT_EQ("thirdwitch", payload->getNick()); +} diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp new file mode 100644 index 0000000..84f8a5e --- /dev/null +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Elements/MIXSetNick.h> +#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h> + +using namespace Swift; + +TEST(MIXSetNickParserTest, WithNick) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse( + "<setnick xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </setnick>" + )); + + auto payload = parser.getPayload<MIXSetNick>(); + ASSERT_TRUE(payload); + ASSERT_EQ("thirdwitch", payload->getNick()); +} diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp new file mode 100644 index 0000000..985a34b --- /dev/null +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Elements/MIXUpdateSubscription.h> +#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h> + +using namespace Swift; + +TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse( + "<update-subscription xmlns=\"urn:xmpp:mix:0\">" + "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" + "</update-subscription>" + )); + + auto payload = parser.getPayload<MIXUpdateSubscription>(); + ASSERT_TRUE(payload); + + ASSERT_FALSE(payload->getJID()); + + auto items = payload->getSubscriptions(); + ASSERT_EQ(static_cast<size_t>(1), items.size()); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages"))); +} + +TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28_WithJID) { + PayloadsParserTester parser; + ASSERT_TRUE(parser.parse( + "<update-subscription xmlns=\"urn:xmpp:mix:0\" jid=\"hag66@shakespeare.example\">" + "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" + "</update-subscription>" + )); + + auto payload = parser.getPayload<MIXUpdateSubscription>(); + ASSERT_TRUE(payload); + + ASSERT_TRUE(payload->getJID()); + ASSERT_EQ(JID("hag66@shakespeare.example"), *payload->getJID()); + + auto items = payload->getSubscriptions(); + ASSERT_EQ(static_cast<size_t>(1), items.size()); + ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages"))); +} diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp index 3d048a5..7115f2a 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp @@ -14,7 +14,7 @@ using namespace Swift; TEST(MIXUserPreferenceParserTest, XEP0369_Example31) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<user-preference xmlns='urn:xmpp:mix:1'/>" + "<user-preference xmlns='urn:xmpp:mix:0'/>" )); auto payload = parser.getPayload<MIXUserPreference>(); @@ -26,10 +26,10 @@ TEST(MIXUserPreferenceParserTest, XEP0369_Example31) { TEST(MIXUserPreferenceParserTest, XEP0369_Example32) { PayloadsParserTester parser; ASSERT_TRUE(parser.parse( - "<user-preference xmlns='urn:xmpp:mix:1'>" + "<user-preference xmlns='urn:xmpp:mix:0'>" "<x xmlns='jabber:x:data' type='result'>" "<field var='FORM_TYPE' type='hidden'>" - "<value>urn:xmpp:mix:1</value>" + "<value>urn:xmpp:mix:0</value>" "</field>" "<field var='JID Visibility'>" "<value>never</value>" diff --git a/Swiften/Parser/PayloadParsers/UserLocationParser.h b/Swiften/Parser/PayloadParsers/UserLocationParser.h index 1445d3e..39df9de 100644 --- a/Swiften/Parser/PayloadParsers/UserLocationParser.h +++ b/Swiften/Parser/PayloadParsers/UserLocationParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/UserLocation.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -18,11 +17,11 @@ namespace Swift { class SWIFTEN_API UserLocationParser : public GenericPayloadParser<UserLocation> { public: UserLocationParser(); - virtual ~UserLocationParser(); + virtual ~UserLocationParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PayloadParsers/UserTuneParser.h b/Swiften/Parser/PayloadParsers/UserTuneParser.h index 5a27273..8c7e8c5 100644 --- a/Swiften/Parser/PayloadParsers/UserTuneParser.h +++ b/Swiften/Parser/PayloadParsers/UserTuneParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <string> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/UserTune.h> #include <Swiften/Parser/GenericPayloadParser.h> @@ -18,11 +17,11 @@ namespace Swift { class SWIFTEN_API UserTuneParser : public GenericPayloadParser<UserTune> { public: UserTuneParser(); - virtual ~UserTuneParser(); + virtual ~UserTuneParser() override; - virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) SWIFTEN_OVERRIDE; - virtual void handleEndElement(const std::string& element, const std::string&) SWIFTEN_OVERRIDE; - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) override; + virtual void handleEndElement(const std::string& element, const std::string&) override; + virtual void handleCharacterData(const std::string& data) override; private: int level; diff --git a/Swiften/Parser/PlatformXMLParserFactory.cpp b/Swiften/Parser/PlatformXMLParserFactory.cpp index 97e1c9e..bf66734 100644 --- a/Swiften/Parser/PlatformXMLParserFactory.cpp +++ b/Swiften/Parser/PlatformXMLParserFactory.cpp @@ -22,9 +22,9 @@ PlatformXMLParserFactory::PlatformXMLParserFactory() { std::unique_ptr<XMLParser> PlatformXMLParserFactory::createXMLParser(XMLParserClient* client) { #ifdef HAVE_LIBXML - return std::unique_ptr<XMLParser>(new LibXMLParser(client)); + return std::make_unique<LibXMLParser>(client); #else - return std::unique_ptr<XMLParser>(new ExpatParser(client)); + return std::make_unique<ExpatParser>(client); #endif } diff --git a/Swiften/Parser/SConscript b/Swiften/Parser/SConscript index 3c778f5..30c61a7 100644 --- a/Swiften/Parser/SConscript +++ b/Swiften/Parser/SConscript @@ -68,11 +68,15 @@ sources = [ "PayloadParsers/VCardUpdateParser.cpp", "PayloadParsers/DelayParser.cpp", "PayloadParsers/MIXParticipantParser.cpp", + "PayloadParsers/MIXSetNickParser.cpp", + "PayloadParsers/MIXRegisterNickParser.cpp", "PayloadParsers/MIXDestroyParser.cpp", "PayloadParsers/MIXCreateParser.cpp", + "PayloadParsers/MIXPayloadParser.cpp", + "PayloadParsers/MIXLeaveParser.cpp", "PayloadParsers/MIXJoinParser.cpp", - "PayloadParsers/MIXSubscribeParser.cpp", "PayloadParsers/MIXUserPreferenceParser.cpp", + "PayloadParsers/MIXUpdateSubscriptionParser.cpp", "PayloadParsers/MUCUserPayloadParser.cpp", "PayloadParsers/MUCAdminPayloadParser.cpp", "PayloadParsers/MUCOwnerPayloadParser.cpp", diff --git a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp index 38e67fb..e313124 100644 --- a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp +++ b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp @@ -29,12 +29,12 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture { public: void setUp() { - channel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel()); + channel = std::make_unique<DummyStanzaChannel>(); testPresence = std::make_shared<Presence>(); testPresence->setStatus("Foo"); secondTestPresence = std::make_shared<Presence>(); secondTestPresence->setStatus("Bar"); - stanzaChannelPresenceSender = std::unique_ptr<StanzaChannelPresenceSender>(new StanzaChannelPresenceSender(channel.get())); + stanzaChannelPresenceSender = std::make_unique<StanzaChannelPresenceSender>(channel.get()); } void testSendPresence() { diff --git a/Swiften/PubSub/PubSubManager.h b/Swiften/PubSub/PubSubManager.h index eba5dd9..477b3de 100644 --- a/Swiften/PubSub/PubSubManager.h +++ b/Swiften/PubSub/PubSubManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include <boost/signals2.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/IQ.h> #include <Swiften/Elements/PubSub.h> #include <Swiften/Elements/PubSubAffiliations.h> diff --git a/Swiften/PubSub/PubSubManagerImpl.h b/Swiften/PubSub/PubSubManagerImpl.h index 2f2b96b..0d0739c 100644 --- a/Swiften/PubSub/PubSubManagerImpl.h +++ b/Swiften/PubSub/PubSubManagerImpl.h @@ -9,11 +9,10 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/PubSub/PubSubManager.h> #define SWIFTEN_PUBSUBMANAGERIMPL_DECLARE_CREATE_REQUEST(payload, container, response) \ virtual std::shared_ptr< PubSubRequest<payload> > \ - createRequest(IQ::Type type, const JID& receiver, std::shared_ptr<payload> p) SWIFTEN_OVERRIDE { \ + createRequest(IQ::Type type, const JID& receiver, std::shared_ptr<payload> p) override { \ return std::make_shared< PubSubRequest<payload> >(type, receiver, p, router); \ } @@ -24,7 +23,7 @@ namespace Swift { class SWIFTEN_API PubSubManagerImpl : public PubSubManager { public: PubSubManagerImpl(StanzaChannel* stanzaChannel, IQRouter* router); - virtual ~PubSubManagerImpl(); + virtual ~PubSubManagerImpl() override; SWIFTEN_PUBSUB_FOREACH_PUBSUB_PAYLOAD_TYPE( SWIFTEN_PUBSUBMANAGERIMPL_DECLARE_CREATE_REQUEST) diff --git a/Swiften/QA/TLSTest/CertificateTest.cpp b/Swiften/QA/TLSTest/CertificateTest.cpp index b53cd2f..02ec0f8 100644 --- a/Swiften/QA/TLSTest/CertificateTest.cpp +++ b/Swiften/QA/TLSTest/CertificateTest.cpp @@ -34,7 +34,7 @@ class CertificateTest : public CppUnit::TestFixture { public: void setUp() { - pathProvider = std::unique_ptr<PlatformApplicationPathProvider>(new PlatformApplicationPathProvider("FileReadBytestreamTest")); + pathProvider = std::make_unique<PlatformApplicationPathProvider>("FileReadBytestreamTest"); readByteArrayFromFile(certificateData, (pathProvider->getExecutableDir() / "jabber_org.crt")); certificateFactory = std::unique_ptr<CertificateFactory>(new CERTIFICATE_FACTORY()); } diff --git a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp index 8a4b9fc..ed242f9 100644 --- a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp +++ b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp @@ -34,8 +34,8 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { public: void setUp() { - channel = std::unique_ptr<DummyIQChannel>(new DummyIQChannel()); - router = std::unique_ptr<IQRouter>(new IQRouter(channel.get())); + channel = std::make_unique<DummyIQChannel>(); + router = std::make_unique<IQRouter>(channel.get()); } void tearDown() { diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp index 94bfed1..fa5072b 100644 --- a/Swiften/Queries/UnitTest/ResponderTest.cpp +++ b/Swiften/Queries/UnitTest/ResponderTest.cpp @@ -32,8 +32,8 @@ class ResponderTest : public CppUnit::TestFixture { public: void setUp() { - channel_ = std::unique_ptr<DummyIQChannel>(new DummyIQChannel()); - router_ = std::unique_ptr<IQRouter>(new IQRouter(channel_.get())); + channel_ = std::make_unique<DummyIQChannel>(); + router_ = std::make_unique<IQRouter>(channel_.get()); payload_ = std::make_shared<SoftwareVersion>("foo"); } diff --git a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp index 73e76d3..4137ebf 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp +++ b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp @@ -30,8 +30,8 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { jid1_ = JID("a@b.c"); jid2_ = JID("b@c.d"); jid3_ = JID("c@d.e"); - roster_ = std::unique_ptr<XMPPRosterImpl>(new XMPPRosterImpl()); - handler_ = std::unique_ptr<XMPPRosterSignalHandler>(new XMPPRosterSignalHandler(roster_.get())); + roster_ = std::make_unique<XMPPRosterImpl>(); + handler_ = std::make_unique<XMPPRosterSignalHandler>(roster_.get()); groups1_.push_back("bobs"); groups1_.push_back("berts"); groups2_.push_back("ernies"); diff --git a/Swiften/SASL/EXTERNALClientAuthenticator.cpp b/Swiften/SASL/EXTERNALClientAuthenticator.cpp index 546140f..027bc89 100644 --- a/Swiften/SASL/EXTERNALClientAuthenticator.cpp +++ b/Swiften/SASL/EXTERNALClientAuthenticator.cpp @@ -12,7 +12,13 @@ EXTERNALClientAuthenticator::EXTERNALClientAuthenticator() : ClientAuthenticator } boost::optional<SafeByteArray> EXTERNALClientAuthenticator::getResponse() const { - return boost::optional<SafeByteArray>(); + const std::string& authorizationID = getAuthorizationID(); + + if (authorizationID.empty()) { + return boost::optional<SafeByteArray>(); + } else { + return createSafeByteArray(authorizationID); + } } bool EXTERNALClientAuthenticator::setChallenge(const boost::optional<ByteArray>&) { diff --git a/Swiften/SASL/SConscript b/Swiften/SASL/SConscript index 6aa3e72..8a248cc 100644 --- a/Swiften/SASL/SConscript +++ b/Swiften/SASL/SConscript @@ -23,6 +23,7 @@ swiften_env.Append(SWIFTEN_OBJECTS = [objects]) env.Append(UNITTEST_SOURCES = [ File("UnitTest/PLAINMessageTest.cpp"), File("UnitTest/PLAINClientAuthenticatorTest.cpp"), + File("UnitTest/EXTERNALClientAuthenticatorTest.cpp"), File("UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp"), File("UnitTest/DIGESTMD5PropertiesTest.cpp"), File("UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp"), diff --git a/Swiften/SASL/UnitTest/EXTERNALClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/EXTERNALClientAuthenticatorTest.cpp new file mode 100644 index 0000000..728eed6 --- /dev/null +++ b/Swiften/SASL/UnitTest/EXTERNALClientAuthenticatorTest.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <QA/Checker/IO.h> + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + +#include <Swiften/SASL/EXTERNALClientAuthenticator.h> + +using namespace Swift; + +class EXTERNALClientAuthenticatorTest : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(EXTERNALClientAuthenticatorTest); + CPPUNIT_TEST(testGetResponse_WithoutAuthzID); + CPPUNIT_TEST(testGetResponse_WithAuthzID); + CPPUNIT_TEST_SUITE_END(); + + public: + void testGetResponse_WithoutAuthzID() { + EXTERNALClientAuthenticator testling; + + // Authcid and password are not used (ignored) + testling.setCredentials("user", createSafeByteArray("pass")); + + boost::optional<SafeByteArray> response = testling.getResponse(); + + // No data should have been returned + bool result = !response; + + CPPUNIT_ASSERT(result); + } + + void testGetResponse_WithAuthzID() { + EXTERNALClientAuthenticator testling; + + // Authcid and password are not used (ignored) + testling.setCredentials("user", createSafeByteArray("pass"), "authz"); + + CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), createSafeByteArray("authz", 5)); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(EXTERNALClientAuthenticatorTest); diff --git a/Swiften/SConscript b/Swiften/SConscript index f52637b..5fb3b47 100644 --- a/Swiften/SConscript +++ b/Swiften/SConscript @@ -164,6 +164,8 @@ if env["SCONS_STAGE"] == "build" : "Elements/IsodeIQDelegation.cpp", "Entity/Entity.cpp", "Entity/PayloadPersister.cpp", + "MIX/MIX.cpp", + "MIX/MIXImpl.cpp", "MUC/MUC.cpp", "MUC/MUCImpl.cpp", "MUC/MUCManager.cpp", @@ -208,11 +210,15 @@ if env["SCONS_STAGE"] == "build" : "Serializer/PayloadSerializers/ErrorSerializer.cpp", "Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp", "Serializer/PayloadSerializers/MIXParticipantSerializer.cpp", + "Serializer/PayloadSerializers/MIXSetNickSerializer.cpp", + "Serializer/PayloadSerializers/MIXRegisterNickSerializer.cpp", "Serializer/PayloadSerializers/MIXDestroySerializer.cpp", "Serializer/PayloadSerializers/MIXCreateSerializer.cpp", + "Serializer/PayloadSerializers/MIXPayloadSerializer.cpp", "Serializer/PayloadSerializers/MIXUserPreferenceSerializer.cpp", + "Serializer/PayloadSerializers/MIXLeaveSerializer.cpp", "Serializer/PayloadSerializers/MIXJoinSerializer.cpp", - "Serializer/PayloadSerializers/MIXSubscribeSerializer.cpp", + "Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.cpp", "Serializer/PayloadSerializers/MUCPayloadSerializer.cpp", "Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp", "Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp", @@ -411,6 +417,7 @@ if env["SCONS_STAGE"] == "build" : File("LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp"), File("LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp"), File("LinkLocal/UnitTest/LinkLocalServiceTest.cpp"), + File("MIX/UnitTest/MIXImplTest.cpp"), File("MUC/UnitTest/MUCTest.cpp"), File("MUC/UnitTest/MockMUC.cpp"), File("Network/UnitTest/HostAddressTest.cpp"), @@ -437,7 +444,12 @@ if env["SCONS_STAGE"] == "build" : File("Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp"), File("Parser/PayloadParsers/UnitTest/JingleParserTest.cpp"), File("Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp"), + File("Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp"), + File("Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp"), + File("Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp"), + File("Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp"), File("Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp"), + File("Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp"), File("Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp"), File("Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp"), File("Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp"), @@ -521,9 +533,14 @@ if env["SCONS_STAGE"] == "build" : File("Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/MUCAdminPayloadSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/MIXParticipantSerializerTest.cpp"), + File("Serializer/PayloadSerializers/UnitTest/MIXSetNickSerializerTest.cpp"), + File("Serializer/PayloadSerializers/UnitTest/MIXUpdateSubscriptionSerializerTest.cpp"), + File("Serializer/PayloadSerializers/UnitTest/MIXRegisterNickSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp"), + File("Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp"), + File("Serializer/PayloadSerializers/UnitTest/MIXLeaveSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/DeliveryReceiptSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/IdleSerializerTest.cpp"), @@ -558,6 +575,10 @@ if env["SCONS_STAGE"] == "build" : File("Whiteboard/UnitTest/WhiteboardServerTest.cpp"), File("Whiteboard/UnitTest/WhiteboardClientTest.cpp"), ]) + if env.get("HAVE_OPENSSL", 0) : + env.Append(UNITTEST_SOURCES = [ + File("TLS/UnitTest/ClientServerTest.cpp"), + ]) # Generate the Swiften header def relpath(path, start) : diff --git a/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h b/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h index f3eb6fb..439e684 100644 --- a/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/ForwardedSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Forwarded.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API ForwardedSerializer : public GenericPayloadSerializer<Forwarded> { public: ForwardedSerializer(PayloadSerializerCollection* serializers); - virtual ~ForwardedSerializer(); + virtual ~ForwardedSerializer() override; - virtual std::string serializePayload(std::shared_ptr<Forwarded>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<Forwarded>) const override; private: PayloadSerializerCollection* serializers_; diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp index 9832bd5..428ce76 100644 --- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp +++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp @@ -47,9 +47,14 @@ #include <Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.h> +#include <Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MIXParticipantSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h> @@ -161,9 +166,14 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() { serializers_.push_back(new ForwardedSerializer(this)); serializers_.push_back(new MIXParticipantSerializer()); serializers_.push_back(new MIXCreateSerializer()); + serializers_.push_back(new MIXRegisterNickSerializer()); + serializers_.push_back(new MIXPayloadSerializer()); + serializers_.push_back(new MIXSetNickSerializer()); serializers_.push_back(new MIXUserPreferenceSerializer()); + serializers_.push_back(new MIXLeaveSerializer()); serializers_.push_back(new MIXJoinSerializer()); serializers_.push_back(new MIXDestroySerializer()); + serializers_.push_back(new MIXUpdateSubscriptionSerializer()); serializers_.push_back(new MAMResultSerializer(this)); serializers_.push_back(new MAMQuerySerializer()); serializers_.push_back(new MAMFinSerializer()); diff --git a/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h b/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h index e7cfef9..419e2d5 100644 --- a/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/IsodeIQDelegationSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/IsodeIQDelegation.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API IsodeIQDelegationSerializer : public GenericPayloadSerializer<IsodeIQDelegation> { public: IsodeIQDelegationSerializer(PayloadSerializerCollection* serializers); - virtual ~IsodeIQDelegationSerializer(); - - virtual std::string serializePayload(std::shared_ptr<IsodeIQDelegation>) const SWIFTEN_OVERRIDE; - - private: + virtual ~IsodeIQDelegationSerializer() override; + virtual std::string serializePayload(std::shared_ptr<IsodeIQDelegation>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h b/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h index 7c5bd29..d8cff6a 100644 --- a/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MAMFin.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -17,8 +16,8 @@ namespace Swift { class SWIFTEN_API MAMFinSerializer : public GenericPayloadSerializer<MAMFin> { public: MAMFinSerializer(); - virtual ~MAMFinSerializer(); + virtual ~MAMFinSerializer() override; - virtual std::string serializePayload(std::shared_ptr<MAMFin>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<MAMFin>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h b/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h index 6b2403f..e2ed063 100644 --- a/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MAMQuerySerializer.h @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MAMQuery.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -17,8 +16,8 @@ namespace Swift { class SWIFTEN_API MAMQuerySerializer : public GenericPayloadSerializer<MAMQuery> { public: MAMQuerySerializer(); - virtual ~MAMQuerySerializer(); + virtual ~MAMQuerySerializer() override; - virtual std::string serializePayload(std::shared_ptr<MAMQuery>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<MAMQuery>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h b/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h index f4fc054..5cac8c4 100644 --- a/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MAMResultSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MAMResult.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API MAMResultSerializer : public GenericPayloadSerializer<MAMResult> { public: MAMResultSerializer(PayloadSerializerCollection* serializers); - virtual ~MAMResultSerializer(); + virtual ~MAMResultSerializer() override; - virtual std::string serializePayload(std::shared_ptr<MAMResult>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<MAMResult>) const override; private: PayloadSerializerCollection* serializers_; diff --git a/Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.cpp index 9476df2..2034d86 100644 --- a/Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.cpp @@ -24,7 +24,7 @@ std::string MIXCreateSerializer::serializePayload(std::shared_ptr<MIXCreate> pay if (!payload) { return ""; } - XMLElement element("create", "urn:xmpp:mix:1"); + XMLElement element("create", "urn:xmpp:mix:0"); if(payload->getChannel()) { element.setAttribute("channel", *payload->getChannel()); diff --git a/Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.h b/Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.h index 23cc65d..54f3adc 100644 --- a/Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MIXCreateSerializer.h @@ -4,12 +4,17 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MIXCreate.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -18,8 +23,8 @@ namespace Swift { class SWIFTEN_API MIXCreateSerializer : public GenericPayloadSerializer<MIXCreate> { public: MIXCreateSerializer(); - virtual ~MIXCreateSerializer(); + virtual ~MIXCreateSerializer() override; - virtual std::string serializePayload(std::shared_ptr<MIXCreate>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<MIXCreate>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.cpp index a395416..ed0d252 100644 --- a/Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.cpp @@ -24,7 +24,7 @@ std::string MIXDestroySerializer::serializePayload(std::shared_ptr<MIXDestroy> p if (!payload) { return ""; } - XMLElement element("destroy", "urn:xmpp:mix:1"); + XMLElement element("destroy", "urn:xmpp:mix:0"); element.setAttribute("channel", payload->getChannel()); return element.serialize(); } diff --git a/Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.h b/Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.h index c14c0dd..a0640a1 100644 --- a/Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MIXDestroySerializer.h @@ -4,12 +4,17 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MIXDestroy.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -18,8 +23,8 @@ namespace Swift { class SWIFTEN_API MIXDestroySerializer : public GenericPayloadSerializer<MIXDestroy> { public: MIXDestroySerializer(); - virtual ~MIXDestroySerializer(); + virtual ~MIXDestroySerializer() override; - virtual std::string serializePayload(std::shared_ptr<MIXDestroy>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<MIXDestroy>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.cpp index cae15c2..509e41e 100644 --- a/Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.cpp @@ -7,8 +7,8 @@ #include <Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.h> #include <memory> +#include <string> -#include <Swiften/Serializer/PayloadSerializers/MIXSubscribeSerializer.h> #include <Swiften/Serializer/PayloadSerializers/FormSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> @@ -25,16 +25,23 @@ std::string MIXJoinSerializer::serializePayload(std::shared_ptr<MIXJoin> payload if (!payload) { return ""; } - XMLElement element("join", "urn:xmpp:mix:1"); + XMLElement element("join", "urn:xmpp:mix:0"); if (payload->getChannel()) { element.setAttribute("channel", *payload->getChannel()); } if (payload->getJID()) { element.setAttribute("jid", *payload->getJID()); } - for (const auto& item : payload->getSubscriptions()) { - element.addNode(std::make_shared<XMLRawTextNode>(MIXSubscribeSerializer().serialize(item))); + auto subscriptionData = payload->getSubscriptions(); + std::vector<std::string> subscriptions(subscriptionData.begin(), subscriptionData.end()); + std::sort(subscriptions.begin(), subscriptions.end()); + + for (const auto& item : subscriptions) { + auto subscribeElement = std::make_shared<XMLElement>("subscribe"); + subscribeElement->setAttribute("node", item); + element.addNode(subscribeElement); } + if (payload->getForm()) { element.addNode(std::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getForm()))); } diff --git a/Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.h b/Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.h index a53fbe3..9be6915 100644 --- a/Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MIXJoinSerializer.h @@ -4,12 +4,17 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MIXJoin.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -18,8 +23,8 @@ namespace Swift { class SWIFTEN_API MIXJoinSerializer : public GenericPayloadSerializer<MIXJoin> { public: MIXJoinSerializer(); - virtual ~MIXJoinSerializer(); + virtual ~MIXJoinSerializer() override; - virtual std::string serializePayload(std::shared_ptr<MIXJoin>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<MIXJoin>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.cpp new file mode 100644 index 0000000..111186a --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.h> + +#include <memory> + +#include <Swiften/Serializer/XML/XMLElement.h> + +namespace Swift { + +MIXLeaveSerializer::MIXLeaveSerializer() { +} + +MIXLeaveSerializer::~MIXLeaveSerializer() { +} + +std::string MIXLeaveSerializer::serializePayload(std::shared_ptr<MIXLeave> payload) const { + if (!payload) { + return ""; + } + XMLElement element("leave", "urn:xmpp:mix:0"); + if (payload->getChannel()) { + element.setAttribute("channel", *payload->getChannel()); + } + return element.serialize(); +} +} diff --git a/Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.h b/Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.h new file mode 100644 index 0000000..dd593b6 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <memory> + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/MIXLeave.h> +#include <Swiften/Serializer/GenericPayloadSerializer.h> + +namespace Swift { + class SWIFTEN_API MIXLeaveSerializer : public GenericPayloadSerializer<MIXLeave> { + public: + MIXLeaveSerializer(); + virtual ~MIXLeaveSerializer() override; + + virtual std::string serializePayload(std::shared_ptr<MIXLeave>) const override; + }; +} diff --git a/Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.cpp new file mode 100644 index 0000000..843270a --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.h> + +#include <memory> + +#include <Swiften/Serializer/XML/XMLElement.h> +#include <Swiften/Serializer/XML/XMLRawTextNode.h> +#include <Swiften/Serializer/XML/XMLTextNode.h> + +namespace Swift { + +MIXPayloadSerializer::MIXPayloadSerializer() : GenericPayloadSerializer<MIXPayload>() { +} + +std::string MIXPayloadSerializer::serializePayload(std::shared_ptr<MIXPayload> payload) const { + XMLElement mixElement("mix", "urn:xmpp:mix:0"); + + if (payload->getNick()) { + std::shared_ptr<XMLElement> nickElement = std::make_shared<XMLElement>("nick"); + nickElement->addNode(std::make_shared<XMLTextNode>(*payload->getNick())); + mixElement.addNode(nickElement); + } + + if (payload->getJID()) { + std::shared_ptr<XMLElement> jidElement = std::make_shared<XMLElement>("jid"); + jidElement->addNode(std::make_shared<XMLTextNode>(*payload->getJID())); + mixElement.addNode(jidElement); + } + + if (payload->getSubmissionID()) { + std::shared_ptr<XMLElement> subIDElement = std::make_shared<XMLElement>("submission-id"); + subIDElement->addNode(std::make_shared<XMLTextNode>(*payload->getSubmissionID())); + mixElement.addNode(subIDElement); + } + + return mixElement.serialize(); +} + +} diff --git a/Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.h new file mode 100644 index 0000000..bc7ec7f --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/MIXPayload.h> +#include <Swiften/Serializer/GenericPayloadSerializer.h> + +namespace Swift { + class SWIFTEN_API MIXPayloadSerializer : public GenericPayloadSerializer<MIXPayload> { + public: + MIXPayloadSerializer(); + + virtual std::string serializePayload(std::shared_ptr<MIXPayload> payload) const override; + }; +} diff --git a/Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.cpp new file mode 100644 index 0000000..9045ffe --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.h> + +#include <memory> + +#include <Swiften/Serializer/XML/XMLElement.h> +#include <Swiften/Serializer/XML/XMLTextNode.h> + +namespace Swift { + +MIXRegisterNickSerializer::MIXRegisterNickSerializer() : GenericPayloadSerializer<MIXRegisterNick>() { +} + +std::string MIXRegisterNickSerializer::serializePayload(std::shared_ptr<MIXRegisterNick> payload) const { + XMLElement registernickElement("register", "urn:xmpp:mix:0"); + + auto nickElement = std::make_shared<XMLElement>("nick"); + nickElement->addNode(std::make_shared<XMLTextNode>(payload->getNick())); + registernickElement.addNode(nickElement); + + return registernickElement.serialize(); +} + +} diff --git a/Swiften/Serializer/PayloadSerializers/MIXSubscribeSerializer.h b/Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.h index b343f86..011fb18 100644 --- a/Swiften/Serializer/PayloadSerializers/MIXSubscribeSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.h @@ -6,20 +6,15 @@ #pragma once -#include <memory> - #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> -#include <Swiften/Elements/MIXSubscribe.h> +#include <Swiften/Elements/MIXRegisterNick.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> namespace Swift { - - class SWIFTEN_API MIXSubscribeSerializer : public GenericPayloadSerializer<MIXSubscribe> { + class SWIFTEN_API MIXRegisterNickSerializer : public GenericPayloadSerializer<MIXRegisterNick> { public: - MIXSubscribeSerializer(); - virtual ~MIXSubscribeSerializer(); + MIXRegisterNickSerializer(); - virtual std::string serializePayload(std::shared_ptr<MIXSubscribe>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<MIXRegisterNick> payload) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.cpp new file mode 100644 index 0000000..d111d8c --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.h> + +#include <memory> + +#include <Swiften/Serializer/XML/XMLElement.h> +#include <Swiften/Serializer/XML/XMLTextNode.h> + +namespace Swift { + +MIXSetNickSerializer::MIXSetNickSerializer() : GenericPayloadSerializer<MIXSetNick>() { +} + +std::string MIXSetNickSerializer::serializePayload(std::shared_ptr<MIXSetNick> payload) const { + XMLElement setnickElement("setnick", "urn:xmpp:mix:0"); + + auto nickElement = std::make_shared<XMLElement>("nick"); + nickElement->addNode(std::make_shared<XMLTextNode>(payload->getNick())); + setnickElement.addNode(nickElement); + + return setnickElement.serialize(); +} + +} diff --git a/Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.h b/Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.h new file mode 100644 index 0000000..7c28d8e --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/MIXSetNick.h> +#include <Swiften/Serializer/GenericPayloadSerializer.h> + +namespace Swift { + class SWIFTEN_API MIXSetNickSerializer : public GenericPayloadSerializer<MIXSetNick> { + public: + MIXSetNickSerializer(); + + virtual std::string serializePayload(std::shared_ptr<MIXSetNick> payload) const override ; + }; +} diff --git a/Swiften/Serializer/PayloadSerializers/MIXSubscribeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXSubscribeSerializer.cpp deleted file mode 100644 index 3ce6d89..0000000 --- a/Swiften/Serializer/PayloadSerializers/MIXSubscribeSerializer.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2017 Tarun Gupta - * Licensed under the simplified BSD license. - * See Documentation/Licenses/BSD-simplified.txt for more information. - */ - -#include <Swiften/Serializer/PayloadSerializers/MIXSubscribeSerializer.h> - -#include <memory> - -#include <Swiften/Serializer/XML/XMLElement.h> -#include <Swiften/Serializer/XML/XMLRawTextNode.h> - -using namespace Swift; - -MIXSubscribeSerializer::MIXSubscribeSerializer() { -} - -MIXSubscribeSerializer::~MIXSubscribeSerializer() { -} - -std::string MIXSubscribeSerializer::serializePayload(std::shared_ptr<MIXSubscribe> payload) const { - if (!payload) { - return ""; - } - XMLElement element("subscribe"); - element.setAttribute("node", payload->getNode()); - return element.serialize(); -} diff --git a/Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.cpp new file mode 100644 index 0000000..8e95474 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.h> + +#include <memory> + +#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h> +#include <Swiften/Serializer/XML/XMLElement.h> +#include <Swiften/Serializer/XML/XMLRawTextNode.h> + +namespace Swift { + +MIXUpdateSubscriptionSerializer::MIXUpdateSubscriptionSerializer() { +} + +MIXUpdateSubscriptionSerializer::~MIXUpdateSubscriptionSerializer() { +} + +std::string MIXUpdateSubscriptionSerializer::serializePayload(std::shared_ptr<MIXUpdateSubscription> payload) const { + if (!payload) { + return ""; + } + XMLElement element("update-subscription", "urn:xmpp:mix:0"); + if (payload->getJID()) { + element.setAttribute("jid", *payload->getJID()); + } + auto subscriptionData = payload->getSubscriptions(); + std::vector<std::string> subscriptions(subscriptionData.begin(), subscriptionData.end()); + std::sort(subscriptions.begin(), subscriptions.end()); + + for (const auto& item : subscriptions) { + auto subscribeElement = std::make_shared<XMLElement>("subscribe"); + subscribeElement->setAttribute("node", item); + element.addNode(subscribeElement); + } + return element.serialize(); +} + +} diff --git a/Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.h new file mode 100644 index 0000000..ee59bf7 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <memory> + +#include <Swiften/Base/API.h> +#include <Swiften/Elements/MIXUpdateSubscription.h> +#include <Swiften/Serializer/GenericPayloadSerializer.h> + +namespace Swift { + + class SWIFTEN_API MIXUpdateSubscriptionSerializer : public GenericPayloadSerializer<MIXUpdateSubscription> { + public: + MIXUpdateSubscriptionSerializer(); + virtual ~MIXUpdateSubscriptionSerializer(); + + virtual std::string serializePayload(std::shared_ptr<MIXUpdateSubscription>) const override; + }; +} diff --git a/Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.cpp index 2d057ad..618e0b3 100644 --- a/Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.cpp @@ -24,7 +24,7 @@ std::string MIXUserPreferenceSerializer::serializePayload(std::shared_ptr<MIXUse if (!payload) { return ""; } - XMLElement element("user-preference", "urn:xmpp:mix:1"); + XMLElement element("user-preference", "urn:xmpp:mix:0"); if(payload->getData()) { element.addNode(std::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData()))); } diff --git a/Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.h b/Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.h index 301083a..f262b83 100644 --- a/Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MIXUserPreferenceSerializer.h @@ -4,12 +4,17 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MIXUserPreference.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -18,8 +23,8 @@ namespace Swift { class SWIFTEN_API MIXUserPreferenceSerializer : public GenericPayloadSerializer<MIXUserPreference> { public: MIXUserPreferenceSerializer(); - virtual ~MIXUserPreferenceSerializer(); + virtual ~MIXUserPreferenceSerializer() override; - virtual std::string serializePayload(std::shared_ptr<MIXUserPreference>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<MIXUserPreference>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h index 8862414..9b6dadb 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubAffiliation.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubAffiliationSerializer : public GenericPayloadSerializer<PubSubAffiliation> { public: PubSubAffiliationSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubAffiliationSerializer(); + virtual ~PubSubAffiliationSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubAffiliation>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubAffiliation>) const override; private: static std::string serializeType(PubSubAffiliation::Type); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h index c51d70e..b8096d3 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubAffiliations.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubAffiliationsSerializer : public GenericPayloadSerializer<PubSubAffiliations> { public: PubSubAffiliationsSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubAffiliationsSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubAffiliations>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubAffiliationsSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubAffiliations>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h index 6a6241c..ead5c4f 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubConfigure.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubConfigureSerializer : public GenericPayloadSerializer<PubSubConfigure> { public: PubSubConfigureSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubConfigureSerializer(); + virtual ~PubSubConfigureSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubConfigure>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubConfigure>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h index 876e26f..0aa32af 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubCreate.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubCreateSerializer : public GenericPayloadSerializer<PubSubCreate> { public: PubSubCreateSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubCreateSerializer(); + virtual ~PubSubCreateSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubCreate>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubCreate>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h index 4f5031b..42419e3 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubDefault.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubDefaultSerializer : public GenericPayloadSerializer<PubSubDefault> { public: PubSubDefaultSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubDefaultSerializer(); + virtual ~PubSubDefaultSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubDefault>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubDefault>) const override; private: static std::string serializeType(PubSubDefault::Type); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h index d3d1227..0f075fe 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubError.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -15,9 +14,9 @@ namespace Swift { class SWIFTEN_API PubSubErrorSerializer : public GenericPayloadSerializer<PubSubError> { public: PubSubErrorSerializer(); - virtual ~PubSubErrorSerializer(); + virtual ~PubSubErrorSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubError>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubError>) const override; private: static std::string serializeType(PubSubError::Type); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h index 9348549..766ad93 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventAssociate.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubEventAssociateSerializer : public GenericPayloadSerializer<PubSubEventAssociate> { public: PubSubEventAssociateSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventAssociateSerializer(); + virtual ~PubSubEventAssociateSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubEventAssociate>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubEventAssociate>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h index 33144e9..749abdd 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventCollection.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubEventCollectionSerializer : public GenericPayloadSerializer<PubSubEventCollection> { public: PubSubEventCollectionSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventCollectionSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubEventCollection>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubEventCollectionSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubEventCollection>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h index a1e565c..3902840 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventConfiguration.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubEventConfigurationSerializer : public GenericPayloadSerializer<PubSubEventConfiguration> { public: PubSubEventConfigurationSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventConfigurationSerializer(); + virtual ~PubSubEventConfigurationSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubEventConfiguration>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubEventConfiguration>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h index e02d44c..94f7441 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventDelete.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubEventDeleteSerializer : public GenericPayloadSerializer<PubSubEventDelete> { public: PubSubEventDeleteSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventDeleteSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubEventDelete>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubEventDeleteSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubEventDelete>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h index 0d2d426..8f9fd00 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventDisassociate.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubEventDisassociateSerializer : public GenericPayloadSerializer<PubSubEventDisassociate> { public: PubSubEventDisassociateSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventDisassociateSerializer(); + virtual ~PubSubEventDisassociateSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubEventDisassociate>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubEventDisassociate>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h index f292a53..5bb2b83 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventItem.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubEventItemSerializer : public GenericPayloadSerializer<PubSubEventItem> { public: PubSubEventItemSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventItemSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubEventItem>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubEventItemSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubEventItem>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h index 7220fde..83d3d95 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventItems.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubEventItemsSerializer : public GenericPayloadSerializer<PubSubEventItems> { public: PubSubEventItemsSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventItemsSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubEventItems>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubEventItemsSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubEventItems>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h index 161a733..533841f 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventPurge.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubEventPurgeSerializer : public GenericPayloadSerializer<PubSubEventPurge> { public: PubSubEventPurgeSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventPurgeSerializer(); + virtual ~PubSubEventPurgeSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubEventPurge>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubEventPurge>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h index 1720847..391d93e 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventRedirect.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubEventRedirectSerializer : public GenericPayloadSerializer<PubSubEventRedirect> { public: PubSubEventRedirectSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventRedirectSerializer(); + virtual ~PubSubEventRedirectSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubEventRedirect>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubEventRedirect>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h index ff2f7e7..5a70fdd 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventRetract.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubEventRetractSerializer : public GenericPayloadSerializer<PubSubEventRetract> { public: PubSubEventRetractSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventRetractSerializer(); + virtual ~PubSubEventRetractSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubEventRetract>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubEventRetract>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h index bebb101..f16a749 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <vector> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEvent.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -20,9 +19,9 @@ namespace Swift { class SWIFTEN_API PubSubEventSerializer : public GenericPayloadSerializer<PubSubEvent> { public: PubSubEventSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventSerializer(); + virtual ~PubSubEventSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubEvent>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubEvent>) const override; private: std::vector< std::shared_ptr<PayloadSerializer> > pubsubSerializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h index 7d85ba1..80830ac 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubEventSubscription.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubEventSubscriptionSerializer : public GenericPayloadSerializer<PubSubEventSubscription> { public: PubSubEventSubscriptionSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubEventSubscriptionSerializer(); + virtual ~PubSubEventSubscriptionSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubEventSubscription>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubEventSubscription>) const override; private: static std::string serializeSubscriptionType(PubSubEventSubscription::SubscriptionType); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h index 866d09b..54a8ead 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubItem.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubItemSerializer : public GenericPayloadSerializer<PubSubItem> { public: PubSubItemSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubItemSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubItem>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubItemSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubItem>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h index 51b0578..416c47e 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubItems.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubItemsSerializer : public GenericPayloadSerializer<PubSubItems> { public: PubSubItemsSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubItemsSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubItems>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubItemsSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubItems>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h index 0b7a9a7..6f30756 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOptions.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubOptionsSerializer : public GenericPayloadSerializer<PubSubOptions> { public: PubSubOptionsSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOptionsSerializer(); + virtual ~PubSubOptionsSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubOptions>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubOptions>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h index ac6379a..ae97086 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerAffiliation.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubOwnerAffiliationSerializer : public GenericPayloadSerializer<PubSubOwnerAffiliation> { public: PubSubOwnerAffiliationSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerAffiliationSerializer(); + virtual ~PubSubOwnerAffiliationSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerAffiliation>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerAffiliation>) const override; private: static std::string serializeType(PubSubOwnerAffiliation::Type); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h index 6c53189..ed244ff 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerAffiliations.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubOwnerAffiliationsSerializer : public GenericPayloadSerializer<PubSubOwnerAffiliations> { public: PubSubOwnerAffiliationsSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerAffiliationsSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerAffiliations>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubOwnerAffiliationsSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerAffiliations>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h index 528f29e..4512eda 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerConfigure.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubOwnerConfigureSerializer : public GenericPayloadSerializer<PubSubOwnerConfigure> { public: PubSubOwnerConfigureSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerConfigureSerializer(); + virtual ~PubSubOwnerConfigureSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerConfigure>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerConfigure>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h index e41900c..c19b250 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerDefault.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubOwnerDefaultSerializer : public GenericPayloadSerializer<PubSubOwnerDefault> { public: PubSubOwnerDefaultSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerDefaultSerializer(); + virtual ~PubSubOwnerDefaultSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerDefault>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerDefault>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h index c06a916..7a0cecc 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerDelete.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubOwnerDeleteSerializer : public GenericPayloadSerializer<PubSubOwnerDelete> { public: PubSubOwnerDeleteSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerDeleteSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerDelete>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubOwnerDeleteSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerDelete>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h index b179c82..13889b6 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -10,7 +10,6 @@ #include <vector> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerPubSub.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -20,9 +19,9 @@ namespace Swift { class SWIFTEN_API PubSubOwnerPubSubSerializer : public GenericPayloadSerializer<PubSubOwnerPubSub> { public: PubSubOwnerPubSubSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerPubSubSerializer(); + virtual ~PubSubOwnerPubSubSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerPubSub>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerPubSub>) const override; private: std::vector< std::shared_ptr<PayloadSerializer> > pubsubSerializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h index 32f6523..d361928 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerPurge.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubOwnerPurgeSerializer : public GenericPayloadSerializer<PubSubOwnerPurge> { public: PubSubOwnerPurgeSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerPurgeSerializer(); + virtual ~PubSubOwnerPurgeSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerPurge>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerPurge>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h index cd78fc8..c35b3ea 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerRedirect.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubOwnerRedirectSerializer : public GenericPayloadSerializer<PubSubOwnerRedirect> { public: PubSubOwnerRedirectSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerRedirectSerializer(); + virtual ~PubSubOwnerRedirectSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerRedirect>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerRedirect>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h index 9f9e80d..52089b7 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerSubscription.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubOwnerSubscriptionSerializer : public GenericPayloadSerializer<PubSubOwnerSubscription> { public: PubSubOwnerSubscriptionSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerSubscriptionSerializer(); + virtual ~PubSubOwnerSubscriptionSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerSubscription>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerSubscription>) const override; private: static std::string serializeSubscriptionType(PubSubOwnerSubscription::SubscriptionType); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h index 0c282b4..42956cf 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubOwnerSubscriptions.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubOwnerSubscriptionsSerializer : public GenericPayloadSerializer<PubSubOwnerSubscriptions> { public: PubSubOwnerSubscriptionsSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubOwnerSubscriptionsSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubOwnerSubscriptions>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubOwnerSubscriptionsSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubOwnerSubscriptions>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h index fb1af2e..5eeb8bf 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubPublish.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubPublishSerializer : public GenericPayloadSerializer<PubSubPublish> { public: PubSubPublishSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubPublishSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubPublish>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubPublishSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubPublish>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h index 64737df..23b6b59 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubRetract.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubRetractSerializer : public GenericPayloadSerializer<PubSubRetract> { public: PubSubRetractSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubRetractSerializer(); + virtual ~PubSubRetractSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubRetract>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubRetract>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h index 829f827..fb14c29 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSub.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubSerializer : public GenericPayloadSerializer<PubSub> { public: PubSubSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubSerializer(); + virtual ~PubSubSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSub>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSub>) const override; private: std::vector< std::shared_ptr<PayloadSerializer> > pubsubSerializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h index fba02fe..028a437 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubSubscribeOptions.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubSubscribeOptionsSerializer : public GenericPayloadSerializer<PubSubSubscribeOptions> { public: PubSubSubscribeOptionsSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubSubscribeOptionsSerializer(); + virtual ~PubSubSubscribeOptionsSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubSubscribeOptions>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubSubscribeOptions>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h index b48e849..1c0070b 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubSubscribe.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubSubscribeSerializer : public GenericPayloadSerializer<PubSubSubscribe> { public: PubSubSubscribeSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubSubscribeSerializer(); + virtual ~PubSubSubscribeSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubSubscribe>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubSubscribe>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h index 5a5f847..b849269 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubSubscription.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,9 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubSubscriptionSerializer : public GenericPayloadSerializer<PubSubSubscription> { public: PubSubSubscriptionSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubSubscriptionSerializer(); + virtual ~PubSubSubscriptionSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubSubscription>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubSubscription>) const override; private: static std::string serializeSubscriptionType(PubSubSubscription::SubscriptionType); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h index caeb3ef..1430cdf 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubSubscriptions.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,12 +18,9 @@ namespace Swift { class SWIFTEN_API PubSubSubscriptionsSerializer : public GenericPayloadSerializer<PubSubSubscriptions> { public: PubSubSubscriptionsSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubSubscriptionsSerializer(); - - virtual std::string serializePayload(std::shared_ptr<PubSubSubscriptions>) const SWIFTEN_OVERRIDE; - - private: + virtual ~PubSubSubscriptionsSerializer() override; + virtual std::string serializePayload(std::shared_ptr<PubSubSubscriptions>) const override; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h index 959bd9f..002d337 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/PubSubUnsubscribe.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API PubSubUnsubscribeSerializer : public GenericPayloadSerializer<PubSubUnsubscribe> { public: PubSubUnsubscribeSerializer(PayloadSerializerCollection* serializers); - virtual ~PubSubUnsubscribeSerializer(); + virtual ~PubSubUnsubscribeSerializer() override; - virtual std::string serializePayload(std::shared_ptr<PubSubUnsubscribe>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<PubSubUnsubscribe>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h index 6a1429a..6f850eb 100644 --- a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.h @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/ResultSet.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -17,8 +16,8 @@ namespace Swift { class SWIFTEN_API ResultSetSerializer : public GenericPayloadSerializer<ResultSet> { public: ResultSetSerializer(); - virtual ~ResultSetSerializer(); + virtual ~ResultSetSerializer() override; - virtual std::string serializePayload(std::shared_ptr<ResultSet>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<ResultSet>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp index 78424be..80210a5 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp @@ -14,7 +14,7 @@ TEST(MIXCreateSerializerTest, XEP0369_Example31) { MIXCreateSerializer testling; auto create = std::make_shared<MIXCreate>(); - std::string expectedResult = "<create xmlns=\"urn:xmpp:mix:1\"/>"; + std::string expectedResult = "<create xmlns=\"urn:xmpp:mix:0\"/>"; ASSERT_EQ(expectedResult, testling.serialize(create)); } @@ -24,6 +24,6 @@ TEST(MIXCreateSerializerTest, XEP0369_Example66) { auto create = std::make_shared<MIXCreate>(); create->setChannel(std::string("coven")); - std::string expectedResult = "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>"; + std::string expectedResult = "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>"; ASSERT_EQ(expectedResult, testling.serialize(create)); } diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp index e9cfa8b..5b21873 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp @@ -16,6 +16,6 @@ TEST(MIXDestroySerializerTest, XEP0369_Example31) { auto destroy = std::make_shared<MIXDestroy>(); destroy->setChannel(std::string("coven")); - std::string expectedResult = "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>"; + std::string expectedResult = "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>"; ASSERT_EQ(expectedResult, testling.serialize(destroy)); } diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp index 61d8a4a..2987a20 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp @@ -16,24 +16,16 @@ TEST(MIXJoinSerializerTest, XEP0369_Example22) { auto join = std::make_shared<MIXJoin>(); join->setChannel(JID("coven@mix.shakespeare.example")); - std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe()); - node1->setNode(std::string("urn:xmpp:mix:nodes:messages")); - join->addSubscription(node1); - std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe()); - node2->setNode(std::string("urn:xmpp:mix:nodes:presence")); - join->addSubscription(node2); - std::shared_ptr<MIXSubscribe> node3(new MIXSubscribe()); - node3->setNode(std::string("urn:xmpp:mix:nodes:participants")); - join->addSubscription(node3); - std::shared_ptr<MIXSubscribe> node4(new MIXSubscribe()); - node4->setNode(std::string("urn:xmpp:mix:nodes:config")); - join->addSubscription(node4); - - std::string expectedResult = "<join channel=\"coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:1\">" + join->addSubscription(std::string("urn:xmpp:mix:nodes:messages")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:presence")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:participants")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:config")); + + std::string expectedResult = "<join channel=\"coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:0\">" + "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" - "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>" - "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>" + "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "</join>"; ASSERT_EQ(expectedResult, testling.serialize(join)); } @@ -43,24 +35,16 @@ TEST(MIXJoinSerializerTest, XEP0369_Example23) { std::shared_ptr<MIXJoin> join(new MIXJoin()); - std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe()); - node1->setNode(std::string("urn:xmpp:mix:nodes:messages")); - join->addSubscription(node1); - std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe()); - node2->setNode(std::string("urn:xmpp:mix:nodes:presence")); - join->addSubscription(node2); - std::shared_ptr<MIXSubscribe> node3(new MIXSubscribe()); - node3->setNode(std::string("urn:xmpp:mix:nodes:participants")); - join->addSubscription(node3); - std::shared_ptr<MIXSubscribe> node4(new MIXSubscribe()); - node4->setNode(std::string("urn:xmpp:mix:nodes:config")); - join->addSubscription(node4); - - std::string expectedResult = "<join xmlns=\"urn:xmpp:mix:1\">" + join->addSubscription(std::string("urn:xmpp:mix:nodes:messages")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:presence")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:participants")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:config")); + + std::string expectedResult = "<join xmlns=\"urn:xmpp:mix:0\">" + "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" - "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>" - "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>" + "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "</join>"; ASSERT_EQ(expectedResult, testling.serialize(join)); } @@ -71,24 +55,16 @@ TEST(MIXJoinSerializerTest, XEP0369_Example24) { std::shared_ptr<MIXJoin> join(new MIXJoin()); join->setJID(JID("123456#coven@mix.shakespeare.example")); - std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe()); - node1->setNode(std::string("urn:xmpp:mix:nodes:messages")); - join->addSubscription(node1); - std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe()); - node2->setNode(std::string("urn:xmpp:mix:nodes:presence")); - join->addSubscription(node2); - std::shared_ptr<MIXSubscribe> node3(new MIXSubscribe()); - node3->setNode(std::string("urn:xmpp:mix:nodes:participants")); - join->addSubscription(node3); - std::shared_ptr<MIXSubscribe> node4(new MIXSubscribe()); - node4->setNode(std::string("urn:xmpp:mix:nodes:config")); - join->addSubscription(node4); - - std::string expectedResult = "<join jid=\"123456#coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:1\">" + join->addSubscription(std::string("urn:xmpp:mix:nodes:messages")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:presence")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:participants")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:config")); + + std::string expectedResult = "<join jid=\"123456#coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:0\">" + "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" - "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>" - "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>" + "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "</join>"; ASSERT_EQ(expectedResult, testling.serialize(join)); } @@ -98,19 +74,15 @@ TEST(MIXJoinSerializerTest, XEP0369_Example29) { std::shared_ptr<MIXJoin> join(new MIXJoin()); - std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe()); - node1->setNode(std::string("urn:xmpp:mix:nodes:messages")); - join->addSubscription(node1); - std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe()); - node2->setNode(std::string("urn:xmpp:mix:nodes:presence")); - join->addSubscription(node2); + join->addSubscription(std::string("urn:xmpp:mix:nodes:messages")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:presence")); std::shared_ptr<Form> parameters(std::make_shared<Form>()); parameters->setType(Form::Type::SubmitType); std::shared_ptr<FormField> fieldType = std::make_shared<FormField>(FormField::HiddenType); fieldType->setName("FORM_TYPE"); - fieldType->addValue("urn:xmpp:mix:1"); + fieldType->addValue("urn:xmpp:mix:0"); parameters->addField(fieldType); std::shared_ptr<FormField> fieldJIDVisibility = std::make_shared<FormField>(); @@ -120,12 +92,12 @@ TEST(MIXJoinSerializerTest, XEP0369_Example29) { join->setForm(parameters); - std::string expectedResult = "<join xmlns=\"urn:xmpp:mix:1\">" + std::string expectedResult = "<join xmlns=\"urn:xmpp:mix:0\">" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<x type=\"submit\" xmlns=\"jabber:x:data\">" "<field type=\"hidden\" var=\"FORM_TYPE\">" - "<value>urn:xmpp:mix:1</value>" + "<value>urn:xmpp:mix:0</value>" "</field>" "<field var=\"JID Visibility\">" "<value>never</value>" @@ -141,19 +113,15 @@ TEST(MIXJoinSerializerTest, XEP0369_Example30) { std::shared_ptr<MIXJoin> join(new MIXJoin()); join->setJID(JID("hag66@shakespeare.example")); - std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe()); - node1->setNode(std::string("urn:xmpp:mix:nodes:messages")); - join->addSubscription(node1); - std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe()); - node2->setNode(std::string("urn:xmpp:mix:nodes:presence")); - join->addSubscription(node2); + join->addSubscription(std::string("urn:xmpp:mix:nodes:messages")); + join->addSubscription(std::string("urn:xmpp:mix:nodes:presence")); std::shared_ptr<Form> parameters(std::make_shared<Form>()); parameters->setType(Form::Type::ResultType); std::shared_ptr<FormField> fieldType = std::make_shared<FormField>(FormField::HiddenType); fieldType->setName("FORM_TYPE"); - fieldType->addValue("urn:xmpp:mix:1"); + fieldType->addValue("urn:xmpp:mix:0"); parameters->addField(fieldType); std::shared_ptr<FormField> fieldJIDVisibility = std::make_shared<FormField>(); @@ -173,12 +141,12 @@ TEST(MIXJoinSerializerTest, XEP0369_Example30) { join->setForm(parameters); - std::string expectedResult = "<join jid=\"hag66@shakespeare.example\" xmlns=\"urn:xmpp:mix:1\">" + std::string expectedResult = "<join jid=\"hag66@shakespeare.example\" xmlns=\"urn:xmpp:mix:0\">" "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>" "<x type=\"result\" xmlns=\"jabber:x:data\">" "<field type=\"hidden\" var=\"FORM_TYPE\">" - "<value>urn:xmpp:mix:1</value>" + "<value>urn:xmpp:mix:0</value>" "</field>" "<field var=\"JID Visibility\">" "<value>never</value>" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXLeaveSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXLeaveSerializerTest.cpp new file mode 100644 index 0000000..d9537a8 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXLeaveSerializerTest.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Serializer/PayloadSerializers/MIXLeaveSerializer.h> + +using namespace Swift; + +TEST(MIXLeaveSerializerTest, XEP0369_Example33) { + MIXLeaveSerializer testling; + + auto leave = std::shared_ptr<MIXLeave>(new MIXLeave()); + leave->setChannel(JID("coven@mix.shakespeare.example")); + + std::string expectedResult = "<leave channel=\"coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:0\"/>"; + ASSERT_EQ(expectedResult, testling.serialize(leave)); +} + +TEST(MIXLeaveSerializerTest, XEP0369_Example34) { + MIXLeaveSerializer testling; + + auto leave = std::shared_ptr<MIXLeave>(new MIXLeave()); + + std::string expectedResult = "<leave xmlns=\"urn:xmpp:mix:0\"/>"; + ASSERT_EQ(expectedResult, testling.serialize(leave)); +} diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp new file mode 100644 index 0000000..266b066 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> + +using namespace Swift; + +TEST(MIXPayloadSerializerTest, testSerializeEmpty) { + MIXPayloadSerializer testling; + + auto mix = std::shared_ptr<MIXPayload>(new MIXPayload()); + + std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\"/>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} + +TEST(MIXPayloadSerializerTest, testSerializeNick) { + MIXPayloadSerializer testling; + + auto mix = std::shared_ptr<MIXPayload>(new MIXPayload()); + mix->setNick("thirdwitch"); + + std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\">" + "<nick>thirdwitch</nick>" + "</mix>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} + +TEST(MIXPayloadSerializerTest, testSerializeJID) { + MIXPayloadSerializer testling; + + auto mix = std::shared_ptr<MIXPayload>(new MIXPayload()); + mix->setJID(JID("hecate@mix.shakespeare.example")); + + std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\">" + "<jid>hecate@mix.shakespeare.example</jid>" + "</mix>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} + +TEST(MIXPayloadSerializerTest, testSerializeAll) { + MIXPayloadSerializer testling; + + auto mix = std::shared_ptr<MIXPayload>(new MIXPayload()); + mix->setNick("thirdwitch"); + mix->setJID(JID("hecate@mix.shakespeare.example")); + mix->setSubmissionID("92vax143g"); + + std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\">" + "<nick>thirdwitch</nick>" + "<jid>hecate@mix.shakespeare.example</jid>" + "<submission-id>92vax143g</submission-id>" + "</mix>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXRegisterNickSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXRegisterNickSerializerTest.cpp new file mode 100644 index 0000000..dc6cf0c --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXRegisterNickSerializerTest.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Serializer/PayloadSerializers/MIXRegisterNickSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> + +using namespace Swift; + +TEST(MIXRegisterNickSerializerTest, testSerializeNick) { + MIXRegisterNickSerializer testling; + + auto mix = std::shared_ptr<MIXRegisterNick>(new MIXRegisterNick()); + mix->setNick(std::string("thirdwitch")); + + std::string expectedResult = "<register xmlns=\"urn:xmpp:mix:0\"><nick>thirdwitch</nick></register>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXSetNickSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXSetNickSerializerTest.cpp new file mode 100644 index 0000000..ab29bc5 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXSetNickSerializerTest.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Serializer/PayloadSerializers/MIXSetNickSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> + +using namespace Swift; + +TEST(MIXSetNickSerializerTest, testSerializeNick) { + MIXSetNickSerializer testling; + + auto mix = std::shared_ptr<MIXSetNick>(new MIXSetNick()); + mix->setNick(std::string("thirdwitch")); + + std::string expectedResult = "<setnick xmlns=\"urn:xmpp:mix:0\"><nick>thirdwitch</nick></setnick>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUpdateSubscriptionSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUpdateSubscriptionSerializerTest.cpp new file mode 100644 index 0000000..3e35a82 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUpdateSubscriptionSerializerTest.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.h> + +using namespace Swift; + +TEST(MIXUpdateSubscriptionSerializerTest, XEP0369_Example28) { + MIXUpdateSubscriptionSerializer testling; + + auto update = std::make_shared<MIXUpdateSubscription>(); + update->addSubscription(std::string("urn:xmpp:mix:nodes:messages")); + + std::string expectedResult = "<update-subscription xmlns=\"urn:xmpp:mix:0\">" + "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" + "</update-subscription>"; + ASSERT_EQ(expectedResult, testling.serialize(update)); +} + +TEST(MIXUpdateSubscriptionSerializerTest, XEP0369_Example28WithJID) { + MIXUpdateSubscriptionSerializer testling; + + auto update = std::make_shared<MIXUpdateSubscription>(); + update->setJID(JID("hag66@shakespeare.example")); + update->addSubscription(std::string("urn:xmpp:mix:nodes:messages")); + + std::string expectedResult = "<update-subscription jid=\"hag66@shakespeare.example\" xmlns=\"urn:xmpp:mix:0\">" + "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>" + "</update-subscription>"; + ASSERT_EQ(expectedResult, testling.serialize(update)); +} diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp index 7cbfbfc..0226b0f 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp @@ -15,7 +15,7 @@ TEST(MIXUserPreferenceSerializerTest, XEP0369_Example31) { MIXUserPreferenceSerializer testling; auto userpreference = std::shared_ptr<MIXUserPreference>(new MIXUserPreference()); - std::string expectedResult = "<user-preference xmlns=\"urn:xmpp:mix:1\"/>"; + std::string expectedResult = "<user-preference xmlns=\"urn:xmpp:mix:0\"/>"; ASSERT_EQ(expectedResult, testling.serialize(userpreference)); } @@ -28,7 +28,7 @@ TEST(MIXUserPreferenceSerializerTest, XEP0369_Example32) { std::shared_ptr<FormField> fieldType = std::make_shared<FormField>(FormField::HiddenType); fieldType->setName("FORM_TYPE"); - fieldType->addValue("urn:xmpp:mix:1"); + fieldType->addValue("urn:xmpp:mix:0"); parameters->addField(fieldType); std::shared_ptr<FormField> fieldJIDVisibility = std::make_shared<FormField>(); @@ -48,10 +48,10 @@ TEST(MIXUserPreferenceSerializerTest, XEP0369_Example32) { userpreference->setData(parameters); - std::string expectedResult = "<user-preference xmlns=\"urn:xmpp:mix:1\">" + std::string expectedResult = "<user-preference xmlns=\"urn:xmpp:mix:0\">" "<x type=\"result\" xmlns=\"jabber:x:data\">" "<field type=\"hidden\" var=\"FORM_TYPE\">" - "<value>urn:xmpp:mix:1</value>" + "<value>urn:xmpp:mix:0</value>" "</field>" "<field var=\"JID Visibility\">" "<value>never</value>" diff --git a/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h index 5d38997..9c2f2db 100644 --- a/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/UserLocation.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API UserLocationSerializer : public GenericPayloadSerializer<UserLocation> { public: UserLocationSerializer(PayloadSerializerCollection* serializers); - virtual ~UserLocationSerializer(); + virtual ~UserLocationSerializer() override; - virtual std::string serializePayload(std::shared_ptr<UserLocation>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<UserLocation>) const override; }; } diff --git a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h index 06e9a0e..1d5737a 100644 --- a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/UserTune.h> #include <Swiften/Serializer/GenericPayloadSerializer.h> @@ -19,8 +18,8 @@ namespace Swift { class SWIFTEN_API UserTuneSerializer : public GenericPayloadSerializer<UserTune> { public: UserTuneSerializer(PayloadSerializerCollection* serializers); - virtual ~UserTuneSerializer(); + virtual ~UserTuneSerializer() override; - virtual std::string serializePayload(std::shared_ptr<UserTune>) const SWIFTEN_OVERRIDE; + virtual std::string serializePayload(std::shared_ptr<UserTune>) const override; }; } diff --git a/Swiften/TLS/CertificateFactory.cpp b/Swiften/TLS/CertificateFactory.cpp index 487f7cd..303bcf7 100644 --- a/Swiften/TLS/CertificateFactory.cpp +++ b/Swiften/TLS/CertificateFactory.cpp @@ -1,14 +1,35 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/TLS/CertificateFactory.h> +#include <cassert> +#include <memory> +#include <sstream> +#include <string> + +#include <boost/algorithm/string/predicate.hpp> +#include <boost/optional.hpp> + +#include <Swiften/Base/Log.h> +#include <Swiften/StringCodecs/Base64.h> +#include <Swiften/TLS/PrivateKey.h> + namespace Swift { CertificateFactory::~CertificateFactory() { } +std::vector<Certificate::ref> CertificateFactory::createCertificateChain(const ByteArray& /* data */) { + assert(false); + return std::vector<Certificate::ref>(); +} + +PrivateKey::ref CertificateFactory::createPrivateKey(const SafeByteArray& data, boost::optional<SafeByteArray> password) { + return std::make_shared<PrivateKey>(data, password); +} + } diff --git a/Swiften/TLS/CertificateFactory.h b/Swiften/TLS/CertificateFactory.h index 522a6e6..cb7fb6e 100644 --- a/Swiften/TLS/CertificateFactory.h +++ b/Swiften/TLS/CertificateFactory.h @@ -1,13 +1,17 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <boost/optional.hpp> + #include <Swiften/Base/API.h> +#include <Swiften/Base/SafeByteArray.h> #include <Swiften/TLS/Certificate.h> +#include <Swiften/TLS/PrivateKey.h> namespace Swift { class SWIFTEN_API CertificateFactory { @@ -15,5 +19,7 @@ namespace Swift { virtual ~CertificateFactory(); virtual Certificate* createCertificateFromDER(const ByteArray& der) = 0; + virtual std::vector<Certificate::ref> createCertificateChain(const ByteArray& data); + PrivateKey::ref createPrivateKey(const SafeByteArray& data, boost::optional<SafeByteArray> password = boost::optional<SafeByteArray>()); }; } diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp index 17ac8cc..8d2d965 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp @@ -30,7 +30,7 @@ OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) { #else const unsigned char* p = vecptr(der); #endif - cert = std::shared_ptr<X509>(d2i_X509(NULL, &p, der.size()), X509_free); + cert = std::shared_ptr<X509>(d2i_X509(nullptr, &p, der.size()), X509_free); if (!cert) { SWIFT_LOG(warning) << "Error creating certificate from DER data" << std::endl; } @@ -42,7 +42,7 @@ ByteArray OpenSSLCertificate::toDER() const { if (!cert) { return result; } - result.resize(i2d_X509(cert.get(), NULL)); + result.resize(i2d_X509(cert.get(), nullptr)); unsigned char* p = vecptr(result); i2d_X509(cert.get(), &p); return result; diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.cpp new file mode 100644 index 0000000..c94702c --- /dev/null +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h> + +#include <openssl/pem.h> + +namespace Swift { + +OpenSSLCertificateFactory::OpenSSLCertificateFactory() { +} + +OpenSSLCertificateFactory::~OpenSSLCertificateFactory() { +} + +Certificate* OpenSSLCertificateFactory::createCertificateFromDER(const ByteArray& der) { + return new OpenSSLCertificate(der); +} + +std::vector<Certificate::ref> OpenSSLCertificateFactory::createCertificateChain(const ByteArray& data) { + std::vector<Certificate::ref> certificateChain; + + if (data.size() > std::numeric_limits<int>::max()) { + return certificateChain; + } + + auto bio = std::shared_ptr<BIO>(BIO_new(BIO_s_mem()), BIO_free); + BIO_write(bio.get(), vecptr(data), int(data.size())); + + // Attempt parsing data as PEM + X509* openSSLCert = nullptr; + auto x509certFromPEM = PEM_read_bio_X509(bio.get(), &openSSLCert, nullptr, nullptr); + if (x509certFromPEM && openSSLCert) { + std::shared_ptr<X509> x509Cert(openSSLCert, X509_free); + certificateChain.push_back(std::make_shared<OpenSSLCertificate>(x509Cert)); + openSSLCert = nullptr; + while ((x509certFromPEM = PEM_read_bio_X509(bio.get(), &openSSLCert, nullptr, nullptr)) != nullptr) { + std::shared_ptr<X509> x509Cert(openSSLCert, X509_free); + certificateChain.push_back(std::make_shared<OpenSSLCertificate>(x509Cert)); + openSSLCert = nullptr; + } + } + + return certificateChain; +} + +} diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h b/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h index c996cd5..af45a33 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -12,8 +12,10 @@ namespace Swift { class OpenSSLCertificateFactory : public CertificateFactory { public: - virtual Certificate* createCertificateFromDER(const ByteArray& der) { - return new OpenSSLCertificate(der); - } + OpenSSLCertificateFactory(); + virtual ~OpenSSLCertificateFactory() override final; + + virtual Certificate* createCertificateFromDER(const ByteArray& der) override final; + virtual std::vector<Certificate::ref> createCertificateChain(const ByteArray& data) override final; }; } diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp index 0805917..89917ee 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp @@ -1,8 +1,9 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ + #include <Swiften/Base/Platform.h> #ifdef SWIFTEN_PLATFORM_WINDOWS @@ -10,15 +11,21 @@ #include <wincrypt.h> #endif +#include <cassert> +#include <memory> #include <vector> + + +#include <openssl/bio.h> #include <openssl/err.h> #include <openssl/pkcs12.h> -#include <memory> #if defined(SWIFTEN_PLATFORM_MACOSX) #include <Security/Security.h> #endif +#include <Swiften/Base/Log.h> +#include <Swiften/Base/Algorithm.h> #include <Swiften/TLS/OpenSSL/OpenSSLContext.h> #include <Swiften/TLS/OpenSSL/OpenSSLCertificate.h> #include <Swiften/TLS/CertificateWithKey.h> @@ -39,10 +46,66 @@ static void freeX509Stack(STACK_OF(X509)* stack) { sk_X509_free(stack); } -OpenSSLContext::OpenSSLContext() : state_(Start), context_(0), handle_(0), readBIO_(0), writeBIO_(0) { +namespace { + class OpenSSLInitializerFinalizer { + public: + OpenSSLInitializerFinalizer() { + SSL_load_error_strings(); + SSL_library_init(); + OpenSSL_add_all_algorithms(); + + // Disable compression + /* + STACK_OF(SSL_COMP)* compressionMethods = SSL_COMP_get_compression_methods(); + sk_SSL_COMP_zero(compressionMethods);*/ + } + + ~OpenSSLInitializerFinalizer() { + EVP_cleanup(); + } + + OpenSSLInitializerFinalizer(const OpenSSLInitializerFinalizer &) = delete; + }; + + std::unique_ptr<SSL_CTX> createSSL_CTX(OpenSSLContext::Mode mode) { + std::unique_ptr<SSL_CTX> sslCtx; + switch (mode) { + case OpenSSLContext::Mode::Client: + sslCtx = std::unique_ptr<SSL_CTX>(SSL_CTX_new(SSLv23_client_method())); + break; + case OpenSSLContext::Mode::Server: + sslCtx = std::unique_ptr<SSL_CTX>(SSL_CTX_new(SSLv23_server_method())); + break; + } + return sslCtx; + } + + std::string openSSLInternalErrorToString() { + auto bio = std::shared_ptr<BIO>(BIO_new(BIO_s_mem()), BIO_free); + ERR_print_errors(bio.get()); + std::string errorString; + errorString.resize(BIO_pending(bio.get())); + BIO_read(bio.get(), (void*)errorString.data(), errorString.size()); + return errorString; + } + } + +OpenSSLContext::OpenSSLContext(Mode mode) : mode_(mode), state_(State::Start) { ensureLibraryInitialized(); - context_ = SSL_CTX_new(SSLv23_client_method()); - SSL_CTX_set_options(context_, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); + context_ = createSSL_CTX(mode_); + SSL_CTX_set_options(context_.get(), SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); + + if (mode_ == Mode::Server) { +#if OPENSSL_VERSION_NUMBER < 0x1010 + // Automatically select highest preference curve used for ECDH temporary keys used during + // key exchange if possible. + // Since version 1.1.0, this option is always enabled. + SSL_CTX_set_ecdh_auto(context_.get(), 1); +#endif + + SSL_CTX_set_tlsext_servername_arg(context_.get(), this); + SSL_CTX_set_tlsext_servername_callback(context_.get(), OpenSSLContext::handleServerNameCallback); + } // TODO: implement CRL checking // TODO: download CRL (HTTP transport) @@ -52,7 +115,7 @@ OpenSSLContext::OpenSSLContext() : state_(Start), context_(0), handle_(0), readB // TODO: handle OCSP stapling see https://www.rfc-editor.org/rfc/rfc4366.txt // Load system certs #if defined(SWIFTEN_PLATFORM_WINDOWS) - X509_STORE* store = SSL_CTX_get_cert_store(context_); + X509_STORE* store = SSL_CTX_get_cert_store(context_.get()); HCERTSTORE systemStore = CertOpenSystemStore(0, "ROOT"); if (systemStore) { PCCERT_CONTEXT certContext = NULL; @@ -68,7 +131,7 @@ OpenSSLContext::OpenSSLContext() : state_(Start), context_(0), handle_(0), readB } } #elif !defined(SWIFTEN_PLATFORM_MACOSX) - SSL_CTX_set_default_verify_paths(context_); + SSL_CTX_set_default_verify_paths(context_.get()); #elif defined(SWIFTEN_PLATFORM_MACOSX) && !defined(SWIFTEN_PLATFORM_IPHONE) // On Mac OS X 10.5 (OpenSSL < 0.9.8), OpenSSL does not automatically look in the system store. // On Mac OS X 10.6 (OpenSSL >= 0.9.8), OpenSSL *does* look in the system store to determine trust. @@ -76,7 +139,7 @@ OpenSSLContext::OpenSSLContext() : state_(Start), context_(0), handle_(0), readB // the certificates first. See // http://opensource.apple.com/source/OpenSSL098/OpenSSL098-27/src/crypto/x509/x509_vfy_apple.c // to understand why. We therefore add all certs from the system store ourselves. - X509_STORE* store = SSL_CTX_get_cert_store(context_); + X509_STORE* store = SSL_CTX_get_cert_store(context_.get()); CFArrayRef anchorCertificates; if (SecTrustCopyAnchorCertificates(&anchorCertificates) == 0) { for (int i = 0; i < CFArrayGetCount(anchorCertificates); ++i) { @@ -99,51 +162,96 @@ OpenSSLContext::OpenSSLContext() : state_(Start), context_(0), handle_(0), readB } OpenSSLContext::~OpenSSLContext() { - SSL_free(handle_); - SSL_CTX_free(context_); } void OpenSSLContext::ensureLibraryInitialized() { - static bool isLibraryInitialized = false; - if (!isLibraryInitialized) { - SSL_load_error_strings(); - SSL_library_init(); - OpenSSL_add_all_algorithms(); + static OpenSSLInitializerFinalizer openSSLInit; +} - // Disable compression - /* - STACK_OF(SSL_COMP)* compressionMethods = SSL_COMP_get_compression_methods(); - sk_SSL_COMP_zero(compressionMethods);*/ +void OpenSSLContext::initAndSetBIOs() { + // Ownership of BIOs is transferred + readBIO_ = BIO_new(BIO_s_mem()); + writeBIO_ = BIO_new(BIO_s_mem()); + SSL_set_bio(handle_.get(), readBIO_, writeBIO_); +} - isLibraryInitialized = true; +void OpenSSLContext::accept() { + assert(mode_ == Mode::Server); + handle_ = std::unique_ptr<SSL>(SSL_new(context_.get())); + if (!handle_) { + state_ = State::Error; + onError(std::make_shared<TLSError>()); + return; } + + initAndSetBIOs(); + + state_ = State::Accepting; + doAccept(); } void OpenSSLContext::connect() { - handle_ = SSL_new(context_); - if (handle_ == nullptr) { - state_ = Error; + connect(std::string()); +} + +void OpenSSLContext::connect(const std::string& requestedServerName) { + assert(mode_ == Mode::Client); + handle_ = std::unique_ptr<SSL>(SSL_new(context_.get())); + if (!handle_) { + state_ = State::Error; onError(std::make_shared<TLSError>()); return; } - // Ownership of BIOs is ransferred - readBIO_ = BIO_new(BIO_s_mem()); - writeBIO_ = BIO_new(BIO_s_mem()); - SSL_set_bio(handle_, readBIO_, writeBIO_); + if (!requestedServerName.empty()) { + if (SSL_set_tlsext_host_name(handle_.get(), const_cast<char*>(requestedServerName.c_str())) != 1) { + SWIFT_LOG(error) << "Failed on SSL_set_tlsext_host_name()." << std::endl; + } + } + + // Ownership of BIOs is transferred to the SSL_CTX instance in handle_. + initAndSetBIOs(); - state_ = Connecting; + state_ = State::Connecting; doConnect(); } +void OpenSSLContext::doAccept() { + auto acceptResult = SSL_accept(handle_.get()); + auto error = SSL_get_error(handle_.get(), acceptResult); + switch (error) { + case SSL_ERROR_NONE: { + state_ = State::Connected; + //std::cout << x->name << std::endl; + //const char* comp = SSL_get_current_compression(handle_.get()); + //std::cout << "Compression: " << SSL_COMP_get_name(comp) << std::endl; + onConnected(); + // The following call is important so the client knowns the handshake is finished. + sendPendingDataToNetwork(); + break; + } + case SSL_ERROR_WANT_READ: + sendPendingDataToNetwork(); + break; + case SSL_ERROR_WANT_WRITE: + sendPendingDataToNetwork(); + break; + default: + SWIFT_LOG(warning) << openSSLInternalErrorToString() << std::endl; + state_ = State::Error; + onError(std::make_shared<TLSError>()); + sendPendingDataToNetwork(); + } +} + void OpenSSLContext::doConnect() { - int connectResult = SSL_connect(handle_); - int error = SSL_get_error(handle_, connectResult); + int connectResult = SSL_connect(handle_.get()); + int error = SSL_get_error(handle_.get(), connectResult); switch (error) { case SSL_ERROR_NONE: { - state_ = Connected; + state_ = State::Connected; //std::cout << x->name << std::endl; - //const char* comp = SSL_get_current_compression(handle_); + //const char* comp = SSL_get_current_compression(handle_.get()); //std::cout << "Compression: " << SSL_COMP_get_name(comp) << std::endl; onConnected(); break; @@ -152,11 +260,30 @@ void OpenSSLContext::doConnect() { sendPendingDataToNetwork(); break; default: - state_ = Error; + SWIFT_LOG(warning) << openSSLInternalErrorToString() << std::endl; + state_ = State::Error; onError(std::make_shared<TLSError>()); } } +int OpenSSLContext::handleServerNameCallback(SSL* ssl, int*, void* arg) { + if (ssl == nullptr) + return SSL_TLSEXT_ERR_NOACK; + + const char* servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name); + if (servername) { + auto serverNameString = std::string(servername); + auto context = reinterpret_cast<OpenSSLContext*>(arg); + context->onServerNameRequested(serverNameString); + + if (context->abortTLSHandshake_) { + context->abortTLSHandshake_ = false; + return SSL_TLSEXT_ERR_ALERT_FATAL; + } + } + return SSL_TLSEXT_ERR_OK; +} + void OpenSSLContext::sendPendingDataToNetwork() { int size = BIO_pending(writeBIO_); if (size > 0) { @@ -170,23 +297,26 @@ void OpenSSLContext::sendPendingDataToNetwork() { void OpenSSLContext::handleDataFromNetwork(const SafeByteArray& data) { BIO_write(readBIO_, vecptr(data), data.size()); switch (state_) { - case Connecting: + case State::Accepting: + doAccept(); + break; + case State::Connecting: doConnect(); break; - case Connected: + case State::Connected: sendPendingDataToApplication(); break; - case Start: assert(false); break; - case Error: /*assert(false);*/ break; + case State::Start: assert(false); break; + case State::Error: /*assert(false);*/ break; } } void OpenSSLContext::handleDataFromApplication(const SafeByteArray& data) { - if (SSL_write(handle_, vecptr(data), data.size()) >= 0) { + if (SSL_write(handle_.get(), vecptr(data), data.size()) >= 0) { sendPendingDataToNetwork(); } else { - state_ = Error; + state_ = State::Error; onError(std::make_shared<TLSError>()); } } @@ -194,19 +324,115 @@ void OpenSSLContext::handleDataFromApplication(const SafeByteArray& data) { void OpenSSLContext::sendPendingDataToApplication() { SafeByteArray data; data.resize(SSL_READ_BUFFERSIZE); - int ret = SSL_read(handle_, vecptr(data), data.size()); + int ret = SSL_read(handle_.get(), vecptr(data), data.size()); while (ret > 0) { data.resize(ret); onDataForApplication(data); data.resize(SSL_READ_BUFFERSIZE); - ret = SSL_read(handle_, vecptr(data), data.size()); + ret = SSL_read(handle_.get(), vecptr(data), data.size()); } - if (ret < 0 && SSL_get_error(handle_, ret) != SSL_ERROR_WANT_READ) { - state_ = Error; + if (ret < 0 && SSL_get_error(handle_.get(), ret) != SSL_ERROR_WANT_READ) { + state_ = State::Error; onError(std::make_shared<TLSError>()); } } +bool OpenSSLContext::setCertificateChain(const std::vector<Certificate::ref>& certificateChain) { + if (certificateChain.size() == 0) { + SWIFT_LOG(warning) << "Trying to load empty certificate chain." << std::endl; + return false; + } + + // load endpoint certificate + auto openSSLCert = std::dynamic_pointer_cast<OpenSSLCertificate>(certificateChain[0]); + if (!openSSLCert) { + return false; + } + + if (SSL_CTX_use_certificate(context_.get(), openSSLCert->getInternalX509().get()) != 1) { + return false; + } + + if (certificateChain.size() > 1) { + for (auto certificate : range(certificateChain.begin() + 1, certificateChain.end())) { + auto openSSLCert = std::dynamic_pointer_cast<OpenSSLCertificate>(certificate); + if (!openSSLCert) { + return false; + } + if (SSL_CTX_add_extra_chain_cert(context_.get(), openSSLCert->getInternalX509().get()) != 1) { + SWIFT_LOG(warning) << "Trying to load empty certificate chain." << std::endl; + return false; + } + } + } + + if (handle_) { + // This workaround is needed as OpenSSL has a shortcut to not do anything + // if you set the SSL_CTX to the existing SSL_CTX and not reloading the + // certificates from the SSL_CTX. + auto dummyContext = createSSL_CTX(mode_); + SSL_set_SSL_CTX(handle_.get(), dummyContext.get()); + SSL_set_SSL_CTX(handle_.get(), context_.get()); + } + + return true; +} + +int empty_or_preset_password_cb(char* buf, int max_len, int flag, void* password); + +int empty_or_preset_password_cb(char* buf, int max_len, int /* flag */, void* password) { + char* charPassword = (char*)password; + if (charPassword == nullptr) { + return 0; + } + int len = strlen(charPassword); + if(len > max_len) { + return 0; + } + memcpy(buf, charPassword, len); + return len; +} + +bool OpenSSLContext::setPrivateKey(const PrivateKey::ref& privateKey) { + if (privateKey->getData().size() > std::numeric_limits<int>::max()) { + return false; + } + + auto bio = std::shared_ptr<BIO>(BIO_new(BIO_s_mem()), BIO_free); + BIO_write(bio.get(), vecptr(privateKey->getData()), int(privateKey->getData().size())); + + SafeByteArray safePassword; + void* password = nullptr; + if (privateKey->getPassword()) { + safePassword = privateKey->getPassword().get(); + safePassword.push_back(0); + password = safePassword.data(); + } + auto resultKey = PEM_read_bio_PrivateKey(bio.get(), nullptr, empty_or_preset_password_cb, password); + if (resultKey) { + if (handle_) { + auto result = SSL_use_PrivateKey(handle_.get(), resultKey);; + if (result != 1) { + return false; + } + } + else { + auto result = SSL_CTX_use_PrivateKey(context_.get(), resultKey); + if (result != 1) { + return false; + } + } + } + else { + return false; + } + return true; +} + +void OpenSSLContext::setAbortTLSHandshake(bool abort) { + abortTLSHandshake_ = abort; +} + bool OpenSSLContext::setClientCertificate(CertificateWithKey::ref certificate) { std::shared_ptr<PKCS12Certificate> pkcs12Certificate = std::dynamic_pointer_cast<PKCS12Certificate>(certificate); if (!pkcs12Certificate || pkcs12Certificate->isNull()) { @@ -216,16 +442,16 @@ bool OpenSSLContext::setClientCertificate(CertificateWithKey::ref certificate) { // Create a PKCS12 structure BIO* bio = BIO_new(BIO_s_mem()); BIO_write(bio, vecptr(pkcs12Certificate->getData()), pkcs12Certificate->getData().size()); - std::shared_ptr<PKCS12> pkcs12(d2i_PKCS12_bio(bio, NULL), PKCS12_free); + std::shared_ptr<PKCS12> pkcs12(d2i_PKCS12_bio(bio, nullptr), PKCS12_free); BIO_free(bio); if (!pkcs12) { return false; } // Parse PKCS12 - X509 *certPtr = 0; - EVP_PKEY* privateKeyPtr = 0; - STACK_OF(X509)* caCertsPtr = 0; + X509 *certPtr = nullptr; + EVP_PKEY* privateKeyPtr = nullptr; + STACK_OF(X509)* caCertsPtr = nullptr; SafeByteArray password(pkcs12Certificate->getPassword()); password.push_back(0); int result = PKCS12_parse(pkcs12.get(), reinterpret_cast<const char*>(vecptr(password)), &privateKeyPtr, &certPtr, &caCertsPtr); @@ -237,21 +463,40 @@ bool OpenSSLContext::setClientCertificate(CertificateWithKey::ref certificate) { std::shared_ptr<STACK_OF(X509)> caCerts(caCertsPtr, freeX509Stack); // Use the key & certificates - if (SSL_CTX_use_certificate(context_, cert.get()) != 1) { + if (SSL_CTX_use_certificate(context_.get(), cert.get()) != 1) { return false; } - if (SSL_CTX_use_PrivateKey(context_, privateKey.get()) != 1) { + if (SSL_CTX_use_PrivateKey(context_.get(), privateKey.get()) != 1) { return false; } for (int i = 0; i < sk_X509_num(caCerts.get()); ++i) { - SSL_CTX_add_extra_chain_cert(context_, sk_X509_value(caCerts.get(), i)); + SSL_CTX_add_extra_chain_cert(context_.get(), sk_X509_value(caCerts.get(), i)); } return true; } +bool OpenSSLContext::setDiffieHellmanParameters(const ByteArray& parametersInOpenSslDer) { + auto bio = std::unique_ptr<BIO, decltype(&BIO_free)>(BIO_new(BIO_s_mem()), BIO_free); + if (bio) { + BIO_write(bio.get(), vecptr(parametersInOpenSslDer), parametersInOpenSslDer.size()); + auto result = 0L; + if (auto dhparams = d2i_DHparams_bio(bio.get(), NULL)) { + if (handle_) { + result = SSL_set_tmp_dh(handle_.get(), dhparams); + } + else { + result = SSL_CTX_set_tmp_dh(context_.get(), dhparams); + } + DH_free(dhparams); + } + return result == 1; + } + return false; +} + std::vector<Certificate::ref> OpenSSLContext::getPeerCertificateChain() const { std::vector<Certificate::ref> result; - STACK_OF(X509)* chain = SSL_get_peer_cert_chain(handle_); + STACK_OF(X509)* chain = SSL_get_peer_cert_chain(handle_.get()); for (int i = 0; i < sk_X509_num(chain); ++i) { std::shared_ptr<X509> x509Cert(X509_dup(sk_X509_value(chain, i)), X509_free); @@ -262,7 +507,7 @@ std::vector<Certificate::ref> OpenSSLContext::getPeerCertificateChain() const { } std::shared_ptr<CertificateVerificationError> OpenSSLContext::getPeerCertificateVerificationError() const { - int verifyResult = SSL_get_verify_result(handle_); + int verifyResult = SSL_get_verify_result(handle_.get()); if (verifyResult != X509_V_OK) { return std::make_shared<CertificateVerificationError>(getVerificationErrorTypeForResult(verifyResult)); } @@ -274,11 +519,19 @@ std::shared_ptr<CertificateVerificationError> OpenSSLContext::getPeerCertificate ByteArray OpenSSLContext::getFinishMessage() const { ByteArray data; data.resize(MAX_FINISHED_SIZE); - size_t size = SSL_get_finished(handle_, vecptr(data), data.size()); + auto size = SSL_get_finished(handle_.get(), vecptr(data), data.size()); data.resize(size); return data; } +ByteArray OpenSSLContext::getPeerFinishMessage() const { + ByteArray data; + data.resize(MAX_FINISHED_SIZE); + auto size = SSL_get_peer_finished(handle_.get(), vecptr(data), data.size()); + data.resize(size); + return data; + } + CertificateVerificationError::Type OpenSSLContext::getVerificationErrorTypeForResult(int result) { assert(result != 0); switch (result) { diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.h b/Swiften/TLS/OpenSSL/OpenSSLContext.h index e75b3c9..cfa852a 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContext.h +++ b/Swiften/TLS/OpenSSL/OpenSSLContext.h @@ -1,11 +1,13 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <memory> + #include <boost/noncopyable.hpp> #include <boost/signals2.hpp> @@ -15,40 +17,69 @@ #include <Swiften/TLS/CertificateWithKey.h> #include <Swiften/TLS/TLSContext.h> -namespace Swift { +namespace std { + template<> + class default_delete<SSL_CTX> { + public: + void operator()(SSL_CTX *ptr) { + SSL_CTX_free(ptr); + } + }; + template<> + class default_delete<SSL> { + public: + void operator()(SSL *ptr) { + SSL_free(ptr); + } + }; +} + +namespace Swift { class OpenSSLContext : public TLSContext, boost::noncopyable { public: - OpenSSLContext(); - virtual ~OpenSSLContext(); + OpenSSLContext(Mode mode); + virtual ~OpenSSLContext() override final; - void connect(); - bool setClientCertificate(CertificateWithKey::ref cert); + void accept() override final; + void connect() override final; + void connect(const std::string& requestHostname) override final; - void handleDataFromNetwork(const SafeByteArray&); - void handleDataFromApplication(const SafeByteArray&); + bool setCertificateChain(const std::vector<Certificate::ref>& certificateChain) override final; + bool setPrivateKey(const PrivateKey::ref& privateKey) override final; + bool setClientCertificate(CertificateWithKey::ref cert) override final; + void setAbortTLSHandshake(bool abort) override final; + bool setDiffieHellmanParameters(const ByteArray& parametersInOpenSslDer) override final; - std::vector<Certificate::ref> getPeerCertificateChain() const; - std::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const; + void handleDataFromNetwork(const SafeByteArray&) override final; + void handleDataFromApplication(const SafeByteArray&) override final; - virtual ByteArray getFinishMessage() const; + std::vector<Certificate::ref> getPeerCertificateChain() const override final; + std::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const override final; + + virtual ByteArray getFinishMessage() const override final; + virtual ByteArray getPeerFinishMessage() const override final; private: static void ensureLibraryInitialized(); - + static int handleServerNameCallback(SSL *ssl, int *ad, void *arg); static CertificateVerificationError::Type getVerificationErrorTypeForResult(int); + void initAndSetBIOs(); + void doAccept(); void doConnect(); void sendPendingDataToNetwork(); void sendPendingDataToApplication(); private: - enum State { Start, Connecting, Connected, Error }; + enum class State { Start, Accepting, Connecting, Connected, Error }; + const Mode mode_; State state_; - SSL_CTX* context_; - SSL* handle_; - BIO* readBIO_; - BIO* writeBIO_; + std::unique_ptr<SSL_CTX> context_; + std::unique_ptr<SSL> handle_; + BIO* readBIO_ = nullptr; + BIO* writeBIO_ = nullptr; + bool abortTLSHandshake_ = false; }; } diff --git a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp index 9f7b2aa..9d0ad72 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp @@ -1,22 +1,48 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/TLS/OpenSSL/OpenSSLContextFactory.h> +#include <openssl/bio.h> +#include <openssl/dh.h> +#include <openssl/pem.h> + #include <Swiften/Base/Log.h> #include <Swiften/TLS/OpenSSL/OpenSSLContext.h> +#pragma clang diagnostic ignored "-Wshorten-64-to-32" + namespace Swift { bool OpenSSLContextFactory::canCreate() const { return true; } -TLSContext* OpenSSLContextFactory::createTLSContext(const TLSOptions&) { - return new OpenSSLContext(); +TLSContext* OpenSSLContextFactory::createTLSContext(const TLSOptions&, TLSContext::Mode mode) { + return new OpenSSLContext(mode); +} + +ByteArray OpenSSLContextFactory::convertDHParametersFromPEMToDER(const std::string& dhParametersInPEM) { + ByteArray dhParametersInDER; + + auto bio = std::unique_ptr<BIO, decltype(&BIO_free)>(BIO_new(BIO_s_mem()), BIO_free); + if (bio) { + BIO_write(bio.get(), dhParametersInPEM.data(), dhParametersInPEM.size()); + if (auto params = PEM_read_bio_DHparams(bio.get(), nullptr, nullptr, nullptr)) { + unsigned char* buffer = nullptr; + auto len = i2d_DHparams(params, &buffer); + if (len > 0) { + dhParametersInDER = createByteArray(buffer, static_cast<size_t>(len)); + free(buffer); + } + DH_free(params); + + } + } + return dhParametersInDER; } void OpenSSLContextFactory::setCheckCertificateRevocation(bool check) { diff --git a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.h b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.h index e121a1a..db7fa34 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.h +++ b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.h @@ -1,23 +1,23 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <cassert> - #include <Swiften/TLS/TLSContextFactory.h> namespace Swift { class OpenSSLContextFactory : public TLSContextFactory { public: - bool canCreate() const; - virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions); + bool canCreate() const override final; + virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions, TLSContext::Mode mode) override final; + + virtual ByteArray convertDHParametersFromPEMToDER(const std::string& dhParametersInPEM) override final; // Not supported - virtual void setCheckCertificateRevocation(bool b); - virtual void setDisconnectOnCardRemoval(bool b); + virtual void setCheckCertificateRevocation(bool b) override final; + virtual void setDisconnectOnCardRemoval(bool b) override final; }; } diff --git a/Swiften/TLS/PrivateKey.cpp b/Swiften/TLS/PrivateKey.cpp new file mode 100644 index 0000000..31cac1d --- /dev/null +++ b/Swiften/TLS/PrivateKey.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <Swiften/TLS/PrivateKey.h> + +namespace Swift { + +PrivateKey::PrivateKey(const SafeByteArray& data, boost::optional<SafeByteArray> password) : data_(data), password_(password) { +} + +const SafeByteArray& PrivateKey::getData() const { + return data_; +} + +const boost::optional<SafeByteArray>& PrivateKey::getPassword() const { + return password_; +} + +} diff --git a/Swiften/TLS/PrivateKey.h b/Swiften/TLS/PrivateKey.h new file mode 100644 index 0000000..332fc48 --- /dev/null +++ b/Swiften/TLS/PrivateKey.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <memory> + +#include <boost/optional.hpp> + +#include <Swiften/Base/SafeByteArray.h> +#include <Swiften/TLS/PrivateKey.h> + +namespace Swift { + +class PrivateKey { +public: + using ref = std::shared_ptr<PrivateKey>; + +public: + PrivateKey(const SafeByteArray& data, boost::optional<SafeByteArray> password = boost::optional<SafeByteArray>()); + + const SafeByteArray& getData() const; + const boost::optional<SafeByteArray>& getPassword() const; + +private: + SafeByteArray data_; + boost::optional<SafeByteArray> password_; +}; + +} diff --git a/Swiften/TLS/SConscript b/Swiften/TLS/SConscript index 68bf50b..a79e6a1 100644 --- a/Swiften/TLS/SConscript +++ b/Swiften/TLS/SConscript @@ -4,6 +4,7 @@ objects = swiften_env.SwiftenObject([ "Certificate.cpp", "CertificateFactory.cpp", "CertificateTrustChecker.cpp", + "PrivateKey.cpp", "ServerIdentityVerifier.cpp", "TLSContext.cpp", "TLSContextFactory.cpp", @@ -16,8 +17,11 @@ if myenv.get("HAVE_OPENSSL", 0) : "OpenSSL/OpenSSLContext.cpp", "OpenSSL/OpenSSLCertificate.cpp", "OpenSSL/OpenSSLContextFactory.cpp", + "OpenSSL/OpenSSLCertificateFactory.cpp", ]) myenv.Append(CPPDEFINES = "HAVE_OPENSSL") + if myenv["PLATFORM"] == "win32" : + myenv.Append(CPPDEFINES = "NOMINMAX") elif myenv.get("HAVE_SCHANNEL", 0) : swiften_env.Append(LIBS = ["Winscard"]) objects += myenv.SwiftenObject([ diff --git a/Swiften/TLS/Schannel/SchannelContextFactory.cpp b/Swiften/TLS/Schannel/SchannelContextFactory.cpp index f78d386..0015fbe 100644 --- a/Swiften/TLS/Schannel/SchannelContextFactory.cpp +++ b/Swiften/TLS/Schannel/SchannelContextFactory.cpp @@ -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. */ @@ -23,7 +23,9 @@ bool SchannelContextFactory::canCreate() const { return true; } -TLSContext* SchannelContextFactory::createTLSContext(const TLSOptions& tlsOptions) { +TLSContext* SchannelContextFactory::createTLSContext(const TLSOptions& tlsOptions, TLSContext::Mode mode) { + // TLS server mode is not supported for the SecureTransport backend yet. + assert(mode == TLSContext::Mode::Client); SchannelContext* context = new SchannelContext(tlsOptions.schannelTLS1_0Workaround); context->setCheckCertificateRevocation(checkCertificateRevocation); context->setDisconnectOnCardRemoval(disconnectOnCardRemoval); diff --git a/Swiften/TLS/Schannel/SchannelContextFactory.h b/Swiften/TLS/Schannel/SchannelContextFactory.h index 142f193..f878037 100644 --- a/Swiften/TLS/Schannel/SchannelContextFactory.h +++ b/Swiften/TLS/Schannel/SchannelContextFactory.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -20,8 +20,7 @@ namespace Swift { SchannelContextFactory(); bool canCreate() const; - virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions); - + virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions, TLSContext::Mode mode = TLSContext::Mode::Client); virtual void setCheckCertificateRevocation(bool b); virtual void setDisconnectOnCardRemoval(bool b); diff --git a/Swiften/TLS/SecureTransport/SecureTransportCertificate.mm b/Swiften/TLS/SecureTransport/SecureTransportCertificate.mm index db0af89..fffb3ed 100644 --- a/Swiften/TLS/SecureTransport/SecureTransportCertificate.mm +++ b/Swiften/TLS/SecureTransport/SecureTransportCertificate.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -93,13 +93,14 @@ void SecureTransportCertificate::parse() { NSDictionary* subjectAltNamesDict = certDict[@"2.5.29.17"][@"value"]; for (NSDictionary* entry in subjectAltNamesDict) { - if ([entry[@"label"] isEqualToString:static_cast<NSString * _Nonnull>([NSString stringWithUTF8String:ID_ON_XMPPADDR_OID])]) { + NSString* label = entry[@"label"]; + if ([label isEqualToString:static_cast<NSString * _Nonnull>([NSString stringWithUTF8String:ID_ON_XMPPADDR_OID])]) { xmppAddresses_.push_back(ns2StdString(entry[@"value"])); } - else if ([entry[@"label"] isEqualToString:static_cast<NSString * _Nonnull>([NSString stringWithUTF8String:ID_ON_DNSSRV_OID])]) { + else if ([label isEqualToString:static_cast<NSString * _Nonnull>([NSString stringWithUTF8String:ID_ON_DNSSRV_OID])]) { srvNames_.push_back(ns2StdString(entry[@"value"])); } - else if ([entry[@"label"] isEqualToString:@"DNS Name"]) { + else if ([label isEqualToString:@"DNS Name"]) { dnsNames_.push_back(ns2StdString(entry[@"value"])); } } diff --git a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp index 1fac1fb..dfb9d67 100644 --- a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp +++ b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -26,7 +26,9 @@ bool SecureTransportContextFactory::canCreate() const { return true; } -TLSContext* SecureTransportContextFactory::createTLSContext(const TLSOptions& /* tlsOptions */) { +TLSContext* SecureTransportContextFactory::createTLSContext(const TLSOptions& /* tlsOptions */, TLSContext::Mode mode) { + // TLS server mode is not supported for the SecureTransport backend yet. + assert(mode == TLSContext::Mode::Client); return new SecureTransportContext(checkCertificateRevocation_); } diff --git a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.h b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.h index 74c598f..5962424 100644 --- a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.h +++ b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,7 +17,7 @@ class SecureTransportContextFactory : public TLSContextFactory { virtual bool canCreate() const; - virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions); + virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions, TLSContext::Mode mode = TLSContext::Mode::Client); virtual void setCheckCertificateRevocation(bool b); virtual void setDisconnectOnCardRemoval(bool b); diff --git a/Swiften/TLS/TLSContext.cpp b/Swiften/TLS/TLSContext.cpp index 2763547..cc05834 100644 --- a/Swiften/TLS/TLSContext.cpp +++ b/Swiften/TLS/TLSContext.cpp @@ -1,19 +1,53 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/TLS/TLSContext.h> +#include <cassert> + namespace Swift { TLSContext::~TLSContext() { } +void TLSContext::accept() { + assert(false); +} + +void TLSContext::connect(const std::string& /* serverName */) { + assert(false); +} + +bool TLSContext::setCertificateChain(const std::vector<Certificate::ref>& /* certificateChain */) { + assert(false); + return false; +} + +bool TLSContext::setPrivateKey(const PrivateKey::ref& /* privateKey */) { + assert(false); + return false; +} + +bool TLSContext::setDiffieHellmanParameters(const ByteArray& /*parametersInOpenSslDer*/) { + assert(false); + return false; +} + +void TLSContext::setAbortTLSHandshake(bool /* abort */) { + assert(false); +} + Certificate::ref TLSContext::getPeerCertificate() const { std::vector<Certificate::ref> chain = getPeerCertificateChain(); return chain.empty() ? Certificate::ref() : chain[0]; } +ByteArray TLSContext::getPeerFinishMessage() const { + assert(false); + return ByteArray(); +} + } diff --git a/Swiften/TLS/TLSContext.h b/Swiften/TLS/TLSContext.h index 79e3485..55a86cd 100644 --- a/Swiften/TLS/TLSContext.h +++ b/Swiften/TLS/TLSContext.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. */ @@ -15,6 +15,7 @@ #include <Swiften/TLS/Certificate.h> #include <Swiften/TLS/CertificateVerificationError.h> #include <Swiften/TLS/CertificateWithKey.h> +#include <Swiften/TLS/PrivateKey.h> #include <Swiften/TLS/TLSError.h> namespace Swift { @@ -23,9 +24,21 @@ namespace Swift { public: virtual ~TLSContext(); + virtual void accept(); virtual void connect() = 0; + virtual void connect(const std::string& serverName); + + virtual bool setCertificateChain(const std::vector<Certificate::ref>& /* certificateChain */); + virtual bool setPrivateKey(const PrivateKey::ref& /* privateKey */); virtual bool setClientCertificate(CertificateWithKey::ref cert) = 0; + virtual bool setDiffieHellmanParameters(const ByteArray& parametersInOpenSslDer); + + /** + * This method can be used during the \ref onServerNameRequested signal, + * to report an error about an unknown host back to the requesting client. + */ + virtual void setAbortTLSHandshake(bool /* abort */); virtual void handleDataFromNetwork(const SafeByteArray&) = 0; virtual void handleDataFromApplication(const SafeByteArray&) = 0; @@ -35,11 +48,20 @@ namespace Swift { virtual CertificateVerificationError::ref getPeerCertificateVerificationError() const = 0; virtual ByteArray getFinishMessage() const = 0; + virtual ByteArray getPeerFinishMessage() const; + + + public: + enum class Mode { + Client, + Server + }; public: boost::signals2::signal<void (const SafeByteArray&)> onDataForNetwork; boost::signals2::signal<void (const SafeByteArray&)> onDataForApplication; boost::signals2::signal<void (std::shared_ptr<TLSError>)> onError; boost::signals2::signal<void ()> onConnected; + boost::signals2::signal<void (const std::string&)> onServerNameRequested; }; } diff --git a/Swiften/TLS/TLSContextFactory.cpp b/Swiften/TLS/TLSContextFactory.cpp index d196e15..91e60d6 100644 --- a/Swiften/TLS/TLSContextFactory.cpp +++ b/Swiften/TLS/TLSContextFactory.cpp @@ -6,9 +6,16 @@ #include <Swiften/TLS/TLSContextFactory.h> +#include <cassert> + namespace Swift { TLSContextFactory::~TLSContextFactory() { } +ByteArray TLSContextFactory::convertDHParametersFromPEMToDER(const std::string& /* pem */) { + assert(false); + return ByteArray(); +} + } diff --git a/Swiften/TLS/TLSContextFactory.h b/Swiften/TLS/TLSContextFactory.h index d2ffe15..9da3392 100644 --- a/Swiften/TLS/TLSContextFactory.h +++ b/Swiften/TLS/TLSContextFactory.h @@ -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. */ @@ -7,19 +7,21 @@ #pragma once #include <Swiften/Base/API.h> +#include <Swiften/Base/ByteArray.h> +#include <Swiften/TLS/TLSContext.h> #include <Swiften/TLS/TLSOptions.h> namespace Swift { - class TLSContext; - class SWIFTEN_API TLSContextFactory { public: virtual ~TLSContextFactory(); virtual bool canCreate() const = 0; - virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions) = 0; + virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions, TLSContext::Mode = TLSContext::Mode::Client) = 0; virtual void setCheckCertificateRevocation(bool b) = 0; virtual void setDisconnectOnCardRemoval(bool b) = 0; + + virtual ByteArray convertDHParametersFromPEMToDER(const std::string& pem); }; } diff --git a/Swiften/TLS/UnitTest/CertificateTest.cpp b/Swiften/TLS/UnitTest/CertificateTest.cpp index 2483dae..aac2cfb 100644 --- a/Swiften/TLS/UnitTest/CertificateTest.cpp +++ b/Swiften/TLS/UnitTest/CertificateTest.cpp @@ -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. */ @@ -10,9 +10,12 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include <Swiften/Base/ByteArray.h> +#include <Swiften/Base/Platform.h> #include <Swiften/Crypto/CryptoProvider.h> #include <Swiften/Crypto/PlatformCryptoProvider.h> #include <Swiften/TLS/Certificate.h> +#include <Swiften/TLS/CertificateFactory.h> +#include <Swiften/TLS/PlatformTLSFactories.h> #include <Swiften/TLS/SimpleCertificate.h> using namespace Swift; @@ -20,6 +23,10 @@ using namespace Swift; class CertificateTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(CertificateTest); CPPUNIT_TEST(testGetSHA1Fingerprint); +#ifdef HAVE_OPENSSL + CPPUNIT_TEST(testParsingPEMCertificate); +#endif + CPPUNIT_TEST(testParsingPEMPrivateKey); CPPUNIT_TEST_SUITE_END(); public: @@ -29,6 +36,108 @@ class CertificateTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(std::string("2f:b5:e1:34:19:fc:89:24:68:65:e7:a3:24:f4:76:ec:62:4e:87:40"), Certificate::getSHA1Fingerprint(testling, std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()).get())); } + + void testParsingPEMCertificate() { + PlatformTLSFactories tlsFactories; + + auto PEMCertificate = R"(-----BEGIN CERTIFICATE----- +MIIEsjCCApoCCQCbkjlQfUqPtTANBgkqhkiG9w0BAQsFADAbMRkwFwYDVQQDDBBt +b250YWd1ZS5leGFtcGxlMB4XDTE4MDExODE2NTMxMloXDTQ1MDYwNDE2NTMxMlow +GzEZMBcGA1UEAwwQbW9udGFndWUuZXhhbXBsZTCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBALAx5xuEYOjDJ9QHMvwRuDzxbHl1zR97SJFPAkmD8xH0sC61 +DNRyUvRq6UXb4znhqeqrNuZ9PV47GyK2Dpy/c/MY5NE3m/c+Z1tUnrcqyCkxITIn +jdSI/elc9yhtMXX6lRi68BdPJnj/9+6trW0cWHlKEgnaSTAgCVB+4Dg9mjTIroCa +HLoAKhr2zS7Ihs28aWb0cSvZ+qFgQhr7FGP2kfssTTQYyRPn9uHhtyWH6RqSv5x9 +BBGZWN5GtjkJvupcYWLt8ftuQyFpwEeEz5cgtiyKgsfz9CYvS9/OcwdLQr4z5Zq6 +eKxsog9GdwIi1Us4KR0X6tKu9ze42iEWF+foEWFP9/bjrVK/tt5lTSKnenk0nA8I +amkG0btNAGihDti3lv60bGpd3B2/uh4gzzT2buXdf0EaybCt52MIr8xkwMU0Tkri +RAYchdS8U8sekWG5Lg9m3L2BDa8/TKS/WflJhGcZeInGQslgIx7fCgO1M7Zr50pO +wSURPXpvqUkXNEBy639UQEUsnBhntEQwZWx/6x6Ma/U5a5dL6qbtEJjlwIvS+nl9 +3w26g3DvWydNMCtZIVhgdrl+dZs+Uw5eA3QkHkDTSfYvQk7X5SYL0J5ZxwBvU9r1 +ED054+TAEuX2euiRA37xLhxonj8BaKkPQGlAHCLZaZPmNJWkNxElJhMoCfqBAgMB +AAEwDQYJKoZIhvcNAQELBQADggIBAF+FNyW3nVeQeugBMksIhj7EMJl1AEKi0+78 +ZPsYX3CDbc/8GRZoTg/EWSiwPCBYc9VsxuKtODEYABCZgk7LnSBYoEauJDKWqkgM +UOKPJI2hu7mIK7FJpjvEZe2MnRRA63oI/NVDJm8T2clrv/vPkY+ppsVl0toC0SpH +/3dF5c65vYI19rTJraRU6kIrrgxFBzxzpn07LGh2rrOCQfy2umTSRMwz3ORAFfmi ++Kek1Dt7c+JVJ0ivCwhhc8MKza3JS2MuDfVWGnXtDLb81Ai0t4tQfLKvZEcgW+lh +Drz9gv22buwncWL/IxtuhzyILtDSDKAYFbhfG6IAQut9BjMgpMnKrBCDlOLJl08K +tgj2h7vUKyNSt3ndcSAtXjr6FD7+xPExJuyn/MgLONGGAZoZHFB4QO90wQaXxMPh +7rnjUtzfLR8qkDmX8ZB4f4VOWpDWo4hBpgjTk0gYfzEkrh+zTqE9reh7CZ1WzwXO +KnIBU2dZOE+XsJe49lW106DLqGzKRuQMUAwFMb7C7Nlg9GKTnvi41o+g6YE+MgxR +uPKu891pCBtnDxZiWPT+7Fa/9UXxdIOTVIHW6utSWiWYbeNwXSmIm2ShfmNfWj9m +x1JgJrFB6daWGR9aDBeDVRhgL6Z35lH7xI62pLJ4o2d2Y/9dUWAJfz5O8opeCyrF +zqCzpwGL +-----END CERTIFICATE----- +)"; + + auto certificateChain = tlsFactories.getCertificateFactory()->createCertificateChain(createByteArray(PEMCertificate)); + CPPUNIT_ASSERT_EQUAL(size_t(1), certificateChain.size()); + + auto certificate = certificateChain[0]; + CPPUNIT_ASSERT_EQUAL(std::string("/CN=montague.example"), certificate->getSubjectName()); + } + + void testParsingPEMPrivateKey() { + PlatformTLSFactories tlsFactories; + + auto PEMPrivateKey = R"(-----BEGIN PRIVATE KEY----- +MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCwMecbhGDowyfU +BzL8Ebg88Wx5dc0fe0iRTwJJg/MR9LAutQzUclL0aulF2+M54anqqzbmfT1eOxsi +tg6cv3PzGOTRN5v3PmdbVJ63KsgpMSEyJ43UiP3pXPcobTF1+pUYuvAXTyZ4//fu +ra1tHFh5ShIJ2kkwIAlQfuA4PZo0yK6Amhy6ACoa9s0uyIbNvGlm9HEr2fqhYEIa ++xRj9pH7LE00GMkT5/bh4bclh+kakr+cfQQRmVjeRrY5Cb7qXGFi7fH7bkMhacBH +hM+XILYsioLH8/QmL0vfznMHS0K+M+WaunisbKIPRncCItVLOCkdF+rSrvc3uNoh +Fhfn6BFhT/f2461Sv7beZU0ip3p5NJwPCGppBtG7TQBooQ7Yt5b+tGxqXdwdv7oe +IM809m7l3X9BGsmwredjCK/MZMDFNE5K4kQGHIXUvFPLHpFhuS4PZty9gQ2vP0yk +v1n5SYRnGXiJxkLJYCMe3woDtTO2a+dKTsElET16b6lJFzRAcut/VEBFLJwYZ7RE +MGVsf+sejGv1OWuXS+qm7RCY5cCL0vp5fd8NuoNw71snTTArWSFYYHa5fnWbPlMO +XgN0JB5A00n2L0JO1+UmC9CeWccAb1Pa9RA9OePkwBLl9nrokQN+8S4caJ4/AWip +D0BpQBwi2WmT5jSVpDcRJSYTKAn6gQIDAQABAoICABqc/wZ2AVlHGP36tGXEm2qB +INxbwcbujTB9mZ/XEWD176KucCiquAL5HxERPIointK2V82Kvzk7fkbI7v4YIQBo +Ey/S0XkP8Panmm2aRa+LHzN/K/odUxTrmN1/WMg0OE8K9Xbf2rTOHPntO9POQ0LW +wFDCqulc/WsuLtnv3Bn68fi0zn/9xF5cRvO5EDuFKPqHE40HGMdFTdbbc+IBfV1N +/L9QuxaJpA3MVSiTFc+QuOZ/L50k53pzfdSxtyeZGpCh1jofFn62hXeIBP8TztB9 +f3GKVKdr328HtPI2GPe3yQeNAOsyYWwjPZiSAFujOPqPAUYfbXH6NuBmgOfjcrRb +AhOv9F1VNi+G56NJ6jo/NPygD+LYQdIKs5rv3E4ehyQzbu+SoGyVCnF3qm0cvz+v +tB5/gNiWiyRhNF94DZHlceDMQSdyB/pfTZsKZ44Yv44Bzl54YbzR8yr/ZKzAj6gt +5lwAqCIcdRj4i5DmIa7psj3iYWe9hYV7f+zwdosPKibRvO9FpvDCbb7biIPkMozw +cYH6QlSsZ+XsK/Z3WPFPq0wHOgoWW9Tr8LYyQxGjLO+xD8ziQ7Rp0KApEunuO29s +CPXj+l1HqNmAK2LkdNI3c/yStlaAcOzYD6pauciHWlTnIGZG8aHV6elIjK0C/h7B +3GndVc0TbewbP0bL56QBAoIBAQDU/yl4nlELhpoI1WW8v/FcDnc3V5dBilJ3LQtp +a3SKBcNWXE850TviOAklMrYmS1wuWdBTjEay9Ka6dImqMFGupmJjLmUw0KXrtPin +xIz5DZ42nmTKnYevuBQoQrrq7toxf5hYow2ZjeH2vSX+igY1gxDZbLW4Wb9GPYMo +Au5+z8XpA8R0key52nvnKastm5YxNstAlBOodAPKlbIr2bzmrHSjXAGjUzb+z6NZ +5Lx+zvQCy9kaIYvfOJm3eLSbMXzeP2S59qbwL+dC4ZJ5m3hjRmMaactV6LSchVNt +eLEYJpm92IdjQhG6oqM0IaU3aSjWMSrOAytylmqoEt4wA+WhAoIBAQDTxJ9VLb+J +OD0x/9cm17KpK1nGQBQ0T0oZQUH5M/tXTPCCoIpoL9UhKQ34vlPaZXkBQrXPw+PN +Y0J26uR6w4CowWAMn8LR6cYsWcOKuURcDYs/SPflD3rraevJwugQhkXtub2nV7dP +88Z/jGvhXthJmjUmNoKq3OC2MuSfHSkm8ipvaAblwb+lt5zBJGQ6iGXbi5TI6b+D +lnAidQpG/V464Zc9gb788P0K2vUeoZRLI7CurYqpDV0mBtPhFv5L1M0S8+psG7Pa +NIEKcW/b76vU9odTrtGBT0gCVYU7f8QnTN4g6c7dEhcZa2Zvg0YSmb4XuU9RQGC5 +As47nEUnPCjhAoIBAQDTXKnAogn2kAmGvoyIs0hFe61d47ObPDH9RVvPruwkkvd2 +WX/c9f6gy853dU0/zwSYklOitM7rgs94s3BwzCYiU8XKeh28RTCBKEKf6PGjq5nW +xXNrhMtC2j5WfXGS9JbdC6sYOiWivSMAgE6Vuk3TCE7OE4x4dcbTYvMl31Lf0Dqq +sixfKPdqrp7Jk5XkWkK+b4teeBLR1N52R/pYfWdw2K2d9g1CD6/BSDbnW46Zn7CQ +nczAm417Y2VWpZdDceZhfTLtPxAFxOOOgN2jg14B1bU+XsGCbLvdnohdV6kVOCjU +NWyUWNnTBNVDRCf5RodZlczORmL1AMKyKpcFurhBAoIBABSxbfBg3AqImFI+ccO1 +6BtnxQn+UPsblF4LZmr3jWPmfMoG7f9oTSdEX70ivAbnS3+4CRQYTDZRsLj2EwV7 +/SKAYuZY5iyk71x+GQGBQRDNsgGpG7AiZxyB6Sx6Azs6I7MrJ0Em7R6+73KfQhtv +rSrkCrWFNheEJeEn7/csXk0T9NmWDLZ+zD9hRcwJxlGB6pIdfZh0XuZ42NRFI4/0 +SjTuvlygRQ1qbw+UfcdUeq0s+6LWCmqih6ujlyizmn3GeZOUih+uRVDZOJLQquGO +9feFb4vZ1VcRbDPuL2q0/XHprPsCXdh0YBV3zTawWTSQGWcwEHQcGld50rU4e/lt +g4ECggEBAKwoqsqIHheL+uS2CHXmwFIr+rvOlLYlfB8XrwV/da3p7QChaDLbNIVM +uOAozCMkJY+dufPGI+3cKsR3kLAGejmfbH5OTzTbwCLOJFCWaoMuvOTY2Govte61 +gU1BWnjUgVJgVA/YTwn2yo02d0nG5/rSZ9xIt3hfO6ac5FhHBTA1DAZ1wDiLeow+ +qngZ2sA4ePtwhGFtvLVwTcGAfkWvQFi2YPBpesFIAmQ/ACGC7Ye75Ja4k36/8YwE +NiXR2Yy1hxwwi7CTWWzI0X+mvE/Oqpd8PUqPJCJcpz892Gq4EGCxM7Bz7NxCcvvw +5IMXuORWuoq0gXiCdEyko+saXsyWlqw= +-----END PRIVATE KEY----- +)"; + + auto privateKey = tlsFactories.getCertificateFactory()->createPrivateKey(createSafeByteArray(PEMPrivateKey)); + + CPPUNIT_ASSERT(privateKey != nullptr); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(CertificateTest); diff --git a/Swiften/TLS/UnitTest/ClientServerTest.cpp b/Swiften/TLS/UnitTest/ClientServerTest.cpp new file mode 100644 index 0000000..e60364e --- /dev/null +++ b/Swiften/TLS/UnitTest/ClientServerTest.cpp @@ -0,0 +1,760 @@ +/* + * Copyright (c) 2010-2018 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <map> +#include <memory> +#include <utility> +#include <vector> + +#include <boost/variant.hpp> + +#include <gtest/gtest.h> + +#include <Swiften/Base/Log.h> +#include <Swiften/TLS/CertificateFactory.h> +#include <Swiften/TLS/PlatformTLSFactories.h> +#include <Swiften/TLS/TLSContext.h> +#include <Swiften/TLS/TLSContextFactory.h> +#include <Swiften/TLS/TLSOptions.h> + +using namespace Swift; +namespace { + + +std::map<std::string, std::string> certificatePEM = { + {"montague.example", +R"(-----BEGIN CERTIFICATE----- +MIIEsjCCApoCCQCbkjlQfUqPtTANBgkqhkiG9w0BAQsFADAbMRkwFwYDVQQDDBBt +b250YWd1ZS5leGFtcGxlMB4XDTE4MDExODE2NTMxMloXDTQ1MDYwNDE2NTMxMlow +GzEZMBcGA1UEAwwQbW9udGFndWUuZXhhbXBsZTCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBALAx5xuEYOjDJ9QHMvwRuDzxbHl1zR97SJFPAkmD8xH0sC61 +DNRyUvRq6UXb4znhqeqrNuZ9PV47GyK2Dpy/c/MY5NE3m/c+Z1tUnrcqyCkxITIn +jdSI/elc9yhtMXX6lRi68BdPJnj/9+6trW0cWHlKEgnaSTAgCVB+4Dg9mjTIroCa +HLoAKhr2zS7Ihs28aWb0cSvZ+qFgQhr7FGP2kfssTTQYyRPn9uHhtyWH6RqSv5x9 +BBGZWN5GtjkJvupcYWLt8ftuQyFpwEeEz5cgtiyKgsfz9CYvS9/OcwdLQr4z5Zq6 +eKxsog9GdwIi1Us4KR0X6tKu9ze42iEWF+foEWFP9/bjrVK/tt5lTSKnenk0nA8I +amkG0btNAGihDti3lv60bGpd3B2/uh4gzzT2buXdf0EaybCt52MIr8xkwMU0Tkri +RAYchdS8U8sekWG5Lg9m3L2BDa8/TKS/WflJhGcZeInGQslgIx7fCgO1M7Zr50pO +wSURPXpvqUkXNEBy639UQEUsnBhntEQwZWx/6x6Ma/U5a5dL6qbtEJjlwIvS+nl9 +3w26g3DvWydNMCtZIVhgdrl+dZs+Uw5eA3QkHkDTSfYvQk7X5SYL0J5ZxwBvU9r1 +ED054+TAEuX2euiRA37xLhxonj8BaKkPQGlAHCLZaZPmNJWkNxElJhMoCfqBAgMB +AAEwDQYJKoZIhvcNAQELBQADggIBAF+FNyW3nVeQeugBMksIhj7EMJl1AEKi0+78 +ZPsYX3CDbc/8GRZoTg/EWSiwPCBYc9VsxuKtODEYABCZgk7LnSBYoEauJDKWqkgM +UOKPJI2hu7mIK7FJpjvEZe2MnRRA63oI/NVDJm8T2clrv/vPkY+ppsVl0toC0SpH +/3dF5c65vYI19rTJraRU6kIrrgxFBzxzpn07LGh2rrOCQfy2umTSRMwz3ORAFfmi ++Kek1Dt7c+JVJ0ivCwhhc8MKza3JS2MuDfVWGnXtDLb81Ai0t4tQfLKvZEcgW+lh +Drz9gv22buwncWL/IxtuhzyILtDSDKAYFbhfG6IAQut9BjMgpMnKrBCDlOLJl08K +tgj2h7vUKyNSt3ndcSAtXjr6FD7+xPExJuyn/MgLONGGAZoZHFB4QO90wQaXxMPh +7rnjUtzfLR8qkDmX8ZB4f4VOWpDWo4hBpgjTk0gYfzEkrh+zTqE9reh7CZ1WzwXO +KnIBU2dZOE+XsJe49lW106DLqGzKRuQMUAwFMb7C7Nlg9GKTnvi41o+g6YE+MgxR +uPKu891pCBtnDxZiWPT+7Fa/9UXxdIOTVIHW6utSWiWYbeNwXSmIm2ShfmNfWj9m +x1JgJrFB6daWGR9aDBeDVRhgL6Z35lH7xI62pLJ4o2d2Y/9dUWAJfz5O8opeCyrF +zqCzpwGL +-----END CERTIFICATE----- +)"}, + {"capulet.example", +R"(-----BEGIN CERTIFICATE----- +MIIEsDCCApgCCQDUGdmqHfGngTANBgkqhkiG9w0BAQsFADAaMRgwFgYDVQQDDA9j +YXB1bGV0LmV4YW1wbGUwHhcNMTgwMTE4MTY1NjEyWhcNNDUwNjA0MTY1NjEyWjAa +MRgwFgYDVQQDDA9jYXB1bGV0LmV4YW1wbGUwggIiMA0GCSqGSIb3DQEBAQUAA4IC +DwAwggIKAoICAQCgA/CpV7UGqUdjhEVoMjFIZ6Ca/C7utrVPAqBvE14eiurIhQrQ +AmYeC9zA4/uXCdqkGq/a/RbF3OOCKLRUejCcynb0EnxiHxHa48ZsvLbKCK6guoXE +pWnaZsmRpvJrBB2z6ohmxRuaDuc5CJT+Oq8AFPp3StTAFDo3Cju3fsGZPkNpCGbj +ELwk4ok9INtEuTrMEmHZTD+VfjpXauUfN4ygKaPXJanCuxuifyin403BWgd8igkD +oSCWxoDFMy3HGbh/NU+nJPJ23FxVC39RdDG3elvjNFpSZnALbiMnyor7YjF5TN93 +1ZWwn3VTnl7DnFquEbKbYyVFUzRII8Cd1TzKOL48rVLrCAqMXwm6YFtST6qPb9TZ +0SX8qZGCwBfHV5OeS0ZgiBMMlmUPYcw9MlyvZnYyDPCOoPWmhEqd2gQzn//7hzb5 +mriCEyfcMzAqohylBNHXUVZTx5KcazJz6oOYdWEs1jfSXNKefgSWlgeoG2fgTXPN +1OkQVS+FOiI0VCAIwR+vxhG3hVTz3kzXWvEt7M51faaHWWlnSzOrbSuj3f0ibS5J +cj6ClyzOQRQDwzofyZ7oPWh6No/XkepVIn3HTTlnj1/8e6VsH+EBKSzoX2XvWPkO +GAZEGHKiKh944u6d6mW37BPD2oKyusP3uPL5j2Fdm+m0HkP3/7yw+5EFVQIDAQAB +MA0GCSqGSIb3DQEBCwUAA4ICAQCfCGK4iDo8H0i12wBC0+6GB9NBmgn8P09AUN0l +tQjZPaqZCtLtBBqOrAaZQBQMfI0QAm5/h/VkhMvz5HQjqmQhI2drSDOmarYzOGgY +yVItkEwtLEVhiGoeJ+L3Smosoqq6QFjcDzH7UzPTrJNspnY+09+m53pJggh41zzt +1TOU+QasaB5oGopFaFUUlwjHAc7FpZgEd+tV6j0cpdT3GabVkkoLg01Z+0mqkpLD +OjRBKJX8XvZ38VESsy3gWpcXnDq03n+8OgZo4R9SEcyyxjWbyb+qg2dzbQvRB2Va +QNoXp5EzemXvFSulhR+TfDk2K1h45BurikRQxDi8LpBTUsCMwiqXdem68HOlTwLi +/kMWbnVBcdurYcWVSwlJU4EJcTEdk51JStO1V0nAA0nCwn/iEhY8I6BitnrcCJ5e +4CGVWr+zAm8DBjaFMTzy46Q5NcT0hwnHGN6T6l4aMcRggIK9anRbXCn6dSzma1pd +R5N/Do00FTpyZGcUlVPnSlIfZVl7y/9XEO1n6xDJURrefL1JrM7UMyB17jA8HMq3 +S05kF7XRpludRB4QkAJt5BNNv6BPP7HPIKyR/rq94ONvzVPAo7uASyFE2sMBsfwP +pXAI1LVolPCoUC13jEkKdmc8kMSxU+XtsvFryNhkfQtZfSg+nBRFYptFE7GrZ9WY +GMSL4g== +-----END CERTIFICATE----- +)"}}; +std::map<std::string, std::string> privateKeyPEM = { + {"montague.example", +R"(-----BEGIN PRIVATE KEY----- +MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCwMecbhGDowyfU +BzL8Ebg88Wx5dc0fe0iRTwJJg/MR9LAutQzUclL0aulF2+M54anqqzbmfT1eOxsi +tg6cv3PzGOTRN5v3PmdbVJ63KsgpMSEyJ43UiP3pXPcobTF1+pUYuvAXTyZ4//fu +ra1tHFh5ShIJ2kkwIAlQfuA4PZo0yK6Amhy6ACoa9s0uyIbNvGlm9HEr2fqhYEIa ++xRj9pH7LE00GMkT5/bh4bclh+kakr+cfQQRmVjeRrY5Cb7qXGFi7fH7bkMhacBH +hM+XILYsioLH8/QmL0vfznMHS0K+M+WaunisbKIPRncCItVLOCkdF+rSrvc3uNoh +Fhfn6BFhT/f2461Sv7beZU0ip3p5NJwPCGppBtG7TQBooQ7Yt5b+tGxqXdwdv7oe +IM809m7l3X9BGsmwredjCK/MZMDFNE5K4kQGHIXUvFPLHpFhuS4PZty9gQ2vP0yk +v1n5SYRnGXiJxkLJYCMe3woDtTO2a+dKTsElET16b6lJFzRAcut/VEBFLJwYZ7RE +MGVsf+sejGv1OWuXS+qm7RCY5cCL0vp5fd8NuoNw71snTTArWSFYYHa5fnWbPlMO +XgN0JB5A00n2L0JO1+UmC9CeWccAb1Pa9RA9OePkwBLl9nrokQN+8S4caJ4/AWip +D0BpQBwi2WmT5jSVpDcRJSYTKAn6gQIDAQABAoICABqc/wZ2AVlHGP36tGXEm2qB +INxbwcbujTB9mZ/XEWD176KucCiquAL5HxERPIointK2V82Kvzk7fkbI7v4YIQBo +Ey/S0XkP8Panmm2aRa+LHzN/K/odUxTrmN1/WMg0OE8K9Xbf2rTOHPntO9POQ0LW +wFDCqulc/WsuLtnv3Bn68fi0zn/9xF5cRvO5EDuFKPqHE40HGMdFTdbbc+IBfV1N +/L9QuxaJpA3MVSiTFc+QuOZ/L50k53pzfdSxtyeZGpCh1jofFn62hXeIBP8TztB9 +f3GKVKdr328HtPI2GPe3yQeNAOsyYWwjPZiSAFujOPqPAUYfbXH6NuBmgOfjcrRb +AhOv9F1VNi+G56NJ6jo/NPygD+LYQdIKs5rv3E4ehyQzbu+SoGyVCnF3qm0cvz+v +tB5/gNiWiyRhNF94DZHlceDMQSdyB/pfTZsKZ44Yv44Bzl54YbzR8yr/ZKzAj6gt +5lwAqCIcdRj4i5DmIa7psj3iYWe9hYV7f+zwdosPKibRvO9FpvDCbb7biIPkMozw +cYH6QlSsZ+XsK/Z3WPFPq0wHOgoWW9Tr8LYyQxGjLO+xD8ziQ7Rp0KApEunuO29s +CPXj+l1HqNmAK2LkdNI3c/yStlaAcOzYD6pauciHWlTnIGZG8aHV6elIjK0C/h7B +3GndVc0TbewbP0bL56QBAoIBAQDU/yl4nlELhpoI1WW8v/FcDnc3V5dBilJ3LQtp +a3SKBcNWXE850TviOAklMrYmS1wuWdBTjEay9Ka6dImqMFGupmJjLmUw0KXrtPin +xIz5DZ42nmTKnYevuBQoQrrq7toxf5hYow2ZjeH2vSX+igY1gxDZbLW4Wb9GPYMo +Au5+z8XpA8R0key52nvnKastm5YxNstAlBOodAPKlbIr2bzmrHSjXAGjUzb+z6NZ +5Lx+zvQCy9kaIYvfOJm3eLSbMXzeP2S59qbwL+dC4ZJ5m3hjRmMaactV6LSchVNt +eLEYJpm92IdjQhG6oqM0IaU3aSjWMSrOAytylmqoEt4wA+WhAoIBAQDTxJ9VLb+J +OD0x/9cm17KpK1nGQBQ0T0oZQUH5M/tXTPCCoIpoL9UhKQ34vlPaZXkBQrXPw+PN +Y0J26uR6w4CowWAMn8LR6cYsWcOKuURcDYs/SPflD3rraevJwugQhkXtub2nV7dP +88Z/jGvhXthJmjUmNoKq3OC2MuSfHSkm8ipvaAblwb+lt5zBJGQ6iGXbi5TI6b+D +lnAidQpG/V464Zc9gb788P0K2vUeoZRLI7CurYqpDV0mBtPhFv5L1M0S8+psG7Pa +NIEKcW/b76vU9odTrtGBT0gCVYU7f8QnTN4g6c7dEhcZa2Zvg0YSmb4XuU9RQGC5 +As47nEUnPCjhAoIBAQDTXKnAogn2kAmGvoyIs0hFe61d47ObPDH9RVvPruwkkvd2 +WX/c9f6gy853dU0/zwSYklOitM7rgs94s3BwzCYiU8XKeh28RTCBKEKf6PGjq5nW +xXNrhMtC2j5WfXGS9JbdC6sYOiWivSMAgE6Vuk3TCE7OE4x4dcbTYvMl31Lf0Dqq +sixfKPdqrp7Jk5XkWkK+b4teeBLR1N52R/pYfWdw2K2d9g1CD6/BSDbnW46Zn7CQ +nczAm417Y2VWpZdDceZhfTLtPxAFxOOOgN2jg14B1bU+XsGCbLvdnohdV6kVOCjU +NWyUWNnTBNVDRCf5RodZlczORmL1AMKyKpcFurhBAoIBABSxbfBg3AqImFI+ccO1 +6BtnxQn+UPsblF4LZmr3jWPmfMoG7f9oTSdEX70ivAbnS3+4CRQYTDZRsLj2EwV7 +/SKAYuZY5iyk71x+GQGBQRDNsgGpG7AiZxyB6Sx6Azs6I7MrJ0Em7R6+73KfQhtv +rSrkCrWFNheEJeEn7/csXk0T9NmWDLZ+zD9hRcwJxlGB6pIdfZh0XuZ42NRFI4/0 +SjTuvlygRQ1qbw+UfcdUeq0s+6LWCmqih6ujlyizmn3GeZOUih+uRVDZOJLQquGO +9feFb4vZ1VcRbDPuL2q0/XHprPsCXdh0YBV3zTawWTSQGWcwEHQcGld50rU4e/lt +g4ECggEBAKwoqsqIHheL+uS2CHXmwFIr+rvOlLYlfB8XrwV/da3p7QChaDLbNIVM +uOAozCMkJY+dufPGI+3cKsR3kLAGejmfbH5OTzTbwCLOJFCWaoMuvOTY2Govte61 +gU1BWnjUgVJgVA/YTwn2yo02d0nG5/rSZ9xIt3hfO6ac5FhHBTA1DAZ1wDiLeow+ +qngZ2sA4ePtwhGFtvLVwTcGAfkWvQFi2YPBpesFIAmQ/ACGC7Ye75Ja4k36/8YwE +NiXR2Yy1hxwwi7CTWWzI0X+mvE/Oqpd8PUqPJCJcpz892Gq4EGCxM7Bz7NxCcvvw +5IMXuORWuoq0gXiCdEyko+saXsyWlqw= +-----END PRIVATE KEY----- +)"},{"capulet.example", +R"(-----BEGIN PRIVATE KEY----- +MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCgA/CpV7UGqUdj +hEVoMjFIZ6Ca/C7utrVPAqBvE14eiurIhQrQAmYeC9zA4/uXCdqkGq/a/RbF3OOC +KLRUejCcynb0EnxiHxHa48ZsvLbKCK6guoXEpWnaZsmRpvJrBB2z6ohmxRuaDuc5 +CJT+Oq8AFPp3StTAFDo3Cju3fsGZPkNpCGbjELwk4ok9INtEuTrMEmHZTD+VfjpX +auUfN4ygKaPXJanCuxuifyin403BWgd8igkDoSCWxoDFMy3HGbh/NU+nJPJ23FxV +C39RdDG3elvjNFpSZnALbiMnyor7YjF5TN931ZWwn3VTnl7DnFquEbKbYyVFUzRI +I8Cd1TzKOL48rVLrCAqMXwm6YFtST6qPb9TZ0SX8qZGCwBfHV5OeS0ZgiBMMlmUP +Ycw9MlyvZnYyDPCOoPWmhEqd2gQzn//7hzb5mriCEyfcMzAqohylBNHXUVZTx5Kc +azJz6oOYdWEs1jfSXNKefgSWlgeoG2fgTXPN1OkQVS+FOiI0VCAIwR+vxhG3hVTz +3kzXWvEt7M51faaHWWlnSzOrbSuj3f0ibS5Jcj6ClyzOQRQDwzofyZ7oPWh6No/X +kepVIn3HTTlnj1/8e6VsH+EBKSzoX2XvWPkOGAZEGHKiKh944u6d6mW37BPD2oKy +usP3uPL5j2Fdm+m0HkP3/7yw+5EFVQIDAQABAoICAQCBom+IYdvwp5eEUhaA0ZkH +lZyRsxi6oB7HAdPD6SbpC5YmGVKnLipY0TdotcqPlJYjONObUErwxYEzY5KkldFo +VMaF+av3OkCW2s1YLpLPnrUK1dGlfHUDUR6f92aRuGXv6mPTDoDMEKLWm9NJG3XH +VTeNCXzOmBSJnqq+f9yML9sg7oOcFWS3ZSfV9BZv2Lh/t6y6BIHGtNrDE4DIB5LP +9qwbkxGzBy7eOLJRQV8u86b5CENBQ3pJbEvKdynxES9dL212dgJQtTnAVG4zKTVV +9bUXnsRF2WOQfwvQItDx051NLjAkv05kJutAcR9IzhTQzNmr9Wiufzft8bkMpUJ3 +Mf8cJk5VNm9mgKvWnqKrPSyfNcicykcVHXr0yDICLgttWy5d9bj9/DcfrIOzEwhd +MOhTixYtR1dv/7p9kqw2mRgMV3GtB6f+AoQ29NrCt9bD6T2Rth9lXSo90sLW47J9 +QIan8jb/T4N7nuga37wLlpL5KhA7nyzlaF37PyvhbErzOxRfq287iQKCyF+nh3n5 +9HzWDWz+8zYcjsxlYc1x7XHWWAYKS1h+ZWPjWCLH8hlh3ZRdPm4CUfwuZmA2EjNT +8dRblRQ8QB9cvsKoLjKt8vB8mIoH6Sjk5I3vqNVXl6Su0JrvLg5A/3tfyPfxsm5c +rTunLQllzpgo2/q6ssz9yQKCAQEAzgDf0ozoyH9+k4ND7LCy5G1vGr8LqMhyjgSC +4AhBIM/Hz56YSrU0hIFpgu/VGWLkGN/0AiwhHBKpt+6KkvLBjxnv71dmI2hBIbb4 +Hzy4EXtPTtFqn4gffYjOen6co8RUl1vTOmRDUdfS6su0v9TD3335TIIfF+5DAGvR +V6OIHkQWWrHazUZx0tbwRyty3Q4NtYgXLFrcWFYfMFd26GhFrM7uHFrbOg5U3gpZ +/YdaaJzfdaJKHNPNQJUPD40n36n8RyjlWSWkUfEV3ITm0IMiCJ19WDjyddLUXuzC +KSoeiTCISXzZ8lhmvnBB4pW9V1O1o8cDJFRT1ouUfOKqK86lxwKCAQEAxtnMzmEp +Z+W3Jlz9istkJHerNATtQzj3KSNHbrM8gB+O0igq0BWbj+lvNtbuZVprLrOpbDk8 +Ksk+PdbgSbsQjALcs1FpoIsPWt6sKTwrZQuMCocHzGfrp0MA613YCRw9sNBM08C6 +TNbjSTiVlBb3xyjsI3hLZ9sj8N9rV6yomlwM6MnpdIDUxfiv5tlqZcqCYdibJ9zu +tWi44O2tim3uCVrajop/NsHXbROjd7MeV4gaj3SsJ4cLyvfcBkfwrhUse5D6qy6y +08ZsbrMUqY50ZG0WUcKzJxJcF/mOANZ+Dgqe9jwKlxV8E1Lj7PaQWWzQ5bWVgnLe +TuKoZurGEaJMAwKCAQEAgWHJMYswlOSGUg2KdrjP0mns8wZ0QzCJyiqJLD3i8cGu +Q/bevWUrs+E3rHYHCCe1DO5zaX3f2arbD1txizOOX9sxd8gTrT9IUO2CztOq48fn +mqAqcEHlTUnELOkiZjTj0CBq/OyF33xGyxLf1e/CibasAeJjtvr89+G/nGRoFGI9 +C/9SZcTNrlcyl/Bw9udhstbjfwceBxkoA4ubcgIzaIKayBJESCVCJiaoOHRvUu7b +5hzkoVBhRCOaTvEfzvkLKoJD8YaTuqdJTLPn56PEl1aap/M0TM36dhgLJiF/BjkG +D+mrVOsytH760l2ripJXraJLleCku0X1H66YpGTodwKCAQA34vCntDEB7VLrKklr +37v2b9ejGBtiwDjey/aAi0lerP/j2rwlnV0KNk42eHOp8p6bEo10SCW71LF0idah +gjylTQygLSpln4+iN2Dlee6sSHGEZ+zuKurVKISyob5c2R4ReomNHeZ+QArDAm8v +nsDmrX6ofV+cAb/5K6Gsk28TavmJ122Qe8DRHxK467P2hdLdExaQPoysWZFUThhv +BnRXFrzEQPJ9/j7Afjt8IdBOQ4dLeDwGI/NRiRXCgieHlZXZ6KY6xDYoROUmu5f8 +C3h03R/fvLvDKGrPpiid3aqx4ZRJmhhT3AryF2LNr4JkT6vqU32Amy4Vt6givKsM +O7PnAoIBAAggpMq7PMugGP4B9PgNb00oGmWfXSa+M83O0GGN7jSirxqkaK+/eDOY +kSnVFWmORNBlSz+bLoA3Bw2mFXI8HfSbHM9E/Qt0scf0hV+SwpTuO3pDWF5ev20G +mL1QEBUNDmvOn2SYERKI1iRevjBBXSzwTpAXnfaWvvTn1XSKzSJK3TjMhFTZHtbj +mgPPV65cznhofUsg2QenT8zKisvYPYN3p3p9Jo6IqHyT/CCymwIB4OMZITiwXxQs +PMAxlZGkX3Uri5A8Ln3QQ46elanI2TlC+ZDa84gu/Gw691JWCfsaSaQDTJKnGqos +dwiNVl130YWaJLjiA9Poc2llKtypfQ8= +-----END PRIVATE KEY----- +)"}}; + +auto montagueEncryptedPEM = R"(-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-256-CBC,6B0A69362920334824667C1B6207279B + +vlDCCnUf9aDbCD4+PUuo5LGvzTFlT03ZRMnHDcBzE2mp1OMBjxeEu4j4cqUJE2qV +NXCRbsedMsydoHlg76LssYM7J/AI9dp5cek0HgYMqdeB+hoNn22AmjRb7WhY4VeW +RqKAzkXT1lsxEF8hykQcalbsrbdmKkPosiNJF4Pb9EEefl01e+Ny3nb7GRs22tzX +lJNBk+lrM0Jlg1Y6c3F5/5CkKHTXP4924Pzjzf6Bw5hG80izrYeBUC5lZJtqDM7B +lmFXAng4RIDKk1TsqeJ11Fa1nMqFkvRvlU8RdrcZ5rtngWxIAvTXAjbDk5mvS6Iw +WdjmH46TrVMQLXC2Qh++grldyx4GDm7rShLm23J9lUAdPLjIvurYT+LfbCRqfgIw +hkPtm6BWkkf95KfpMKZ0giOhikqnF2YsozgqI5SphDFIAGN7bXa7Z8g/xFI9Uqie +2+rWqVvBOQ8PBepTd2H2uahV+pP1wHmgqN/bp/paXt6+Qf7ptH6MNTwgnTanDfnk +wzyhVlw5tTsG8okjD1cT2R7RbuDQRkArpzbnATPEU9Itrx0Sh/ZPKPDDVS+aSBHA +3JytZX5yzd/yilNjE3NfN1G923lcWXRX3KsdZUQjbcPugML7xbC+orqwxeYLipMN +jfNEGK0IrTNmRN5HqFU6JBNbas67BlFU4Zt4Tt73sUHrMpSSRINd8itRZaKtqZuM +8upj7ZUD/j6j/JmSxN2w+TcmHXfNWZirTFWUvtF/l1WCHilsuO49VW/CqGFW2Bad +32YzPkENljj/xuijGOHr1qVFozfG4/noXdVtJm0oflt1ImdjvOO91LneaAhVE8lO +K5SwOnsrlr6UM0tb/HnunT5Se49YQSGnXOiXO68bPO9S0JZ33MeAP5kSbMSZ6VXr +luw7dga0jfJLqnWU2arxOqruc9bSwkfU0RUoWXZqrKwUiXdyl/vVeU1Y67yuYqXH +7eUrdL+BdSDbeOC/5xmWAkeheC4OBBYCcwbVv1Aw67sUaQIcyWMkx8Kq9tn8vpRa +ETcagVjUXqAjrYtRpmCXU6KdmeGKoQZq14EVREytk0KnTUQTFtv8LJhsau16v4pS +in7Yt658hdf9CSA5snfUcvLeETNeQHQWvmN+0uD/UB9vRPbHp3kPSvitoS799QB1 +ydrD8zXdUSpcW+V2P75c7u0XkcUTbyGIBuwLAtr5fweyyiKs/v//rPaBlzEG1WUr +OFSH9KZ+m9UwqmauXesySXoVsmjCQKUVVj4/QI/aWftmMY58CDNJw+q77dAzSYrj +yFbhUt5ZKqAvb+rt3dJswkZ1sxAbmTw290NAV4NPP8cjXUjLwmU+KNZ2VFkxt77p +1LxG+Ia+TV1JystBvFeiJ6sWEC3lQ7+0b8oDfE5aovQpGk+Cb7hyt0EvDh0/AkvT +B/KCQc8wUjyn+yejBicfMzHVaOphwlajrt+vSNF4G7J+Wo5luTEXpWQrKq22xnah +sal7IusjSgPdFpLCuyAy6atb/4aQoeXlE/r8tXbmrl48SnadwAndoZVt3gzIv1/Z +oDc5koTBQk6aIoWHb6qslRt9tmrnF22aP+/a10oahgIliWAL3jUwLqZYzdbMKkMv +NEbobf7kO5LTzv+w09K0A8miF+8js351FBw05gsaUHgufF3OCGAdQfXDN7d6Lxho +HbhiuzxlHOnth3TWNfqhvNkwFP3gfAIaqlU1Z28AP6pZtUw93QYNABUez8QFZj5c +sdUpopUO8krnwUPNup6yTB/m72Vx2aSqXgu4upxUNVJlgDFmnCBhOe0KKjzduIvy +bRHxL93UZxDnpn8DBB1bgmdSzgInc2gfq91j1AyL+nbZv+kob/jG3OxMWNjenVDj ++TeyP3OypAUK/8jP98ExS75mE661mN28kKrUfTRxZGt8CJY4AFL4lAzIf2p4JMch +aPE30/DmXmKng+VP+3ik5FEomMLIc6QkrEzzcMYQkDsNdjd202CAXRSAqnT+VFtR +MlopkSVvEpn83HdCqcANl8rNo+ANnFMyyPL7sFd470KhSVTcQVSb+wR8DOiZr8Vt +uR0G3+KgdEDAvZStkWTCr5eMYhm95QVclnHhsLq0AaLrOm32PqBi2C4mGyW04Mud +m7lUuRkf/mLKWZZfKleefp12waahMqSXAo3shqyTNVPKOFSVA/UF0mFGon1Npo/x +6z4hd5sbG1kiPlrt9EeTgtwFhQ0lxM755QTvAB6GXcLxkGkdNdqhJzFtTRAE9P01 +CiI1JYEvTHBdGcsBbw9zJikOEXCA19fAMkHqSfo5aU/qbuvDsY2QLZkgfiMnpoOx +ghQzeJ95jiYE3V5WNtB/7CRthfC54moWW7w6ZgdIuCEN6JvK0zmsahv2o16kkzWA +YTw1lqaNMHIhlidRwy2Q+ke0mmNTIHHtNqLGVfOE4TwSN3VIIhXNZ5E65LuBw7tQ +SyFK07dfMQXixqaeo+ytXBNTFEq1MEza/PxwUojn7njbCKhO5qGavkiyNs5nk3ZE +htkhtreIUj6kHzWAvylxLbRy9+4AJA3/UCnudMRtX/McjtN2jNwZKPaXWCQF85ff +koOclVf4j/eYQnWT03zXjAx1DKazIk0laEfB4soXfQfgXdFyj3YKXKKD8WzCW/ag +cloY4yZVa+SWnj0P23oPdptL9vOM1NK1lXAp2tvvZHPp0UmLtXVU4eNaabC79dXC +3KU9bVruCdpQki4kGk3MvsoB9OyNEZE1jxLZ+7FI0D1XKJ4qHZcwOyGqD07+Xect +w2xs4stXxvogUZdQ3G6GBANFXEjDzEu5vZn9z668mCe0cQG/iNWOR5ZGmdjlmW5O +6O9ibFmk7pc975V9SVHH9rS/GZGz/PW6CJ8O0GALw5y9fczXxjvCz7dPHK5MO40m +fDWCwIqK1D2LOEewMFqOOleBhHMpVfQX+Uu34UlWHGFnOm1fK+dIdT7tss5o8Gkz +gCBFpmjyi8H+VtXOy5JTTIi/80pnLO8nsv27FNPVU3UZJCZjfR9LCeqZwgF1MFIe +X137HnkpmtJGF+bcMRwY5u9fSQQZtBNLCadRsvHnz6J+1uodFDnre0+Q4dokmFfv +0UveWc1CDRa3qXpzW5U6NpFjYWQmiS3KA5VY5/KHE7UJxnEI1R1gEaQ6/Ogp2cmI +-----END RSA PRIVATE KEY----- +)"; + +auto dhParamsOpenSslDer1024 = R"(-----BEGIN DH PARAMETERS----- +MIGHAoGBANjw4f5+gu8b8X8O6ALyJA1tH9TQTWZEI3YjUKQ1m0dVBMJ6XDC7FLJn +gqE4hIGcm1FAWwIiuo0uMufqyVwFT2c+G8j4JHWK5z1tEP+GaqiO34N0cUo86qHp +THSkJN7LuHbYRqI9fHWDZocW/5yAsDq5RPUCjFZAoh1BWdfDFfrjAgEC +-----END DH PARAMETERS----- +)"; +auto dhParamsOpenSslDer2048 = R"(-----BEGIN DH PARAMETERS----- +MIIBCAKCAQEA0Q6vD5qtrh3XEkVkbN29ord/k3sgo2Q3PiFmyFt89qqVbebEzYmt +t8DwaFGMcGlyKs4Lb1s7vocm9y3M9C0FZm85Muvv8WCbLZVZ+wfEtMibOjgRoDqt +p7Qqe7/iPgMVrSjWegVkg3V8K8dnPpohPClM0yOe4NpBjSVNgBVJRpEtH8gFiCor +H7hw63HpN/MgFdkjZNeCN+erv8p673xH8LrN98gQpkdQ9vCqYt1dHxF2XZcxBp8x +XganwPeGgQosofkA6nVB70hyjwjEyxnHJZIMlx6DPXWC7X6ed0SazgH0sQNdACvG +uU1zHCVIv6/f0adKrJg0s1jrM3qWZ6HmUwIBAg== +-----END DH PARAMETERS----- +)"; + +auto createTLSContext = [](TLSContext::Mode mode) { + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + auto tlsContextFactory = tlsFactories->getTLSContextFactory(); + + auto tlsContext = std::unique_ptr<TLSContext>(tlsContextFactory->createTLSContext({}, mode)); + return tlsContext; +}; + +// This connects a TLSContext to another TLSContext +class ClientServerConnector { + public: + ClientServerConnector(TLSContext* client, TLSContext* server) : clientContext_(client), serverContext_(server) { + connections_.push_back(clientContext_->onDataForNetwork.connect([&](const SafeByteArray& data) { + serverContext_->handleDataFromNetwork(data); + })); + connections_.push_back(serverContext_->onDataForNetwork.connect([&](const SafeByteArray& data) { + clientContext_->handleDataFromNetwork(data); + })); + } + + private: + TLSContext* clientContext_; + TLSContext* serverContext_; + std::vector<boost::signals2::connection> connections_; +}; + +struct TLSDataForNetwork { + SafeByteArray data; +}; + +struct TLSDataForApplication { + SafeByteArray data; +}; + +struct TLSFault { + std::shared_ptr<Swift::TLSError> error; +}; + +struct TLSConnected { + std::vector<Certificate::ref> chain; +}; + +struct TLSServerNameRequested { + std::string name; +}; + +using TLSEvent = boost::variant<TLSDataForNetwork, TLSDataForApplication, TLSFault, TLSConnected, TLSServerNameRequested>; + +class TLSEventToSafeByteArrayVisitor : public boost::static_visitor<SafeByteArray> { + public: + SafeByteArray operator()(const TLSDataForNetwork& tlsData) const { + return tlsData.data; + } + + SafeByteArray operator()(const TLSDataForApplication& tlsData) const { + return tlsData.data; + } + + SafeByteArray operator()(const TLSFault&) const { + return createSafeByteArray(""); + } + + SafeByteArray operator()(const TLSConnected&) const { + return createSafeByteArray(""); + } + + SafeByteArray operator()(const TLSServerNameRequested&) const { + return createSafeByteArray(""); + } + +}; + +class TLSEventToStringVisitor : public boost::static_visitor<std::string> { + public: + std::string operator()(const TLSDataForNetwork& event) const { + return std::string("TLSDataForNetwork(") + "size: " + std::to_string(event.data.size()) + ")"; + } + + std::string operator()(const TLSDataForApplication& event) const { + return std::string("TLSDataForApplication(") + "size: " + std::to_string(event.data.size()) + ")"; + } + + std::string operator()(const TLSFault&) const { + return "TLSFault()"; + } + + std::string operator()(const TLSConnected& event) const { + std::string certificates; + for (auto cert : event.chain) { + certificates += "\t" + cert->getSubjectName() + "\n"; + } + return std::string("TLSConnected()") + "\n" + certificates; + } + + std::string operator()(const TLSServerNameRequested& event) const { + return std::string("TLSServerNameRequested(") + "name: " + event.name + ")"; + } +}; + +class TLSClientServerEventHistory { + public: + TLSClientServerEventHistory(TLSContext* client, TLSContext* server) { + connectContext(std::string("client"), client); + connectContext(std::string("server"), server); + } + + __attribute__((unused)) + void print() { + auto count = 0; + std::cout << "\n"; + for (auto event : events) { + if (event.first == "server") { + std::cout << std::string(80, ' '); + } + std::cout << count << ". "; + std::cout << event.first << " : " << boost::apply_visitor(TLSEventToStringVisitor(), event.second) << std::endl; + count++; + } + } + + private: + void connectContext(const std::string& name, TLSContext* context) { + connections_.push_back(context->onDataForNetwork.connect([=](const SafeByteArray& data) { + events.push_back(std::pair<std::string, TLSEvent>(name, TLSDataForNetwork{data})); + })); + connections_.push_back(context->onDataForApplication.connect([=](const SafeByteArray& data) { + events.push_back(std::pair<std::string, TLSEvent>(name, TLSDataForApplication{data})); + })); + connections_.push_back(context->onError.connect([=](std::shared_ptr<Swift::TLSError> error) { + events.push_back(std::pair<std::string, TLSEvent>(name, TLSFault{error})); + })); + connections_.push_back(context->onConnected.connect([=](){ + events.push_back(std::pair<std::string, TLSEvent>(name, TLSConnected{context->getPeerCertificateChain()})); + })); + } + + public: + std::vector<std::pair<std::string, TLSEvent>> events; + + private: + std::vector<boost::signals2::connection> connections_; +}; + +} + +TEST(ClientServerTest, testInitAndFreeContext) { + auto tlsClientContext = createTLSContext(TLSContext::Mode::Client); + auto tlsServerContext = createTLSContext(TLSContext::Mode::Server); +} + +TEST(ClientServerTest, testServerSetPrivateKey) { + auto tlsServerContext = createTLSContext(TLSContext::Mode::Server); +} + +TEST(ClientServerTest, testServerSetCertificateChain) { + auto tlsServerContext = createTLSContext(TLSContext::Mode::Server); +} + +TEST(ClientServerTest, testClientServerBasicCommunicationWithCertificateMissing) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM["capulet.example"])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + + serverContext->accept(); + clientContext->connect(); + + ASSERT_EQ("server", events.events[1].first); + ASSERT_EQ("TLSFault()", boost::apply_visitor(TLSEventToStringVisitor(), events.events[1].second)); +} + +TEST(ClientServerTest, testClientServerBasicCommunicationWithPrivateKeyMissing) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["capulet.example"])))); + + serverContext->accept(); + clientContext->connect(); + + ASSERT_EQ("server", events.events[1].first); + ASSERT_EQ("TLSFault()", boost::apply_visitor(TLSEventToStringVisitor(), events.events[1].second)); +} + +TEST(ClientServerTest, testWrongPrivateKeyAfterCertificate) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["capulet.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM["montague.example"])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(false, serverContext->setPrivateKey(privateKey)); + + serverContext->accept(); + clientContext->connect(); +} + +TEST(ClientServerTest, testWrongCertificateAfterPrivateKey) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM["montague.example"])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["capulet.example"])))); + + serverContext->accept(); + clientContext->connect(); + + ASSERT_EQ("server", events.events[1].first); + ASSERT_EQ("TLSFault()", boost::apply_visitor(TLSEventToStringVisitor(), events.events[1].second)); +} + +TEST(ClientServerTest, testClientServerBasicCommunication) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["capulet.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM["capulet.example"])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + + serverContext->accept(); + clientContext->connect(); + + clientContext->handleDataFromApplication(createSafeByteArray("This is a test message from the client.")); + serverContext->handleDataFromApplication(createSafeByteArray("This is a test message from the server.")); + + ASSERT_EQ(safeByteArrayToString(createSafeByteArray("This is a test message from the client.")), safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "server" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); + ASSERT_EQ(safeByteArrayToString(createSafeByteArray("This is a test message from the server.")), safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "client" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); +} + +TEST(ClientServerTest, testClientServerBasicCommunicationEncryptedPrivateKeyRightPassword) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["montague.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(montagueEncryptedPEM), createSafeByteArray("test")); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + + serverContext->accept(); + clientContext->connect(); + + clientContext->handleDataFromApplication(createSafeByteArray("This is a test message from the client.")); + serverContext->handleDataFromApplication(createSafeByteArray("This is a test message from the server.")); + + ASSERT_EQ(safeByteArrayToString(createSafeByteArray("This is a test message from the client.")), safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "server" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); + ASSERT_EQ(safeByteArrayToString(createSafeByteArray("This is a test message from the server.")), safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "client" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); +} + +TEST(ClientServerTest, testSettingPrivateKeyWithWrongPassword) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["montague.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(montagueEncryptedPEM), createSafeByteArray("foo")); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(false, serverContext->setPrivateKey(privateKey)); +} + +TEST(ClientServerTest, testSettingPrivateKeyWithoutRequiredPassword) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["montague.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(montagueEncryptedPEM)); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(false, serverContext->setPrivateKey(privateKey)); +} + +TEST(ClientServerTest, testClientServerSNIRequestedHostAvailable) { + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + serverContext->onServerNameRequested.connect([&](const std::string& requestedName) { + if (certificatePEM.find(requestedName) != certificatePEM.end() && privateKeyPEM.find(requestedName) != privateKeyPEM.end()) { + auto certChain = tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM[requestedName])); + ASSERT_EQ(true, serverContext->setCertificateChain(certChain)); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM[requestedName])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + } + }); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["capulet.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM["capulet.example"])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + + serverContext->accept(); + clientContext->connect("montague.example"); + + clientContext->handleDataFromApplication(createSafeByteArray("This is a test message from the client.")); + serverContext->handleDataFromApplication(createSafeByteArray("This is a test message from the server.")); + ASSERT_EQ("This is a test message from the client.", safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "server" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); + ASSERT_EQ("This is a test message from the server.", safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "client" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); + + ASSERT_EQ("/CN=montague.example", boost::get<TLSConnected>(events.events[5].second).chain[0]->getSubjectName()); +} + +TEST(ClientServerTest, testClientServerSNIRequestedHostUnavailable) { + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + serverContext->onServerNameRequested.connect([&](const std::string&) { + serverContext->setAbortTLSHandshake(true); + }); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["capulet.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM["capulet.example"])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + + serverContext->accept(); + clientContext->connect("montague.example"); + + ASSERT_EQ("server", events.events[1].first); + ASSERT_EQ("TLSFault()", boost::apply_visitor(TLSEventToStringVisitor(), events.events[1].second)); + + ASSERT_EQ("client", events.events[3].first); + ASSERT_EQ("TLSFault()", boost::apply_visitor(TLSEventToStringVisitor(), events.events[3].second)); +} + +TEST(ClientServerTest, testClientServerEqualFinishedMessage) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["capulet.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM["capulet.example"])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + + serverContext->accept(); + clientContext->connect(); + + ASSERT_EQ(serverContext->getPeerFinishMessage(), clientContext->getFinishMessage()); + ASSERT_EQ(clientContext->getPeerFinishMessage(), serverContext->getFinishMessage()); +} + +TEST(ClientServerTest, testClientServerBasicCommunicationWith2048BitDHParams) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["capulet.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM["capulet.example"])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + + ASSERT_EQ(true, serverContext->setDiffieHellmanParameters(tlsFactories->getTLSContextFactory()->convertDHParametersFromPEMToDER(dhParamsOpenSslDer2048))); + + serverContext->accept(); + clientContext->connect(); + + clientContext->handleDataFromApplication(createSafeByteArray("This is a test message from the client.")); + serverContext->handleDataFromApplication(createSafeByteArray("This is a test message from the server.")); + + ASSERT_EQ(safeByteArrayToString(createSafeByteArray("This is a test message from the client.")), safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "server" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); + ASSERT_EQ(safeByteArrayToString(createSafeByteArray("This is a test message from the server.")), safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "client" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); +} + +TEST(ClientServerTest, testClientServerBasicCommunicationWith1024BitDHParams) { + auto clientContext = createTLSContext(TLSContext::Mode::Client); + auto serverContext = createTLSContext(TLSContext::Mode::Server); + + TLSClientServerEventHistory events(clientContext.get(), serverContext.get()); + + ClientServerConnector connector(clientContext.get(), serverContext.get()); + + auto tlsFactories = std::make_shared<PlatformTLSFactories>(); + + ASSERT_EQ(true, serverContext->setCertificateChain(tlsFactories->getCertificateFactory()->createCertificateChain(createByteArray(certificatePEM["capulet.example"])))); + + auto privateKey = tlsFactories->getCertificateFactory()->createPrivateKey(createSafeByteArray(privateKeyPEM["capulet.example"])); + ASSERT_NE(nullptr, privateKey.get()); + ASSERT_EQ(true, serverContext->setPrivateKey(privateKey)); + + ASSERT_EQ(true, serverContext->setDiffieHellmanParameters(tlsFactories->getTLSContextFactory()->convertDHParametersFromPEMToDER(dhParamsOpenSslDer1024))); + + serverContext->accept(); + clientContext->connect(); + + clientContext->handleDataFromApplication(createSafeByteArray("This is a test message from the client.")); + serverContext->handleDataFromApplication(createSafeByteArray("This is a test message from the server.")); + + ASSERT_EQ(safeByteArrayToString(createSafeByteArray("This is a test message from the client.")), safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "server" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); + ASSERT_EQ(safeByteArrayToString(createSafeByteArray("This is a test message from the server.")), safeByteArrayToString(boost::apply_visitor(TLSEventToSafeByteArrayVisitor(), std::find_if(events.events.begin(), events.events.end(), [](std::pair<std::string, TLSEvent>& event){ + return event.first == "client" && (event.second.type() == typeid(TLSDataForApplication)); + })->second))); +} |