diff options
-rw-r--r-- | .appveyor.yml | 9 | ||||
-rw-r--r-- | .travis.yml | 14 | ||||
m--------- | 3rdparty/libQtOlm | 0 | ||||
-rw-r--r-- | examples/qmc-example.cpp | 6 | ||||
-rw-r--r-- | lib/converters.h | 32 |
5 files changed, 44 insertions, 17 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index 4e2d4b5d..f596b856 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,14 +1,13 @@ -image: Visual Studio 2015 +image: Visual Studio 2017 environment: #DEPLOY_DIR: libqmatrixclient-%APPVEYOR_BUILD_VERSION% matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - QTDIR: C:\Qt\5.9\msvc2017_64 + - QTDIR: C:\Qt\5.12\msvc2017_64 VCVARS: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat" PLATFORM: - - QTDIR: C:\Qt\5.9\msvc2015 - VCVARS: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat" + - QTDIR: C:\Qt\5.12\msvc2017 + VCVARS: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvars32.bat" PLATFORM: x86 init: diff --git a/.travis.yml b/.travis.yml index 6880844b..d02c5058 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: cpp +dist: xenial git: depth: false @@ -14,19 +15,18 @@ addons: apt: sources: - ubuntu-toolchain-r-test - - sourceline: 'ppa:beineri/opt-qt571-trusty' + - sourceline: 'ppa:beineri/opt-qt597-xenial' packages: - ninja-build - - g++-5 - - qt57base - - qt57multimedia + - libgl1-mesa-dev # Forgotten Qt dep + - qt59base + - qt59multimedia - valgrind matrix: include: - os: linux compiler: gcc - env: [ 'ENV_EVAL="CC=gcc-5 && CXX=g++-5"' ] - os: linux compiler: clang - os: osx @@ -40,7 +40,9 @@ matrix: before_install: - eval "${ENV_EVAL}" -- if [ "$TRAVIS_OS_NAME" = "linux" ]; then USE_NINJA="-GNinja"; VALGRIND="valgrind $VALGRIND_OPTIONS"; . /opt/qt57/bin/qt57-env.sh; fi +- if [ "$TRAVIS_OS_NAME" = "linux" ]; then USE_NINJA="-GNinja"; . /opt/qt59/bin/qt59-env.sh; fi +# Switching off temporarily due to broken Valgrind being installed in xenial container. +#- if [ "$TRAVIS_OS_NAME" = "linux" ]; then VALGRIND="valgrind $VALGRIND_OPTIONS"; fi install: - pushd 3rdparty/libQtOlm diff --git a/3rdparty/libQtOlm b/3rdparty/libQtOlm -Subproject f610197ba38ef87bbab8bcff1053bda684a5994 +Subproject 8b7040c3e1213563f41ead669fbb368322e4e36 diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp index bd9190b9..e97c7812 100644 --- a/examples/qmc-example.cpp +++ b/examples/qmc-example.cpp @@ -180,10 +180,8 @@ void QMCTest::doTests() void QMCTest::loadMembers() { running.push_back("Loading members"); - // The dedicated qmc-test room is too small to test - // lazy-loading-then-full-loading; use #qmatrixclient:matrix.org instead. - // TODO: #264 - auto* r = c->room(QStringLiteral("!PCzUtxtOjUySxSelof:matrix.org")); + auto* r = c->roomByAlias(QStringLiteral("#quotient:matrix.org"), + JoinState::Join); if (!r) { cout << "#test:matrix.org is not found in the test user's rooms" << endl; diff --git a/lib/converters.h b/lib/converters.h index af2be645..5f00dc43 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -107,6 +107,10 @@ namespace QMatrixClient return JsonConverter<T>::load(jd); } + // Convenience fromJson() overloads that deduce T instead of requiring + // the coder to explicitly type it. They still enforce the + // overwrite-everything semantics of fromJson(), unlike fillFromJson() + template <typename T> inline void fromJson(const QJsonValue& jv, T& pod) { @@ -357,7 +361,8 @@ namespace QMatrixClient q.addQueryItem(it.key(), it.value().toString()); } - // This one is for types that don't have isEmpty() + // This one is for types that don't have isEmpty() and for all types + // when Force is true template <typename ValT, bool Force = true, typename = bool> struct AddNode { @@ -369,7 +374,7 @@ namespace QMatrixClient } }; - // This one is for types that have isEmpty() + // This one is for types that have isEmpty() when Force is false template <typename ValT> struct AddNode<ValT, false, decltype(std::declval<ValT>().isEmpty())> @@ -420,6 +425,29 @@ namespace QMatrixClient static constexpr bool IfNotEmpty = false; + /*! Add a key-value pair to QJsonObject or QUrlQuery + * + * Adds a key-value pair(s) specified by \p key and \p value to + * \p container, optionally (in case IfNotEmpty is passed for the first + * template parameter) taking into account the value "emptiness". + * With IfNotEmpty, \p value is NOT added to the container if and only if: + * - it has a method `isEmpty()` and `value.isEmpty() == true`, or + * - it's an `Omittable<>` and `value.omitted() == true`. + * + * If \p container is a QUrlQuery, an attempt to fit \p value into it is + * made as follows: + * - if \p value is a QJsonObject, \p key is ignored and pairs from \p value + * are copied to \p container, assuming that the value in each pair + * is a string; + * - if \p value is a QStringList, it is "exploded" into a list of key-value + * pairs with key equal to \p key and value taken from each list item; + * - if \p value is a bool, its OpenAPI (i.e. JSON) representation is added + * to the query (`true` or `false`, respectively). + * + * \tparam Force add the pair even if the value is empty. This is true + * by default; passing IfNotEmpty or false for this parameter + * enables emptiness checks as described above + */ template <bool Force = true, typename ContT, typename ValT> inline void addParam(ContT& container, const QString& key, ValT&& value) { |