diff --git a/CMakeLists.txt b/CMakeLists.txt index 456bf59e..c734b6a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set( CACHE FILEPATH "Default toolchain" ) -set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard") +set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ standard") set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Require C++ standard to be supported") set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "compile as PIC by default") set(CMAKE_AUTOMOC ON) @@ -582,7 +582,7 @@ if(USE_BUNDLED_MTXCLIENT) FetchContent_Declare( MatrixClient GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git - GIT_TAG 251dc12469ecd96d0ec491551589b244f12d6d92 + GIT_TAG 8dd9214f622fe5f307249b37029c17f1fdff25ab ) set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") diff --git a/README.md b/README.md index 33cf70a7..87044be7 100644 --- a/README.md +++ b/README.md @@ -245,7 +245,7 @@ sharing easier. - [libnice](https://gitlab.freedesktop.org/libnice/libnice) - XCB, XCB-EWMH: For screensharing support on X11. VOIP needs to be enabled. Can be disabled with `-DSCREENSHARE_X11=OFF`. - [qtkeychain](https://github.com/frankosterfeld/qtkeychain) (You need at least version 0.12 for proper Gnome Keychain support. The bundled version requires libsecret, unless you pass `-DLIBSECRET_SUPPORT=OFF`.) -- A compiler that supports C++ 17: +- A compiler that supports C++ 20: - Clang 6 (tested on Travis CI) - GCC 7 (tested on Travis CI) - MSVC 19.13 (tested on AppVeyor) @@ -346,12 +346,11 @@ brew install qt5 lmdb cmake llvm spdlog boost cmark libolm qtkeychain ##### Windows -1. Install Visual Studio 2017's "Desktop Development" and "Linux Development with C++" +1. Install Visual Studio 2022's "Desktop Development" and "Linux Development with C++" (for the CMake integration) workloads. 2. Download the latest Qt for windows installer and install it somewhere. -Make sure to install the `MSVC 2017 64-bit` toolset for at least Qt 5.10 -(lower versions does not support VS2017). +Make sure to install the `MSVC 2022 64-bit` toolset for at least Qt 5.15. 3. If you don't have openssl installed, you will need to install perl to build it (i.e. Strawberry Perl). diff --git a/appveyor.yml b/appveyor.yml index f0930d19..6a08f555 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ version: 0.10.1-{build} configuration: Release -image: Visual Studio 2019 +image: Visual Studio 2022 platform: x64 environment: @@ -23,9 +23,7 @@ build: install: - set QT_DIR=C:\Qt\5.15\msvc2019_64 - - set PATH=Path=C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files\Git\cmd;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\PowerShell\7\;C:\Program Files\7-Zip;C:\Program Files\Microsoft\Web Platform Installer\;C:\Tools\NuGet;C:\Tools\PsTools;C:\Program Files\Git\usr\bin;C:\Program Files\Git LFS;C:\Program Files\Mercurial\;C:\Program Files (x86)\Subversion\bin;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\dotnet\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin;C:\Tools\xUnit;C:\Tools\xUnit20;C:\Tools\NUnit\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform;C:\Ruby193\bin;C:\Tools\WebDriver;C:\Python27;C:\Python27\Scripts;C:\Program Files\erl10.7\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft DirectX SDK;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Tools\Doxygen;C:\Program Files (x86)\CMake\bin;C:\ProgramData\chocolatey\bin;C:\Tools\vcpkg;C:\Tools\Coverity\bin;C:\Program Files (x86)\NSIS;C:\Tools\Octopus;C:\Program Files\Meson\;C:\Tools\GitVersion;C:\Tools\NUnit3\bin;C:\Users\appveyor\AppData\Local\Microsoft\WindowsApps;C:\Users\appveyor\.dotnet\tools;C:\Program Files\AppVeyor\BuildAgent\ - set PATH=C:\Strawberry\perl\bin;C:\Python39-x64;%QT_DIR%\bin;%PATH% - - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 build_script: # VERSION format: branch-master/branch-1.2 @@ -47,7 +45,7 @@ build_script: - echo %DATE% # Build nheko - - cmake -G "Visual Studio 16 2019" -A x64 -H. -Bbuild + - cmake -G "Visual Studio 17 2022" -A x64 -H. -Bbuild -DHUNTER_ROOT="C:\hunter" -DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF -DUSE_BUNDLED_OPENSSL=ON -DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release diff --git a/io.github.NhekoReborn.Nheko.yaml b/io.github.NhekoReborn.Nheko.yaml index 12c32641..04f1bf05 100644 --- a/io.github.NhekoReborn.Nheko.yaml +++ b/io.github.NhekoReborn.Nheko.yaml @@ -173,7 +173,7 @@ modules: buildsystem: cmake-ninja name: mtxclient sources: - - commit: 251dc12469ecd96d0ec491551589b244f12d6d92 + - commit: 8dd9214f622fe5f307249b37029c17f1fdff25ab #tag: v0.8.2 type: git url: https://github.com/Nheko-Reborn/mtxclient.git diff --git a/src/EventAccessors.cpp b/src/EventAccessors.cpp index 659338a0..da0eeff2 100644 --- a/src/EventAccessors.cpp +++ b/src/EventAccessors.cpp @@ -9,12 +9,10 @@ #include #include +#include #include namespace { -template class Op, class... Args> -using is_detected = typename nheko::detail::detector::value_t; - struct IsStateEvent { template @@ -31,19 +29,13 @@ struct IsStateEvent struct EventMsgType { - template - using msgtype_t = decltype(E::msgtype); template mtx::events::MessageType operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { - if constexpr (std::is_same_v, - std::remove_cv_t>) - return mtx::events::getMessageType(e.content.msgtype.value()); - else if constexpr (std::is_same_v>) - return mtx::events::getMessageType(e.content.msgtype); - } + if constexpr (requires(decltype(e) t) { t.content.msgtype.value(); }) + return mtx::events::getMessageType(e.content.msgtype.value()); + else if constexpr (requires(decltype(e) t) { std::string{t.content.msgtype}; }) + return mtx::events::getMessageType(e.content.msgtype); return mtx::events::MessageType::Unknown; } }; @@ -94,31 +86,23 @@ struct CallType struct EventBody { - template - using body_t = decltype(C::body); template std::string operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { - if constexpr (std::is_same_v, - std::remove_cv_t>) - return e.content.body ? e.content.body.value() : ""; - else if constexpr (std::is_same_v>) - return e.content.body; - } + if constexpr (requires(decltype(e) t) { t.content.body.value(); }) + return e.content.body ? e.content.body.value() : ""; + else if constexpr (requires(decltype(e) t) { std::string{t.content.body}; }) + return e.content.body; return ""; } }; struct EventFormattedBody { - template - using formatted_body_t = decltype(C::formatted_body); template std::string operator()(const mtx::events::RoomEvent &e) { - if constexpr (is_detected::value) { + if constexpr (requires { T::formatted_body; }) { if (e.content.format == "org.matrix.custom.html") return e.content.formatted_body; } @@ -128,12 +112,10 @@ struct EventFormattedBody struct EventFile { - template - using file_t = decltype(Content::file); template std::optional operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) + if constexpr (requires { T::file; }) return e.content.file; return std::nullopt; } @@ -141,12 +123,10 @@ struct EventFile struct EventThumbnailFile { - template - using file_t = decltype(Content::info.thumbnail_file); template std::optional operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) + if constexpr (requires { T::thumbnail_file; }) return e.content.info.thumbnail_file; return std::nullopt; } @@ -154,12 +134,10 @@ struct EventThumbnailFile struct EventUrl { - template - using url_t = decltype(Content::url); template std::string operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { + if constexpr (requires { T::url; }) { if (auto file = EventFile{}(e)) return file->url; return e.content.url; @@ -170,12 +148,10 @@ struct EventUrl struct EventThumbnailUrl { - template - using thumbnail_url_t = decltype(Content::info.thumbnail_url); template std::string operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { + if constexpr (requires { e.content.info.thumbnail_url; }) { if (auto file = EventThumbnailFile{}(e)) return file->url; return e.content.info.thumbnail_url; @@ -186,12 +162,10 @@ struct EventThumbnailUrl struct EventDuration { - template - using thumbnail_url_t = decltype(Content::info.duration); template uint64_t operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { + if constexpr (requires { e.content.info.duration; }) { return e.content.info.duration; } return 0; @@ -200,12 +174,10 @@ struct EventDuration struct EventBlurhash { - template - using blurhash_t = decltype(Content::info.blurhash); template std::string operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { + if constexpr (requires { e.content.info.blurhash; }) { return e.content.info.blurhash; } return ""; @@ -245,12 +217,10 @@ struct EventFilename struct EventMimeType { - template - using mimetype_t = decltype(Content::info.mimetype); template std::string operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { + if constexpr (requires { e.content.info.mimetype; }) { return e.content.info.mimetype; } return ""; @@ -259,12 +229,10 @@ struct EventMimeType struct EventFilesize { - template - using filesize_t = decltype(Content::info.size); template int64_t operator()(const mtx::events::RoomEvent &e) { - if constexpr (is_detected::value) { + if constexpr (requires { e.content.info.size; }) { return e.content.info.size; } return 0; @@ -275,12 +243,10 @@ struct EventRelations { inline const static mtx::common::Relations empty; - template - using related_ev_id_t = decltype(Content::relations); template const mtx::common::Relations &operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { + if constexpr (requires { T::relations; }) { return e.content.relations; } return empty; @@ -290,12 +256,10 @@ struct EventRelations struct SetEventRelations { mtx::common::Relations new_relations; - template - using related_ev_id_t = decltype(Content::relations); template void operator()(mtx::events::Event &e) { - if constexpr (is_detected::value) { + if constexpr (requires { T::relations; }) { e.content.relations = std::move(new_relations); } } @@ -317,12 +281,10 @@ struct EventTransactionId struct EventMediaHeight { - template - using h_t = decltype(Content::info.h); template uint64_t operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { + if constexpr (requires { e.content.info.h; }) { return e.content.info.h; } return -1; @@ -331,12 +293,10 @@ struct EventMediaHeight struct EventMediaWidth { - template - using w_t = decltype(Content::info.w); template uint64_t operator()(const mtx::events::Event &e) { - if constexpr (is_detected::value) { + if constexpr (requires { e.content.info.h; }) { return e.content.info.w; } return -1; diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp index a0c73f84..1b96d2d6 100644 --- a/src/timeline/CommunitiesModel.cpp +++ b/src/timeline/CommunitiesModel.cpp @@ -852,7 +852,8 @@ CommunitiesModel::updateSpaceStatus(QString space, .arg(QString::fromStdString(err->matrix_error.error))); nhlog::net()->error("Failed to update child {} of {}: {}", room.toStdString(), - space.toStdString()); + space.toStdString(), + *err); } }); } @@ -869,7 +870,8 @@ CommunitiesModel::updateSpaceStatus(QString space, .arg(QString::fromStdString(err->matrix_error.error))); nhlog::net()->error("Failed to delete child {} of {}: {}", room.toStdString(), - space.toStdString()); + space.toStdString(), + *err); } }); } @@ -891,7 +893,8 @@ CommunitiesModel::updateSpaceStatus(QString space, .arg(QString::fromStdString(err->matrix_error.error))); nhlog::net()->error("Failed to update parent {} of {}: {}", space.toStdString(), - room.toStdString()); + room.toStdString(), + *err); } }); } @@ -908,7 +911,8 @@ CommunitiesModel::updateSpaceStatus(QString space, .arg(QString::fromStdString(err->matrix_error.error))); nhlog::net()->error("Failed to delete parent {} of {}: {}", space.toStdString(), - room.toStdString()); + room.toStdString(), + *err); } }); } diff --git a/toolchain.cmake b/toolchain.cmake index 85571957..90f05868 100644 --- a/toolchain.cmake +++ b/toolchain.cmake @@ -1,3 +1,3 @@ -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)