diff options
418 files changed, 5867 insertions, 1849 deletions
diff --git a/3rdParty/OpenSSL/SConscript b/3rdParty/OpenSSL/SConscript index c95ea05..6e114e4 100644 --- a/3rdParty/OpenSSL/SConscript +++ b/3rdParty/OpenSSL/SConscript @@ -2,10 +2,15 @@ Import("env", "conf_env") openssl_bundle_dir = "openssl" +if env["PLATFORM"] == "win32" : + systemIncludeFlag = "/I" +else: + systemIncludeFlag = "-isystem" + if env.get("OPENSSL_BUNDLED", False) : if env["SCONS_STAGE"] == "flags" : env["OPENSSL_FLAGS"] = { - "CPPPATH": [Dir(openssl_bundle_dir + "/include")], + "CCFLAGS": [systemIncludeFlag + Dir(openssl_bundle_dir + "/include").abspath], "LIBPATH": [Dir(".")], "LIBS": ["ssl", "crypto"] } diff --git a/Backport/memory b/Backport/memory new file mode 100644 index 0000000..018113e --- /dev/null +++ b/Backport/memory @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include_next <memory> + + +#if __cplusplus < 201402L && !MSC_VER +namespace std { + +template<typename T, typename ...Args> +std::unique_ptr<T> make_unique( Args&& ...args ) +{ + return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) ); +} + +} +#endif + diff --git a/BuildTools/CrashReportAnalysis/WindowsMinidumpAnalyse.py b/BuildTools/CrashReportAnalysis/WindowsMinidumpAnalyse.py index dada920..de0633d 100644 --- a/BuildTools/CrashReportAnalysis/WindowsMinidumpAnalyse.py +++ b/BuildTools/CrashReportAnalysis/WindowsMinidumpAnalyse.py @@ -3,7 +3,7 @@ # ---- # This script requires: # - cdb, the Windows command line debugger installed and available in PATH. -# - the SWIFT_DIST environment variable set to a locatioon that contains msi and pdb.gz files. +# - the SWIFT_DIST environment variable set to a location that contains msi and pdb.gz files. import sys from subprocess import call diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot index 3b21dde..40f2425 100644 --- a/BuildTools/SCons/SConscript.boot +++ b/BuildTools/SCons/SConscript.boot @@ -37,7 +37,8 @@ if os.name == "mac" or (os.name == "posix" and os.uname()[0] == "Darwin"): vars.Add(BoolVariable("mac105", "Link against the 10.5 frameworks", "no")) vars.Add(BoolVariable("mac106", "Link against the 10.6 frameworks", "no")) if os.name == "nt" : - vars.Add(PathVariable("vcredist", "MSVC redistributable dir", None, PathVariable.PathAccept)) + vars.Add(PathVariable("vcredist", "MSVC redistributable path", None, PathVariable.PathAccept)) + vars.Add(PathVariable("vcredistdir", "MSVC redistributable dir", None, PathVariable.PathAccept)) if os.name == "nt" : vars.Add(PathVariable("wix_bindir", "Path to WiX binaries", "", PathVariable.PathAccept)) if os.name == "nt" : @@ -249,6 +250,9 @@ for flags_type in ["ccflags", "cxxflags", "linkflags"] : # where you need it env["OBJCCFLAGS"] = [] +if env["PLATFORM"] != "win32" : + env.AppendUnique(CCFLAGS=['-isystem', Dir('#').abspath + '/Backport/']) + # Compile code as C++11 if env["PLATFORM"] != "win32" : env.Append(CXXFLAGS = ["-std=c++11"]) @@ -363,7 +367,6 @@ else : "-Wno-direct-ivar-access", # Obj-C code warning "-Wno-potentially-evaluated-expression", # Caused due to calling shared_ptr::get() inside typeid() - "-Wno-inconsistent-missing-destructor-override", # FIXME: fix source code issues regarding this warning later "-Wno-shadow-field", # FIXME: fix source code issues regarding this warning later "-Wno-unused-template", # FIXME: fix source code issues regarding this warning later ]) diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct index 6d63d5b..70bffbc 100644 --- a/BuildTools/SCons/SConstruct +++ b/BuildTools/SCons/SConstruct @@ -554,6 +554,10 @@ conf.Finish() if env["qt"] : env["QTDIR"] = env["qt"] +if env["PLATFORM"] == "win32" : + systemIncludeFlag = "/I" +else: + systemIncludeFlag = "-isystem" ################################################################################ # TLS backend selection @@ -583,9 +587,9 @@ elif env.get("tls_backend") == "openssl" : openssl_include = env.get("openssl_include") openssl_libdir = env.get("openssl_libdir") if openssl_include: - openssl_flags = {"CPPPATH":[openssl_include]} + openssl_flags = { "CPPFLAGS": [systemIncludeFlag + openssl_include]} else: - openssl_flags = { "CPPPATH": [os.path.join(openssl_prefix, "include")] } + openssl_flags = { "CPPFLAGS": [systemIncludeFlag + os.path.join(openssl_prefix, "include")] } if openssl_libdir: openssl_flags["LIBPATH"] = [openssl_libdir] env["OPENSSL_DIR"] = openssl_prefix diff --git a/BuildTools/SCons/Tools/wix.py b/BuildTools/SCons/Tools/wix.py index 907b6d9..889afe4 100644 --- a/BuildTools/SCons/Tools/wix.py +++ b/BuildTools/SCons/Tools/wix.py @@ -38,7 +38,7 @@ def generate(env) : light_builder = SCons.Builder.Builder( - action = '"$WIX_LIGHT" $WIX_LIGHT_OPTIONS -b "$WIX_SOURCE_OBJECT_DIR" ${SOURCES} -o ${TARGET}', + action = '"$WIX_LIGHT" $WIX_LIGHT_OPTIONS -b "$WIX_SOURCE_OBJECT_DIR" ${SOURCES} -loc Swift\\Packaging\\WiX\\Swift_en-us.wxl -o ${TARGET}', src_suffix = '.wixobj', src_builder = candle_builder) @@ -48,4 +48,3 @@ def generate(env) : def exists(env) : return True - diff --git a/BuildTools/TranslationCoverage.xslt b/BuildTools/TranslationCoverage.xslt new file mode 100644 index 0000000..4329174 --- /dev/null +++ b/BuildTools/TranslationCoverage.xslt @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + +<!-- + +To use this XSLT, run it with xsltproc: + + xsltproc BuildTools/TranslationCoverage.xslt Swift/Translations/swift_nl.ts + +Supported parameters: + + full if set to 1 or true, generate a full report instead of the default oneliner. + +--> + +<xsl:param name="full" select="'0'" /> +<xsl:param name="filename" /> +<xsl:output method="text" /> + +<xsl:variable name="contexts" select="count(TS/context)"/> +<xsl:variable name="vanished" select="count(TS/context/message/translation[@type = 'vanished'])"/> +<xsl:variable name="obsolete" select="count(TS/context/message/translation[@type = 'obsolete'])"/> +<xsl:variable name="strings" select="count(TS/context/message/source) - $vanished - $obsolete"/> +<xsl:variable name="translations" select="count(TS/context/message/translation[not(@type) and text()])"/> +<xsl:variable name="missing" select="$strings - $translations"/> +<xsl:variable name="percent_done" select="floor($translations div $strings * 100)"/> + +<xsl:template match="/TS"> + <xsl:choose> + <xsl:when test="$full != '0' and $full != 'false'"><xsl:call-template name="full" /></xsl:when> + <xsl:otherwise><xsl:call-template name="terse" /></xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="terse"><xsl:value-of select="$percent_done"/>% complete, <xsl:value-of select="$vanished"/> vanished, <xsl:value-of select="$obsolete"/> obsolete, <xsl:value-of select="$missing"/> missing +</xsl:template> + +<xsl:template name="full"><xsl:if test="$filename">Report for <xsl:value-of select="$filename" />: + +</xsl:if>Contexts: <xsl:value-of select="$contexts"/> +Active Strings: <xsl:value-of select="$strings"/> +Translations: <xsl:value-of select="$translations"/>, <xsl:value-of select="$percent_done"/>% complete +Missing: <xsl:value-of select="$missing"/> +Vanished: <xsl:value-of select="$vanished"/> +Obsolete: <xsl:value-of select="$obsolete"/> + +Note: Strings and Translations do not include vanished or obsolete messages. +</xsl:template> + +</xsl:stylesheet> diff --git a/COPYING.thirdparty b/COPYING.thirdparty index 6a91f40..082e183 100644 --- a/COPYING.thirdparty +++ b/COPYING.thirdparty @@ -97,7 +97,7 @@ with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, +fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The @@ -264,6 +264,46 @@ SUCH DAMAGE. --- END OF SOLARIS getifaddrs() LICENSE +=========== +Google Test +=========== + +The checker application uses QA\Checker\CppUnitTestResultPrinter.cpp file +which incorporates PrettyUnitTestResultPrinter class from gtest.cc under the following license: + +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) +// +// The Google C++ Testing Framework (Google Test) + ========= Trolltech ========= diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 3e48510..5873300 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -46,10 +46,11 @@ The Windows package consist of a Widnows Installer (.msi) file. This is generate For packaging use: - Microsoft VS 2013 Express - WiX -- Download the C++ redistributable package from Microsoft and put it at `C:\Program Files (x86)\Common Files\Merge Modules\` +- Swift has a dependency on C++ redistributable package from Microsoft that needs to be deployed during install. If the common tools for Visual C++ is installed, then the installation file should be located under `C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\1033\` (for Visual Studio 2013). If not download from Microsoft and put it at `C:\Program Files (x86)\Common Files\Merge Modules\` - `config.py` should contain: qt = "c:\\qt\\5.4.2" - vcredist = "C:\\Program Files (x86)\\Common Files\\Merge Modules\\vcredist_x86.exe" + vcredist = "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\redist\\vcredist_x86.exe" + vcredistdir = "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\redist\\x86\Microsoft.VC120.CRT\\" debug = 1 optimize = 1 wix_bindir = "c:\\program files\\Windows Installer XML v3.5\\bin" diff --git a/QA/Checker/CppUnitTestResultPrinter.cpp b/QA/Checker/CppUnitTestResultPrinter.cpp new file mode 100644 index 0000000..75eea72 --- /dev/null +++ b/QA/Checker/CppUnitTestResultPrinter.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + + // Copyright 2005, Google Inc. + // All rights reserved. + // + // Redistribution and use in source and binary forms, with or without + // modification, are permitted provided that the following conditions are + // met: + // + // * Redistributions of source code must retain the above copyright + // notice, this list of conditions and the following disclaimer. + // * Redistributions in binary form must reproduce the above + // copyright notice, this list of conditions and the following disclaimer + // in the documentation and/or other materials provided with the + // distribution. + // * Neither the name of Google Inc. nor the names of its + // contributors may be used to endorse or promote products derived from + // this software without specific prior written permission. + // + // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + // + // Author: wan@google.com (Zhanyong Wan) + // + // The Google C++ Testing Framework (Google Test) + +#include <QA/Checker/CppUnitTestResultPrinter.h> + +namespace testing { + + namespace internal { + enum GTestColor { + COLOR_DEFAULT, + COLOR_RED, + COLOR_GREEN, + COLOR_YELLOW + }; + void ColoredPrintf(GTestColor color, const char* fmt, ...); + } + +using namespace internal; + +static std::string plural(const std::string msg1, const std::string msg2, int n) { + if (n == 1) { + return msg1; + } + return msg2; +} + +static std::string PrintTestPartResultToString(const TestPartResult& testPartResult) { + return (Message() << internal::FormatFileLocation(testPartResult.file_name(), testPartResult.line_number()) + << " " << (testPartResult.type() == TestPartResult::Type::kSuccess ? "Success" : "Failure") << std::endl << testPartResult.message()).GetString(); +} + +void CppUnitTestResultPrinter::OnTestIterationStart(const UnitTest& unitTest, int iteration) { + if (GTEST_FLAG(repeat) != 1) { + std::cout << std::endl << "Repeating all tests (iteration" << iteration + 1 << ") . . ." << std::endl << std::endl; + } + const char* const filter = GTEST_FLAG(filter).c_str(); + if (!String::CStringEquals(filter, "*")) { + ColoredPrintf(COLOR_YELLOW, "Note: %s filter = %s\n", GTEST_NAME_, filter); + } + if (GTEST_FLAG(shuffle)) { + ColoredPrintf(COLOR_YELLOW, "Note: Randomizing tests' orders with a seed of %d .\n", unitTest.random_seed()); + } + ColoredPrintf(COLOR_GREEN, "[==========] "); + std::cout << "Running " << unitTest.test_to_run_count() << " " << plural("test", "tests", unitTest.test_to_run_count()); + std::cout << " from " << unitTest.test_case_to_run_count() << " " << plural("test case", "test cases", unitTest.test_case_to_run_count()) << "." << std::endl; + std::cout.flush(); +} + +void CppUnitTestResultPrinter::OnTestPartResult(const TestPartResult& testPartResult) { + if (testPartResult.failed()) { + assertionsFailures_ << PrintTestPartResultToString(testPartResult) << std::endl; + } +} + +void CppUnitTestResultPrinter::OnTestEnd(const TestInfo& testInfo) { + if (testInfo.result()->Passed()) { + ColoredPrintf(COLOR_GREEN, "."); + } + else { + ColoredPrintf(COLOR_RED, "F"); + testFailures_ << std::endl << testInfo.name() << "." << testInfo.test_case_name() << std::endl << assertionsFailures_.rdbuf(); + assertionsFailures_.clear(); + } +} + +void CppUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unitTest, int) { + ColoredPrintf(COLOR_GREEN, "\n[==========] "); + std::cout << unitTest.test_to_run_count() << " " << plural("test", "tests", unitTest.test_to_run_count()) << " from " << unitTest.test_case_to_run_count() << " " << plural("test case", "test cases", unitTest.test_case_to_run_count()) << " ran. "; + if (GTEST_FLAG(print_time)) { + std::cout << "(" << StreamableToString(unitTest.elapsed_time()).c_str() << " ms total)"; + } + ColoredPrintf(COLOR_GREEN, "\n[ PASSED ] "); + std::cout << unitTest.successful_test_count() << " " << plural("test", "tests", unitTest.successful_test_count()) << "." << std::endl; + + int num_failures = unitTest.failed_test_count(); + if (!unitTest.Passed()) { + ColoredPrintf(COLOR_RED, "[ FAILED ] "); + std::cout << unitTest.failed_test_count() << " " << plural("test", "tests", unitTest.failed_test_count()) << ", listed below:" << std::endl; + PrintFailedTests(unitTest); + std::cout << std::endl << num_failures << " FAILED " << plural("TEST", "TESTS", num_failures) << std::endl; + } + int num_disabled = unitTest.reportable_disabled_test_count(); + if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) { + if (!num_failures) { + std::cout << std::endl; + } + std::cout << num_disabled << " " << plural("test", "tests", num_disabled) << " were disabled." << std::endl << std::endl; + } + std::cout << testFailures_.rdbuf(); + std::cout.flush(); +} + +// Internal helper for printing the list of failed tests. +void CppUnitTestResultPrinter::PrintFailedTests(const UnitTest& unitTest) { + if (unitTest.failed_test_count() == 0) { + return; + } + for (int i = 0; i < unitTest.total_test_case_count(); ++i) { + const TestCase& testCase = *unitTest.GetTestCase(i); + if (!testCase.should_run() || (testCase.failed_test_count() == 0)) { + continue; + } + for (int j = 0; j < testCase.total_test_count(); ++j) { + const TestInfo& testInfo = *testCase.GetTestInfo(j); + if (!testInfo.should_run() || testInfo.result()->Passed()) { + continue; + } + ColoredPrintf(COLOR_RED, "[ FAILED ] "); + std::cout << testCase.name() << "." << testInfo.name() << std::endl; + } + } +} + +} diff --git a/QA/Checker/CppUnitTestResultPrinter.h b/QA/Checker/CppUnitTestResultPrinter.h new file mode 100644 index 0000000..8e09243 --- /dev/null +++ b/QA/Checker/CppUnitTestResultPrinter.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + + // Copyright 2005, Google Inc. + // All rights reserved. + // + // Redistribution and use in source and binary forms, with or without + // modification, are permitted provided that the following conditions are + // met: + // + // * Redistributions of source code must retain the above copyright + // notice, this list of conditions and the following disclaimer. + // * Redistributions in binary form must reproduce the above + // copyright notice, this list of conditions and the following disclaimer + // in the documentation and/or other materials provided with the + // distribution. + // * Neither the name of Google Inc. nor the names of its + // contributors may be used to endorse or promote products derived from + // this software without specific prior written permission. + // + // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + // + // Author: wan@google.com (Zhanyong Wan) + // + // The Google C++ Testing Framework (Google Test) + +#pragma once + +#include <gtest/gtest.h> + +namespace testing { + + //CppUnitTestResultPrinter is based on PrettyUnitTestResultPrinter from the google test suite + class CppUnitTestResultPrinter : public ::testing::EmptyTestEventListener { + public: + virtual void OnTestIterationStart(const ::testing::UnitTest& unitTest, int iteration); + virtual void OnTestPartResult(const ::testing::TestPartResult& testPartResult); + virtual void OnTestEnd(const ::testing::TestInfo& test_info); + virtual void OnTestIterationEnd(const ::testing::UnitTest& unitTest, int); + private: + static void PrintFailedTests(const ::testing::UnitTest& unitTest); + std::stringstream assertionsFailures_; + std::stringstream testFailures_; + }; +} diff --git a/QA/Checker/SConscript b/QA/Checker/SConscript index a41a5f9..70458f0 100644 --- a/QA/Checker/SConscript +++ b/QA/Checker/SConscript @@ -21,4 +21,4 @@ if env["TEST"] : checker_env.UseFlags(env["BOOST_FLAGS"]) checker_env.UseFlags(env["CPPUNIT_FLAGS"]) checker_env.UseFlags(env["GOOGLETEST_FLAGS"]) - checker_env.Library("Checker", ["checker.cpp", "IO.cpp"]) + checker_env.Library("Checker", ["checker.cpp", "IO.cpp", "CppUnitTestResultPrinter.cpp"]) diff --git a/QA/Checker/checker.cpp b/QA/Checker/checker.cpp index bcf0f5c..3cc7713 100644 --- a/QA/Checker/checker.cpp +++ b/QA/Checker/checker.cpp @@ -10,6 +10,7 @@ #include <sstream> #include <gtest/gtest.h> +#include <QA/Checker/CppUnitTestResultPrinter.h> #include <cppunit/BriefTestProgressListener.h> #include <cppunit/TextOutputter.h> @@ -126,6 +127,12 @@ int main(int argc, char* argv[]) { auto googleTestWasSuccessful = false; try { + if (!verbose) { + testing::UnitTest& unitTest = *testing::UnitTest::GetInstance(); + testing::TestEventListeners& listeners = unitTest.listeners(); + delete listeners.Release(listeners.default_result_printer()); + listeners.Append(new testing::CppUnitTestResultPrinter); + } googleTestWasSuccessful = RUN_ALL_TESTS() == 0 ? true : false; } catch (const ::testing::internal::GoogleTestFailureException& e) { googleTestWasSuccessful = false; diff --git a/Sluift/Console.h b/Sluift/Console.h index 6ed6f58..0d5ceb0 100644 --- a/Sluift/Console.h +++ b/Sluift/Console.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,8 +10,6 @@ #include <boost/optional/optional.hpp> -#include <Swiften/Base/Override.h> - #include <Sluift/Completer.h> struct lua_State; @@ -22,7 +20,7 @@ namespace Swift { class Console : public Completer { public: Console(lua_State* L, Terminal* terminal); - virtual ~Console(); + virtual ~Console() override; void run(); @@ -34,7 +32,7 @@ namespace Swift { bool readCommand(); int tryLoadCommand(const std::string& command); - virtual std::vector<std::string> getCompletions(const std::string&, int start, int end) SWIFTEN_OVERRIDE; + virtual std::vector<std::string> getCompletions(const std::string&, int start, int end) override; private: lua_State* L; diff --git a/Sluift/EditlineTerminal.h b/Sluift/EditlineTerminal.h index ec4cf63..8f4624b 100644 --- a/Sluift/EditlineTerminal.h +++ b/Sluift/EditlineTerminal.h @@ -1,13 +1,11 @@ /* - * 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 <Sluift/Terminal.h> namespace Swift { @@ -17,10 +15,10 @@ namespace Swift { private: EditlineTerminal(); - virtual ~EditlineTerminal(); + virtual ~EditlineTerminal() override; - virtual boost::optional<std::string> readLine(const std::string& prompt) SWIFTEN_OVERRIDE; - virtual void printError(const std::string& message) SWIFTEN_OVERRIDE; - virtual void addToHistory(const std::string& command) SWIFTEN_OVERRIDE; + virtual boost::optional<std::string> readLine(const std::string& prompt) override; + virtual void printError(const std::string& message) override; + virtual void addToHistory(const std::string& command) override; }; } diff --git a/Sluift/ElementConvertors/BodyConvertor.h b/Sluift/ElementConvertors/BodyConvertor.h index 64ff4d0..574fca9 100644 --- a/Sluift/ElementConvertors/BodyConvertor.h +++ b/Sluift/ElementConvertors/BodyConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/Body.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,9 +16,9 @@ namespace Swift { class BodyConvertor : public GenericLuaElementConvertor<Body> { public: BodyConvertor(); - virtual ~BodyConvertor(); + virtual ~BodyConvertor() override; - virtual std::shared_ptr<Body> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<Body>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Body> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<Body>) override; }; } diff --git a/Sluift/ElementConvertors/CarbonsReceivedConvertor.h b/Sluift/ElementConvertors/CarbonsReceivedConvertor.h index f18f699..cc4e6dc 100644 --- a/Sluift/ElementConvertors/CarbonsReceivedConvertor.h +++ b/Sluift/ElementConvertors/CarbonsReceivedConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/CarbonsReceived.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class CarbonsReceivedConvertor : public GenericLuaElementConvertor<CarbonsReceived> { public: CarbonsReceivedConvertor(LuaElementConvertors* convertors); - virtual ~CarbonsReceivedConvertor(); + virtual ~CarbonsReceivedConvertor() override; - virtual std::shared_ptr<CarbonsReceived> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<CarbonsReceived>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<CarbonsReceived> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<CarbonsReceived>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/CarbonsSentConvertor.h b/Sluift/ElementConvertors/CarbonsSentConvertor.h index a36a6a8..794e0ed 100644 --- a/Sluift/ElementConvertors/CarbonsSentConvertor.h +++ b/Sluift/ElementConvertors/CarbonsSentConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/CarbonsSent.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class CarbonsSentConvertor : public GenericLuaElementConvertor<CarbonsSent> { public: CarbonsSentConvertor(LuaElementConvertors* convertors); - virtual ~CarbonsSentConvertor(); + virtual ~CarbonsSentConvertor() override; - virtual std::shared_ptr<CarbonsSent> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<CarbonsSent>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<CarbonsSent> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<CarbonsSent>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/CommandConvertor.h b/Sluift/ElementConvertors/CommandConvertor.h index 1b0d481..274eaa6 100644 --- a/Sluift/ElementConvertors/CommandConvertor.h +++ b/Sluift/ElementConvertors/CommandConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/Command.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class CommandConvertor : public GenericLuaElementConvertor<Command> { public: CommandConvertor(LuaElementConvertors* convertors); - virtual ~CommandConvertor(); + virtual ~CommandConvertor() override; - virtual std::shared_ptr<Command> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<Command>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Command> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<Command>) override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/DOMElementConvertor.cpp b/Sluift/ElementConvertors/DOMElementConvertor.cpp index b957686..56b45aa 100644 --- a/Sluift/ElementConvertors/DOMElementConvertor.cpp +++ b/Sluift/ElementConvertors/DOMElementConvertor.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. */ @@ -34,7 +34,7 @@ namespace { virtual void handleStartElement( const std::string& element, const std::string& ns, - const AttributeMap& attributes) SWIFTEN_OVERRIDE { + const AttributeMap& attributes) override { lua_checkstack(L, 6); lua_pushnumber(L, currentIndex); lua_newtable(L); @@ -70,7 +70,7 @@ namespace { } virtual void handleEndElement( - const std::string&, const std::string&) SWIFTEN_OVERRIDE { + const std::string&, const std::string&) override { lua_setfield(L, -2, "children"); lua_settable(L, -3); currentIndex = indexStack.back(); @@ -78,7 +78,7 @@ namespace { currentIndex++; } - virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE { + virtual void handleCharacterData(const std::string& data) override { lua_checkstack(L, 2); lua_pushnumber(L, currentIndex); lua_pushstring(L, data.c_str()); diff --git a/Sluift/ElementConvertors/DOMElementConvertor.h b/Sluift/ElementConvertors/DOMElementConvertor.h index 7b1ba58..dd8d79b 100644 --- a/Sluift/ElementConvertors/DOMElementConvertor.h +++ b/Sluift/ElementConvertors/DOMElementConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Parser/PlatformXMLParserFactory.h> #include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> @@ -16,10 +15,10 @@ namespace Swift { class DOMElementConvertor : public LuaElementConvertor { public: DOMElementConvertor(); - virtual ~DOMElementConvertor(); + virtual ~DOMElementConvertor() override; - virtual std::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) SWIFTEN_OVERRIDE; - virtual boost::optional<std::string> convertToLua(lua_State*, std::shared_ptr<Element>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) override; + virtual boost::optional<std::string> convertToLua(lua_State*, std::shared_ptr<Element>) override; private: PlatformXMLParserFactory parsers; diff --git a/Sluift/ElementConvertors/DefaultElementConvertor.h b/Sluift/ElementConvertors/DefaultElementConvertor.h index 4aec300..dfef3e8 100644 --- a/Sluift/ElementConvertors/DefaultElementConvertor.h +++ b/Sluift/ElementConvertors/DefaultElementConvertor.h @@ -1,22 +1,20 @@ /* - * 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 <Sluift/LuaElementConvertor.h> namespace Swift { class DefaultElementConvertor : public LuaElementConvertor { public: DefaultElementConvertor(); - virtual ~DefaultElementConvertor(); + virtual ~DefaultElementConvertor() override; - virtual std::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) SWIFTEN_OVERRIDE; - virtual boost::optional<std::string> convertToLua(lua_State*, std::shared_ptr<Element>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) override; + virtual boost::optional<std::string> convertToLua(lua_State*, std::shared_ptr<Element>) override; }; } diff --git a/Sluift/ElementConvertors/DelayConvertor.h b/Sluift/ElementConvertors/DelayConvertor.h index b9f72f2..ad340da 100644 --- a/Sluift/ElementConvertors/DelayConvertor.h +++ b/Sluift/ElementConvertors/DelayConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Delay.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -15,9 +14,9 @@ namespace Swift { class DelayConvertor : public GenericLuaElementConvertor<Delay> { public: DelayConvertor(); - virtual ~DelayConvertor(); + virtual ~DelayConvertor() override; - virtual std::shared_ptr<Delay> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<Delay>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Delay> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<Delay>) override; }; } diff --git a/Sluift/ElementConvertors/DiscoInfoConvertor.h b/Sluift/ElementConvertors/DiscoInfoConvertor.h index c1b2910..b0e0849 100644 --- a/Sluift/ElementConvertors/DiscoInfoConvertor.h +++ b/Sluift/ElementConvertors/DiscoInfoConvertor.h @@ -6,7 +6,6 @@ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/DiscoInfo.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class DiscoInfoConvertor : public GenericLuaElementConvertor<DiscoInfo> { public: DiscoInfoConvertor(LuaElementConvertors* convertors); - virtual ~DiscoInfoConvertor(); + virtual ~DiscoInfoConvertor() override; - virtual std::shared_ptr<DiscoInfo> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<DiscoInfo>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<DiscoInfo> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<DiscoInfo>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/DiscoItemsConvertor.h b/Sluift/ElementConvertors/DiscoItemsConvertor.h index a77b948..98dcb5c 100644 --- a/Sluift/ElementConvertors/DiscoItemsConvertor.h +++ b/Sluift/ElementConvertors/DiscoItemsConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/DiscoItems.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -15,9 +14,9 @@ namespace Swift { class DiscoItemsConvertor : public GenericLuaElementConvertor<DiscoItems> { public: DiscoItemsConvertor(); - virtual ~DiscoItemsConvertor(); + virtual ~DiscoItemsConvertor() override; - virtual std::shared_ptr<DiscoItems> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<DiscoItems>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<DiscoItems> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<DiscoItems>) override; }; } diff --git a/Sluift/ElementConvertors/FormConvertor.cpp b/Sluift/ElementConvertors/FormConvertor.cpp index 90fd9fe..245e0f9 100644 --- a/Sluift/ElementConvertors/FormConvertor.cpp +++ b/Sluift/ElementConvertors/FormConvertor.cpp @@ -29,7 +29,7 @@ namespace { lua_pushnil(L); for (lua_pushnil(L); lua_next(L, index) != 0; ) { lua_getfield(L, -1, "name"); - if (lua_equal(L, -1, 2)) { + if (lua_compare(L, -1, 2, LUA_OPEQ)) { lua_pop(L, 1); return 1; } @@ -44,7 +44,7 @@ namespace { if (lua_type(L, -1) == LUA_TTABLE) { for (lua_pushnil(L); lua_next(L, -2) != 0; ) { lua_getfield(L, -1, "name"); - if (lua_equal(L, -1, 2)) { + if (lua_compare(L, -1, 2, LUA_OPEQ)) { lua_pushvalue(L, 3); lua_setfield(L, -3, "value"); foundField = true; diff --git a/Sluift/ElementConvertors/FormConvertor.h b/Sluift/ElementConvertors/FormConvertor.h index b32a940..8ca20cc 100644 --- a/Sluift/ElementConvertors/FormConvertor.h +++ b/Sluift/ElementConvertors/FormConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/Form.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -15,9 +14,9 @@ namespace Swift { class FormConvertor : public GenericLuaElementConvertor<Form> { public: FormConvertor(); - virtual ~FormConvertor(); + virtual ~FormConvertor() override; - virtual std::shared_ptr<Form> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<Form>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Form> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<Form>) override; }; } diff --git a/Sluift/ElementConvertors/ForwardedConvertor.h b/Sluift/ElementConvertors/ForwardedConvertor.h index a83b5f4..32d29e6 100644 --- a/Sluift/ElementConvertors/ForwardedConvertor.h +++ b/Sluift/ElementConvertors/ForwardedConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Forwarded.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,14 +16,13 @@ namespace Swift { class ForwardedConvertor : public GenericLuaElementConvertor<Forwarded> { public: ForwardedConvertor(LuaElementConvertors* convertors); - virtual ~ForwardedConvertor(); + virtual ~ForwardedConvertor() override; - virtual std::shared_ptr<Forwarded> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<Forwarded>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Forwarded> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<Forwarded>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: - private: LuaElementConvertors* convertors; }; } diff --git a/Sluift/ElementConvertors/IQConvertor.h b/Sluift/ElementConvertors/IQConvertor.h index 859900a..6ccaa46 100644 --- a/Sluift/ElementConvertors/IQConvertor.h +++ b/Sluift/ElementConvertors/IQConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/IQ.h> #include <Sluift/ElementConvertors/StanzaConvertor.h> @@ -17,12 +16,12 @@ namespace Swift { class IQConvertor : public StanzaConvertor<IQ> { public: IQConvertor(LuaElementConvertors* convertors); - virtual ~IQConvertor(); + virtual ~IQConvertor() override; - virtual std::shared_ptr<IQ> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<IQ>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<IQ> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<IQ>) override; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual boost::optional<Documentation> getDocumentation() const override; static std::string convertIQTypeToString(IQ::Type type); static IQ::Type convertIQTypeFromString(const std::string& type); diff --git a/Sluift/ElementConvertors/IsodeIQDelegationConvertor.h b/Sluift/ElementConvertors/IsodeIQDelegationConvertor.h index f8b8c4a..f573b13 100644 --- a/Sluift/ElementConvertors/IsodeIQDelegationConvertor.h +++ b/Sluift/ElementConvertors/IsodeIQDelegationConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/IsodeIQDelegation.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class IsodeIQDelegationConvertor : public GenericLuaElementConvertor<IsodeIQDelegation> { public: IsodeIQDelegationConvertor(LuaElementConvertors* convertors); - virtual ~IsodeIQDelegationConvertor(); + virtual ~IsodeIQDelegationConvertor() override; - virtual std::shared_ptr<IsodeIQDelegation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<IsodeIQDelegation>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<IsodeIQDelegation> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<IsodeIQDelegation>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/MAMFinConvertor.h b/Sluift/ElementConvertors/MAMFinConvertor.h index 371076a..6e5d58c 100644 --- a/Sluift/ElementConvertors/MAMFinConvertor.h +++ b/Sluift/ElementConvertors/MAMFinConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MAMFin.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class MAMFinConvertor : public GenericLuaElementConvertor<MAMFin> { public: MAMFinConvertor(LuaElementConvertors* convertors); - virtual ~MAMFinConvertor(); + virtual ~MAMFinConvertor() override; - virtual std::shared_ptr<MAMFin> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<MAMFin>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<MAMFin> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<MAMFin>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/MAMQueryConvertor.h b/Sluift/ElementConvertors/MAMQueryConvertor.h index 4ee119e..3e9d387 100644 --- a/Sluift/ElementConvertors/MAMQueryConvertor.h +++ b/Sluift/ElementConvertors/MAMQueryConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MAMQuery.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class MAMQueryConvertor : public GenericLuaElementConvertor<MAMQuery> { public: MAMQueryConvertor(LuaElementConvertors* convertors); - virtual ~MAMQueryConvertor(); + virtual ~MAMQueryConvertor() override; - virtual std::shared_ptr<MAMQuery> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<MAMQuery>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<MAMQuery> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<MAMQuery>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/MAMResultConvertor.h b/Sluift/ElementConvertors/MAMResultConvertor.h index a1b2564..cd1d27d 100644 --- a/Sluift/ElementConvertors/MAMResultConvertor.h +++ b/Sluift/ElementConvertors/MAMResultConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/MAMResult.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class MAMResultConvertor : public GenericLuaElementConvertor<MAMResult> { public: MAMResultConvertor(LuaElementConvertors* convertors); - virtual ~MAMResultConvertor(); + virtual ~MAMResultConvertor() override; - virtual std::shared_ptr<MAMResult> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<MAMResult>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<MAMResult> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<MAMResult>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/MessageConvertor.h b/Sluift/ElementConvertors/MessageConvertor.h index 2031552..723e1b1 100644 --- a/Sluift/ElementConvertors/MessageConvertor.h +++ b/Sluift/ElementConvertors/MessageConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Message.h> #include <Sluift/ElementConvertors/StanzaConvertor.h> @@ -17,12 +16,12 @@ namespace Swift { class MessageConvertor : public StanzaConvertor<Message> { public: MessageConvertor(LuaElementConvertors* convertors); - virtual ~MessageConvertor(); + virtual ~MessageConvertor() override; - virtual std::shared_ptr<Message> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<Message>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Message> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<Message>) override; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual boost::optional<Documentation> getDocumentation() const override; static std::string convertMessageTypeToString(Message::Type type); static Message::Type convertMessageTypeFromString(const std::string& type); diff --git a/Sluift/ElementConvertors/PresenceConvertor.h b/Sluift/ElementConvertors/PresenceConvertor.h index 11ec547..b13398d 100644 --- a/Sluift/ElementConvertors/PresenceConvertor.h +++ b/Sluift/ElementConvertors/PresenceConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Presence.h> #include <Sluift/ElementConvertors/StanzaConvertor.h> @@ -17,12 +16,12 @@ namespace Swift { class PresenceConvertor : public StanzaConvertor<Presence> { public: PresenceConvertor(LuaElementConvertors* convertors); - virtual ~PresenceConvertor(); + virtual ~PresenceConvertor() override; - virtual std::shared_ptr<Presence> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<Presence>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Presence> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<Presence>) override; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual boost::optional<Documentation> getDocumentation() const override; static std::string convertPresenceTypeToString(Presence::Type type); static Presence::Type convertPresenceTypeFromString(const std::string& type); diff --git a/Sluift/ElementConvertors/PubSubAffiliationConvertor.h b/Sluift/ElementConvertors/PubSubAffiliationConvertor.h index 456ef4e..1b5cd60 100644 --- a/Sluift/ElementConvertors/PubSubAffiliationConvertor.h +++ b/Sluift/ElementConvertors/PubSubAffiliationConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubAffiliation.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubAffiliationConvertor : public GenericLuaElementConvertor<PubSubAffiliation> { public: PubSubAffiliationConvertor(); - virtual ~PubSubAffiliationConvertor(); + virtual ~PubSubAffiliationConvertor() override; - virtual std::shared_ptr<PubSubAffiliation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubAffiliation>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubAffiliation> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubAffiliation>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp index c6ba09e..8f8a660 100644 --- a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp @@ -33,7 +33,7 @@ std::shared_ptr<PubSubAffiliations> PubSubAffiliationsConvertor::doConvertFromLu lua_pop(L, 1); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<PubSubAffiliation> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.h b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.h index 8ad38b2..eda218b 100644 --- a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.h +++ b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubAffiliations.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubAffiliationsConvertor : public GenericLuaElementConvertor<PubSubAffiliations> { public: PubSubAffiliationsConvertor(LuaElementConvertors* convertors); - virtual ~PubSubAffiliationsConvertor(); + virtual ~PubSubAffiliationsConvertor() override; - virtual std::shared_ptr<PubSubAffiliations> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubAffiliations>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubAffiliations> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubAffiliations>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubConfigureConvertor.h b/Sluift/ElementConvertors/PubSubConfigureConvertor.h index e41bb68..f1848c2 100644 --- a/Sluift/ElementConvertors/PubSubConfigureConvertor.h +++ b/Sluift/ElementConvertors/PubSubConfigureConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubConfigure.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubConfigureConvertor : public GenericLuaElementConvertor<PubSubConfigure> { public: PubSubConfigureConvertor(LuaElementConvertors* convertors); - virtual ~PubSubConfigureConvertor(); + virtual ~PubSubConfigureConvertor() override; - virtual std::shared_ptr<PubSubConfigure> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubConfigure>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubConfigure> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubConfigure>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubCreateConvertor.h b/Sluift/ElementConvertors/PubSubCreateConvertor.h index 12c47da..f3b11bd 100644 --- a/Sluift/ElementConvertors/PubSubCreateConvertor.h +++ b/Sluift/ElementConvertors/PubSubCreateConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubCreate.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubCreateConvertor : public GenericLuaElementConvertor<PubSubCreate> { public: PubSubCreateConvertor(LuaElementConvertors* convertors); - virtual ~PubSubCreateConvertor(); + virtual ~PubSubCreateConvertor() override; - virtual std::shared_ptr<PubSubCreate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubCreate>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubCreate> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubCreate>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubDefaultConvertor.h b/Sluift/ElementConvertors/PubSubDefaultConvertor.h index fbdbf95..1049cd4 100644 --- a/Sluift/ElementConvertors/PubSubDefaultConvertor.h +++ b/Sluift/ElementConvertors/PubSubDefaultConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubDefault.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubDefaultConvertor : public GenericLuaElementConvertor<PubSubDefault> { public: PubSubDefaultConvertor(); - virtual ~PubSubDefaultConvertor(); + virtual ~PubSubDefaultConvertor() override; - virtual std::shared_ptr<PubSubDefault> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubDefault>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubDefault> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubDefault>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubEventAssociateConvertor.h b/Sluift/ElementConvertors/PubSubEventAssociateConvertor.h index 975aa60..e84460f 100644 --- a/Sluift/ElementConvertors/PubSubEventAssociateConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventAssociateConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventAssociate.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubEventAssociateConvertor : public GenericLuaElementConvertor<PubSubEventAssociate> { public: PubSubEventAssociateConvertor(); - virtual ~PubSubEventAssociateConvertor(); + virtual ~PubSubEventAssociateConvertor() override; - virtual std::shared_ptr<PubSubEventAssociate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventAssociate>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventAssociate> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventAssociate>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubEventCollectionConvertor.h b/Sluift/ElementConvertors/PubSubEventCollectionConvertor.h index e8feada..cab3b97 100644 --- a/Sluift/ElementConvertors/PubSubEventCollectionConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventCollectionConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventCollection.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubEventCollectionConvertor : public GenericLuaElementConvertor<PubSubEventCollection> { public: PubSubEventCollectionConvertor(LuaElementConvertors* convertors); - virtual ~PubSubEventCollectionConvertor(); + virtual ~PubSubEventCollectionConvertor() override; - virtual std::shared_ptr<PubSubEventCollection> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventCollection>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventCollection> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventCollection>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h b/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h index dd327d4..c2d82a5 100644 --- a/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventConfiguration.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubEventConfigurationConvertor : public GenericLuaElementConvertor<PubSubEventConfiguration> { public: PubSubEventConfigurationConvertor(LuaElementConvertors* convertors); - virtual ~PubSubEventConfigurationConvertor(); + virtual ~PubSubEventConfigurationConvertor() override; - virtual std::shared_ptr<PubSubEventConfiguration> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventConfiguration>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventConfiguration> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventConfiguration>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubEventConvertor.h b/Sluift/ElementConvertors/PubSubEventConvertor.h index 8b0cbec..b116c68 100644 --- a/Sluift/ElementConvertors/PubSubEventConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEvent.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubEventConvertor : public GenericLuaElementConvertor<PubSubEvent> { public: PubSubEventConvertor(LuaElementConvertors* convertors); - virtual ~PubSubEventConvertor(); + virtual ~PubSubEventConvertor() override; - virtual std::shared_ptr<PubSubEvent> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEvent>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEvent> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEvent>) override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubEventDeleteConvertor.h b/Sluift/ElementConvertors/PubSubEventDeleteConvertor.h index ba2b0b8..66c706f 100644 --- a/Sluift/ElementConvertors/PubSubEventDeleteConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventDeleteConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventDelete.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubEventDeleteConvertor : public GenericLuaElementConvertor<PubSubEventDelete> { public: PubSubEventDeleteConvertor(LuaElementConvertors* convertors); - virtual ~PubSubEventDeleteConvertor(); + virtual ~PubSubEventDeleteConvertor() override; - virtual std::shared_ptr<PubSubEventDelete> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventDelete>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventDelete> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventDelete>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h b/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h index 0a1d678..17f9ae9 100644 --- a/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventDisassociate.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubEventDisassociateConvertor : public GenericLuaElementConvertor<PubSubEventDisassociate> { public: PubSubEventDisassociateConvertor(); - virtual ~PubSubEventDisassociateConvertor(); + virtual ~PubSubEventDisassociateConvertor() override; - virtual std::shared_ptr<PubSubEventDisassociate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventDisassociate>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventDisassociate> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventDisassociate>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp b/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp index ac86024..19ab09a 100644 --- a/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp @@ -39,7 +39,7 @@ std::shared_ptr<PubSubEventItem> PubSubEventItemConvertor::doConvertFromLua(lua_ lua_getfield(L, -1, "data"); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<Payload> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubEventItemConvertor.h b/Sluift/ElementConvertors/PubSubEventItemConvertor.h index 6239b14..9e29ce8 100644 --- a/Sluift/ElementConvertors/PubSubEventItemConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventItemConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventItem.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubEventItemConvertor : public GenericLuaElementConvertor<PubSubEventItem> { public: PubSubEventItemConvertor(LuaElementConvertors* convertors); - virtual ~PubSubEventItemConvertor(); + virtual ~PubSubEventItemConvertor() override; - virtual std::shared_ptr<PubSubEventItem> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventItem>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventItem> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventItem>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp b/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp index 7a3cde1..66f798e 100644 --- a/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp @@ -34,7 +34,7 @@ std::shared_ptr<PubSubEventItems> PubSubEventItemsConvertor::doConvertFromLua(lu lua_getfield(L, -1, "items"); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<PubSubEventItem> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { @@ -51,7 +51,7 @@ std::shared_ptr<PubSubEventItems> PubSubEventItemsConvertor::doConvertFromLua(lu lua_getfield(L, -1, "retracts"); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<PubSubEventRetract> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubEventItemsConvertor.h b/Sluift/ElementConvertors/PubSubEventItemsConvertor.h index ea8942b..8f7e3fe 100644 --- a/Sluift/ElementConvertors/PubSubEventItemsConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventItemsConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventItems.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubEventItemsConvertor : public GenericLuaElementConvertor<PubSubEventItems> { public: PubSubEventItemsConvertor(LuaElementConvertors* convertors); - virtual ~PubSubEventItemsConvertor(); + virtual ~PubSubEventItemsConvertor() override; - virtual std::shared_ptr<PubSubEventItems> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventItems>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventItems> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventItems>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubEventPurgeConvertor.h b/Sluift/ElementConvertors/PubSubEventPurgeConvertor.h index e3321b1..1c2cdbb 100644 --- a/Sluift/ElementConvertors/PubSubEventPurgeConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventPurgeConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventPurge.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubEventPurgeConvertor : public GenericLuaElementConvertor<PubSubEventPurge> { public: PubSubEventPurgeConvertor(); - virtual ~PubSubEventPurgeConvertor(); + virtual ~PubSubEventPurgeConvertor() override; - virtual std::shared_ptr<PubSubEventPurge> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventPurge>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventPurge> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventPurge>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubEventRedirectConvertor.h b/Sluift/ElementConvertors/PubSubEventRedirectConvertor.h index b1f33d2..a61cb79 100644 --- a/Sluift/ElementConvertors/PubSubEventRedirectConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventRedirectConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventRedirect.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubEventRedirectConvertor : public GenericLuaElementConvertor<PubSubEventRedirect> { public: PubSubEventRedirectConvertor(); - virtual ~PubSubEventRedirectConvertor(); + virtual ~PubSubEventRedirectConvertor() override; - virtual std::shared_ptr<PubSubEventRedirect> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventRedirect>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventRedirect> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventRedirect>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubEventRetractConvertor.h b/Sluift/ElementConvertors/PubSubEventRetractConvertor.h index 65aac36..f437ad5 100644 --- a/Sluift/ElementConvertors/PubSubEventRetractConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventRetractConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventRetract.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubEventRetractConvertor : public GenericLuaElementConvertor<PubSubEventRetract> { public: PubSubEventRetractConvertor(); - virtual ~PubSubEventRetractConvertor(); + virtual ~PubSubEventRetractConvertor() override; - virtual std::shared_ptr<PubSubEventRetract> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventRetract>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventRetract> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventRetract>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h b/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h index 0b3181b..61d1f21 100644 --- a/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h +++ b/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubEventSubscription.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubEventSubscriptionConvertor : public GenericLuaElementConvertor<PubSubEventSubscription> { public: PubSubEventSubscriptionConvertor(); - virtual ~PubSubEventSubscriptionConvertor(); + virtual ~PubSubEventSubscriptionConvertor() override; - virtual std::shared_ptr<PubSubEventSubscription> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventSubscription>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubEventSubscription> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventSubscription>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubItemConvertor.cpp b/Sluift/ElementConvertors/PubSubItemConvertor.cpp index 27fd4a3..b46419a 100644 --- a/Sluift/ElementConvertors/PubSubItemConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubItemConvertor.cpp @@ -29,7 +29,7 @@ std::shared_ptr<PubSubItem> PubSubItemConvertor::doConvertFromLua(lua_State* L) lua_getfield(L, -1, "data"); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<Payload> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubItemConvertor.h b/Sluift/ElementConvertors/PubSubItemConvertor.h index 2772932..87c3809 100644 --- a/Sluift/ElementConvertors/PubSubItemConvertor.h +++ b/Sluift/ElementConvertors/PubSubItemConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubItem.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubItemConvertor : public GenericLuaElementConvertor<PubSubItem> { public: PubSubItemConvertor(LuaElementConvertors* convertors); - virtual ~PubSubItemConvertor(); + virtual ~PubSubItemConvertor() override; - virtual std::shared_ptr<PubSubItem> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubItem>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubItem> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubItem>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubItemsConvertor.cpp b/Sluift/ElementConvertors/PubSubItemsConvertor.cpp index 5fa1bd3..0bb8eb9 100644 --- a/Sluift/ElementConvertors/PubSubItemsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubItemsConvertor.cpp @@ -33,7 +33,7 @@ std::shared_ptr<PubSubItems> PubSubItemsConvertor::doConvertFromLua(lua_State* L lua_pop(L, 1); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<PubSubItem> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubItemsConvertor.h b/Sluift/ElementConvertors/PubSubItemsConvertor.h index 56348b0..9e0f73a 100644 --- a/Sluift/ElementConvertors/PubSubItemsConvertor.h +++ b/Sluift/ElementConvertors/PubSubItemsConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubItems.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubItemsConvertor : public GenericLuaElementConvertor<PubSubItems> { public: PubSubItemsConvertor(LuaElementConvertors* convertors); - virtual ~PubSubItemsConvertor(); + virtual ~PubSubItemsConvertor() override; - virtual std::shared_ptr<PubSubItems> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubItems>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubItems> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubItems>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubOptionsConvertor.h b/Sluift/ElementConvertors/PubSubOptionsConvertor.h index 60d11cc..add661a 100644 --- a/Sluift/ElementConvertors/PubSubOptionsConvertor.h +++ b/Sluift/ElementConvertors/PubSubOptionsConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOptions.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubOptionsConvertor : public GenericLuaElementConvertor<PubSubOptions> { public: PubSubOptionsConvertor(LuaElementConvertors* convertors); - virtual ~PubSubOptionsConvertor(); + virtual ~PubSubOptionsConvertor() override; - virtual std::shared_ptr<PubSubOptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOptions>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOptions> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOptions>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h b/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h index 9020482..92b001b 100644 --- a/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h +++ b/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOwnerAffiliation.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubOwnerAffiliationConvertor : public GenericLuaElementConvertor<PubSubOwnerAffiliation> { public: PubSubOwnerAffiliationConvertor(); - virtual ~PubSubOwnerAffiliationConvertor(); + virtual ~PubSubOwnerAffiliationConvertor() override; - virtual std::shared_ptr<PubSubOwnerAffiliation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerAffiliation>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOwnerAffiliation> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerAffiliation>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp index ee8a8cb..9ca76fc 100644 --- a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp @@ -33,7 +33,7 @@ std::shared_ptr<PubSubOwnerAffiliations> PubSubOwnerAffiliationsConvertor::doCon lua_pop(L, 1); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<PubSubOwnerAffiliation> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h index 3026e2c..f0c45a3 100644 --- a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h +++ b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOwnerAffiliations.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubOwnerAffiliationsConvertor : public GenericLuaElementConvertor<PubSubOwnerAffiliations> { public: PubSubOwnerAffiliationsConvertor(LuaElementConvertors* convertors); - virtual ~PubSubOwnerAffiliationsConvertor(); + virtual ~PubSubOwnerAffiliationsConvertor() override; - virtual std::shared_ptr<PubSubOwnerAffiliations> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerAffiliations>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOwnerAffiliations> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerAffiliations>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h b/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h index 4b39fdf..9f0ed9f 100644 --- a/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h +++ b/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOwnerConfigure.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubOwnerConfigureConvertor : public GenericLuaElementConvertor<PubSubOwnerConfigure> { public: PubSubOwnerConfigureConvertor(LuaElementConvertors* convertors); - virtual ~PubSubOwnerConfigureConvertor(); + virtual ~PubSubOwnerConfigureConvertor() override; - virtual std::shared_ptr<PubSubOwnerConfigure> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerConfigure>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOwnerConfigure> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerConfigure>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h b/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h index ae0f018..ab4a25b 100644 --- a/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h +++ b/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOwnerDefault.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubOwnerDefaultConvertor : public GenericLuaElementConvertor<PubSubOwnerDefault> { public: PubSubOwnerDefaultConvertor(LuaElementConvertors* convertors); - virtual ~PubSubOwnerDefaultConvertor(); + virtual ~PubSubOwnerDefaultConvertor() override; - virtual std::shared_ptr<PubSubOwnerDefault> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerDefault>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOwnerDefault> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerDefault>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h b/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h index 54a2cf9..8c44b5c 100644 --- a/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h +++ b/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOwnerDelete.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubOwnerDeleteConvertor : public GenericLuaElementConvertor<PubSubOwnerDelete> { public: PubSubOwnerDeleteConvertor(LuaElementConvertors* convertors); - virtual ~PubSubOwnerDeleteConvertor(); + virtual ~PubSubOwnerDeleteConvertor() override; - virtual std::shared_ptr<PubSubOwnerDelete> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerDelete>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOwnerDelete> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerDelete>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h b/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h index 4696f45..b2cb565 100644 --- a/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h +++ b/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOwnerPurge.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubOwnerPurgeConvertor : public GenericLuaElementConvertor<PubSubOwnerPurge> { public: PubSubOwnerPurgeConvertor(); - virtual ~PubSubOwnerPurgeConvertor(); + virtual ~PubSubOwnerPurgeConvertor() override; - virtual std::shared_ptr<PubSubOwnerPurge> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerPurge>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOwnerPurge> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerPurge>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h b/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h index 3517a49..433303f 100644 --- a/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h +++ b/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOwnerRedirect.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubOwnerRedirectConvertor : public GenericLuaElementConvertor<PubSubOwnerRedirect> { public: PubSubOwnerRedirectConvertor(); - virtual ~PubSubOwnerRedirectConvertor(); + virtual ~PubSubOwnerRedirectConvertor() override; - virtual std::shared_ptr<PubSubOwnerRedirect> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerRedirect>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOwnerRedirect> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerRedirect>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h b/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h index 2908654..bf054b3 100644 --- a/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h +++ b/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOwnerSubscription.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubOwnerSubscriptionConvertor : public GenericLuaElementConvertor<PubSubOwnerSubscription> { public: PubSubOwnerSubscriptionConvertor(); - virtual ~PubSubOwnerSubscriptionConvertor(); + virtual ~PubSubOwnerSubscriptionConvertor() override; - virtual std::shared_ptr<PubSubOwnerSubscription> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerSubscription>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOwnerSubscription> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerSubscription>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp index 88085b5..3530efe 100644 --- a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp @@ -33,7 +33,7 @@ std::shared_ptr<PubSubOwnerSubscriptions> PubSubOwnerSubscriptionsConvertor::doC lua_pop(L, 1); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<PubSubOwnerSubscription> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h index c89b814..2e3f9be 100644 --- a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h +++ b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubOwnerSubscriptions.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubOwnerSubscriptionsConvertor : public GenericLuaElementConvertor<PubSubOwnerSubscriptions> { public: PubSubOwnerSubscriptionsConvertor(LuaElementConvertors* convertors); - virtual ~PubSubOwnerSubscriptionsConvertor(); + virtual ~PubSubOwnerSubscriptionsConvertor() override; - virtual std::shared_ptr<PubSubOwnerSubscriptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerSubscriptions>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubOwnerSubscriptions> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerSubscriptions>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubPublishConvertor.cpp b/Sluift/ElementConvertors/PubSubPublishConvertor.cpp index 63c97bc..d8a2742 100644 --- a/Sluift/ElementConvertors/PubSubPublishConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubPublishConvertor.cpp @@ -34,7 +34,7 @@ std::shared_ptr<PubSubPublish> PubSubPublishConvertor::doConvertFromLua(lua_Stat lua_getfield(L, -1, "items"); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<PubSubItem> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubPublishConvertor.h b/Sluift/ElementConvertors/PubSubPublishConvertor.h index 1765caf..ae28f14 100644 --- a/Sluift/ElementConvertors/PubSubPublishConvertor.h +++ b/Sluift/ElementConvertors/PubSubPublishConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubPublish.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubPublishConvertor : public GenericLuaElementConvertor<PubSubPublish> { public: PubSubPublishConvertor(LuaElementConvertors* convertors); - virtual ~PubSubPublishConvertor(); + virtual ~PubSubPublishConvertor() override; - virtual std::shared_ptr<PubSubPublish> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubPublish>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubPublish> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubPublish>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubRetractConvertor.cpp b/Sluift/ElementConvertors/PubSubRetractConvertor.cpp index c070ad6..c27ad7d 100644 --- a/Sluift/ElementConvertors/PubSubRetractConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubRetractConvertor.cpp @@ -34,7 +34,7 @@ std::shared_ptr<PubSubRetract> PubSubRetractConvertor::doConvertFromLua(lua_Stat lua_getfield(L, -1, "items"); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<PubSubItem> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubRetractConvertor.h b/Sluift/ElementConvertors/PubSubRetractConvertor.h index 13f7d0d..ca15ca7 100644 --- a/Sluift/ElementConvertors/PubSubRetractConvertor.h +++ b/Sluift/ElementConvertors/PubSubRetractConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubRetract.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubRetractConvertor : public GenericLuaElementConvertor<PubSubRetract> { public: PubSubRetractConvertor(LuaElementConvertors* convertors); - virtual ~PubSubRetractConvertor(); + virtual ~PubSubRetractConvertor() override; - virtual std::shared_ptr<PubSubRetract> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubRetract>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubRetract> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubRetract>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubSubscribeConvertor.h b/Sluift/ElementConvertors/PubSubSubscribeConvertor.h index 238f677..5f9d224 100644 --- a/Sluift/ElementConvertors/PubSubSubscribeConvertor.h +++ b/Sluift/ElementConvertors/PubSubSubscribeConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubSubscribe.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubSubscribeConvertor : public GenericLuaElementConvertor<PubSubSubscribe> { public: PubSubSubscribeConvertor(LuaElementConvertors* convertors); - virtual ~PubSubSubscribeConvertor(); + virtual ~PubSubSubscribeConvertor() override; - virtual std::shared_ptr<PubSubSubscribe> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscribe>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubSubscribe> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscribe>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h b/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h index fed8779..d853989 100644 --- a/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h +++ b/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubSubscribeOptions.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubSubscribeOptionsConvertor : public GenericLuaElementConvertor<PubSubSubscribeOptions> { public: PubSubSubscribeOptionsConvertor(); - virtual ~PubSubSubscribeOptionsConvertor(); + virtual ~PubSubSubscribeOptionsConvertor() override; - virtual std::shared_ptr<PubSubSubscribeOptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscribeOptions>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubSubscribeOptions> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscribeOptions>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/PubSubSubscriptionConvertor.h b/Sluift/ElementConvertors/PubSubSubscriptionConvertor.h index 5635181..9cad963 100644 --- a/Sluift/ElementConvertors/PubSubSubscriptionConvertor.h +++ b/Sluift/ElementConvertors/PubSubSubscriptionConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubSubscription.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubSubscriptionConvertor : public GenericLuaElementConvertor<PubSubSubscription> { public: PubSubSubscriptionConvertor(LuaElementConvertors* convertors); - virtual ~PubSubSubscriptionConvertor(); + virtual ~PubSubSubscriptionConvertor() override; - virtual std::shared_ptr<PubSubSubscription> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscription>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubSubscription> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscription>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp index 3712192..2325181 100644 --- a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp @@ -33,7 +33,7 @@ std::shared_ptr<PubSubSubscriptions> PubSubSubscriptionsConvertor::doConvertFrom lua_pop(L, 1); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::shared_ptr<PubSubSubscription> > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h index 2c941e6..94b4533 100644 --- a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h +++ b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubSubscriptions.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class PubSubSubscriptionsConvertor : public GenericLuaElementConvertor<PubSubSubscriptions> { public: PubSubSubscriptionsConvertor(LuaElementConvertors* convertors); - virtual ~PubSubSubscriptionsConvertor(); + virtual ~PubSubSubscriptionsConvertor() override; - virtual std::shared_ptr<PubSubSubscriptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscriptions>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubSubscriptions> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscriptions>) override; + virtual boost::optional<Documentation> getDocumentation() const override; private: LuaElementConvertors* convertors; diff --git a/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h b/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h index 7270917..f76f2b1 100644 --- a/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h +++ b/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/PubSubUnsubscribe.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class PubSubUnsubscribeConvertor : public GenericLuaElementConvertor<PubSubUnsubscribe> { public: PubSubUnsubscribeConvertor(); - virtual ~PubSubUnsubscribeConvertor(); + virtual ~PubSubUnsubscribeConvertor() override; - virtual std::shared_ptr<PubSubUnsubscribe> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubUnsubscribe>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<PubSubUnsubscribe> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubUnsubscribe>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/RawXMLElementConvertor.h b/Sluift/ElementConvertors/RawXMLElementConvertor.h index 79f648f..af3625b 100644 --- a/Sluift/ElementConvertors/RawXMLElementConvertor.h +++ b/Sluift/ElementConvertors/RawXMLElementConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> #include <Sluift/LuaElementConvertor.h> @@ -15,10 +14,10 @@ namespace Swift { class RawXMLElementConvertor : public LuaElementConvertor { public: RawXMLElementConvertor(); - virtual ~RawXMLElementConvertor(); + virtual ~RawXMLElementConvertor() override; - virtual std::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) SWIFTEN_OVERRIDE; - virtual boost::optional<std::string> convertToLua(lua_State*, std::shared_ptr<Element>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) override; + virtual boost::optional<std::string> convertToLua(lua_State*, std::shared_ptr<Element>) override; private: FullPayloadSerializerCollection serializers; diff --git a/Sluift/ElementConvertors/ResultSetConvertor.h b/Sluift/ElementConvertors/ResultSetConvertor.h index e1b826c..e098605 100644 --- a/Sluift/ElementConvertors/ResultSetConvertor.h +++ b/Sluift/ElementConvertors/ResultSetConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/ResultSet.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,11 +16,11 @@ namespace Swift { class ResultSetConvertor : public GenericLuaElementConvertor<ResultSet> { public: ResultSetConvertor(); - virtual ~ResultSetConvertor(); + virtual ~ResultSetConvertor() override; - virtual std::shared_ptr<ResultSet> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<ResultSet>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<ResultSet> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<ResultSet>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/SecurityLabelConvertor.cpp b/Sluift/ElementConvertors/SecurityLabelConvertor.cpp index 21d9a8f..8bc323a 100644 --- a/Sluift/ElementConvertors/SecurityLabelConvertor.cpp +++ b/Sluift/ElementConvertors/SecurityLabelConvertor.cpp @@ -26,7 +26,7 @@ std::shared_ptr<SecurityLabel> SecurityLabelConvertor::doConvertFromLua(lua_Stat lua_getfield(L, -1, "equivalent_labels"); if (lua_type(L, -1) == LUA_TTABLE) { std::vector< std::string > items; - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (lua_isstring(L, -1)) { diff --git a/Sluift/ElementConvertors/SecurityLabelConvertor.h b/Sluift/ElementConvertors/SecurityLabelConvertor.h index a0e7fea..22d11ca 100644 --- a/Sluift/ElementConvertors/SecurityLabelConvertor.h +++ b/Sluift/ElementConvertors/SecurityLabelConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/SecurityLabel.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class SecurityLabelConvertor : public GenericLuaElementConvertor<SecurityLabel> { public: SecurityLabelConvertor(); - virtual ~SecurityLabelConvertor(); + virtual ~SecurityLabelConvertor() override; - virtual std::shared_ptr<SecurityLabel> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<SecurityLabel>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<SecurityLabel> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<SecurityLabel>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/SoftwareVersionConvertor.h b/Sluift/ElementConvertors/SoftwareVersionConvertor.h index 29b1483..791aede 100644 --- a/Sluift/ElementConvertors/SoftwareVersionConvertor.h +++ b/Sluift/ElementConvertors/SoftwareVersionConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/SoftwareVersion.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -15,9 +14,9 @@ namespace Swift { class SoftwareVersionConvertor : public GenericLuaElementConvertor<SoftwareVersion> { public: SoftwareVersionConvertor(); - virtual ~SoftwareVersionConvertor(); + virtual ~SoftwareVersionConvertor() override; - virtual std::shared_ptr<SoftwareVersion> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<SoftwareVersion>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<SoftwareVersion> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<SoftwareVersion>) override; }; } diff --git a/Sluift/ElementConvertors/StanzaConvertor.h b/Sluift/ElementConvertors/StanzaConvertor.h index bdaaad3..a7b4e4e 100644 --- a/Sluift/ElementConvertors/StanzaConvertor.h +++ b/Sluift/ElementConvertors/StanzaConvertor.h @@ -46,7 +46,7 @@ namespace Swift { lua_pop(L, 1); lua_getfield(L, -1, "payloads"); if (lua_type(L, -1) == LUA_TTABLE) { - for(size_t i = 0; i < lua_objlen(L, -1); ++i) { + for(size_t i = 0; i < lua_rawlen(L, -1); ++i) { lua_pushnumber(L, i + 1); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { diff --git a/Sluift/ElementConvertors/StatusConvertor.h b/Sluift/ElementConvertors/StatusConvertor.h index 53da0ad..994cee5 100644 --- a/Sluift/ElementConvertors/StatusConvertor.h +++ b/Sluift/ElementConvertors/StatusConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Status.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -15,9 +14,9 @@ namespace Swift { class StatusConvertor : public GenericLuaElementConvertor<Status> { public: StatusConvertor(); - virtual ~StatusConvertor(); + virtual ~StatusConvertor() override; - virtual std::shared_ptr<Status> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<Status>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Status> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<Status>) override; }; } diff --git a/Sluift/ElementConvertors/StatusShowConvertor.h b/Sluift/ElementConvertors/StatusShowConvertor.h index 1521ca3..41be6b3 100644 --- a/Sluift/ElementConvertors/StatusShowConvertor.h +++ b/Sluift/ElementConvertors/StatusShowConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/StatusShow.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -15,10 +14,10 @@ namespace Swift { class StatusShowConvertor : public GenericLuaElementConvertor<StatusShow> { public: StatusShowConvertor(); - virtual ~StatusShowConvertor(); + virtual ~StatusShowConvertor() override; - virtual std::shared_ptr<StatusShow> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<StatusShow>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<StatusShow> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<StatusShow>) override; static std::string convertStatusShowTypeToString(const StatusShow::Type &show); static StatusShow::Type convertStatusShowTypeFromString(const std::string& show); diff --git a/Sluift/ElementConvertors/SubjectConvertor.h b/Sluift/ElementConvertors/SubjectConvertor.h index 1520004..f8eb152 100644 --- a/Sluift/ElementConvertors/SubjectConvertor.h +++ b/Sluift/ElementConvertors/SubjectConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/Subject.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,9 +16,9 @@ namespace Swift { class SubjectConvertor : public GenericLuaElementConvertor<Subject> { public: SubjectConvertor(); - virtual ~SubjectConvertor(); + virtual ~SubjectConvertor() override; - virtual std::shared_ptr<Subject> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<Subject>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<Subject> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<Subject>) override; }; } diff --git a/Sluift/ElementConvertors/UserLocationConvertor.h b/Sluift/ElementConvertors/UserLocationConvertor.h index 36e3a0b..b667d2a 100644 --- a/Sluift/ElementConvertors/UserLocationConvertor.h +++ b/Sluift/ElementConvertors/UserLocationConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/UserLocation.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class UserLocationConvertor : public GenericLuaElementConvertor<UserLocation> { public: UserLocationConvertor(); - virtual ~UserLocationConvertor(); + virtual ~UserLocationConvertor() override; - virtual std::shared_ptr<UserLocation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<UserLocation>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<UserLocation> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<UserLocation>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/UserTuneConvertor.h b/Sluift/ElementConvertors/UserTuneConvertor.h index ba57747..90bda41 100644 --- a/Sluift/ElementConvertors/UserTuneConvertor.h +++ b/Sluift/ElementConvertors/UserTuneConvertor.h @@ -1,12 +1,11 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swiften/Base/Override.h> #include <Swiften/Elements/UserTune.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -17,10 +16,10 @@ namespace Swift { class UserTuneConvertor : public GenericLuaElementConvertor<UserTune> { public: UserTuneConvertor(); - virtual ~UserTuneConvertor(); + virtual ~UserTuneConvertor() override; - virtual std::shared_ptr<UserTune> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<UserTune>) SWIFTEN_OVERRIDE; - virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE; + virtual std::shared_ptr<UserTune> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<UserTune>) override; + virtual boost::optional<Documentation> getDocumentation() const override; }; } diff --git a/Sluift/ElementConvertors/VCardConvertor.h b/Sluift/ElementConvertors/VCardConvertor.h index d63ef10..1d59c69 100644 --- a/Sluift/ElementConvertors/VCardConvertor.h +++ b/Sluift/ElementConvertors/VCardConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/VCard.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -15,9 +14,9 @@ namespace Swift { class VCardConvertor : public GenericLuaElementConvertor<VCard> { public: VCardConvertor(); - virtual ~VCardConvertor(); + virtual ~VCardConvertor() override; - virtual std::shared_ptr<VCard> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<VCard>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<VCard> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<VCard>) override; }; } diff --git a/Sluift/ElementConvertors/VCardUpdateConvertor.h b/Sluift/ElementConvertors/VCardUpdateConvertor.h index 851f3b1..19e42c6 100644 --- a/Sluift/ElementConvertors/VCardUpdateConvertor.h +++ b/Sluift/ElementConvertors/VCardUpdateConvertor.h @@ -1,12 +1,11 @@ /* - * 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/Elements/VCardUpdate.h> #include <Sluift/GenericLuaElementConvertor.h> @@ -15,9 +14,9 @@ namespace Swift { class VCardUpdateConvertor : public GenericLuaElementConvertor<VCardUpdate> { public: VCardUpdateConvertor(); - virtual ~VCardUpdateConvertor(); + virtual ~VCardUpdateConvertor() override; - virtual std::shared_ptr<VCardUpdate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE; - virtual void doConvertToLua(lua_State*, std::shared_ptr<VCardUpdate>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<VCardUpdate> doConvertFromLua(lua_State*) override; + virtual void doConvertToLua(lua_State*, std::shared_ptr<VCardUpdate>) override; }; } diff --git a/Sluift/Examples/SendReference.lua b/Sluift/Examples/SendReference.lua new file mode 100644 index 0000000..b705172 --- /dev/null +++ b/Sluift/Examples/SendReference.lua @@ -0,0 +1,70 @@ +#!/usr/bin/env sluift -- + +-- This is an example of sending a custom payload, a XEP-0372 reference in this +-- case. +-- +-- Running this requires a sluift binary somewhere in the PATH. Alternatively, +-- you can feed this to sluift, or to a Lua that has sluift.so in its library +-- path. + +require("sluift") + +DEFAULT_URI = "http://example.com/kitten.jpg" + +function usage(err) + print("Usage: SendReference.lua jid [tojid] [datauri]") + print() + print("This tool will log in as jid, and send a reference to tojid. If no tojid") + print("is provided, a message to itself is sent. The datauri defaults to") + print(DEFAULT_URI .. ", but can be overridden.") + + if err then + print("") + print("Error: " .. err) + end + os.exit(1) +end + +function get_password(prompt) + if prompt then + io.write(prompt) + end + local stty_ret = os.execute("stty -echo 2>/dev/null") + if stty_ret then + io.write("\027[8m") + end + local ok, pass = pcall(io.read, "*l") + if stty_ret then + io.write("\027[m") + else + os.execute("stty sane") + end + io.write("\n"); + if ok then + return pass + end +end + +if #arg < 1 then + usage("no jid specified") +end +jid = arg[1] +password = os.getenv("XMPP_PASSWORD") or get_password("Password: ") +tojid = #arg > 1 and arg[2] or jid +datauri = #arg > 2 and arg[3] or DEFAULT_URI + +sluift.debug = 1 +sluift.with(sluift.new_client(jid, password), function() + connect(options) + reference = { + ['_type'] = 'dom', + ['tag'] = 'reference', + ['ns'] = 'urn:xmpp:reference:0', + ['attributes'] = { + { ['name'] = 'type', ['value'] = 'data' }, + { ['name'] = 'uri', ['value'] = datauri }, + }, + } + send_message{to=tojid, body="Check out this data!", payloads={reference}} + disconnect() +end) diff --git a/Sluift/GenericLuaElementConvertor.h b/Sluift/GenericLuaElementConvertor.h index d94a324..4e52d9e 100644 --- a/Sluift/GenericLuaElementConvertor.h +++ b/Sluift/GenericLuaElementConvertor.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,8 +10,6 @@ #include <lua.hpp> -#include <Swiften/Base/Override.h> - #include <Sluift/Lua/Check.h> #include <Sluift/Lua/LuaUtils.h> #include <Sluift/LuaElementConvertor.h> @@ -23,9 +21,9 @@ namespace Swift { GenericLuaElementConvertor(const std::string& type) : type(type) { } - virtual ~GenericLuaElementConvertor() {} + virtual ~GenericLuaElementConvertor() override {} - virtual std::shared_ptr<Element> convertFromLua(lua_State* L, int index, const std::string& payloadType) SWIFTEN_OVERRIDE { + virtual std::shared_ptr<Element> convertFromLua(lua_State* L, int index, const std::string& payloadType) override { if (payloadType == type) { Lua::checkType(L, index, LUA_TTABLE); lua_pushvalue(L, index); @@ -37,7 +35,7 @@ namespace Swift { } virtual boost::optional<std::string> convertToLua( - lua_State* L, std::shared_ptr<Element> payload) SWIFTEN_OVERRIDE { + lua_State* L, std::shared_ptr<Element> payload) override { if (std::shared_ptr<T> actualPayload = std::dynamic_pointer_cast<T>(payload)) { doConvertToLua(L, actualPayload); assert(lua_type(L, -1) == LUA_TTABLE); diff --git a/Sluift/Helpers.h b/Sluift/Helpers.h index 6af3906..41bfc97 100644 --- a/Sluift/Helpers.h +++ b/Sluift/Helpers.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> namespace Swift { class ClientError; diff --git a/Sluift/Lua/FunctionRegistration.h b/Sluift/Lua/FunctionRegistration.h index 8e1410d..285c3d0 100644 --- a/Sluift/Lua/FunctionRegistration.h +++ b/Sluift/Lua/FunctionRegistration.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 <lua.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Sluift/Lua/FunctionRegistry.h> diff --git a/Sluift/Lua/FunctionRegistry.h b/Sluift/Lua/FunctionRegistry.h index acab3aa..88e15d5 100644 --- a/Sluift/Lua/FunctionRegistry.h +++ b/Sluift/Lua/FunctionRegistry.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,8 +11,6 @@ #include <lua.hpp> -#include <Swiften/Base/Override.h> - namespace Swift { namespace Lua { class FunctionRegistry { diff --git a/Sluift/Lua/LuaUtils.h b/Sluift/Lua/LuaUtils.h index b87eb38..b9f5bff 100644 --- a/Sluift/Lua/LuaUtils.h +++ b/Sluift/Lua/LuaUtils.h @@ -12,7 +12,22 @@ #include <vector> #if LUA_VERSION_NUM < 502 -#define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) +#define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) +#define lua_compare(L,idx1,idx2,LUA_OPEQ) lua_equal(L,(idx1),(idx2)) +#define lua_rawlen(L, i) lua_objlen(L,(i)) +#endif +#if LUA_VERSION_NUM >= 503 +#undef luaL_register +#define luaL_register(L, n, l) \ + lua_getglobal( L, n ); \ + if( lua_isnil( L, -1 ) ) \ + { \ + lua_pop( L, 1 ); \ + lua_newtable( L ); \ + } \ + luaL_setfuncs( L, (l), 0 ); \ + lua_pushvalue( L, -1 ); \ + lua_setglobal( L, n ); #endif namespace Swift { diff --git a/Sluift/LuaElementConvertor.h b/Sluift/LuaElementConvertor.h index 2cf98e7..eb3a24f 100644 --- a/Sluift/LuaElementConvertor.h +++ b/Sluift/LuaElementConvertor.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,8 +11,6 @@ #include <boost/optional.hpp> -#include <Swiften/Base/Override.h> - struct lua_State; namespace Swift { diff --git a/Sluift/LuaElementConvertors.h b/Sluift/LuaElementConvertors.h index 8e1d10b..bfcffdd 100644 --- a/Sluift/LuaElementConvertors.h +++ b/Sluift/LuaElementConvertors.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,8 +11,6 @@ #include <boost/optional.hpp> -#include <Swiften/Base/Override.h> - struct lua_State; namespace Swift { diff --git a/Sluift/StandardTerminal.h b/Sluift/StandardTerminal.h index 2109878..f32bd1c 100644 --- a/Sluift/StandardTerminal.h +++ b/Sluift/StandardTerminal.h @@ -1,23 +1,21 @@ /* - * 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 <Sluift/Terminal.h> namespace Swift { class StandardTerminal : public Terminal { public: StandardTerminal(); - virtual ~StandardTerminal(); + virtual ~StandardTerminal() override; - virtual boost::optional<std::string> readLine(const std::string& prompt) SWIFTEN_OVERRIDE; - virtual void printError(const std::string& message) SWIFTEN_OVERRIDE; - virtual void addToHistory(const std::string& command) SWIFTEN_OVERRIDE; + virtual boost::optional<std::string> readLine(const std::string& prompt) override; + virtual void printError(const std::string& message) override; + virtual void addToHistory(const std::string& command) override; }; } diff --git a/Sluift/client.cpp b/Sluift/client.cpp index 75f675d..ae2f610 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -701,7 +701,7 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( lua_getfield(L, 2, "groups"); if (!lua_isnil(L, -1)) { if (lua_type(L, -1) == LUA_TTABLE) { - for (size_t i = 1; i <= lua_objlen(L, -1); ++i) { + for (size_t i = 1; i <= lua_rawlen(L, -1); ++i) { lua_rawgeti(L, -1, boost::numeric_cast<int>(i)); const char* rawGroup = lua_tostring(L, -1); if (rawGroup) { diff --git a/Sluift/core.lua b/Sluift/core.lua index 89c96ba..f35a603 100644 --- a/Sluift/core.lua +++ b/Sluift/core.lua @@ -6,7 +6,8 @@ local sluift = select(1, ...) local _G = _G -local pairs, ipairs, print, tostring, type, error, assert, next, rawset, xpcall, unpack, io = pairs, ipairs, print, tostring, type, error, assert, next, rawset, xpcall, unpack, io +local pairs, ipairs, print, tostring, type, error, assert, next, rawset, xpcall, io = pairs, ipairs, print, tostring, type, error, assert, next, rawset, xpcall, io +local unpack = table.unpack or unpack local setmetatable, getmetatable = setmetatable, getmetatable local string = require "string" local table = require "table" @@ -961,7 +962,7 @@ register_help(Component.process_events) -- component:set_command{to = 'alice@wonderland.lit', command = { type = 'execute', node = 'uptime' }} -- local get_set_shortcuts = { - get = {'software_version', 'disco_items', 'xml', 'dom', 'vcard'}, + get = {'software_version', 'disco_items', 'disco_info', 'xml', 'dom', 'vcard'}, set = {'command', 'vcard'} } for query_action, query_types in pairs(get_set_shortcuts) do diff --git a/SwifTools/MacOSXChecker.mm b/SwifTools/MacOSXChecker.mm index aefe3e7..afaa87c 100644 --- a/SwifTools/MacOSXChecker.mm +++ b/SwifTools/MacOSXChecker.mm @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -19,6 +19,8 @@ #include <AppKit/AppKit.h> +#include <SwifTools/Cocoa/CocoaUtil.h> + namespace Swift { MacOSXChecker::MacOSXChecker() { @@ -54,7 +56,7 @@ void MacOSXChecker::getSuggestions(const std::string& word, std::vector<std::str NSString* wordString = [[NSString alloc] initWithUTF8String: word.c_str()]; NSArray* suggestions = [spellChecker guessesForWordRange:NSMakeRange(0, [wordString length]) inString:wordString language:nil inSpellDocumentWithTag:0]; for(unsigned int i = 0; i < [suggestions count]; ++i) { - list.push_back(std::string([[suggestions objectAtIndex:i] UTF8String])); + list.push_back(ns2StdString([suggestions objectAtIndex:i])); } [wordString release]; } diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 40f6156..5f5f41d 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -52,8 +52,8 @@ namespace Swift { /** * The controller does not gain ownership of the stanzaChannel, nor the factory. */ -ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &contact, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool isInMUC, bool useDelayForLatency, UIEventStream* eventStream, TimerFactory* timerFactory, EventController* eventController, EntityCapsProvider* entityCapsProvider, bool userWantsReceipts, SettingsProvider* settings, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, ClientBlockListManager* clientBlockListManager, std::shared_ptr<ChatMessageParser> chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider) - : ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, contact, nickResolver, presenceOracle, avatarManager, useDelayForLatency, eventStream, eventController, entityCapsProvider, historyController, mucRegistry, highlightManager, chatMessageParser, autoAcceptMUCInviteDecider), userWantsReceipts_(userWantsReceipts), settings_(settings), clientBlockListManager_(clientBlockListManager) { +ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &contact, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool isInMUC, bool useDelayForLatency, UIEventStream* eventStream, TimerFactory* timerFactory, EventController* eventController, EntityCapsProvider* entityCapsProvider, bool userWantsReceipts, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, ClientBlockListManager* clientBlockListManager, std::shared_ptr<ChatMessageParser> chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider, SettingsProvider* settings) + : ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, contact, nickResolver, presenceOracle, avatarManager, useDelayForLatency, eventStream, eventController, entityCapsProvider, historyController, mucRegistry, highlightManager, chatMessageParser, autoAcceptMUCInviteDecider, settings), userWantsReceipts_(userWantsReceipts), clientBlockListManager_(clientBlockListManager) { isInMUC_ = isInMUC; lastWasPresence_ = false; chatStateNotifier_ = new ChatStateNotifier(stanzaChannel, contact, entityCapsProvider, timerFactory, 20000); diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h index a9093d0..72acc27 100644 --- a/Swift/Controllers/Chat/ChatController.h +++ b/Swift/Controllers/Chat/ChatController.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <map> #include <string> -#include <Swiften/Base/Override.h> #include <Swiften/Base/Tristate.h> #include <Swift/Controllers/Chat/ChatControllerBase.h> @@ -31,42 +30,42 @@ namespace Swift { class ChatController : public ChatControllerBase { public: - ChatController(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &contact, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool isInMUC, bool useDelayForLatency, UIEventStream* eventStream, TimerFactory* timerFactory, EventController* eventController, EntityCapsProvider* entityCapsProvider, bool userWantsReceipts, SettingsProvider* settings, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, ClientBlockListManager* clientBlockListManager, std::shared_ptr<ChatMessageParser> chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider); - virtual ~ChatController(); - virtual void setToJID(const JID& jid) SWIFTEN_OVERRIDE; - virtual void setAvailableServerFeatures(std::shared_ptr<DiscoInfo> info) SWIFTEN_OVERRIDE; - virtual void setOnline(bool online) SWIFTEN_OVERRIDE; + ChatController(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &contact, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool isInMUC, bool useDelayForLatency, UIEventStream* eventStream, TimerFactory* timerFactory, EventController* eventController, EntityCapsProvider* entityCapsProvider, bool userWantsReceipts, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, ClientBlockListManager* clientBlockListManager, std::shared_ptr<ChatMessageParser> chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider, SettingsProvider* settings); + virtual ~ChatController() override; + virtual void setToJID(const JID& jid) override; + virtual void setAvailableServerFeatures(std::shared_ptr<DiscoInfo> info) override; + virtual void setOnline(bool online) override; virtual void handleNewFileTransferController(FileTransferController* ftc); virtual void handleWhiteboardSessionRequest(bool senderIsSelf); virtual void handleWhiteboardStateChange(const ChatWindow::WhiteboardSessionState state); - virtual void setContactIsReceivingPresence(bool /*isReceivingPresence*/) SWIFTEN_OVERRIDE; - virtual ChatWindow* detachChatWindow() SWIFTEN_OVERRIDE; - virtual void handleIncomingOwnMessage(std::shared_ptr<Message> message) SWIFTEN_OVERRIDE; + virtual void setContactIsReceivingPresence(bool /*isReceivingPresence*/) override; + virtual ChatWindow* detachChatWindow() override; + virtual void handleIncomingOwnMessage(std::shared_ptr<Message> message) override; protected: - virtual void cancelReplaces() SWIFTEN_OVERRIDE; - virtual JID getBaseJID() SWIFTEN_OVERRIDE; - virtual void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming) SWIFTEN_OVERRIDE; - virtual bool shouldIgnoreMessage(std::shared_ptr<Message> message) SWIFTEN_OVERRIDE; - virtual JID messageCorrectionJID(const JID& fromJID) SWIFTEN_OVERRIDE; + virtual void cancelReplaces() override; + virtual JID getBaseJID() override; + virtual void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming) override; + virtual bool shouldIgnoreMessage(std::shared_ptr<Message> message) override; + virtual JID messageCorrectionJID(const JID& fromJID) override; private: void handlePresenceChange(std::shared_ptr<Presence> newPresence); std::string getStatusChangeString(std::shared_ptr<Presence> presence); - virtual bool isIncomingMessageFromMe(std::shared_ptr<Message> message) SWIFTEN_OVERRIDE; - virtual void postSendMessage(const std::string &body, std::shared_ptr<Stanza> sentStanza) SWIFTEN_OVERRIDE; - virtual void preHandleIncomingMessage(std::shared_ptr<MessageEvent> messageEvent) SWIFTEN_OVERRIDE; - virtual void addMessageHandleIncomingMessage(const JID& from, const ChatWindow::ChatMessage& message, const std::string& messageID, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& timeStamp) SWIFTEN_OVERRIDE; - virtual void handleIncomingReplaceMessage(const JID& from, const ChatWindow::ChatMessage& message, const std::string& messageID, const std::string& idToReplace, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& timeStamp) SWIFTEN_OVERRIDE; - virtual void postHandleIncomingMessage(std::shared_ptr<MessageEvent> messageEvent, const ChatWindow::ChatMessage& chatMessage) SWIFTEN_OVERRIDE; - virtual void preSendMessageRequest(std::shared_ptr<Message>) SWIFTEN_OVERRIDE; - virtual std::string senderHighlightNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; - virtual std::string senderDisplayNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; - virtual boost::optional<boost::posix_time::ptime> getMessageTimestamp(std::shared_ptr<Message>) const SWIFTEN_OVERRIDE; + virtual bool isIncomingMessageFromMe(std::shared_ptr<Message> message) override; + virtual void postSendMessage(const std::string &body, std::shared_ptr<Stanza> sentStanza) override; + virtual void preHandleIncomingMessage(std::shared_ptr<MessageEvent> messageEvent) override; + virtual void addMessageHandleIncomingMessage(const JID& from, const ChatWindow::ChatMessage& message, const std::string& messageID, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& timeStamp) override; + virtual void handleIncomingReplaceMessage(const JID& from, const ChatWindow::ChatMessage& message, const std::string& messageID, const std::string& idToReplace, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& timeStamp) override; + virtual void postHandleIncomingMessage(std::shared_ptr<MessageEvent> messageEvent, const ChatWindow::ChatMessage& chatMessage) override; + virtual void preSendMessageRequest(std::shared_ptr<Message>) override; + virtual std::string senderHighlightNameFromMessage(const JID& from) override; + virtual std::string senderDisplayNameFromMessage(const JID& from) override; + virtual boost::optional<boost::posix_time::ptime> getMessageTimestamp(std::shared_ptr<Message>) const override; void handleStanzaAcked(std::shared_ptr<Stanza> stanza); - virtual void dayTicked() SWIFTEN_OVERRIDE { lastWasPresence_ = false; } + virtual void dayTicked() override { lastWasPresence_ = false; } void handleContactNickChanged(const JID& jid, const std::string& /*oldNick*/); - virtual void handleBareJIDCapsChanged(const JID& jid) SWIFTEN_OVERRIDE; + virtual void handleBareJIDCapsChanged(const JID& jid) override; void handleFileTransferCancel(std::string /* id */); void handleFileTransferStart(std::string /* id */, std::string /* description */); @@ -105,7 +104,6 @@ namespace Swift { bool receivingPresenceFromUs_ = false; bool userWantsReceipts_; std::map<std::string, FileTransferController*> ftControllers; - SettingsProvider* settings_; std::string lastWbID_; std::string lastHandledMessageID_; diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index 19bbf8d..b1854d8 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -38,7 +38,7 @@ namespace Swift { -ChatControllerBase::ChatControllerBase(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &toJID, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool useDelayForLatency, UIEventStream* eventStream, EventController* eventController, EntityCapsProvider* entityCapsProvider, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, std::shared_ptr<ChatMessageParser> chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider) : selfJID_(self), stanzaChannel_(stanzaChannel), iqRouter_(iqRouter), chatWindowFactory_(chatWindowFactory), toJID_(toJID), labelsEnabled_(false), presenceOracle_(presenceOracle), avatarManager_(avatarManager), useDelayForLatency_(useDelayForLatency), eventController_(eventController), entityCapsProvider_(entityCapsProvider), historyController_(historyController), mucRegistry_(mucRegistry), chatMessageParser_(chatMessageParser), autoAcceptMUCInviteDecider_(autoAcceptMUCInviteDecider), eventStream_(eventStream) { +ChatControllerBase::ChatControllerBase(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &toJID, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool useDelayForLatency, UIEventStream* eventStream, EventController* eventController, EntityCapsProvider* entityCapsProvider, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, std::shared_ptr<ChatMessageParser> chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider, SettingsProvider* settings) : selfJID_(self), stanzaChannel_(stanzaChannel), iqRouter_(iqRouter), chatWindowFactory_(chatWindowFactory), toJID_(toJID), labelsEnabled_(false), presenceOracle_(presenceOracle), avatarManager_(avatarManager), useDelayForLatency_(useDelayForLatency), eventController_(eventController), entityCapsProvider_(entityCapsProvider), historyController_(historyController), mucRegistry_(mucRegistry), chatMessageParser_(chatMessageParser), autoAcceptMUCInviteDecider_(autoAcceptMUCInviteDecider), eventStream_(eventStream), roomSecurityMarking_(""), previousMessageSecurityMarking_(""), settings_(settings) { chatWindow_ = chatWindowFactory_->createChatWindow(toJID, eventStream); chatWindow_->onAllMessagesRead.connect(boost::bind(&ChatControllerBase::handleAllMessagesRead, this)); chatWindow_->onSendMessageRequest.connect(boost::bind(&ChatControllerBase::handleSendMessageRequest, this, _1, _2)); @@ -193,11 +193,33 @@ void ChatControllerBase::updateMessageCount() { } std::string ChatControllerBase::addMessage(const ChatWindow::ChatMessage& chatMessage, const std::string& senderName, bool senderIsSelf, const std::shared_ptr<SecurityLabel> label, const boost::filesystem::path& avatarPath, const boost::posix_time::ptime& time) { + auto displayedLabel = label; + + if (settings_->getSetting(SettingConstants::MUC_MARKING_ELISION)) { + if (roomSecurityMarking_ != "") { + + if (label && label->getDisplayMarking() == roomSecurityMarking_) { + if (label->getDisplayMarking() == previousMessageSecurityMarking_) { + displayedLabel = std::make_shared<SecurityLabel>(); + } + previousMessageSecurityMarking_ = label->getDisplayMarking(); + } + else if (!label || label->getDisplayMarking().empty()) { + displayedLabel = std::make_shared<SecurityLabel>(); + displayedLabel->setDisplayMarking("Unmarked"); + previousMessageSecurityMarking_ = "Unmarked"; + } + else { + previousMessageSecurityMarking_ = displayedLabel->getDisplayMarking(); + } + } + } + if (chatMessage.isMeCommand()) { - return chatWindow_->addAction(chatMessage, senderName, senderIsSelf, label, pathToString(avatarPath), time); + return chatWindow_->addAction(chatMessage, senderName, senderIsSelf, displayedLabel, pathToString(avatarPath), time); } else { - return chatWindow_->addMessage(chatMessage, senderName, senderIsSelf, label, pathToString(avatarPath), time); + return chatWindow_->addMessage(chatMessage, senderName, senderIsSelf, displayedLabel, pathToString(avatarPath), time); } } @@ -287,7 +309,9 @@ void ChatControllerBase::handleIncomingMessage(std::shared_ptr<MessageEvent> mes addMessageHandleIncomingMessage(from, chatMessage, message->getID(), senderIsSelf, label, timeStamp); } +#ifdef SWIFT_EXPERIMENTAL_HISTORY logMessage(body, from, selfJID_, timeStamp, true); +#endif } chatWindow_->show(); updateMessageCount(); diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h index 88cb95c..f635a46 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.h +++ b/Swift/Controllers/Chat/ChatControllerBase.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -28,6 +28,7 @@ #include <Swift/Controllers/Highlighting/HighlightManager.h> #include <Swift/Controllers/HistoryController.h> +#include <Swift/Controllers/Settings/SettingsProvider.h> #include <Swift/Controllers/UIInterfaces/ChatWindow.h> #include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> #include <Swift/Controllers/XMPPEvents/MessageEvent.h> @@ -79,7 +80,7 @@ namespace Swift { boost::signals2::signal<void(ChatWindow* /*window to reuse*/, const std::vector<JID>& /*invite people*/, const std::string& /*reason*/)> onConvertToMUC; protected: - ChatControllerBase(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &toJID, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool useDelayForLatency, UIEventStream* eventStream, EventController* eventController, EntityCapsProvider* entityCapsProvider, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, std::shared_ptr<ChatMessageParser> chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider); + ChatControllerBase(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &toJID, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool useDelayForLatency, UIEventStream* eventStream, EventController* eventController, EntityCapsProvider* entityCapsProvider, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, std::shared_ptr<ChatMessageParser> chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider, SettingsProvider* settings); /** * Pass the Message appended, and the stanza used to send it. @@ -150,5 +151,8 @@ namespace Swift { AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider_; UIEventStream* eventStream_; bool lastWasPresence_ = false; + std::string roomSecurityMarking_; + std::string previousMessageSecurityMarking_; + SettingsProvider* settings_; }; } diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 19400f9..81892fc 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -732,7 +732,7 @@ ChatController* ChatsManager::getChatControllerOrFindAnother(const JID &contact) ChatController* ChatsManager::createNewChatController(const JID& contact) { assert(chatControllers_.find(contact) == chatControllers_.end()); std::shared_ptr<ChatMessageParser> chatMessageParser = std::make_shared<ChatMessageParser>(emoticons_, highlightManager_->getConfiguration(), ChatMessageParser::Mode::Chat); /* a message parser that knows this is a chat (not a room/MUC) */ - ChatController* controller = new ChatController(jid_, stanzaChannel_, iqRouter_, chatWindowFactory_, contact, nickResolver_, presenceOracle_, avatarManager_, mucRegistry_->isMUC(contact.toBare()), useDelayForLatency_, uiEventStream_, timerFactory_, eventController_, entityCapsProvider_, userWantsReceipts_, settings_, historyController_, mucRegistry_, highlightManager_, clientBlockListManager_, chatMessageParser, autoAcceptMUCInviteDecider_); + auto controller = new ChatController(jid_, stanzaChannel_, iqRouter_, chatWindowFactory_, contact, nickResolver_, presenceOracle_, avatarManager_, mucRegistry_->isMUC(contact.toBare()), useDelayForLatency_, uiEventStream_, timerFactory_, eventController_, entityCapsProvider_, userWantsReceipts_, historyController_, mucRegistry_, highlightManager_, clientBlockListManager_, chatMessageParser, autoAcceptMUCInviteDecider_, settings_); chatControllers_[contact] = controller; controller->setAvailableServerFeatures(serverDiscoInfo_); controller->onActivity.connect(boost::bind(&ChatsManager::handleChatActivity, this, contact, _1, false)); @@ -821,7 +821,7 @@ MUC::ref ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::opti chatWindowFactoryAdapter = new SingleChatWindowFactoryAdapter(reuseChatwindow); } std::shared_ptr<ChatMessageParser> chatMessageParser = std::make_shared<ChatMessageParser>(emoticons_, highlightManager_->getConfiguration(), ChatMessageParser::Mode::GroupChat); /* a message parser that knows this is a room/MUC (not a chat) */ - controller = new MUCController(jid_, muc, password, nick, stanzaChannel_, iqRouter_, reuseChatwindow ? chatWindowFactoryAdapter : chatWindowFactory_, nickResolver_, presenceOracle_, avatarManager_, uiEventStream_, false, timerFactory_, eventController_, entityCapsProvider_, roster_, historyController_, mucRegistry_, highlightManager_, clientBlockListManager_, chatMessageParser, isImpromptu, autoAcceptMUCInviteDecider_, vcardManager_, mucBookmarkManager_); + controller = new MUCController(jid_, muc, password, nick, stanzaChannel_, iqRouter_, reuseChatwindow ? chatWindowFactoryAdapter : chatWindowFactory_, nickResolver_, presenceOracle_, avatarManager_, uiEventStream_, false, timerFactory_, eventController_, entityCapsProvider_, roster_, historyController_, mucRegistry_, highlightManager_, clientBlockListManager_, chatMessageParser, isImpromptu, autoAcceptMUCInviteDecider_, vcardManager_, mucBookmarkManager_, settings_); if (chatWindowFactoryAdapter) { /* The adapters are only passed to chat windows, which are deleted in their * controllers' dtor, which are deleted in ChatManager's dtor. The adapters diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index d10e6d4..4c3f524 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -23,6 +23,7 @@ #include <Swiften/Client/ClientBlockListManager.h> #include <Swiften/Client/StanzaChannel.h> #include <Swiften/Disco/EntityCapsProvider.h> +#include <Swiften/Disco/GetDiscoInfoRequest.h> #include <Swiften/Elements/Delay.h> #include <Swiften/Elements/Thread.h> #include <Swiften/MUC/MUC.h> @@ -98,8 +99,9 @@ MUCController::MUCController ( bool isImpromptu, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider, VCardManager* vcardManager, - MUCBookmarkManager* mucBookmarkManager) : - ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, muc->getJID(), nickResolver, presenceOracle, avatarManager, useDelayForLatency, uiEventStream, eventController, entityCapsProvider, historyController, mucRegistry, highlightManager, chatMessageParser, autoAcceptMUCInviteDecider), muc_(muc), nick_(nick), desiredNick_(nick), password_(password), renameCounter_(0), isImpromptu_(isImpromptu), isImpromptuAlreadyConfigured_(false), clientBlockListManager_(clientBlockListManager), mucBookmarkManager_(mucBookmarkManager) { + MUCBookmarkManager* mucBookmarkManager, + SettingsProvider* settings) : + ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, muc->getJID(), nickResolver, presenceOracle, avatarManager, useDelayForLatency, uiEventStream, eventController, entityCapsProvider, historyController, mucRegistry, highlightManager, chatMessageParser, autoAcceptMUCInviteDecider, settings), muc_(muc), nick_(nick), desiredNick_(nick), password_(password), renameCounter_(0), isImpromptu_(isImpromptu), isImpromptuAlreadyConfigured_(false), clientBlockListManager_(clientBlockListManager), mucBookmarkManager_(mucBookmarkManager) { assert(avatarManager_); parting_ = true; @@ -112,7 +114,7 @@ MUCController::MUCController ( isInitialJoin_ = true; chatWindowTitle_ = ""; - roster_ = std::unique_ptr<Roster>(new Roster(false, true)); + roster_ = std::make_unique<Roster>(false, true); rosterVCardProvider_ = new RosterVCardProvider(roster_.get(), vcardManager, JID::WithResource); completer_ = new TabComplete(); chatWindow_->setRosterModel(roster_.get()); @@ -273,6 +275,9 @@ void MUCController::rejoin() { lastActivity_ = historyController_->getLastTimeStampFromMUC(selfJID_, toJID_); } #endif + + requestSecurityMarking(); + if (lastActivity_ == boost::posix_time::not_a_date_time) { muc_->joinAs(nick_); } @@ -1243,4 +1248,63 @@ void MUCController::setChatWindowTitle(const std::string& title) { chatWindow_->setName(chatWindowTitle_); } +void MUCController::requestSecurityMarking() { + auto discoInfoRequest = GetDiscoInfoRequest::create(muc_->getJID(), iqRouter_); + discoInfoRequest->onResponse.connect( + [this](std::shared_ptr<DiscoInfo> discoInfoRef, ErrorPayload::ref errorPayloadRef) { + if (!discoInfoRef || errorPayloadRef) { + return; + } + const std::vector<Form::ref>& extensionsList = discoInfoRef->getExtensions(); + if (extensionsList.empty()) { + return; + } + // Get the correct form if it exists + Form::ref roomInfoForm; + for (const auto& form : extensionsList) { + if (form->getFormType() == "http://jabber.org/protocol/muc#roominfo") { + roomInfoForm = form; + break; + } + } + if (!roomInfoForm) { + return; + } + // It exists, now examine the security marking data + auto marking = roomInfoForm->getField("x-isode#roominfo_marking"); + if (!marking) { + return; + } + // Now we know the marking is valid + auto markingValue = marking->getTextSingleValue(); + if (markingValue == "") { + setMUCSecurityMarkingDefault(); + return; + } + auto markingForegroundColor = roomInfoForm->getField("x-isode#roominfo_marking_fg_color"); + auto markingBackgroundColor = roomInfoForm->getField("x-isode#roominfo_marking_bg_color"); + std::string markingForegroundColorValue = "Black"; + std::string markingBackgroundColorValue = "White"; + if (markingForegroundColor) { + markingForegroundColorValue = markingForegroundColor->getTextSingleValue(); + } + if (markingBackgroundColor) { + markingBackgroundColorValue = markingBackgroundColor->getTextSingleValue(); + } + setMUCSecurityMarking(markingValue, markingForegroundColorValue, markingBackgroundColorValue); + } + ); + discoInfoRequest->send(); +} + +void MUCController::setMUCSecurityMarking(const std::string& markingValue, const std::string& markingForegroundColorValue, const std::string& markingBackgroundColorValue) { + roomSecurityMarking_ = markingValue; + chatWindow_->setChatSecurityMarking(markingValue, markingForegroundColorValue, markingBackgroundColorValue); +} + +void MUCController::setMUCSecurityMarkingDefault() { + roomSecurityMarking_ = ""; + chatWindow_->removeChatSecurityMarking(); +} + } diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index 258eaaf..afc524f 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -14,7 +14,6 @@ #include <boost/signals2.hpp> #include <boost/signals2/connection.hpp> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/DiscoInfo.h> #include <Swiften/Elements/MUCOccupant.h> #include <Swiften/Elements/Message.h> @@ -54,14 +53,14 @@ namespace Swift { class MUCController : public ChatControllerBase { public: - MUCController(const JID& self, MUC::ref muc, const boost::optional<std::string>& password, const std::string &nick, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, UIEventStream* events, bool useDelayForLatency, TimerFactory* timerFactory, EventController* eventController, EntityCapsProvider* entityCapsProvider, XMPPRoster* xmppRoster, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, ClientBlockListManager* clientBlockListManager, std::shared_ptr<ChatMessageParser> chatMessageParser, bool isImpromptu, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider, VCardManager* vcardManager, MUCBookmarkManager* mucBookmarkManager); - virtual ~MUCController(); + MUCController(const JID& self, MUC::ref muc, const boost::optional<std::string>& password, const std::string &nick, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, UIEventStream* events, bool useDelayForLatency, TimerFactory* timerFactory, EventController* eventController, EntityCapsProvider* entityCapsProvider, XMPPRoster* xmppRoster, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, ClientBlockListManager* clientBlockListManager, std::shared_ptr<ChatMessageParser> chatMessageParser, bool isImpromptu, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider, VCardManager* vcardManager, MUCBookmarkManager* mucBookmarkManager, SettingsProvider* settings); + virtual ~MUCController() override; boost::signals2::signal<void ()> onUserLeft; boost::signals2::signal<void ()> onUserJoined; boost::signals2::signal<void ()> onImpromptuConfigCompleted; boost::signals2::signal<void (const std::string&, const std::string& )> onUserNicknameChanged; - virtual void setOnline(bool online) SWIFTEN_OVERRIDE; - virtual void setAvailableServerFeatures(std::shared_ptr<DiscoInfo> info) SWIFTEN_OVERRIDE; + virtual void setOnline(bool online) override; + virtual void setAvailableServerFeatures(std::shared_ptr<DiscoInfo> info) override; void rejoin(); static void appendToJoinParts(std::vector<NickJoinPart>& joinParts, const NickJoinPart& newEvent); static std::string generateJoinPartString(const std::vector<NickJoinPart>& joinParts, bool isImpromptu); @@ -76,18 +75,18 @@ namespace Swift { void setChatWindowTitle(const std::string& title); protected: - virtual void preSendMessageRequest(std::shared_ptr<Message> message) SWIFTEN_OVERRIDE; - virtual bool isIncomingMessageFromMe(std::shared_ptr<Message> message) SWIFTEN_OVERRIDE; - virtual std::string senderHighlightNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; - virtual std::string senderDisplayNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; - virtual boost::optional<boost::posix_time::ptime> getMessageTimestamp(std::shared_ptr<Message> message) const SWIFTEN_OVERRIDE; - virtual void preHandleIncomingMessage(std::shared_ptr<MessageEvent>) SWIFTEN_OVERRIDE; - virtual void addMessageHandleIncomingMessage(const JID& from, const ChatWindow::ChatMessage& message, const std::string& messageID, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& time) SWIFTEN_OVERRIDE; - virtual void handleIncomingReplaceMessage(const JID& from, const ChatWindow::ChatMessage& message, const std::string& messageID, const std::string& idToReplace, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& timeStamp) SWIFTEN_OVERRIDE; - virtual void postHandleIncomingMessage(std::shared_ptr<MessageEvent>, const ChatWindow::ChatMessage& chatMessage) SWIFTEN_OVERRIDE; - virtual void cancelReplaces() SWIFTEN_OVERRIDE; - virtual void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming) SWIFTEN_OVERRIDE; - virtual JID messageCorrectionJID(const JID& fromJID) SWIFTEN_OVERRIDE; + virtual void preSendMessageRequest(std::shared_ptr<Message> message) override; + virtual bool isIncomingMessageFromMe(std::shared_ptr<Message> message) override; + virtual std::string senderHighlightNameFromMessage(const JID& from) override; + virtual std::string senderDisplayNameFromMessage(const JID& from) override; + virtual boost::optional<boost::posix_time::ptime> getMessageTimestamp(std::shared_ptr<Message> message) const override; + virtual void preHandleIncomingMessage(std::shared_ptr<MessageEvent>) override; + virtual void addMessageHandleIncomingMessage(const JID& from, const ChatWindow::ChatMessage& message, const std::string& messageID, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& time) override; + virtual void handleIncomingReplaceMessage(const JID& from, const ChatWindow::ChatMessage& message, const std::string& messageID, const std::string& idToReplace, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& timeStamp) override; + virtual void postHandleIncomingMessage(std::shared_ptr<MessageEvent>, const ChatWindow::ChatMessage& chatMessage) override; + virtual void cancelReplaces() override; + virtual void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming) override; + virtual JID messageCorrectionJID(const JID& fromJID) override; private: void setAvailableRoomActions(const MUCOccupant::Affiliation& affiliation, const MUCOccupant::Role& role); @@ -116,9 +115,9 @@ namespace Swift { bool messageTargetsMe(std::shared_ptr<Message> message); void updateJoinParts(); bool shouldUpdateJoinParts(); - virtual void dayTicked() SWIFTEN_OVERRIDE { clearPresenceQueue(); } + virtual void dayTicked() override { clearPresenceQueue(); } void processUserPart(); - virtual void handleBareJIDCapsChanged(const JID& jid) SWIFTEN_OVERRIDE; + virtual void handleBareJIDCapsChanged(const JID& jid) override; void handleConfigureRequest(Form::ref); void handleConfigurationFailed(ErrorPayload::ref); void handleConfigurationFormReceived(Form::ref); @@ -149,6 +148,10 @@ namespace Swift { void displaySubjectIfChanged(const std::string& sucject); void addChatSystemMessage(); + void requestSecurityMarking(); + void setMUCSecurityMarking(const std::string& markingValue, const std::string& markingForegroundColorValue, const std::string& markingBackgroundColorValue); + void setMUCSecurityMarkingDefault(); + private: MUC::ref muc_; std::string nick_; @@ -190,4 +193,3 @@ namespace Swift { std::string chatWindowTitle_; }; } - diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index ac62942..4a46b32 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -167,7 +167,7 @@ class ChatsManagerTest : public CppUnit::TestFixture { public: void setUp() { mocks_ = new MockRepository(); - notifier_ = std::unique_ptr<DummyNotifier>(new DummyNotifier()); + notifier_ = std::make_unique<DummyNotifier>(); jid_ = JID("test@test.com/resource"); stanzaChannel_ = new DummyStanzaChannel(); iqRouter_ = new IQRouter(stanzaChannel_); @@ -783,7 +783,7 @@ public: // send message to participantA auto messageBody = std::string("message body to send"); window->onSendMessageRequest(messageBody, false); - auto sendMessageStanza = stanzaChannel_->getStanzaAtIndex<Message>(2); + auto sendMessageStanza = stanzaChannel_->getStanzaAtIndex<Message>(3); CPPUNIT_ASSERT_EQUAL(messageBody, *sendMessageStanza->getBody()); // receive reply with error @@ -1565,7 +1565,11 @@ public: uiEventStream_->send(std::make_shared<CreateImpromptuMUCUIEvent>(jids, mucJID, "")); CPPUNIT_ASSERT_EQUAL(std::string("bar@test.com, foo@test.com"), manager_->getRecentChats()[0].getTitle()); - auto mucJoinPresence = std::dynamic_pointer_cast<Presence>(stanzaChannel_->sentStanzas[2]); + // Check the MUC security marking request + auto mucInfoRequest = std::dynamic_pointer_cast<IQ>(stanzaChannel_->sentStanzas[2]); + CPPUNIT_ASSERT(mucInfoRequest); + + auto mucJoinPresence = std::dynamic_pointer_cast<Presence>(stanzaChannel_->sentStanzas[3]); CPPUNIT_ASSERT(mucJoinPresence); // MUC presence reply diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp index 1f69f4f..9b45794 100644 --- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp @@ -36,6 +36,7 @@ #include <Swift/Controllers/Chat/UserSearchController.h> #include <Swift/Controllers/Roster/GroupRosterItem.h> #include <Swift/Controllers/Roster/Roster.h> +#include <Swift/Controllers/SettingConstants.h> #include <Swift/Controllers/Settings/DummySettingsProvider.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIInterfaces/ChatWindow.h> @@ -68,6 +69,25 @@ class MUCControllerTest : public CppUnit::TestFixture { CPPUNIT_TEST(testNonImpromptuMUCWindowTitle); + CPPUNIT_TEST(testSecurityMarkingRequestCompleteMarking); + CPPUNIT_TEST(testSecurityMarkingRequestCompleteMarkingWithExtraForm); + CPPUNIT_TEST(testSecurityMarkingRequestEmptyMarking); + CPPUNIT_TEST(testSecurityMarkingRequestWithMarkingNoFormType); + CPPUNIT_TEST(testSecurityMarkingRequestNoMarking); + CPPUNIT_TEST(testSecurityMarkingRequestNoForm); + CPPUNIT_TEST(testSecurityMarkingRequestError); + + CPPUNIT_TEST(testSecurityMarkingAddedToMessage_Elision_NoRoomMarkingA); + CPPUNIT_TEST(testSecurityMarkingAddedToMessage_Elision_NoRoomMarkingB); + CPPUNIT_TEST(testSecurityMarkingAddedToMessage_Elision_WithRoomMarkingA); + CPPUNIT_TEST(testSecurityMarkingAddedToMessage_Elision_WithRoomMarkingB); + CPPUNIT_TEST(testSecurityMarkingAddedToMessage_Elision_WithRoomMarkingC); + + CPPUNIT_TEST(testSecurityMarkingAddedToMessage_NoElision_NoRoomMarkingA); + CPPUNIT_TEST(testSecurityMarkingAddedToMessage_NoElision_NoRoomMarkingB); + CPPUNIT_TEST(testSecurityMarkingAddedToMessage_NoElision_WithRoomMarkingA); + CPPUNIT_TEST(testSecurityMarkingAddedToMessage_NoElision_WithRoomMarkingB); + CPPUNIT_TEST_SUITE_END(); public: @@ -104,7 +124,7 @@ public: nickResolver_ = new NickResolver(self_, xmppRoster_, vcardManager_, mucRegistry_); clientBlockListManager_ = new ClientBlockListManager(iqRouter_); mucBookmarkManager_ = new MUCBookmarkManager(iqRouter_); - controller_ = new MUCController (self_, muc_, boost::optional<std::string>(), nick_, stanzaChannel_, iqRouter_, chatWindowFactory_, nickResolver_, presenceOracle_, avatarManager_, uiEventStream_, false, timerFactory, eventController_, entityCapsProvider_, nullptr, nullptr, mucRegistry_, highlightManager_, clientBlockListManager_, chatMessageParser_, false, nullptr, vcardManager_, mucBookmarkManager_); + controller_ = new MUCController (self_, muc_, boost::optional<std::string>(), nick_, stanzaChannel_, iqRouter_, chatWindowFactory_, nickResolver_, presenceOracle_, avatarManager_, uiEventStream_, false, timerFactory, eventController_, entityCapsProvider_, nullptr, nullptr, mucRegistry_, highlightManager_, clientBlockListManager_, chatMessageParser_, false, nullptr, vcardManager_, mucBookmarkManager_, settings_); } void tearDown() { @@ -163,6 +183,44 @@ public: } } + void setMUCSecurityMarking(const std::string& markingValue, const std::string & markingForegroundColorValue, const std::string& markingBackgroundColorValue, const bool includeFormTypeField = true) { + auto form = std::make_shared<Form>(Form::Type::ResultType); + + if (includeFormTypeField) { + std::shared_ptr<FormField> formTypeField = std::make_shared<FormField>(FormField::Type::HiddenType, "http://jabber.org/protocol/muc#roominfo"); + formTypeField->setName("FORM_TYPE"); + form->addField(formTypeField); + } + + auto markingField = std::make_shared<FormField>(FormField::Type::TextSingleType, markingValue); + auto markingForegroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, markingForegroundColorValue); + auto markingBackgroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, markingBackgroundColorValue); + + markingField->setName("x-isode#roominfo_marking"); + markingForegroundColorField->setName("x-isode#roominfo_marking_fg_color"); + markingBackgroundColorField->setName("x-isode#roominfo_marking_bg_color"); + + form->addField(markingField); + form->addField(markingForegroundColorField); + form->addField(markingBackgroundColorField); + + auto discoInfoRef = std::make_shared<DiscoInfo>(); + discoInfoRef->addExtension(form); + + auto infoResponse = IQ::createResult(self_, mucJID_, "test-id", discoInfoRef); + iqChannel_->onIQReceived(infoResponse); + } + + Message::ref createTestMessageWithoutSecurityLabel() { + auto message = std::make_shared<Message>(); + message->setType(Message::Type::Groupchat); + message->setID("test-id"); + message->setTo(self_); + message->setFrom(mucJID_.withResource("TestNickname")); + message->setBody("Do Not Read This Message"); + return message; + } + void testAddressedToSelf() { finishJoin(); Message::ref message(new Message()); @@ -593,6 +651,323 @@ public: CPPUNIT_ASSERT_EQUAL(muc_->getJID().getNode(), window_->name_); } + void testSecurityMarkingRequestCompleteMarking() { + setMUCSecurityMarking("Test|Highest Possible Security", "Black", "Red", true); + + CPPUNIT_ASSERT_EQUAL(std::string("Test|Highest Possible Security"), window_->markingValue_); + CPPUNIT_ASSERT_EQUAL(std::string("Black"), window_->markingForegroundColorValue_); + CPPUNIT_ASSERT_EQUAL(std::string("Red"), window_->markingBackgroundColorValue_); + } + + void testSecurityMarkingRequestCompleteMarkingWithExtraForm() { + auto formTypeField = std::make_shared<FormField>(FormField::Type::HiddenType, "http://jabber.org/protocol/muc#roominfo"); + auto markingField = std::make_shared<FormField>(FormField::Type::TextSingleType, "Test|Highest Possible Security"); + auto markingForegroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, "Black"); + auto markingBackgroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, "Red"); + formTypeField->setName("FORM_TYPE"); + markingField->setName("x-isode#roominfo_marking"); + markingForegroundColorField->setName("x-isode#roominfo_marking_fg_color"); + markingBackgroundColorField->setName("x-isode#roominfo_marking_bg_color"); + + auto extraForm = std::make_shared<Form>(Form::Type::ResultType); + auto form = std::make_shared<Form>(Form::Type::ResultType); + form->addField(formTypeField); + form->addField(markingField); + form->addField(markingForegroundColorField); + form->addField(markingBackgroundColorField); + + auto discoInfoRef = std::make_shared<DiscoInfo>(); + discoInfoRef->addExtension(extraForm); + discoInfoRef->addExtension(form); + + auto infoResponse = IQ::createResult(self_, mucJID_, "test-id", discoInfoRef); + iqChannel_->onIQReceived(infoResponse); + CPPUNIT_ASSERT_EQUAL(std::string("Test|Highest Possible Security"), window_->markingValue_); + CPPUNIT_ASSERT_EQUAL(std::string("Black"), window_->markingForegroundColorValue_); + CPPUNIT_ASSERT_EQUAL(std::string("Red"), window_->markingBackgroundColorValue_); + } + + void testSecurityMarkingRequestNoColorsInMarking() { + auto formTypeField = std::make_shared<FormField>(FormField::Type::HiddenType, "http://jabber.org/protocol/muc#roominfo"); + auto markingField = std::make_shared<FormField>(FormField::Type::TextSingleType, "Test|Highest Possible Security"); + auto markingForegroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, ""); + auto markingBackgroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, ""); + formTypeField->setName("FORM_TYPE"); + markingField->setName("x-isode#roominfo_marking"); + markingForegroundColorField->setName("x-isode#roominfo_marking_fg_color"); + markingBackgroundColorField->setName("x-isode#roominfo_marking_bg_color"); + + auto form = std::make_shared<Form>(Form::Type::ResultType); + form->addField(formTypeField); + form->addField(markingField); + form->addField(markingForegroundColorField); + form->addField(markingBackgroundColorField); + + auto discoInfoRef = std::make_shared<DiscoInfo>(); + discoInfoRef->addExtension(form); + + auto infoResponse = IQ::createResult(self_, mucJID_, "test-id", discoInfoRef); + iqChannel_->onIQReceived(infoResponse); + CPPUNIT_ASSERT_EQUAL(std::string("Test|Highest Possible Security"), window_->markingValue_); + CPPUNIT_ASSERT_EQUAL(std::string("Black"), window_->markingForegroundColorValue_); + CPPUNIT_ASSERT_EQUAL(std::string("White"), window_->markingBackgroundColorValue_); + } + + void testSecurityMarkingRequestEmptyMarking() { + setMUCSecurityMarking("", "", "", true); + + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingForegroundColorValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingBackgroundColorValue_); + } + + void testSecurityMarkingRequestWithMarkingNoFormType() { + setMUCSecurityMarking("Test|Highest Possible Security", "Black", "Red", false); + + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingForegroundColorValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingBackgroundColorValue_); + } + + void testSecurityMarkingRequestNoMarking() { + auto form = std::make_shared<Form>(Form::Type::ResultType); + + auto discoInfoRef = std::make_shared<DiscoInfo>(); + discoInfoRef->addExtension(form); + + auto infoResponse = IQ::createResult(self_, mucJID_, "test-id", discoInfoRef); + iqChannel_->onIQReceived(infoResponse); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingForegroundColorValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingBackgroundColorValue_); + } + + void testSecurityMarkingRequestNoForm() { + auto discoInfoRef = std::make_shared<DiscoInfo>(); + + auto infoResponse = IQ::createResult( self_, mucJID_, "test-id", discoInfoRef); + iqChannel_->onIQReceived(infoResponse); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingForegroundColorValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingBackgroundColorValue_); + } + + void testSecurityMarkingRequestError() { + auto errorPayload = std::make_shared<ErrorPayload>(ErrorPayload::Condition::NotAuthorized, ErrorPayload::Type::Auth); + + auto infoResponse = IQ::createResult( self_, mucJID_, "test-id", errorPayload); + iqChannel_->onIQReceived(infoResponse); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingForegroundColorValue_); + CPPUNIT_ASSERT_EQUAL(std::string(""), window_->markingBackgroundColorValue_); + } + + void testSecurityMarkingAddedToMessage_Elision_NoRoomMarkingA() { + settings_->storeSetting(SettingConstants::MUC_MARKING_ELISION, true); + setMUCSecurityMarking("", "Black", "Red"); + + auto messageLabel = std::make_shared<SecurityLabel>(); + messageLabel->setDisplayMarking("Test|Highest Possible Security"); + + auto sentMessage = createTestMessageWithoutSecurityLabel(); + sentMessage->addPayload(messageLabel); + + auto sentMessageEvent = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent); + + auto storedSecurityLabel = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string("Test|Highest Possible Security"), storedSecurityLabel->getDisplayMarking()); + } + + void testSecurityMarkingAddedToMessage_Elision_NoRoomMarkingB() { + settings_->storeSetting(SettingConstants::MUC_MARKING_ELISION, true); + setMUCSecurityMarking("", "Black", "Red"); + + auto messageLabel = std::make_shared<SecurityLabel>(); + messageLabel->setDisplayMarking(""); + + auto sentMessage = createTestMessageWithoutSecurityLabel(); + sentMessage->addPayload(messageLabel); + + auto sentMessageEvent = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent); + + auto storedSecurityLabel = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string(""), storedSecurityLabel->getDisplayMarking()); + } + + void testSecurityMarkingAddedToMessage_Elision_WithRoomMarkingA() { + settings_->storeSetting(SettingConstants::MUC_MARKING_ELISION, true); + setMUCSecurityMarking("Test|Highest Possible Security", "Black", "Red"); + + auto messageLabel = std::make_shared<SecurityLabel>(); + messageLabel->setDisplayMarking("Test|Highest Possible Security"); + + auto sentMessage = createTestMessageWithoutSecurityLabel(); + sentMessage->addPayload(messageLabel); + + // Test the first message matching MUC marking. This message SHOULD have a marking + + auto sentMessageEvent1 = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent1); + + auto storedSecurityLabel1 = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel1 == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string("Test|Highest Possible Security"), storedSecurityLabel1->getDisplayMarking()); + + // Test a consecutive message matching MUC marking. This message SHOULD NOT have a marking + + auto sentMessageEvent2 = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent2); + + auto storedSecurityLabel2 = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel2 == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string(""), storedSecurityLabel2->getDisplayMarking()); + } + + void testSecurityMarkingAddedToMessage_Elision_WithRoomMarkingB() { + settings_->storeSetting(SettingConstants::MUC_MARKING_ELISION, true); + setMUCSecurityMarking("Test|Lower Security Marking", "Black", "Red"); + + auto messageLabel = std::make_shared<SecurityLabel>(); + messageLabel->setDisplayMarking("Test|Highest Possible Security"); + + auto sentMessage = createTestMessageWithoutSecurityLabel(); + sentMessage->addPayload(messageLabel); + + auto sentMessageEvent = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent); + + auto storedSecurityLabel = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string("Test|Highest Possible Security"), storedSecurityLabel->getDisplayMarking()); + } + + void testSecurityMarkingAddedToMessage_Elision_WithRoomMarkingC() { + settings_->storeSetting(SettingConstants::MUC_MARKING_ELISION, true); + setMUCSecurityMarking("Test|Highest Possible Security", "Black", "Red"); + + auto messageLabel = std::make_shared<SecurityLabel>(); + messageLabel->setDisplayMarking(""); + + auto sentMessage = createTestMessageWithoutSecurityLabel(); + sentMessage->addPayload(messageLabel); + + auto sentMessageEvent = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent); + + auto storedSecurityLabel = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string("Unmarked"), storedSecurityLabel->getDisplayMarking()); + } + + void testSecurityMarkingAddedToMessage_NoElision_NoRoomMarkingA() { + settings_->storeSetting(SettingConstants::MUC_MARKING_ELISION, false); + setMUCSecurityMarking("", "Black", "Red"); + + auto messageLabel = std::make_shared<SecurityLabel>(); + messageLabel->setDisplayMarking("Test|Highest Possible Security"); + + auto sentMessage = createTestMessageWithoutSecurityLabel(); + sentMessage->addPayload(messageLabel); + + auto sentMessageEvent = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent); + + auto storedSecurityLabel = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string("Test|Highest Possible Security"), storedSecurityLabel->getDisplayMarking()); + } + + void testSecurityMarkingAddedToMessage_NoElision_NoRoomMarkingB() { + settings_->storeSetting(SettingConstants::MUC_MARKING_ELISION, false); + setMUCSecurityMarking("", "Black", "Red"); + + auto messageLabel = std::make_shared<SecurityLabel>(); + messageLabel->setDisplayMarking(""); + + auto sentMessage = createTestMessageWithoutSecurityLabel(); + sentMessage->addPayload(messageLabel); + + auto sentMessageEvent = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent); + + auto storedSecurityLabel = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string(""), storedSecurityLabel->getDisplayMarking()); + } + + void testSecurityMarkingAddedToMessage_NoElision_WithRoomMarkingA() { + settings_->storeSetting(SettingConstants::MUC_MARKING_ELISION, false); + setMUCSecurityMarking("Test|Highest Possible Security", "Black", "Red"); + + auto messageLabel = std::make_shared<SecurityLabel>(); + messageLabel->setDisplayMarking("Test|Highest Possible Security"); + + auto sentMessage = createTestMessageWithoutSecurityLabel(); + sentMessage->addPayload(messageLabel); + + // Test the first message matching MUC marking. This message SHOULD have a marking + + auto sentMessageEvent1 = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent1); + + auto storedSecurityLabel1 = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel1 == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string("Test|Highest Possible Security"), storedSecurityLabel1->getDisplayMarking()); + + // Test a consecutive message matching MUC marking. This message SHOULD ALSO have a marking + + auto sentMessageEvent2 = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent2); + + auto storedSecurityLabel2 = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel2 == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string("Test|Highest Possible Security"), storedSecurityLabel2->getDisplayMarking()); + } + + void testSecurityMarkingAddedToMessage_NoElision_WithRoomMarkingB() { + settings_->storeSetting(SettingConstants::MUC_MARKING_ELISION, false); + setMUCSecurityMarking("", "Black", "Red"); + + auto messageLabel = std::make_shared<SecurityLabel>(); + messageLabel->setDisplayMarking(""); + + auto sentMessage = createTestMessageWithoutSecurityLabel(); + sentMessage->addPayload(messageLabel); + + auto sentMessageEvent = std::make_shared<MessageEvent>(sentMessage); + controller_->handleIncomingMessage(sentMessageEvent); + + auto storedSecurityLabel = window_->lastAddedMessageSecurityLabel_; + + CPPUNIT_ASSERT_EQUAL(false, storedSecurityLabel == nullptr); + // This is the potentially altered security label that is displayed on the screen + CPPUNIT_ASSERT_EQUAL(std::string(""), storedSecurityLabel->getDisplayMarking()); + } + private: JID self_; JID mucJID_; diff --git a/Swift/Controllers/Roster/Roster.cpp b/Swift/Controllers/Roster/Roster.cpp index f6f6ce0..5b7e454 100644 --- a/Swift/Controllers/Roster/Roster.cpp +++ b/Swift/Controllers/Roster/Roster.cpp @@ -23,7 +23,7 @@ namespace Swift { -Roster::Roster(bool sortByStatus, bool fullJIDMapping) : fullJIDMapping_(fullJIDMapping), sortByStatus_(sortByStatus), root_(std::unique_ptr<GroupRosterItem>(new GroupRosterItem("Dummy-Root", nullptr, sortByStatus_))) { +Roster::Roster(bool sortByStatus, bool fullJIDMapping) : fullJIDMapping_(fullJIDMapping), sortByStatus_(sortByStatus), root_(std::make_unique<GroupRosterItem>("Dummy-Root", nullptr, sortByStatus_)) { root_->onChildrenChanged.connect(boost::bind(&Roster::handleChildrenChanged, this, root_.get())); } diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp index 1d20c4a..f5de801 100644 --- a/Swift/Controllers/Roster/RosterController.cpp +++ b/Swift/Controllers/Roster/RosterController.cpp @@ -79,7 +79,7 @@ RosterController::RosterController(const JID& jid, XMPPRoster* xmppRoster, Avata subscriptionManager_->onPresenceSubscriptionRequest.connect(boost::bind(&RosterController::handleSubscriptionRequest, this, _1, _2)); uiEventConnection_ = uiEventStream->onUIEvent.connect(boost::bind(&RosterController::handleUIEvent, this, _1)); - featureOracle_ = std::unique_ptr<FeatureOracle>(new FeatureOracle(entityCapsManager_, presenceOracle_)); + featureOracle_ = std::make_unique<FeatureOracle>(entityCapsManager_, presenceOracle_); vcardManager_->onOwnVCardChanged.connect(boost::bind(&RosterController::handleOwnVCardChanged, this, _1)); avatarManager_->onAvatarChanged.connect(boost::bind(&RosterController::handleAvatarChanged, this, _1)); diff --git a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp index 2f15fb5..9b64def 100644 --- a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp @@ -72,7 +72,7 @@ class RosterControllerTest : public CppUnit::TestFixture { mainWindowFactory_ = new MockMainWindowFactory(); mucRegistry_ = new MUCRegistry(); crypto_ = PlatformCryptoProvider::create(); - storages_ = std::unique_ptr<MemoryStorages>(new MemoryStorages(crypto_)); + storages_ = std::make_unique<MemoryStorages>(crypto_); nickResolver_ = new NickResolver(jid_.toBare(), xmppRoster_, nullptr, mucRegistry_); channel_ = new DummyIQChannel(); router_ = new IQRouter(channel_); @@ -83,7 +83,7 @@ class RosterControllerTest : public CppUnit::TestFixture { uiEventStream_ = new UIEventStream(); settings_ = new DummySettingsProvider(); nickManager_ = new DummyNickManager(); - capsManager_ = std::unique_ptr<CapsManager>(new CapsManager(storages_->getCapsStorage(), stanzaChannel_, router_, crypto_)); + capsManager_ = std::make_unique<CapsManager>(storages_->getCapsStorage(), stanzaChannel_, router_, crypto_); entityCapsManager_ = new EntityCapsManager(capsManager_.get(), stanzaChannel_); jingleSessionManager_ = new JingleSessionManager(router_); @@ -92,7 +92,7 @@ class RosterControllerTest : public CppUnit::TestFixture { vcardManager_ = new VCardManager(jid_, router_, vcardStorage_); rosterController_ = new RosterController(jid_, xmppRoster_, avatarManager_, mainWindowFactory_, nickManager_, nickResolver_, presenceOracle_, subscriptionManager_, eventController_, uiEventStream_, router_, settings_, entityCapsManager_, clientBlockListManager_, vcardManager_); mainWindow_ = mainWindowFactory_->last; - capsInfoGenerator_ = std::unique_ptr<CapsInfoGenerator>(new CapsInfoGenerator("", crypto_)); + capsInfoGenerator_ = std::make_unique<CapsInfoGenerator>("", crypto_); } void tearDown() { diff --git a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp index 5f500d4..045a5e4 100644 --- a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp @@ -30,7 +30,7 @@ class RosterTest : public CppUnit::TestFixture { jid1_ = JID("a@b.c"); jid2_ = JID("b@c.d"); jid3_ = JID("c@d.e"); - roster_ = std::unique_ptr<Roster>(new Roster()); + roster_ = std::make_unique<Roster>(); } void testGetGroup() { diff --git a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp index ddc8785..7ebce17 100644 --- a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp @@ -34,8 +34,8 @@ class TableRosterTest : public CppUnit::TestFixture { public: void setUp() { - timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory()); - roster = std::unique_ptr<Roster>(new Roster()); + timerFactory = std::make_unique<DummyTimerFactory>(); + roster = std::make_unique<Roster>(); jid1 = JID("jid1@example.com"); jid2 = JID("jid2@example.com"); } diff --git a/Swift/Controllers/SettingConstants.cpp b/Swift/Controllers/SettingConstants.cpp index f0064ba..5347d4e 100644 --- a/Swift/Controllers/SettingConstants.cpp +++ b/Swift/Controllers/SettingConstants.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017 Isode Limited. + * Copyright (c) 2012-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -24,5 +24,6 @@ const SettingsProvider::Setting<std::string> SettingConstants::HIGHLIGHT_RULES_V const SettingsProvider::Setting<std::string> SettingConstants::INVITE_AUTO_ACCEPT_MODE("inviteAutoAcceptMode", "presence"); const SettingsProvider::Setting<bool> SettingConstants::DISCONNECT_ON_CARD_REMOVAL("disconnectOnCardRemoval", true); const SettingsProvider::Setting<bool> SettingConstants::SINGLE_SIGN_ON("singleSignOn", false); +const SettingsProvider::Setting<bool> SettingConstants::MUC_MARKING_ELISION("mucMarkingElision", true); } diff --git a/Swift/Controllers/SettingConstants.h b/Swift/Controllers/SettingConstants.h index fec2d27..61781e0 100644 --- a/Swift/Controllers/SettingConstants.h +++ b/Swift/Controllers/SettingConstants.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017 Isode Limited. + * Copyright (c) 2012-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -93,5 +93,16 @@ namespace Swift { * log in the user; else not. */ static const SettingsProvider::Setting<bool> SINGLE_SIGN_ON; + /** + * The #MUC_MARKING_ELISION setting + * specifies whether or not messages with the default muc + * marking display their marking, and whether unmarked messages + * are marked as such. + * + * If set true, unmarked messages will be marked with the marking + * "unmarked", and messages with the room default marking will + * have their markings stripped. + */ + static const SettingsProvider::Setting<bool> MUC_MARKING_ELISION; }; } diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index 8273802..13cbb7d 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -33,6 +33,8 @@ namespace Swift { class ContactRosterItem; class FileTransferController; class UserSearchWindow; + class DiscoInfo; + class ErrorPayload; class ChatWindow { @@ -219,6 +221,9 @@ namespace Swift { virtual void showBookmarkWindow(const MUCBookmark& bookmark) = 0; virtual void setBookmarkState(RoomBookmarkState bookmarkState) = 0; + virtual void setChatSecurityMarking(const std::string& markingValue, const std::string& markingForegroundColorValue, const std::string& markingBackgroundColorValue) = 0; + virtual void removeChatSecurityMarking() = 0; + /** * A handle that uniquely identities an alert message. */ @@ -282,4 +287,3 @@ namespace Swift { boost::signals2::signal<void ()> onUnblockUserRequest; }; } - diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h index 7682781..389d787 100644 --- a/Swift/Controllers/UnitTest/MockChatWindow.h +++ b/Swift/Controllers/UnitTest/MockChatWindow.h @@ -17,10 +17,11 @@ namespace Swift { MockChatWindow() {} virtual ~MockChatWindow(); - virtual std::string addMessage(const ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) { + virtual std::string addMessage(const ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) { lastAddedMessage_ = message; lastAddedMessageSenderName_ = senderName; lastAddedMessageSenderIsSelf_ = senderIsSelf; + lastAddedMessageSecurityLabel_ = label; return "id"; } @@ -133,10 +134,19 @@ namespace Swift { lastAddedMessageSenderIsSelf_ = lastAddedActionSenderIsSelf_ = false; } + void setChatSecurityMarking(const std::string& markingValue, const std::string& markingForegroundColorValue, const std::string& markingBackgroundColorValue) { + markingValue_ = markingValue; + markingForegroundColorValue_ = markingForegroundColorValue; + markingBackgroundColorValue_ = markingBackgroundColorValue; + } + + void removeChatSecurityMarking() {} + std::string name_; ChatMessage lastAddedMessage_; std::string lastAddedMessageSenderName_; bool lastAddedMessageSenderIsSelf_ = false; + std::shared_ptr<SecurityLabel> lastAddedMessageSecurityLabel_ = nullptr; ChatMessage lastAddedAction_; std::string lastAddedActionSenderName_; bool lastAddedActionSenderIsSelf_ = false; @@ -154,6 +164,9 @@ namespace Swift { Roster* roster_ = nullptr; std::vector<std::pair<std::string, ReceiptState>> receiptChanges_; boost::optional<MUCType> mucType_; + std::string markingValue_; + std::string markingForegroundColorValue_; + std::string markingBackgroundColorValue_; }; } diff --git a/Swift/Packaging/WiX/Swift.wxs b/Swift/Packaging/WiX/Swift.wxs index 1e8d129..a2e8dd6 100644 --- a/Swift/Packaging/WiX/Swift.wxs +++ b/Swift/Packaging/WiX/Swift.wxs @@ -3,18 +3,29 @@ <!-- For a sensible tutorial on WiX, see http://wix.tramontana.co.hu/tutorial --> <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'> - <?include variables.wxs ?> <Product Name='Swift' Id='*' UpgradeCode='D7F276D5-BA67-421E-817B-9E7AB4B7D2BF' Language='1033' Codepage='1252' Version='$(var.Version)' Manufacturer='Swift.im'> - <Package Id='*' Keywords='Installer' Description="Swift Installer" Comments="Swift is available under the GPL version 3" Manufacturer="Swift.im" InstallerVersion='300' Languages='1033' Compressed='yes' SummaryCodepage='1252' InstallScope="perMachine"/> + <Package Id='*' Keywords='Installer' Description="Swift Installer" Comments="Swift is available under the GPL version 3" Manufacturer="Swift.im" InstallerVersion='500' Languages='1033' Compressed='yes' SummaryCodepage='1252' /> + <Property Id="ALLUSERS" Value="2" /> + <Property Id="MSIINSTALLPERUSER" Value="1" /> + <Property Id="WIXUIVCREDISTINSTALL" Value="0" /> + + <Property Id="VCREDISTINSTALLED"> + <RegistrySearch Id="VCREDISTINSTALLED" + Root="HKLM" + Key="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\$(var.MsvcDotVersion)\VC\Runtimes\$(sys.BUILDARCH)" + Name="Installed" + Type="raw" /> + + </Property> <Media Id='1' Cabinet='Swift.cab' EmbedCab='yes'/> <!-- Schedule the upgrade to afterInstallExecute means that MSI will first install the new version over the existing version and run the uninstall of the old version afterwards. This way shortcuts are not recreated on every new installation and pinned shortcuts stay alive. However this requires that the components for installed files with the same filename will always - have the same GUID (do not run heat.exe with -gg flag) or else when MSI removes the components + have the same GUID (do not run heat.exe with -gg flag) or else when MSI removes the components of the old version with the same filename as components of the new version it will delete the files that belong to components of the new version.--> <MajorUpgrade Schedule="afterInstallExecute" DowngradeErrorMessage="A newer version is already installed. Remove this version if you wish to downgrade." /> @@ -25,6 +36,9 @@ --> <Directory Id='ProgramFilesFolder' Name='PFiles'> + <Directory Id="APPLICATIONFOLDER" Name="Swift"> + </Directory> + <!--<Directory Id='INSTALLDIR' Name='Swift'> </Directory>--> </Directory> @@ -42,8 +56,11 @@ <Directory Id="DesktopFolder" Name="Desktop" /> </Directory> + <Property Id="WixAppFolder" Value="WixPerUserFolder" /> + <Feature Id='Core' Level='1' Title='Swift' Description='All necessary Swift files' Display='expand' ConfigurableDirectory='INSTALLDIR' AllowAdvertise='no' Absent='disallow'> <ComponentGroupRef Id='Files' /> + <ComponentGroupRef Id='VCFiles' /> <!--<ComponentRef Id='Manual' />--> </Feature> @@ -53,23 +70,133 @@ <!--<UIRef Id='WixUI_Advanced'/>--> <!--<UIRef Id="WixUI_Minimal"/>--> - <UIRef Id="WixUI_Mondo"/> + <!--UIRef Id="WixUI_Mondo"/--> + <UIRef Id="WixUI_Swift"/> + <WixVariable Id='WixUILicenseRtf' Value='COPYING.rtf'/> <Icon Id="Swift.exe" SourceFile="Swift.exe" /> <Property Id="ARPPRODUCTICON" Value="Swift.exe"/> <!-- The icon in the "Programs" dialog --> - <!-- - VC Redistributable + <!-- + VC Redistributable --> <Binary Id="CRTBinary" SourceFile="$(var.VCCRTFile)"/> <CustomAction Id="CRTAction" Impersonate="no" Return="asyncNoWait" Execute="deferred" BinaryKey="CRTBinary" ExeCommand="/passive"/> - + <InstallUISequence> + <!-- Suppress FindRelatedProducts untill the user selects the scope of the install --> + <FindRelatedProducts Suppress="yes" /> + </InstallUISequence> <InstallExecuteSequence> - <Custom Action='CRTAction' After='InstallInitialize'/> + <Custom Action='CRTAction' After='InstallInitialize'>(NOT VCREDISTINSTALLED AND ALLUSERS = 1) OR WIXUIVCREDISTINSTALL = 1</Custom> </InstallExecuteSequence> </Product> + <Fragment> + <DirectoryRef Id="INSTALLDIR"> + <Component Id="msvcp.dll" Guid="*"> + <Condition>(NOT (VCREDISTINSTALLED OR ALLUSERS = 1)) AND WIXUIVCREDISTINSTALL = 0 </Condition> + <File Id="msvcp$(var.MsvcVersion).dll" KeyPath="yes" Source="$(var.VCCRTPath)\msvcp$(var.MsvcVersion).dll" /> + </Component> + <Component Id="vcruntime.dll" Guid="*"> + <Condition>(NOT (VCREDISTINSTALLED OR ALLUSERS = 1)) AND WIXUIVCREDISTINSTALL = 0 </Condition> + <?if $(var.MsvcVersion) > "120"?> + <File Id="vcruntime$(var.MsvcVersion).dll" KeyPath="yes" Source="$(var.VCCRTPath)\vcruntime$(var.MsvcVersion).dll" /> + <?else?> + <File Id="msvcr$(var.MsvcVersion).dll" KeyPath="yes" Source="$(var.VCCRTPath)\msvcr$(var.MsvcVersion).dll" /> + <?endif?> + </Component> + </DirectoryRef> + </Fragment> + <Fragment> + <ComponentGroup Id="VCFiles"> + <ComponentRef Id="msvcp.dll" /> + <ComponentRef Id="vcruntime.dll" /> + </ComponentGroup> + </Fragment> + <Fragment> + + <WixVariable Id="WixUISupportPerUser" Value="1" Overridable="yes" /> + <WixVariable Id="WixUISupportPerMachine" Value="1" Overridable="yes" /> + + <!-- This is Based on WixUI_Mondo, but it adds an InstallScopeDlg dialog --> + <UI Id="WixUI_Swift"> + <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" /> + <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" /> + <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" /> + + <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" /> + <Property Id="WixUI_Mode" Value="Mondo" /> + + <DialogRef Id="ErrorDlg" /> + <DialogRef Id="FatalError" /> + <DialogRef Id="FilesInUse" /> + <DialogRef Id="MsiRMFilesInUse" /> + <DialogRef Id="PrepareDlg" /> + <DialogRef Id="ProgressDlg" /> + <DialogRef Id="ResumeDlg" /> + <DialogRef Id="UserExit" /> + + <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish> + + <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed AND NOT PATCH</Publish> + <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish> + + <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish> + <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="InstallScopeDlg" Order="2">LicenseAccepted = "1"</Publish> + + <Publish Dialog="InstallScopeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish> + <!-- override default WixAppFolder of WixPerMachineFolder as standard user won't be shown the radio group to set WixAppFolder --> + <Publish Dialog="InstallScopeDlg" Control="Next" Property="WixAppFolder" Value="WixPerUserFolder" Order="1">!(wix.WixUISupportPerUser) AND NOT Privileged</Publish> + <Publish Dialog="InstallScopeDlg" Control="Next" Property="ALLUSERS" Value="{}" Order="2">WixAppFolder = "WixPerUserFolder"</Publish> + <Publish Dialog="InstallScopeDlg" Control="Next" Property="ALLUSERS" Value="1" Order="3">WixAppFolder = "WixPerMachineFolder"</Publish> + <Publish Dialog="InstallScopeDlg" Control="Next" Property="APPLICATIONFOLDER" Value="[WixPerUserFolder]" Order="4">WixAppFolder = "WixPerUserFolder"</Publish> + <Publish Dialog="InstallScopeDlg" Control="Next" Property="APPLICATIONFOLDER" Value="[WixPerMachineFolder]" Order="5">WixAppFolder = "WixPerMachineFolder"</Publish> + <Publish Dialog="InstallScopeDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg">1</Publish> + <!-- After selecting the scope of the installation, run FindRelatedProducts to find previous versions that needs upgrading --> + <Publish Dialog="InstallScopeDlg" Control="Next" Event="DoAction" Value="FindRelatedProducts" Order="6">1</Publish> + + <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="InstallScopeDlg">1</Publish> + <Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VCResdistDialog">NOT VCREDISTINSTALLED AND NOT ALLUSERS </Publish> + <Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="CustomizeDlg">NOT VCREDISTINSTALLED AND NOT ALLUSERS </Publish> + <Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="VCResdistDialog">NOT VCREDISTINSTALLED AND NOT ALLUSERS </Publish> + <Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VerifyReadyDlg">VCREDISTINSTALLED OR ALLUSERS = 1</Publish> + <Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="CustomizeDlg">VCREDISTINSTALLED OR ALLUSERS = 1</Publish> + <Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="VerifyReadyDlg">VCREDISTINSTALLED OR ALLUSERS = 1</Publish> + + <Dialog Id="VCResdistDialog" Width="260" Height="85" Title="[ProductName] Setup"> + <Control Id="VcRredistNo" Type="PushButton" X="132" Y="57" Width="56" Height="17" Default="yes" Cancel="yes" Text="!(loc.WixUINo)"> + <Publish Property="WIXUIVCREDISTINSTALL" Value="0">1</Publish> + <Publish Event="NewDialog" Value="VerifyReadyDlg">1</Publish> + </Control> + <Control Id="VcRredistYes" Type="PushButton" X="72" Y="57" Width="56" Height="17" Text="!(loc.WixUIYes)"> + <Publish Property="WIXUIVCREDISTINSTALL" Value="1">1</Publish> + <Publish Event="NewDialog" Value="VerifyReadyDlg">1</Publish> + </Control> + <Control Id="Text" Type="Text" X="48" Y="15" Width="194" Height="30" NoPrefix="yes" Text="Visual Studio redistributables installation was not found on your computer. Would you like Swift to install them?" /> + <Control Id="Icon" Type="Icon" X="15" Y="15" Width="24" Height="24" ToolTip="!(loc.CancelDlgIconTooltip)" FixedSize="yes" IconSize="32" Text="!(loc.CancelDlgIcon)" /> + </Dialog> + + <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">WixUI_InstallMode = "Change"</Publish> + <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallCustom"</Publish> + <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VCResdistDialog" Order="1">NOT VCREDISTINSTALLED AND NOT ALLUSERS</Publish> + <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="2">VCREDISTINSTALLED OR ALLUSERS = 1</Publish> + + <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="1">WixUI_InstallMode = "InstallCustom"</Publish> + <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallTypical" OR WixUI_InstallMode = "InstallComplete"</Publish> + <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="3">WixUI_InstallMode = "Change"</Publish> + <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="4">WixUI_InstallMode = "Repair" OR WixUI_InstallMode = "Remove"</Publish> + <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">WixUI_InstallMode = "Update"</Publish> + + <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish> + + <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish> + <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish> + <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish> + <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish> + </UI> + <UIRef Id="WixUI_Common" /> + </Fragment> </Wix> diff --git a/Swift/Packaging/WiX/Swift_en-us.wxl b/Swift/Packaging/WiX/Swift_en-us.wxl new file mode 100644 index 0000000..780b290 --- /dev/null +++ b/Swift/Packaging/WiX/Swift_en-us.wxl @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization"> + <String Id="InstallScopeDlgPerUserDescription">[ProductName] will be installed in a user folder and auto-updates will be enabled. The application be installed only for your user and you do not need to be an Administrator. </String> +</WixLocalization> diff --git a/Swift/QtUI/FlowLayout.h b/Swift/QtUI/FlowLayout.h index 1453d45..29d527f 100644 --- a/Swift/QtUI/FlowLayout.h +++ b/Swift/QtUI/FlowLayout.h @@ -59,7 +59,7 @@ class FlowLayout : public QLayout public: explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); - ~FlowLayout(); + ~FlowLayout() override; void addItem(QLayoutItem *item) override; int horizontalSpacing() const; diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 874f710..5981f9c 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -111,7 +111,7 @@ QtChatWindow::QtChatWindow(const QString& contact, QtChatTheme* theme, UIEventSt messageLog_ = new QtPlainChatView(this, eventStream_); } else { - messageLog_ = new QtWebKitChatView(this, eventStream_, theme, this); // I accept that passing the ChatWindow in so that the view can call the signals is somewhat inelegant, but it saves a lot of boilerplate. This patch is unpleasant enough already. So let's fix this soon (it at least needs fixing by the time history is sorted), but not now. + messageLog_ = new QtWebKitChatView(this, eventStream_, theme, this, settings); // I accept that passing the ChatWindow in so that the view can call the signals is somewhat inelegant, but it saves a lot of boilerplate. This patch is unpleasant enough already. So let's fix this soon (it at least needs fixing by the time history is sorted), but not now. } logRosterSplitter_->addWidget(messageLog_); @@ -693,7 +693,7 @@ void QtChatWindow::handleEmojisButtonClicked() { emojisLayout->setContentsMargins(style()->pixelMetric(QStyle::PM_MenuHMargin),style()->pixelMetric(QStyle::PM_MenuVMargin), style()->pixelMetric(QStyle::PM_MenuHMargin),style()->pixelMetric(QStyle::PM_MenuVMargin)); emojisLayout->addWidget(emojisGrid_); - emojisMenu_ = std::unique_ptr<QMenu>(new QMenu()); + emojisMenu_ = std::make_unique<QMenu>(); emojisMenu_->setLayout(emojisLayout); emojisMenu_->adjustSize(); @@ -984,4 +984,46 @@ void QtChatWindow::setBookmarkState(RoomBookmarkState bookmarkState) { roomBookmarkState_ = bookmarkState; } +void QtChatWindow::setChatSecurityMarking(const std::string& markingValue, const std::string& markingForegroundColorValue, const std::string& markingBackgroundColorValue) { + auto layout = static_cast<QBoxLayout*>(this->layout()); + + if (securityMarkingLayout_) { + layout->removeItem(securityMarkingLayout_); + securityMarkingLayout_->removeWidget(securityMarkingDisplay_); + delete securityMarkingLayout_; + } + delete securityMarkingDisplay_; + + securityMarkingLayout_ = new QHBoxLayout(); + securityMarkingDisplay_ = new QLabel(P2QSTRING(markingValue)); + + securityMarkingLayout_->addWidget(securityMarkingDisplay_); + layout->insertLayout(1, securityMarkingLayout_); + + auto palette = securityMarkingDisplay_->palette(); + palette.setColor(securityMarkingDisplay_->foregroundRole(), P2QSTRING(markingForegroundColorValue)); + palette.setColor(securityMarkingDisplay_->backgroundRole(), P2QSTRING(markingBackgroundColorValue)); + + securityMarkingDisplay_->setPalette(palette); + securityMarkingDisplay_->setContentsMargins(4,4,4,4); + securityMarkingDisplay_->setAutoFillBackground(true); + securityMarkingDisplay_->setAlignment(Qt::AlignCenter); +} + +void QtChatWindow::removeChatSecurityMarking() { + if (!securityMarkingLayout_) { + return; + } + + auto layout = static_cast<QBoxLayout*>(this->layout()); + + layout->removeItem(securityMarkingLayout_); + securityMarkingLayout_->removeWidget(securityMarkingDisplay_); + + delete securityMarkingDisplay_; + delete securityMarkingLayout_; + securityMarkingDisplay_ = nullptr; + securityMarkingLayout_ = nullptr; +} + } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index 361d7c6..4e10053 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -194,6 +194,9 @@ namespace Swift { void resetDayChangeTimer(); + void setChatSecurityMarking(const std::string& markingValue, const std::string& markingForegroundColorValue, const std::string& markingBackgroundColorValue); + void removeChatSecurityMarking(); + private: int unreadCount_; bool contactIsTyping_; @@ -241,5 +244,7 @@ namespace Swift { QPointer<QtEmojisSelector> emojisGrid_; std::map<std::string, std::string> emoticonsMap_; QTimer* dayChangeTimer = nullptr; + QHBoxLayout* securityMarkingLayout_ = nullptr; + QLabel* securityMarkingDisplay_ = nullptr; }; } diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp index 77a7f12..983d0e9 100644 --- a/Swift/QtUI/QtHistoryWindow.cpp +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -49,7 +49,7 @@ QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* even idCounter_ = 0; delete ui_.conversation_; - conversation_ = new QtWebKitChatView(nullptr, nullptr, theme_, this, true); // Horrible unsafe. Do not do this. FIXME + conversation_ = new QtWebKitChatView(nullptr, nullptr, theme_, this, settings, true); // Horrible unsafe. Do not do this. FIXME QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(80); sizePolicy.setVerticalStretch(0); diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp index ea9a9c6..f3d23e7 100644 --- a/Swift/QtUI/QtWebKitChatView.cpp +++ b/Swift/QtUI/QtWebKitChatView.cpp @@ -28,6 +28,8 @@ #include <Swiften/Base/Log.h> #include <Swiften/StringCodecs/Base64.h> +#include <Swift/Controllers/SettingConstants.h> +#include <Swift/Controllers/Settings/SettingsProvider.h> #include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> @@ -56,7 +58,7 @@ namespace { const double minimalFontScaling = 0.7; } -QtWebKitChatView::QtWebKitChatView(QtChatWindow* window, UIEventStream* eventStream, QtChatTheme* theme, QWidget* parent, bool disableAutoScroll) : QtChatView(parent), window_(window), eventStream_(eventStream), fontSizeSteps_(0), disableAutoScroll_(disableAutoScroll), previousMessageKind_(PreviosuMessageWasNone), previousMessageWasSelf_(false), showEmoticons_(false), insertingLastLine_(false), idCounter_(0) { +QtWebKitChatView::QtWebKitChatView(QtChatWindow* window, UIEventStream* eventStream, QtChatTheme* theme, QWidget* parent, SettingsProvider* settings, bool disableAutoScroll /*= false*/) : QtChatView(parent), window_(window), eventStream_(eventStream), fontSizeSteps_(0), disableAutoScroll_(disableAutoScroll), previousMessageKind_(PreviosuMessageWasNone), previousMessageWasSelf_(false), showEmoticons_(false), insertingLastLine_(false), idCounter_(0), settings_(settings) { theme_ = theme; QVBoxLayout* mainLayout = new QVBoxLayout(this); @@ -555,10 +557,13 @@ std::string QtWebKitChatView::addMessage( QString scaledAvatarPath = QtScaledAvatarCache(32).getScaledAvatarPath(avatarPath.c_str()); + std::string messageMarkingValue = ""; + QString htmlString; if (label) { + messageMarkingValue = label->getDisplayMarking(); htmlString = QString("<span style=\"border: thin dashed grey; padding-left: .5em; padding-right: .5em; color: %1; background-color: %2; font-size: 90%; margin-right: .5em; \" class='swift_label'>").arg(QtUtilities::htmlEscape(P2QSTRING(label->getForegroundColor()))).arg(QtUtilities::htmlEscape(P2QSTRING(label->getBackgroundColor()))); - htmlString += QString("%1</span> ").arg(QtUtilities::htmlEscape(P2QSTRING(label->getDisplayMarking()))); + htmlString += QString("%1</span> ").arg(QtUtilities::htmlEscape(P2QSTRING(messageMarkingValue))); } QString styleSpanStart = style == "" ? "" : "<span style=\"" + style + "\">"; @@ -569,7 +574,7 @@ std::string QtWebKitChatView::addMessage( QString highlightSpanEnd = highlightWholeMessage ? "</span>" : ""; htmlString += "<span class='swift_inner_message'>" + styleSpanStart + highlightSpanStart + message + highlightSpanEnd + styleSpanEnd + "</span>" ; - bool appendToPrevious = appendToPreviousCheck(PreviousMessageWasMessage, senderName, senderIsSelf); + bool appendToPrevious = appendToPreviousCheck(PreviousMessageWasMessage, senderName, senderIsSelf, label); QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.svg" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded(); std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++); @@ -578,6 +583,7 @@ std::string QtWebKitChatView::addMessage( previousMessageWasSelf_ = senderIsSelf; previousSenderName_ = P2QSTRING(senderName); previousMessageKind_ = PreviousMessageWasMessage; + previousMessageDisplayMarking_ = messageMarkingValue; return id; } @@ -978,12 +984,19 @@ void QtWebKitChatView::setMessageReceiptState(const std::string& id, ChatWindow: setReceiptXML(P2QSTRING(id), xml); } -bool QtWebKitChatView::appendToPreviousCheck(PreviousMessageKind messageKind, const std::string& senderName, bool senderIsSelf) { +bool QtWebKitChatView::appendToPreviousCheck(PreviousMessageKind messageKind, const std::string& senderName, bool senderIsSelf, const std::shared_ptr<SecurityLabel>& label /*=nullptr*/) { bool result = previousMessageKind_ == messageKind && ((senderIsSelf && previousMessageWasSelf_) || (!senderIsSelf && !previousMessageWasSelf_&& previousSenderName_ == P2QSTRING(senderName))); if (insertingLastLine_) { insertingLastLine_ = false; return false; } + if (settings_->getSetting(SettingConstants::MUC_MARKING_ELISION)) { + if (label && label->getDisplayMarking() != previousMessageDisplayMarking_) { + if (label->getDisplayMarking() != "") { + return false; + } + } + } return result; } diff --git a/Swift/QtUI/QtWebKitChatView.h b/Swift/QtUI/QtWebKitChatView.h index 802c216..a2eafe6 100644 --- a/Swift/QtUI/QtWebKitChatView.h +++ b/Swift/QtUI/QtWebKitChatView.h @@ -13,8 +13,6 @@ #include <QWebElement> #include <QWidget> -#include <Swiften/Base/Override.h> - #include <Swift/Controllers/UIInterfaces/ChatWindow.h> #include <Swift/QtUI/ChatSnippet.h> @@ -30,6 +28,7 @@ namespace Swift { class QtChatWindowJSBridge; class UIEventStream; class QtChatWindow; + class SettingsProvider; class QtWebKitChatView : public QtChatView { Q_OBJECT @@ -44,42 +43,42 @@ namespace Swift { static const QString ButtonFileTransferOpenFile; static const QString ButtonMUCInvite; public: - QtWebKitChatView(QtChatWindow* window, UIEventStream* eventStream, QtChatTheme* theme, QWidget* parent, bool disableAutoScroll = false); - ~QtWebKitChatView(); + QtWebKitChatView(QtChatWindow* window, UIEventStream* eventStream, QtChatTheme* theme, QWidget* parent, SettingsProvider* settings, bool disableAutoScroll = false); + ~QtWebKitChatView() override; /** Add message to window. * @return id of added message (for acks). */ - virtual std::string addMessage(const ChatWindow::ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time) SWIFTEN_OVERRIDE; + virtual std::string addMessage(const ChatWindow::ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time) override; /** Adds action to window. * @return id of added message (for acks); */ - virtual std::string addAction(const ChatWindow::ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time) SWIFTEN_OVERRIDE; - - virtual std::string addSystemMessage(const ChatWindow::ChatMessage& message, ChatWindow::Direction direction) SWIFTEN_OVERRIDE; - virtual void addPresenceMessage(const ChatWindow::ChatMessage& message, ChatWindow::Direction direction) SWIFTEN_OVERRIDE; - - virtual void addErrorMessage(const ChatWindow::ChatMessage& message) SWIFTEN_OVERRIDE; - virtual void replaceMessage(const ChatWindow::ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time) SWIFTEN_OVERRIDE; - virtual void replaceSystemMessage(const ChatWindow::ChatMessage& message, const std::string& id, ChatWindow::TimestampBehaviour timestampBehaviour) SWIFTEN_OVERRIDE; - virtual void replaceWithAction(const ChatWindow::ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time) SWIFTEN_OVERRIDE; - virtual void replaceLastMessage(const ChatWindow::ChatMessage& message, const ChatWindow::TimestampBehaviour timestampBehaviour) SWIFTEN_OVERRIDE; - virtual void setAckState(const std::string& id, ChatWindow::AckState state) SWIFTEN_OVERRIDE; - - virtual std::string addFileTransfer(const std::string& senderName, const std::string& avatarPath, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes, const std::string& description) SWIFTEN_OVERRIDE; - virtual void setFileTransferProgress(std::string, const int percentageDone) SWIFTEN_OVERRIDE; - virtual void setFileTransferStatus(std::string, const ChatWindow::FileTransferState state, const std::string& msg = "") SWIFTEN_OVERRIDE; - virtual void addMUCInvitation(const std::string& senderName, const JID& jid, const std::string& reason, const std::string& password, bool direct, bool isImpromptu, bool isContinuation) SWIFTEN_OVERRIDE; - virtual std::string addWhiteboardRequest(const QString& contact, bool senderIsSelf) SWIFTEN_OVERRIDE; - virtual void setWhiteboardSessionStatus(const std::string& id, const ChatWindow::WhiteboardSessionState state) SWIFTEN_OVERRIDE; - virtual void setMessageReceiptState(const std::string& id, ChatWindow::ReceiptState state) SWIFTEN_OVERRIDE; - - virtual void showEmoticons(bool show) SWIFTEN_OVERRIDE; + virtual std::string addAction(const ChatWindow::ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time) override; + + virtual std::string addSystemMessage(const ChatWindow::ChatMessage& message, ChatWindow::Direction direction) override; + virtual void addPresenceMessage(const ChatWindow::ChatMessage& message, ChatWindow::Direction direction) override; + + virtual void addErrorMessage(const ChatWindow::ChatMessage& message) override; + virtual void replaceMessage(const ChatWindow::ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time) override; + virtual void replaceSystemMessage(const ChatWindow::ChatMessage& message, const std::string& id, ChatWindow::TimestampBehaviour timestampBehaviour) override; + virtual void replaceWithAction(const ChatWindow::ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time) override; + virtual void replaceLastMessage(const ChatWindow::ChatMessage& message, const ChatWindow::TimestampBehaviour timestampBehaviour) override; + virtual void setAckState(const std::string& id, ChatWindow::AckState state) override; + + virtual std::string addFileTransfer(const std::string& senderName, const std::string& avatarPath, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes, const std::string& description) override; + virtual void setFileTransferProgress(std::string, const int percentageDone) override; + virtual void setFileTransferStatus(std::string, const ChatWindow::FileTransferState state, const std::string& msg = "") override; + virtual void addMUCInvitation(const std::string& senderName, const JID& jid, const std::string& reason, const std::string& password, bool direct, bool isImpromptu, bool isContinuation) override; + virtual std::string addWhiteboardRequest(const QString& contact, bool senderIsSelf) override; + virtual void setWhiteboardSessionStatus(const std::string& id, const ChatWindow::WhiteboardSessionState state) override; + virtual void setMessageReceiptState(const std::string& id, ChatWindow::ReceiptState state) override; + + virtual void showEmoticons(bool show) override; void addMessageTop(std::shared_ptr<ChatSnippet> snippet); void addMessageBottom(std::shared_ptr<ChatSnippet> snippet); int getSnippetPositionByDate(const QDate& date); // FIXME : This probably shouldn't have been public - virtual void addLastSeenLine() SWIFTEN_OVERRIDE; + virtual void addLastSeenLine() override; private: // previously public, now private void replaceLastMessage(const QString& newMessage, const ChatWindow::TimestampBehaviour timestampBehaviour); @@ -116,9 +115,9 @@ namespace Swift { void resetTopInsertPoint(); void increaseFontSize(int numSteps = 1); void decreaseFontSize(); - virtual void resizeFont(int fontSizeSteps) SWIFTEN_OVERRIDE; - virtual void scrollToBottom() SWIFTEN_OVERRIDE; - virtual void handleKeyPressEvent(QKeyEvent* event) SWIFTEN_OVERRIDE; + virtual void resizeFont(int fontSizeSteps) override; + virtual void scrollToBottom() override; + virtual void handleKeyPressEvent(QKeyEvent* event) override; private slots: void handleViewLoadFinished(bool); @@ -152,7 +151,7 @@ namespace Swift { const boost::posix_time::ptime& time, const QString& style, const HighlightAction& highlight); - bool appendToPreviousCheck(PreviousMessageKind messageKind, const std::string& senderName, bool senderIsSelf); + bool appendToPreviousCheck(PreviousMessageKind messageKind, const std::string& senderName, bool senderIsSelf, const std::shared_ptr<SecurityLabel>& label = nullptr); static ChatSnippet::Direction getActualDirection(const ChatWindow::ChatMessage& message, ChatWindow::Direction direction); QString getHighlightSpanStart(const std::string& text, const std::string& background); QString getHighlightSpanStart(const HighlightAction& highlight); @@ -160,7 +159,7 @@ namespace Swift { static QString buildChatWindowButton(const QString& name, const QString& id, const QString& arg1 = QString(), const QString& arg2 = QString(), const QString& arg3 = QString(), const QString& arg4 = QString(), const QString& arg5 = QString()); protected: - void resizeEvent(QResizeEvent* event) SWIFTEN_OVERRIDE; + void resizeEvent(QResizeEvent* event) override; private: void headerEncode(); @@ -191,5 +190,7 @@ namespace Swift { QString previousSenderName_; std::map<QString, QString> descriptions_; std::map<QString, QString> filePaths_; + std::string previousMessageDisplayMarking_; + SettingsProvider* settings_ = nullptr; }; } diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 54f0450..3755187 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -478,9 +478,16 @@ if env["PLATFORM"] == "win32" : outfile.close() infile.close() copying = env.Command(["Swift/COPYING.rtf"], ["COPYING"], convertToRTF) + if env.get("vcredistdir", "") : + vcredistdir = os.path.dirname(env["vcredistdir"]) + else: + vcredistdir = os.path.dirname(env["vcredist"])+"\\..\\" + ("x86" if env["win_target_arch"] == "x86" else "x64") + "\\Microsoft.VC"+env.get("MSVC_VERSION", "").replace(".","")[:3]+".CRT\\" wixvariables = { 'VCCRTFile': env["vcredist"], - 'Version': str(myenv["SWIFT_VERSION_MAJOR"]) + "." + str(myenv["SWIFT_VERSION_MINOR"]) + "." + str(myenv["SWIFT_VERSION_PATCH"]) + 'VCCRTPath': vcredistdir, + 'Version': str(myenv["SWIFT_VERSION_MAJOR"]) + "." + str(myenv["SWIFT_VERSION_MINOR"]) + "." + str(myenv["SWIFT_VERSION_PATCH"]), + 'MsvcVersion': str(env.get("MSVC_VERSION", "").replace(".","")[:3]), + 'MsvcDotVersion': str(env.get("MSVC_VERSION", "")[:4]) } wixincludecontent = "<Include>" for key in wixvariables: diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.h b/Swift/QtUI/UserSearch/QtUserSearchWindow.h index 0714ac1..d487a91 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.h +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.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,8 +10,6 @@ #include <QWizard> -#include <Swiften/Base/Override.h> - #include <Swift/Controllers/UIInterfaces/UserSearchWindow.h> #include <Swift/QtUI/UserSearch/ui_QtUserSearchWizard.h> @@ -33,34 +31,34 @@ namespace Swift { Q_OBJECT public: QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type, const std::set<std::string>& groups, SettingsProvider* settingsProvider); - virtual ~QtUserSearchWindow(); + virtual ~QtUserSearchWindow() override; - virtual void addSavedServices(const std::vector<JID>& services) SWIFTEN_OVERRIDE; + virtual void addSavedServices(const std::vector<JID>& services) override; - virtual void clear() SWIFTEN_OVERRIDE; - virtual void show() SWIFTEN_OVERRIDE; - virtual void setResults(const std::vector<UserSearchResult>& results) SWIFTEN_OVERRIDE; - virtual void setResultsForm(Form::ref results) SWIFTEN_OVERRIDE; - virtual void setSelectedService(const JID& jid) SWIFTEN_OVERRIDE; - virtual void setServerSupportsSearch(bool error) SWIFTEN_OVERRIDE; - virtual void setSearchError(bool error) SWIFTEN_OVERRIDE; - virtual void setSearchFields(std::shared_ptr<SearchPayload> fields) SWIFTEN_OVERRIDE; - virtual void setNameSuggestions(const std::vector<std::string>& suggestions) SWIFTEN_OVERRIDE; - virtual void prepopulateJIDAndName(const JID& jid, const std::string& name) SWIFTEN_OVERRIDE; - virtual void setContactSuggestions(const std::vector<Contact::ref>& suggestions) SWIFTEN_OVERRIDE; - virtual void setJIDs(const std::vector<JID> &jids) SWIFTEN_OVERRIDE; - virtual void setOriginator(const JID& originator) SWIFTEN_OVERRIDE; - virtual void setRoomJID(const JID &roomJID) SWIFTEN_OVERRIDE; - virtual std::string getReason() const SWIFTEN_OVERRIDE; - virtual std::vector<JID> getJIDs() const SWIFTEN_OVERRIDE; - virtual void setCanStartImpromptuChats(bool supportsImpromptu) SWIFTEN_OVERRIDE; - virtual void updateContacts(const std::vector<Contact::ref> &contacts) SWIFTEN_OVERRIDE; - virtual void addContacts(const std::vector<Contact::ref>& contacts) SWIFTEN_OVERRIDE; - virtual void setCanSupplyDescription(bool allowed) SWIFTEN_OVERRIDE; - virtual void setWarning(const boost::optional<std::string>& message) SWIFTEN_OVERRIDE; + virtual void clear() override; + virtual void show() override; + virtual void setResults(const std::vector<UserSearchResult>& results) override; + virtual void setResultsForm(Form::ref results) override; + virtual void setSelectedService(const JID& jid) override; + virtual void setServerSupportsSearch(bool error) override; + virtual void setSearchError(bool error) override; + virtual void setSearchFields(std::shared_ptr<SearchPayload> fields) override; + virtual void setNameSuggestions(const std::vector<std::string>& suggestions) override; + virtual void prepopulateJIDAndName(const JID& jid, const std::string& name) override; + virtual void setContactSuggestions(const std::vector<Contact::ref>& suggestions) override; + virtual void setJIDs(const std::vector<JID> &jids) override; + virtual void setOriginator(const JID& originator) override; + virtual void setRoomJID(const JID &roomJID) override; + virtual std::string getReason() const override; + virtual std::vector<JID> getJIDs() const override; + virtual void setCanStartImpromptuChats(bool supportsImpromptu) override; + virtual void updateContacts(const std::vector<Contact::ref> &contacts) override; + virtual void addContacts(const std::vector<Contact::ref>& contacts) override; + virtual void setCanSupplyDescription(bool allowed) override; + virtual void setWarning(const boost::optional<std::string>& message) override; protected: - virtual int nextId() const SWIFTEN_OVERRIDE; + virtual int nextId() const override; private slots: void handleFirstPageRadioChange(); 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))); +} |