mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Update to c++17
This commit is contained in:
parent
2ea1e11ffc
commit
659e36b113
17 changed files with 284 additions and 284 deletions
|
@ -3,14 +3,6 @@
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
||||||
brew update
|
|
||||||
|
|
||||||
# uninstall packages, that would get upgraded by upgrading cmake (and we don't need)
|
|
||||||
brew uninstall --force cgal node sfcgal postgis
|
|
||||||
|
|
||||||
brew install qt5 lmdb clang-format ninja libsodium cmark
|
|
||||||
brew upgrade boost cmake icu4c || true
|
|
||||||
|
|
||||||
brew tap nlohmann/json
|
brew tap nlohmann/json
|
||||||
brew install --with-cmake nlohmann_json
|
brew install --with-cmake nlohmann_json
|
||||||
|
|
||||||
|
@ -25,11 +17,11 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||||
|
sudo update-alternatives --install /usr/bin/gcc gcc "/usr/bin/${CC}" 10
|
||||||
|
sudo update-alternatives --install /usr/bin/g++ g++ "/usr/bin/${CXX}" 10
|
||||||
|
|
||||||
if [ -z "$QT_VERSION" ]; then
|
sudo update-alternatives --set gcc "/usr/bin/${CC}"
|
||||||
QT_VERSION="592"
|
sudo update-alternatives --set g++ "/usr/bin/${CXX}"
|
||||||
QT_PKG="59"
|
|
||||||
fi
|
|
||||||
|
|
||||||
wget https://cmake.org/files/v3.15/cmake-3.15.5-Linux-x86_64.sh
|
wget https://cmake.org/files/v3.15/cmake-3.15.5-Linux-x86_64.sh
|
||||||
sudo sh cmake-3.15.5-Linux-x86_64.sh --skip-license --prefix=/usr/local
|
sudo sh cmake-3.15.5-Linux-x86_64.sh --skip-license --prefix=/usr/local
|
||||||
|
@ -40,21 +32,4 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||||
tar xfz libsodium-1.0.17.tar.gz
|
tar xfz libsodium-1.0.17.tar.gz
|
||||||
cd libsodium-1.0.17/
|
cd libsodium-1.0.17/
|
||||||
./configure && make && sudo make install )
|
./configure && make && sudo make install )
|
||||||
|
|
||||||
sudo add-apt-repository -y ppa:beineri/opt-qt${QT_VERSION}-trusty
|
|
||||||
# needed for git-lfs, otherwise the follow apt update fails.
|
|
||||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 6B05F25D762E3157
|
|
||||||
|
|
||||||
# needed for mongodb repository: https://github.com/travis-ci/travis-ci/issues/9037
|
|
||||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
|
|
||||||
|
|
||||||
sudo apt update -qq
|
|
||||||
sudo apt install -qq -y \
|
|
||||||
qt${QT_PKG}base \
|
|
||||||
qt${QT_PKG}tools \
|
|
||||||
qt${QT_PKG}svg \
|
|
||||||
qt${QT_PKG}multimedia \
|
|
||||||
qt${QT_PKG}quickcontrols2 \
|
|
||||||
qt${QT_PKG}graphicaleffects \
|
|
||||||
liblmdb-dev
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -36,7 +36,7 @@ unset LD_LIBRARY_PATH
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
export ARCH
|
export ARCH
|
||||||
LD_LIBRARY_PATH=$(pwd)/.deps/usr/lib/:$LD_LIBRARY_PATH
|
LD_LIBRARY_PATH=$(pwd)/.deps/usr/lib/:/usr/local/lib/:$LD_LIBRARY_PATH
|
||||||
export LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH
|
||||||
|
|
||||||
for res in ./linuxdeployqt*.AppImage
|
for res in ./linuxdeployqt*.AppImage
|
||||||
|
|
|
@ -3,17 +3,9 @@
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||||
export CC=${C_COMPILER}
|
|
||||||
export CXX=${CXX_COMPILER}
|
|
||||||
# make build use all available cores
|
# make build use all available cores
|
||||||
export CMAKE_BUILD_PARALLEL_LEVEL=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l)
|
export CMAKE_BUILD_PARALLEL_LEVEL=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l)
|
||||||
|
|
||||||
sudo update-alternatives --install /usr/bin/gcc gcc "/usr/bin/${C_COMPILER}" 10
|
|
||||||
sudo update-alternatives --install /usr/bin/g++ g++ "/usr/bin/${CXX_COMPILER}" 10
|
|
||||||
|
|
||||||
sudo update-alternatives --set gcc "/usr/bin/${C_COMPILER}"
|
|
||||||
sudo update-alternatives --set g++ "/usr/bin/${CXX_COMPILER}"
|
|
||||||
|
|
||||||
export PATH="/usr/local/bin/:${PATH}"
|
export PATH="/usr/local/bin/:${PATH}"
|
||||||
cmake --version
|
cmake --version
|
||||||
fi
|
fi
|
||||||
|
|
105
.travis.yml
105
.travis.yml
|
@ -1,6 +1,6 @@
|
||||||
language: cpp
|
language: cpp
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: xenial
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
webhooks:
|
webhooks:
|
||||||
|
@ -19,61 +19,108 @@ matrix:
|
||||||
include:
|
include:
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
# Use the default osx image, because that one is actually tested to work with homebrew and probably the oldest supported version
|
# C++17 support
|
||||||
# osx_image: xcode9
|
osx_image: xcode10.2
|
||||||
env:
|
env:
|
||||||
- DEPLOYMENT=1
|
- DEPLOYMENT=1
|
||||||
- USE_BUNDLED_BOOST=0
|
- USE_BUNDLED_BOOST=0
|
||||||
- USE_BUNDLED_CMARK=0
|
- USE_BUNDLED_CMARK=0
|
||||||
- USE_BUNDLED_JSON=0
|
- USE_BUNDLED_JSON=0
|
||||||
- MTX_STATIC=1
|
- MTX_STATIC=1
|
||||||
|
addons:
|
||||||
|
homebrew:
|
||||||
|
taps: nlohmann/json
|
||||||
|
packages:
|
||||||
|
- boost
|
||||||
|
- clang-format
|
||||||
|
- cmake
|
||||||
|
- cmark
|
||||||
|
- icu4c
|
||||||
|
- libsodium
|
||||||
|
- lmdb
|
||||||
|
- ninja
|
||||||
|
- openssl
|
||||||
|
- qt5
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc-7
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=g++-5
|
- CXX=g++-7
|
||||||
- C_COMPILER=gcc-5
|
- CC=gcc-7
|
||||||
- QT_VERSION="-5.10.1"
|
- QT_PKG=512
|
||||||
- QT_PKG=510
|
|
||||||
- DEPLOYMENT=1
|
- DEPLOYMENT=1
|
||||||
- USE_BUNDLED_BOOST=1
|
- USE_BUNDLED_BOOST=1
|
||||||
- USE_BUNDLED_CMARK=1
|
- USE_BUNDLED_CMARK=1
|
||||||
- USE_BUNDLED_JSON=1
|
- USE_BUNDLED_JSON=1
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ["ubuntu-toolchain-r-test"]
|
sources:
|
||||||
packages: ["g++-5", "ninja-build"]
|
- ubuntu-toolchain-r-test
|
||||||
|
- sourceline: 'ppa:beineri/opt-qt-5.12.6-xenial'
|
||||||
|
packages:
|
||||||
|
- g++-7
|
||||||
|
- ninja-build
|
||||||
|
- qt512base
|
||||||
|
- qt512tools
|
||||||
|
- qt512svg
|
||||||
|
- qt512multimedia
|
||||||
|
- qt512quickcontrols2
|
||||||
|
- qt512graphicaleffects
|
||||||
|
- liblmdb-dev
|
||||||
|
- libgl1-mesa-dev # needed for missing gl.h
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc-8
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=g++-8
|
- CXX=g++-8
|
||||||
- C_COMPILER=gcc-8
|
- CC=gcc-8
|
||||||
- QT_VERSION=592
|
|
||||||
- QT_PKG=59
|
- QT_PKG=59
|
||||||
- USE_BUNDLED_BOOST=1
|
- USE_BUNDLED_BOOST=1
|
||||||
- USE_BUNDLED_CMARK=1
|
- USE_BUNDLED_CMARK=1
|
||||||
- USE_BUNDLED_JSON=1
|
- USE_BUNDLED_JSON=1
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ["ubuntu-toolchain-r-test"]
|
sources:
|
||||||
packages: ["g++-8", "ninja-build"]
|
- ubuntu-toolchain-r-test
|
||||||
|
- sourceline: 'ppa:beineri/opt-qt597-xenial'
|
||||||
|
packages:
|
||||||
|
- g++-8
|
||||||
|
- ninja-build
|
||||||
|
- qt59base
|
||||||
|
- qt59tools
|
||||||
|
- qt59svg
|
||||||
|
- qt59multimedia
|
||||||
|
- qt59quickcontrols2
|
||||||
|
- qt59graphicaleffects
|
||||||
|
- liblmdb-dev
|
||||||
|
- libgl1-mesa-dev # needed for missing gl.h
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang
|
compiler: clang-6
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=clang++-5.0
|
- CXX=clang++-6.0
|
||||||
- C_COMPILER=clang-5.0
|
- CC=clang-6.0
|
||||||
- QT_VERSION=592
|
|
||||||
- QT_PKG=59
|
- QT_PKG=59
|
||||||
- USE_BUNDLED_BOOST=1
|
- USE_BUNDLED_BOOST=1
|
||||||
- USE_BUNDLED_CMARK=1
|
- USE_BUNDLED_CMARK=1
|
||||||
- USE_BUNDLED_JSON=1
|
- USE_BUNDLED_JSON=1
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-5.0"]
|
sources:
|
||||||
packages: ["clang-5.0", "g++-7", "ninja-build"]
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-xenial-6.0
|
||||||
|
- sourceline: 'ppa:beineri/opt-qt597-xenial'
|
||||||
|
packages:
|
||||||
|
- clang++-6.0
|
||||||
|
- g++-7
|
||||||
|
- ninja-build
|
||||||
|
- qt59base
|
||||||
|
- qt59tools
|
||||||
|
- qt59svg
|
||||||
|
- qt59multimedia
|
||||||
|
- qt59quickcontrols2
|
||||||
|
- qt59graphicaleffects
|
||||||
|
- liblmdb-dev
|
||||||
|
- libgl1-mesa-dev # needed for missing gl.h
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- export CXX=${CXX_COMPILER}
|
|
||||||
- export CC=${C_COMPILER}
|
|
||||||
# Use TRAVIS_TAG if defined, or the short commit SHA otherwise
|
# Use TRAVIS_TAG if defined, or the short commit SHA otherwise
|
||||||
- export VERSION=${TRAVIS_TAG:-$(git rev-parse --short HEAD)}
|
- export VERSION=${TRAVIS_TAG:-$(git rev-parse --short HEAD)}
|
||||||
install:
|
install:
|
||||||
|
|
|
@ -5,9 +5,6 @@ option(ASAN "Compile with address sanitizers" OFF)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
add_definitions(-DBOOST_MPL_LIMIT_LIST_SIZE=30)
|
|
||||||
add_definitions(-DBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS)
|
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# Include Qt basic functions
|
# Include Qt basic functions
|
||||||
|
@ -15,8 +12,8 @@ include(QtCommon)
|
||||||
|
|
||||||
project(nheko LANGUAGES C CXX)
|
project(nheko LANGUAGES C CXX)
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "6")
|
set(CPACK_PACKAGE_VERSION_MINOR "7")
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH "4")
|
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
||||||
set(PROJECT_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR})
|
set(PROJECT_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR})
|
||||||
set(PROJECT_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR})
|
set(PROJECT_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR})
|
||||||
set(PROJECT_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH})
|
set(PROJECT_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH})
|
||||||
|
@ -27,7 +24,7 @@ fix_project_version()
|
||||||
|
|
||||||
# Set additional project information
|
# Set additional project information
|
||||||
set(COMPANY "Nheko")
|
set(COMPANY "Nheko")
|
||||||
set(COPYRIGHT "Copyright (c) 2018 Nheko Contributors")
|
set(COPYRIGHT "Copyright (c) 2019 Nheko Contributors")
|
||||||
set(IDENTIFIER "com.github.mujx.nheko")
|
set(IDENTIFIER "com.github.mujx.nheko")
|
||||||
|
|
||||||
add_project_meta(META_FILES_TO_INCLUDE)
|
add_project_meta(META_FILES_TO_INCLUDE)
|
||||||
|
@ -91,7 +88,7 @@ if (NOT MSVC)
|
||||||
set(CMAKE_C_COMPILER gcc)
|
set(CMAKE_C_COMPILER gcc)
|
||||||
endif(NOT MSVC)
|
endif(NOT MSVC)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
|
@ -106,7 +103,7 @@ if(NOT MSVC)
|
||||||
-fsized-deallocation \
|
-fsized-deallocation \
|
||||||
-fdiagnostics-color=always \
|
-fdiagnostics-color=always \
|
||||||
-Wunreachable-code \
|
-Wunreachable-code \
|
||||||
-std=c++14"
|
-std=c++17"
|
||||||
)
|
)
|
||||||
if (NOT CMAKE_COMPILER_IS_GNUCXX)
|
if (NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||||
# -Wshadow is buggy and broken in GCC, so do not enable it.
|
# -Wshadow is buggy and broken in GCC, so do not enable it.
|
||||||
|
|
4
deps/CMakeLists.txt
vendored
4
deps/CMakeLists.txt
vendored
|
@ -46,10 +46,10 @@ set(BOOST_SHA256
|
||||||
|
|
||||||
set(
|
set(
|
||||||
MTXCLIENT_URL
|
MTXCLIENT_URL
|
||||||
https://github.com/Nheko-Reborn/mtxclient/archive/1945952864ef87a6afeb57b0beb80756d0647381.zip
|
https://github.com/Nheko-Reborn/mtxclient/archive/fd5208d85ecc9e077fe0fde5424ba225849cccf7.zip
|
||||||
)
|
)
|
||||||
set(MTXCLIENT_HASH
|
set(MTXCLIENT_HASH
|
||||||
727cd145c0c1e9c168aaeded3b7cc9801c63b4da5e8cd0a4782982d08770816e)
|
24ef9d5562ed6d83d6c28f6c8de559487029f3bdc35d9fe8e5799283ff999513)
|
||||||
set(
|
set(
|
||||||
TWEENY_URL
|
TWEENY_URL
|
||||||
https://github.com/mobius3/tweeny/archive/b94ce07cfb02a0eb8ac8aaf66137dabdaea857cf.tar.gz
|
https://github.com/mobius3/tweeny/archive/b94ce07cfb02a0eb8ac8aaf66137dabdaea857cf.tar.gz
|
||||||
|
|
2
deps/cmake/Json.cmake
vendored
2
deps/cmake/Json.cmake
vendored
|
@ -13,7 +13,7 @@ ExternalProject_Add(
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||||
|
|
||||||
BUILD_COMMAND ${CMAKE_COMMAND} --build ${DEPS_BUILD_DIR}/json
|
BUILD_COMMAND ${CMAKE_COMMAND} --build ${DEPS_BUILD_DIR}/json
|
||||||
INSTALL_COMMAND make install
|
INSTALL_COMMAND ${CMAKE_COMMAND} --build ${DEPS_BUILD_DIR}/json --target install
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND THIRD_PARTY_DEPS Json)
|
list(APPEND THIRD_PARTY_DEPS Json)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
@ -26,7 +27,6 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include <boost/variant.hpp>
|
|
||||||
#include <mtx/responses/common.hpp>
|
#include <mtx/responses/common.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
|
@ -395,7 +395,7 @@ Cache::saveOlmSession(const std::string &curve25519, mtx::crypto::OlmSessionPtr
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<mtx::crypto::OlmSessionPtr>
|
std::optional<mtx::crypto::OlmSessionPtr>
|
||||||
Cache::getOlmSession(const std::string &curve25519, const std::string &session_id)
|
Cache::getOlmSession(const std::string &curve25519, const std::string &session_id)
|
||||||
{
|
{
|
||||||
using namespace mtx::crypto;
|
using namespace mtx::crypto;
|
||||||
|
@ -413,7 +413,7 @@ Cache::getOlmSession(const std::string &curve25519, const std::string &session_i
|
||||||
return unpickle<SessionObject>(data, SECRET);
|
return unpickle<SessionObject>(data, SECRET);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::none;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
|
@ -967,8 +967,8 @@ Cache::saveState(const mtx::responses::Sync &res)
|
||||||
bool has_new_tags = false;
|
bool has_new_tags = false;
|
||||||
for (const auto &evt : room.second.account_data.events) {
|
for (const auto &evt : room.second.account_data.events) {
|
||||||
// for now only fetch tag events
|
// for now only fetch tag events
|
||||||
if (evt.type() == typeid(Event<account_data::Tag>)) {
|
if (std::holds_alternative<Event<account_data::Tag>>(evt)) {
|
||||||
auto tags_evt = boost::get<Event<account_data::Tag>>(evt);
|
auto tags_evt = std::get<Event<account_data::Tag>>(evt);
|
||||||
has_new_tags = true;
|
has_new_tags = true;
|
||||||
for (const auto &tag : tags_evt.content.tags) {
|
for (const auto &tag : tags_evt.content.tags) {
|
||||||
updatedInfo.tags.push_back(tag.first);
|
updatedInfo.tags.push_back(tag.first);
|
||||||
|
@ -1049,19 +1049,17 @@ Cache::saveInvite(lmdb::txn &txn,
|
||||||
using namespace mtx::events::state;
|
using namespace mtx::events::state;
|
||||||
|
|
||||||
for (const auto &e : room.invite_state) {
|
for (const auto &e : room.invite_state) {
|
||||||
if (boost::get<StrippedEvent<Member>>(&e) != nullptr) {
|
if (auto msg = std::get_if<StrippedEvent<Member>>(&e)) {
|
||||||
auto msg = boost::get<StrippedEvent<Member>>(e);
|
auto display_name = msg->content.display_name.empty()
|
||||||
|
? msg->state_key
|
||||||
|
: msg->content.display_name;
|
||||||
|
|
||||||
auto display_name = msg.content.display_name.empty()
|
MemberInfo tmp{display_name, msg->content.avatar_url};
|
||||||
? msg.state_key
|
|
||||||
: msg.content.display_name;
|
|
||||||
|
|
||||||
MemberInfo tmp{display_name, msg.content.avatar_url};
|
|
||||||
|
|
||||||
lmdb::dbi_put(
|
lmdb::dbi_put(
|
||||||
txn, membersdb, lmdb::val(msg.state_key), lmdb::val(json(tmp).dump()));
|
txn, membersdb, lmdb::val(msg->state_key), lmdb::val(json(tmp).dump()));
|
||||||
} else {
|
} else {
|
||||||
boost::apply_visitor(
|
std::visit(
|
||||||
[&txn, &statesdb](auto msg) {
|
[&txn, &statesdb](auto msg) {
|
||||||
bool res = lmdb::dbi_put(txn,
|
bool res = lmdb::dbi_put(txn,
|
||||||
statesdb,
|
statesdb,
|
||||||
|
@ -1122,7 +1120,7 @@ Cache::roomsWithTagUpdates(const mtx::responses::Sync &res)
|
||||||
for (const auto &room : res.rooms.join) {
|
for (const auto &room : res.rooms.join) {
|
||||||
bool hasUpdates = false;
|
bool hasUpdates = false;
|
||||||
for (const auto &evt : room.second.account_data.events) {
|
for (const auto &evt : room.second.account_data.events) {
|
||||||
if (evt.type() == typeid(Event<account_data::Tag>)) {
|
if (std::holds_alternative<Event<account_data::Tag>>(evt)) {
|
||||||
hasUpdates = true;
|
hasUpdates = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1940,7 +1938,7 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
|
||||||
if (isStateEvent(e))
|
if (isStateEvent(e))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (boost::get<RedactionEvent<msg::Redaction>>(&e) != nullptr)
|
if (std::holds_alternative<RedactionEvent<msg::Redaction>>(e))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
json obj = json::object();
|
json obj = json::object();
|
||||||
|
|
85
src/Cache.h
85
src/Cache.h
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <mutex>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -25,11 +26,11 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <lmdb++.h>
|
#include <lmdb++.h>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <mtx/events/join_rules.hpp>
|
#include <mtx/events/join_rules.hpp>
|
||||||
#include <mtx/responses.hpp>
|
#include <mtx/responses.hpp>
|
||||||
#include <mtxclient/crypto/client.hpp>
|
#include <mtxclient/crypto/client.hpp>
|
||||||
#include <mutex>
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
|
@ -453,8 +454,8 @@ public:
|
||||||
//
|
//
|
||||||
void saveOlmSession(const std::string &curve25519, mtx::crypto::OlmSessionPtr session);
|
void saveOlmSession(const std::string &curve25519, mtx::crypto::OlmSessionPtr session);
|
||||||
std::vector<std::string> getOlmSessions(const std::string &curve25519);
|
std::vector<std::string> getOlmSessions(const std::string &curve25519);
|
||||||
boost::optional<mtx::crypto::OlmSessionPtr> getOlmSession(const std::string &curve25519,
|
std::optional<mtx::crypto::OlmSessionPtr> getOlmSession(const std::string &curve25519,
|
||||||
const std::string &session_id);
|
const std::string &session_id);
|
||||||
|
|
||||||
void saveOlmAccount(const std::string &pickled);
|
void saveOlmAccount(const std::string &pickled);
|
||||||
std::string restoreOlmAccount();
|
std::string restoreOlmAccount();
|
||||||
|
@ -517,52 +518,50 @@ private:
|
||||||
using namespace mtx::events;
|
using namespace mtx::events;
|
||||||
using namespace mtx::events::state;
|
using namespace mtx::events::state;
|
||||||
|
|
||||||
if (boost::get<StateEvent<Member>>(&event) != nullptr) {
|
if (auto e = std::get_if<StateEvent<Member>>(&event); e != nullptr) {
|
||||||
const auto e = boost::get<StateEvent<Member>>(event);
|
switch (e->content.membership) {
|
||||||
|
|
||||||
switch (e.content.membership) {
|
|
||||||
//
|
//
|
||||||
// We only keep users with invite or join membership.
|
// We only keep users with invite or join membership.
|
||||||
//
|
//
|
||||||
case Membership::Invite:
|
case Membership::Invite:
|
||||||
case Membership::Join: {
|
case Membership::Join: {
|
||||||
auto display_name = e.content.display_name.empty()
|
auto display_name = e->content.display_name.empty()
|
||||||
? e.state_key
|
? e->state_key
|
||||||
: e.content.display_name;
|
: e->content.display_name;
|
||||||
|
|
||||||
// Lightweight representation of a member.
|
// Lightweight representation of a member.
|
||||||
MemberInfo tmp{display_name, e.content.avatar_url};
|
MemberInfo tmp{display_name, e->content.avatar_url};
|
||||||
|
|
||||||
lmdb::dbi_put(txn,
|
lmdb::dbi_put(txn,
|
||||||
membersdb,
|
membersdb,
|
||||||
lmdb::val(e.state_key),
|
lmdb::val(e->state_key),
|
||||||
lmdb::val(json(tmp).dump()));
|
lmdb::val(json(tmp).dump()));
|
||||||
|
|
||||||
insertDisplayName(QString::fromStdString(room_id),
|
insertDisplayName(QString::fromStdString(room_id),
|
||||||
QString::fromStdString(e.state_key),
|
QString::fromStdString(e->state_key),
|
||||||
QString::fromStdString(display_name));
|
QString::fromStdString(display_name));
|
||||||
|
|
||||||
insertAvatarUrl(QString::fromStdString(room_id),
|
insertAvatarUrl(QString::fromStdString(room_id),
|
||||||
QString::fromStdString(e.state_key),
|
QString::fromStdString(e->state_key),
|
||||||
QString::fromStdString(e.content.avatar_url));
|
QString::fromStdString(e->content.avatar_url));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
lmdb::dbi_del(
|
lmdb::dbi_del(
|
||||||
txn, membersdb, lmdb::val(e.state_key), lmdb::val(""));
|
txn, membersdb, lmdb::val(e->state_key), lmdb::val(""));
|
||||||
|
|
||||||
removeDisplayName(QString::fromStdString(room_id),
|
removeDisplayName(QString::fromStdString(room_id),
|
||||||
QString::fromStdString(e.state_key));
|
QString::fromStdString(e->state_key));
|
||||||
removeAvatarUrl(QString::fromStdString(room_id),
|
removeAvatarUrl(QString::fromStdString(room_id),
|
||||||
QString::fromStdString(e.state_key));
|
QString::fromStdString(e->state_key));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (boost::get<StateEvent<Encryption>>(&event) != nullptr) {
|
} else if (std::holds_alternative<StateEvent<Encryption>>(event)) {
|
||||||
setEncryptedRoom(txn, room_id);
|
setEncryptedRoom(txn, room_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -570,7 +569,7 @@ private:
|
||||||
if (!isStateEvent(event))
|
if (!isStateEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boost::apply_visitor(
|
std::visit(
|
||||||
[&txn, &statesdb](auto e) {
|
[&txn, &statesdb](auto e) {
|
||||||
lmdb::dbi_put(
|
lmdb::dbi_put(
|
||||||
txn, statesdb, lmdb::val(to_string(e.type)), lmdb::val(json(e).dump()));
|
txn, statesdb, lmdb::val(to_string(e.type)), lmdb::val(json(e).dump()));
|
||||||
|
@ -584,17 +583,17 @@ private:
|
||||||
using namespace mtx::events;
|
using namespace mtx::events;
|
||||||
using namespace mtx::events::state;
|
using namespace mtx::events::state;
|
||||||
|
|
||||||
return boost::get<StateEvent<Aliases>>(&e) != nullptr ||
|
return std::holds_alternative<StateEvent<Aliases>>(e) ||
|
||||||
boost::get<StateEvent<state::Avatar>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<state::Avatar>>(e) ||
|
||||||
boost::get<StateEvent<CanonicalAlias>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<CanonicalAlias>>(e) ||
|
||||||
boost::get<StateEvent<Create>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<Create>>(e) ||
|
||||||
boost::get<StateEvent<GuestAccess>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<GuestAccess>>(e) ||
|
||||||
boost::get<StateEvent<HistoryVisibility>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<HistoryVisibility>>(e) ||
|
||||||
boost::get<StateEvent<JoinRules>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<JoinRules>>(e) ||
|
||||||
boost::get<StateEvent<Name>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<Name>>(e) ||
|
||||||
boost::get<StateEvent<Member>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<Member>>(e) ||
|
||||||
boost::get<StateEvent<PowerLevels>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<PowerLevels>>(e) ||
|
||||||
boost::get<StateEvent<Topic>>(&e) != nullptr;
|
std::holds_alternative<StateEvent<Topic>>(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -603,11 +602,11 @@ private:
|
||||||
using namespace mtx::events;
|
using namespace mtx::events;
|
||||||
using namespace mtx::events::state;
|
using namespace mtx::events::state;
|
||||||
|
|
||||||
return boost::get<StateEvent<state::Avatar>>(&e) != nullptr ||
|
return std::holds_alternative<StateEvent<state::Avatar>>(e) ||
|
||||||
boost::get<StateEvent<CanonicalAlias>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<CanonicalAlias>>(e) ||
|
||||||
boost::get<StateEvent<Name>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<Name>>(e) ||
|
||||||
boost::get<StateEvent<Member>>(&e) != nullptr ||
|
std::holds_alternative<StateEvent<Member>>(e) ||
|
||||||
boost::get<StateEvent<Topic>>(&e) != nullptr;
|
std::holds_alternative<StateEvent<Topic>>(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool containsStateUpdates(const mtx::events::collections::StrippedEvents &e)
|
bool containsStateUpdates(const mtx::events::collections::StrippedEvents &e)
|
||||||
|
@ -615,11 +614,11 @@ private:
|
||||||
using namespace mtx::events;
|
using namespace mtx::events;
|
||||||
using namespace mtx::events::state;
|
using namespace mtx::events::state;
|
||||||
|
|
||||||
return boost::get<StrippedEvent<state::Avatar>>(&e) != nullptr ||
|
return std::holds_alternative<StrippedEvent<state::Avatar>>(e) ||
|
||||||
boost::get<StrippedEvent<CanonicalAlias>>(&e) != nullptr ||
|
std::holds_alternative<StrippedEvent<CanonicalAlias>>(e) ||
|
||||||
boost::get<StrippedEvent<Name>>(&e) != nullptr ||
|
std::holds_alternative<StrippedEvent<Name>>(e) ||
|
||||||
boost::get<StrippedEvent<Member>>(&e) != nullptr ||
|
std::holds_alternative<StrippedEvent<Member>>(e) ||
|
||||||
boost::get<StrippedEvent<Topic>>(&e) != nullptr;
|
std::holds_alternative<StrippedEvent<Topic>>(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveInvites(lmdb::txn &txn,
|
void saveInvites(lmdb::txn &txn,
|
||||||
|
|
|
@ -54,7 +54,7 @@ constexpr int CHECK_CONNECTIVITY_INTERVAL = 15'000;
|
||||||
constexpr int RETRY_TIMEOUT = 5'000;
|
constexpr int RETRY_TIMEOUT = 5'000;
|
||||||
constexpr size_t MAX_ONETIME_KEYS = 50;
|
constexpr size_t MAX_ONETIME_KEYS = 50;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(boost::optional<mtx::crypto::EncryptedFile>)
|
Q_DECLARE_METATYPE(std::optional<mtx::crypto::EncryptedFile>)
|
||||||
|
|
||||||
ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
@ -64,8 +64,8 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
{
|
{
|
||||||
setObjectName("chatPage");
|
setObjectName("chatPage");
|
||||||
|
|
||||||
qRegisterMetaType<boost::optional<mtx::crypto::EncryptedFile>>(
|
qRegisterMetaType<std::optional<mtx::crypto::EncryptedFile>>(
|
||||||
"boost::optional<mtx::crypto::EncryptedFile>");
|
"std::optional<mtx::crypto::EncryptedFile>");
|
||||||
|
|
||||||
topLayout_ = new QHBoxLayout(this);
|
topLayout_ = new QHBoxLayout(this);
|
||||||
topLayout_->setSpacing(0);
|
topLayout_->setSpacing(0);
|
||||||
|
@ -318,7 +318,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
|
|
||||||
auto bin = dev->peek(dev->size());
|
auto bin = dev->peek(dev->size());
|
||||||
auto payload = std::string(bin.data(), bin.size());
|
auto payload = std::string(bin.data(), bin.size());
|
||||||
boost::optional<mtx::crypto::EncryptedFile> encryptedFile;
|
std::optional<mtx::crypto::EncryptedFile> encryptedFile;
|
||||||
if (cache::client()->isRoomEncrypted(current_room_.toStdString())) {
|
if (cache::client()->isRoomEncrypted(current_room_.toStdString())) {
|
||||||
mtx::crypto::BinaryBuf buf;
|
mtx::crypto::BinaryBuf buf;
|
||||||
std::tie(buf, encryptedFile) = mtx::crypto::encrypt_file(payload);
|
std::tie(buf, encryptedFile) = mtx::crypto::encrypt_file(payload);
|
||||||
|
@ -371,7 +371,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
this,
|
this,
|
||||||
[this](QString roomid,
|
[this](QString roomid,
|
||||||
QString filename,
|
QString filename,
|
||||||
boost::optional<mtx::crypto::EncryptedFile> encryptedFile,
|
std::optional<mtx::crypto::EncryptedFile> encryptedFile,
|
||||||
QString url,
|
QString url,
|
||||||
QString mimeClass,
|
QString mimeClass,
|
||||||
QString mime,
|
QString mime,
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <boost/optional.hpp>
|
#include <optional>
|
||||||
#include <boost/variant.hpp>
|
#include <variant>
|
||||||
|
|
||||||
#include <mtx/common.hpp>
|
#include <mtx/common.hpp>
|
||||||
#include <mtx/responses.hpp>
|
#include <mtx/responses.hpp>
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ signals:
|
||||||
void uploadFailed(const QString &msg);
|
void uploadFailed(const QString &msg);
|
||||||
void mediaUploaded(const QString &roomid,
|
void mediaUploaded(const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
const boost::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &mimeClass,
|
const QString &mimeClass,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
|
@ -252,9 +253,8 @@ ChatPage::getMemberships(const std::vector<Collection> &collection) const
|
||||||
using Member = mtx::events::StateEvent<mtx::events::state::Member>;
|
using Member = mtx::events::StateEvent<mtx::events::state::Member>;
|
||||||
|
|
||||||
for (const auto &event : collection) {
|
for (const auto &event : collection) {
|
||||||
if (boost::get<Member>(event) != nullptr) {
|
if (auto member = std::get_if<Member>(event)) {
|
||||||
auto member = boost::get<Member>(event);
|
memberships.emplace(member->state_key, *member);
|
||||||
memberships.emplace(member.state_key, member);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <boost/variant.hpp>
|
#include <variant>
|
||||||
|
|
||||||
#include "Olm.h"
|
#include "Olm.h"
|
||||||
|
|
||||||
|
@ -289,14 +289,13 @@ request_keys(const std::string &room_id, const std::string &event_id)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boost::get<EncryptedEvent<msg::Encrypted>>(&res) == nullptr) {
|
if (!std::holds_alternative<EncryptedEvent<msg::Encrypted>>(res)) {
|
||||||
nhlog::net()->info(
|
nhlog::net()->info(
|
||||||
"retrieved event is not encrypted: {} from {}", event_id, room_id);
|
"retrieved event is not encrypted: {} from {}", event_id, room_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
olm::send_key_request_for(room_id,
|
olm::send_key_request_for(room_id, std::get<EncryptedEvent<msg::Encrypted>>(res));
|
||||||
boost::get<EncryptedEvent<msg::Encrypted>>(res));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,10 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include <boost/variant.hpp>
|
#include <cmath>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
#include <cmark.h>
|
#include <cmark.h>
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
@ -122,34 +123,33 @@ utils::getMessageDescription(const TimelineEvent &event,
|
||||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||||
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
||||||
|
|
||||||
if (boost::get<Audio>(&event) != nullptr) {
|
if (std::holds_alternative<Audio>(event)) {
|
||||||
return createDescriptionInfo<Audio>(event, localUser, room_id);
|
return createDescriptionInfo<Audio>(event, localUser, room_id);
|
||||||
} else if (boost::get<Emote>(&event) != nullptr) {
|
} else if (std::holds_alternative<Emote>(event)) {
|
||||||
return createDescriptionInfo<Emote>(event, localUser, room_id);
|
return createDescriptionInfo<Emote>(event, localUser, room_id);
|
||||||
} else if (boost::get<File>(&event) != nullptr) {
|
} else if (std::holds_alternative<File>(event)) {
|
||||||
return createDescriptionInfo<File>(event, localUser, room_id);
|
return createDescriptionInfo<File>(event, localUser, room_id);
|
||||||
} else if (boost::get<Image>(&event) != nullptr) {
|
} else if (std::holds_alternative<Image>(event)) {
|
||||||
return createDescriptionInfo<Image>(event, localUser, room_id);
|
return createDescriptionInfo<Image>(event, localUser, room_id);
|
||||||
} else if (boost::get<Notice>(&event) != nullptr) {
|
} else if (std::holds_alternative<Notice>(event)) {
|
||||||
return createDescriptionInfo<Notice>(event, localUser, room_id);
|
return createDescriptionInfo<Notice>(event, localUser, room_id);
|
||||||
} else if (boost::get<Text>(&event) != nullptr) {
|
} else if (std::holds_alternative<Text>(event)) {
|
||||||
return createDescriptionInfo<Text>(event, localUser, room_id);
|
return createDescriptionInfo<Text>(event, localUser, room_id);
|
||||||
} else if (boost::get<Video>(&event) != nullptr) {
|
} else if (std::holds_alternative<Video>(event)) {
|
||||||
return createDescriptionInfo<Video>(event, localUser, room_id);
|
return createDescriptionInfo<Video>(event, localUser, room_id);
|
||||||
} else if (boost::get<mtx::events::Sticker>(&event) != nullptr) {
|
} else if (std::holds_alternative<mtx::events::Sticker>(event)) {
|
||||||
return createDescriptionInfo<mtx::events::Sticker>(event, localUser, room_id);
|
return createDescriptionInfo<mtx::events::Sticker>(event, localUser, room_id);
|
||||||
} else if (boost::get<Encrypted>(&event) != nullptr) {
|
} else if (auto msg = std::get_if<Encrypted>(&event); msg != nullptr) {
|
||||||
const auto msg = boost::get<Encrypted>(event);
|
const auto sender = QString::fromStdString(msg->sender);
|
||||||
const auto sender = QString::fromStdString(msg.sender);
|
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
const auto username = Cache::displayName(room_id, sender);
|
||||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
const auto ts = QDateTime::fromMSecsSinceEpoch(msg->origin_server_ts);
|
||||||
|
|
||||||
DescInfo info;
|
DescInfo info;
|
||||||
info.userid = sender;
|
info.userid = sender;
|
||||||
info.body = QString(" %1").arg(messageDescription<Encrypted>());
|
info.body = QString(" %1").arg(messageDescription<Encrypted>());
|
||||||
info.timestamp = utils::descriptiveTime(ts);
|
info.timestamp = utils::descriptiveTime(ts);
|
||||||
info.event_id = QString::fromStdString(msg.event_id);
|
info.event_id = QString::fromStdString(msg->event_id);
|
||||||
info.datetime = ts;
|
info.datetime = ts;
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
|
@ -217,30 +217,25 @@ utils::levenshtein_distance(const std::string &s1, const std::string &s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
utils::event_body(const mtx::events::collections::TimelineEvents &event)
|
utils::event_body(const mtx::events::collections::TimelineEvents &e)
|
||||||
{
|
{
|
||||||
using namespace mtx::events;
|
using namespace mtx::events;
|
||||||
using namespace mtx::events::msg;
|
if (auto ev = std::get_if<RoomEvent<msg::Audio>>(&e); ev != nullptr)
|
||||||
|
return QString::fromStdString(ev->content.body);
|
||||||
|
if (auto ev = std::get_if<RoomEvent<msg::Emote>>(&e); ev != nullptr)
|
||||||
|
return QString::fromStdString(ev->content.body);
|
||||||
|
if (auto ev = std::get_if<RoomEvent<msg::File>>(&e); ev != nullptr)
|
||||||
|
return QString::fromStdString(ev->content.body);
|
||||||
|
if (auto ev = std::get_if<RoomEvent<msg::Image>>(&e); ev != nullptr)
|
||||||
|
return QString::fromStdString(ev->content.body);
|
||||||
|
if (auto ev = std::get_if<RoomEvent<msg::Notice>>(&e); ev != nullptr)
|
||||||
|
return QString::fromStdString(ev->content.body);
|
||||||
|
if (auto ev = std::get_if<RoomEvent<msg::Text>>(&e); ev != nullptr)
|
||||||
|
return QString::fromStdString(ev->content.body);
|
||||||
|
if (auto ev = std::get_if<RoomEvent<msg::Video>>(&e); ev != nullptr)
|
||||||
|
return QString::fromStdString(ev->content.body);
|
||||||
|
|
||||||
if (boost::get<RoomEvent<Audio>>(&event) != nullptr) {
|
return "";
|
||||||
return message_body<RoomEvent<Audio>>(event);
|
|
||||||
} else if (boost::get<RoomEvent<Emote>>(&event) != nullptr) {
|
|
||||||
return message_body<RoomEvent<Emote>>(event);
|
|
||||||
} else if (boost::get<RoomEvent<File>>(&event) != nullptr) {
|
|
||||||
return message_body<RoomEvent<File>>(event);
|
|
||||||
} else if (boost::get<RoomEvent<Image>>(&event) != nullptr) {
|
|
||||||
return message_body<RoomEvent<Image>>(event);
|
|
||||||
} else if (boost::get<RoomEvent<Notice>>(&event) != nullptr) {
|
|
||||||
return message_body<RoomEvent<Notice>>(event);
|
|
||||||
} else if (boost::get<Sticker>(&event) != nullptr) {
|
|
||||||
return message_body<Sticker>(event);
|
|
||||||
} else if (boost::get<RoomEvent<Text>>(&event) != nullptr) {
|
|
||||||
return message_body<RoomEvent<Text>>(event);
|
|
||||||
} else if (boost::get<RoomEvent<Video>>(&event) != nullptr) {
|
|
||||||
return message_body<RoomEvent<Video>>(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap
|
QPixmap
|
||||||
|
|
17
src/Utils.h
17
src/Utils.h
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/variant.hpp>
|
#include <variant>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "RoomInfoListItem.h"
|
#include "RoomInfoListItem.h"
|
||||||
|
@ -165,7 +165,7 @@ template<class T, class Event>
|
||||||
DescInfo
|
DescInfo
|
||||||
createDescriptionInfo(const Event &event, const QString &localUser, const QString &room_id)
|
createDescriptionInfo(const Event &event, const QString &localUser, const QString &room_id)
|
||||||
{
|
{
|
||||||
const auto msg = boost::get<T>(event);
|
const auto msg = std::get<T>(event);
|
||||||
const auto sender = QString::fromStdString(msg.sender);
|
const auto sender = QString::fromStdString(msg.sender);
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
const auto username = Cache::displayName(room_id, sender);
|
||||||
|
@ -200,25 +200,25 @@ erase_if(ContainerT &items, const PredicateT &predicate)
|
||||||
inline uint64_t
|
inline uint64_t
|
||||||
event_timestamp(const mtx::events::collections::TimelineEvents &event)
|
event_timestamp(const mtx::events::collections::TimelineEvents &event)
|
||||||
{
|
{
|
||||||
return boost::apply_visitor([](auto msg) { return msg.origin_server_ts; }, event);
|
return std::visit([](auto msg) { return msg.origin_server_ts; }, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline nlohmann::json
|
inline nlohmann::json
|
||||||
serialize_event(const mtx::events::collections::TimelineEvents &event)
|
serialize_event(const mtx::events::collections::TimelineEvents &event)
|
||||||
{
|
{
|
||||||
return boost::apply_visitor([](auto msg) { return json(msg); }, event);
|
return std::visit([](auto msg) { return json(msg); }, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline mtx::events::EventType
|
inline mtx::events::EventType
|
||||||
event_type(const mtx::events::collections::TimelineEvents &event)
|
event_type(const mtx::events::collections::TimelineEvents &event)
|
||||||
{
|
{
|
||||||
return boost::apply_visitor([](auto msg) { return msg.type; }, event);
|
return std::visit([](auto msg) { return msg.type; }, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string
|
inline std::string
|
||||||
event_id(const mtx::events::collections::TimelineEvents &event)
|
event_id(const mtx::events::collections::TimelineEvents &event)
|
||||||
{
|
{
|
||||||
return boost::apply_visitor([](auto msg) { return msg.event_id; }, event);
|
return std::visit([](auto msg) { return msg.event_id; }, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString
|
inline QString
|
||||||
|
@ -230,15 +230,14 @@ eventId(const mtx::events::collections::TimelineEvents &event)
|
||||||
inline QString
|
inline QString
|
||||||
event_sender(const mtx::events::collections::TimelineEvents &event)
|
event_sender(const mtx::events::collections::TimelineEvents &event)
|
||||||
{
|
{
|
||||||
return boost::apply_visitor([](auto msg) { return QString::fromStdString(msg.sender); },
|
return std::visit([](auto msg) { return QString::fromStdString(msg.sender); }, event);
|
||||||
event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
QString
|
QString
|
||||||
message_body(const mtx::events::collections::TimelineEvents &event)
|
message_body(const mtx::events::collections::TimelineEvents &event)
|
||||||
{
|
{
|
||||||
return QString::fromStdString(boost::get<T>(event).content.body);
|
return QString::fromStdString(std::get<T>(event).content.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Calculate the Levenshtein distance between two strings with character skipping.
|
//! Calculate the Levenshtein distance between two strings with character skipping.
|
||||||
|
|
|
@ -117,17 +117,17 @@ eventFormattedBody(const mtx::events::RoomEvent<T> &e)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
boost::optional<mtx::crypto::EncryptedFile>
|
std::optional<mtx::crypto::EncryptedFile>
|
||||||
eventEncryptionInfo(const mtx::events::Event<T> &)
|
eventEncryptionInfo(const mtx::events::Event<T> &)
|
||||||
{
|
{
|
||||||
return boost::none;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
auto
|
auto
|
||||||
eventEncryptionInfo(const mtx::events::RoomEvent<T> &e) -> std::enable_if_t<
|
eventEncryptionInfo(const mtx::events::RoomEvent<T> &e) -> std::enable_if_t<
|
||||||
std::is_same<decltype(e.content.file), boost::optional<mtx::crypto::EncryptedFile>>::value,
|
std::is_same<decltype(e.content.file), std::optional<mtx::crypto::EncryptedFile>>::value,
|
||||||
boost::optional<mtx::crypto::EncryptedFile>>
|
std::optional<mtx::crypto::EncryptedFile>>
|
||||||
{
|
{
|
||||||
return e.content.file;
|
return e.content.file;
|
||||||
}
|
}
|
||||||
|
@ -407,7 +407,7 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
||||||
}
|
}
|
||||||
eventOrder[idx] = event_id;
|
eventOrder[idx] = event_id;
|
||||||
auto ev = events.value(txn_id);
|
auto ev = events.value(txn_id);
|
||||||
ev = boost::apply_visitor(
|
ev = std::visit(
|
||||||
[event_id](const auto &e) -> mtx::events::collections::TimelineEvents {
|
[event_id](const auto &e) -> mtx::events::collections::TimelineEvents {
|
||||||
auto eventCopy = e;
|
auto eventCopy = e;
|
||||||
eventCopy.event_id = event_id.toStdString();
|
eventCopy.event_id = event_id.toStdString();
|
||||||
|
@ -483,29 +483,30 @@ TimelineModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
||||||
mtx::events::collections::TimelineEvents event = events.value(id);
|
mtx::events::collections::TimelineEvents event = events.value(id);
|
||||||
|
|
||||||
if (auto e = boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) {
|
if (auto e =
|
||||||
|
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) {
|
||||||
event = decryptEvent(*e).event;
|
event = decryptEvent(*e).event;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Section: {
|
case Section: {
|
||||||
QDateTime date = boost::apply_visitor(
|
QDateTime date =
|
||||||
[](const auto &e) -> QDateTime { return eventTimestamp(e); }, event);
|
std::visit([](const auto &e) -> QDateTime { return eventTimestamp(e); }, event);
|
||||||
date.setTime(QTime());
|
date.setTime(QTime());
|
||||||
|
|
||||||
QString userId =
|
QString userId =
|
||||||
boost::apply_visitor([](const auto &e) -> QString { return senderId(e); }, event);
|
std::visit([](const auto &e) -> QString { return senderId(e); }, event);
|
||||||
|
|
||||||
for (int r = index.row() - 1; r > 0; r--) {
|
for (int r = index.row() - 1; r > 0; r--) {
|
||||||
auto tempEv = events.value(eventOrder[r]);
|
auto tempEv = events.value(eventOrder[r]);
|
||||||
QDateTime prevDate = boost::apply_visitor(
|
QDateTime prevDate = std::visit(
|
||||||
[](const auto &e) -> QDateTime { return eventTimestamp(e); }, tempEv);
|
[](const auto &e) -> QDateTime { return eventTimestamp(e); }, tempEv);
|
||||||
prevDate.setTime(QTime());
|
prevDate.setTime(QTime());
|
||||||
if (prevDate != date)
|
if (prevDate != date)
|
||||||
return QString("%2 %1").arg(date.toMSecsSinceEpoch()).arg(userId);
|
return QString("%2 %1").arg(date.toMSecsSinceEpoch()).arg(userId);
|
||||||
|
|
||||||
QString prevUserId = boost::apply_visitor(
|
QString prevUserId =
|
||||||
[](const auto &e) -> QString { return senderId(e); }, tempEv);
|
std::visit([](const auto &e) -> QString { return senderId(e); }, tempEv);
|
||||||
if (userId != prevUserId)
|
if (userId != prevUserId)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -513,62 +514,61 @@ TimelineModel::data(const QModelIndex &index, int role) const
|
||||||
return QString("%1").arg(userId);
|
return QString("%1").arg(userId);
|
||||||
}
|
}
|
||||||
case UserId:
|
case UserId:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> QString { return senderId(e); }, event));
|
std::visit([](const auto &e) -> QString { return senderId(e); }, event));
|
||||||
case UserName:
|
case UserName:
|
||||||
return QVariant(displayName(boost::apply_visitor(
|
return QVariant(displayName(
|
||||||
[](const auto &e) -> QString { return senderId(e); }, event)));
|
std::visit([](const auto &e) -> QString { return senderId(e); }, event)));
|
||||||
|
|
||||||
case Timestamp:
|
case Timestamp:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> QDateTime { return eventTimestamp(e); }, event));
|
std::visit([](const auto &e) -> QDateTime { return eventTimestamp(e); }, event));
|
||||||
case Type:
|
case Type:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(std::visit(
|
||||||
[](const auto &e) -> qml_mtx_events::EventType { return toRoomEventType(e); },
|
[](const auto &e) -> qml_mtx_events::EventType { return toRoomEventType(e); },
|
||||||
event));
|
event));
|
||||||
case Body:
|
case Body:
|
||||||
return QVariant(utils::replaceEmoji(boost::apply_visitor(
|
return QVariant(utils::replaceEmoji(
|
||||||
[](const auto &e) -> QString { return eventBody(e); }, event)));
|
std::visit([](const auto &e) -> QString { return eventBody(e); }, event)));
|
||||||
case FormattedBody:
|
case FormattedBody:
|
||||||
return QVariant(
|
return QVariant(
|
||||||
utils::replaceEmoji(
|
utils::replaceEmoji(
|
||||||
utils::linkifyMessage(boost::apply_visitor(
|
utils::linkifyMessage(std::visit(
|
||||||
[](const auto &e) -> QString { return eventFormattedBody(e); }, event)))
|
[](const auto &e) -> QString { return eventFormattedBody(e); }, event)))
|
||||||
.remove("<mx-reply>")
|
.remove("<mx-reply>")
|
||||||
.remove("</mx-reply>"));
|
.remove("</mx-reply>"));
|
||||||
case Url:
|
case Url:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> QString { return eventUrl(e); }, event));
|
std::visit([](const auto &e) -> QString { return eventUrl(e); }, event));
|
||||||
case ThumbnailUrl:
|
case ThumbnailUrl:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> QString { return eventThumbnailUrl(e); }, event));
|
std::visit([](const auto &e) -> QString { return eventThumbnailUrl(e); }, event));
|
||||||
case Filename:
|
case Filename:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> QString { return eventFilename(e); }, event));
|
std::visit([](const auto &e) -> QString { return eventFilename(e); }, event));
|
||||||
case Filesize:
|
case Filesize:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(std::visit(
|
||||||
[](const auto &e) -> QString {
|
[](const auto &e) -> QString {
|
||||||
return utils::humanReadableFileSize(eventFilesize(e));
|
return utils::humanReadableFileSize(eventFilesize(e));
|
||||||
},
|
},
|
||||||
event));
|
event));
|
||||||
case MimeType:
|
case MimeType:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> QString { return eventMimeType(e); }, event));
|
std::visit([](const auto &e) -> QString { return eventMimeType(e); }, event));
|
||||||
case Height:
|
case Height:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> qulonglong { return eventHeight(e); }, event));
|
std::visit([](const auto &e) -> qulonglong { return eventHeight(e); }, event));
|
||||||
case Width:
|
case Width:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> qulonglong { return eventWidth(e); }, event));
|
std::visit([](const auto &e) -> qulonglong { return eventWidth(e); }, event));
|
||||||
case ProportionalHeight:
|
case ProportionalHeight:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> double { return eventPropHeight(e); }, event));
|
std::visit([](const auto &e) -> double { return eventPropHeight(e); }, event));
|
||||||
case Id:
|
case Id:
|
||||||
return id;
|
return id;
|
||||||
case State:
|
case State:
|
||||||
// only show read receipts for messages not from us
|
// only show read receipts for messages not from us
|
||||||
if (boost::apply_visitor([](const auto &e) -> QString { return senderId(e); },
|
if (std::visit([](const auto &e) -> QString { return senderId(e); }, event)
|
||||||
event)
|
|
||||||
.toStdString() != http::client()->user_id().to_string())
|
.toStdString() != http::client()->user_id().to_string())
|
||||||
return qml_mtx_events::Empty;
|
return qml_mtx_events::Empty;
|
||||||
else if (failed.contains(id))
|
else if (failed.contains(id))
|
||||||
|
@ -582,20 +582,20 @@ TimelineModel::data(const QModelIndex &index, int role) const
|
||||||
return qml_mtx_events::Received;
|
return qml_mtx_events::Received;
|
||||||
case IsEncrypted: {
|
case IsEncrypted: {
|
||||||
auto tempEvent = events[id];
|
auto tempEvent = events[id];
|
||||||
return boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
return std::holds_alternative<
|
||||||
&tempEvent) != nullptr;
|
mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(tempEvent);
|
||||||
}
|
}
|
||||||
case ReplyTo: {
|
case ReplyTo: {
|
||||||
QString evId = boost::apply_visitor(
|
QString evId =
|
||||||
[](const auto &e) -> QString { return eventRelatesTo(e); }, event);
|
std::visit([](const auto &e) -> QString { return eventRelatesTo(e); }, event);
|
||||||
return QVariant(evId);
|
return QVariant(evId);
|
||||||
}
|
}
|
||||||
case RoomName:
|
case RoomName:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> QString { return eventRoomName(e); }, event));
|
std::visit([](const auto &e) -> QString { return eventRoomName(e); }, event));
|
||||||
case RoomTopic:
|
case RoomTopic:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(
|
||||||
[](const auto &e) -> QString { return eventRoomTopic(e); }, event));
|
std::visit([](const auto &e) -> QString { return eventRoomTopic(e); }, event));
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -646,13 +646,12 @@ TimelineModel::updateLastMessage()
|
||||||
{
|
{
|
||||||
for (auto it = eventOrder.rbegin(); it != eventOrder.rend(); ++it) {
|
for (auto it = eventOrder.rbegin(); it != eventOrder.rend(); ++it) {
|
||||||
auto event = events.value(*it);
|
auto event = events.value(*it);
|
||||||
if (auto e = boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
if (auto e = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
||||||
&event)) {
|
&event)) {
|
||||||
event = decryptEvent(*e).event;
|
event = decryptEvent(*e).event;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!boost::apply_visitor([](const auto &e) -> bool { return isMessage(e); },
|
if (!std::visit([](const auto &e) -> bool { return isMessage(e); }, event))
|
||||||
event))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto description = utils::getMessageDescription(
|
auto description = utils::getMessageDescription(
|
||||||
|
@ -668,8 +667,7 @@ TimelineModel::internalAddEvents(
|
||||||
{
|
{
|
||||||
std::vector<QString> ids;
|
std::vector<QString> ids;
|
||||||
for (auto e : timeline) {
|
for (auto e : timeline) {
|
||||||
QString id =
|
QString id = std::visit([](const auto &e) -> QString { return eventId(e); }, e);
|
||||||
boost::apply_visitor([](const auto &e) -> QString { return eventId(e); }, e);
|
|
||||||
|
|
||||||
if (this->events.contains(id)) {
|
if (this->events.contains(id)) {
|
||||||
this->events.insert(id, e);
|
this->events.insert(id, e);
|
||||||
|
@ -679,12 +677,12 @@ TimelineModel::internalAddEvents(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto redaction =
|
if (auto redaction =
|
||||||
boost::get<mtx::events::RedactionEvent<mtx::events::msg::Redaction>>(&e)) {
|
std::get_if<mtx::events::RedactionEvent<mtx::events::msg::Redaction>>(&e)) {
|
||||||
QString redacts = QString::fromStdString(redaction->redacts);
|
QString redacts = QString::fromStdString(redaction->redacts);
|
||||||
auto redacted = std::find(eventOrder.begin(), eventOrder.end(), redacts);
|
auto redacted = std::find(eventOrder.begin(), eventOrder.end(), redacts);
|
||||||
|
|
||||||
if (redacted != eventOrder.end()) {
|
if (redacted != eventOrder.end()) {
|
||||||
auto redactedEvent = boost::apply_visitor(
|
auto redactedEvent = std::visit(
|
||||||
[](const auto &ev)
|
[](const auto &ev)
|
||||||
-> mtx::events::RoomEvent<mtx::events::msg::Redacted> {
|
-> mtx::events::RoomEvent<mtx::events::msg::Redacted> {
|
||||||
mtx::events::RoomEvent<mtx::events::msg::Redacted>
|
mtx::events::RoomEvent<mtx::events::msg::Redacted>
|
||||||
|
@ -707,11 +705,11 @@ TimelineModel::internalAddEvents(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto event =
|
if (auto event =
|
||||||
boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&e)) {
|
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&e)) {
|
||||||
e = decryptEvent(*event).event;
|
e = decryptEvent(*event).event;
|
||||||
}
|
}
|
||||||
auto encInfo = boost::apply_visitor(
|
auto encInfo = std::visit(
|
||||||
[](const auto &ev) -> boost::optional<mtx::crypto::EncryptedFile> {
|
[](const auto &ev) -> std::optional<mtx::crypto::EncryptedFile> {
|
||||||
return eventEncryptionInfo(ev);
|
return eventEncryptionInfo(ev);
|
||||||
},
|
},
|
||||||
e);
|
e);
|
||||||
|
@ -947,11 +945,12 @@ void
|
||||||
TimelineModel::replyAction(QString id)
|
TimelineModel::replyAction(QString id)
|
||||||
{
|
{
|
||||||
auto event = events.value(id);
|
auto event = events.value(id);
|
||||||
if (auto e = boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) {
|
if (auto e =
|
||||||
|
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) {
|
||||||
event = decryptEvent(*e).event;
|
event = decryptEvent(*e).event;
|
||||||
}
|
}
|
||||||
|
|
||||||
RelatedInfo related = boost::apply_visitor(
|
RelatedInfo related = std::visit(
|
||||||
[](const auto &ev) -> RelatedInfo {
|
[](const auto &ev) -> RelatedInfo {
|
||||||
RelatedInfo related_ = {};
|
RelatedInfo related_ = {};
|
||||||
related_.quoted_user = QString::fromStdString(ev.sender);
|
related_.quoted_user = QString::fromStdString(ev.sender);
|
||||||
|
@ -959,10 +958,10 @@ TimelineModel::replyAction(QString id)
|
||||||
return related_;
|
return related_;
|
||||||
},
|
},
|
||||||
event);
|
event);
|
||||||
related.type = mtx::events::getMessageType(boost::apply_visitor(
|
related.type = mtx::events::getMessageType(
|
||||||
[](const auto &e) -> std::string { return eventMsgType(e); }, event));
|
std::visit([](const auto &e) -> std::string { return eventMsgType(e); }, event));
|
||||||
related.quoted_body = boost::apply_visitor(
|
related.quoted_body =
|
||||||
[](const auto &e) -> QString { return eventFormattedBody(e); }, event);
|
std::visit([](const auto &e) -> QString { return eventFormattedBody(e); }, event);
|
||||||
related.quoted_body.remove(QRegularExpression(
|
related.quoted_body.remove(QRegularExpression(
|
||||||
"<mx-reply>.*</mx-reply>", QRegularExpression::DotMatchesEverythingOption));
|
"<mx-reply>.*</mx-reply>", QRegularExpression::DotMatchesEverythingOption));
|
||||||
nhlog::ui()->debug("after replacement: {}", related.quoted_body.toStdString());
|
nhlog::ui()->debug("after replacement: {}", related.quoted_body.toStdString());
|
||||||
|
@ -1396,7 +1395,7 @@ TimelineModel::processOnePendingMessage()
|
||||||
QString txn_id_qstr = pending.first();
|
QString txn_id_qstr = pending.first();
|
||||||
|
|
||||||
auto event = events.value(txn_id_qstr);
|
auto event = events.value(txn_id_qstr);
|
||||||
boost::apply_visitor(SendMessageVisitor{txn_id_qstr, this}, event);
|
std::visit(SendMessageVisitor{txn_id_qstr, this}, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1405,7 +1404,7 @@ TimelineModel::addPendingMessage(mtx::events::collections::TimelineEvents event)
|
||||||
internalAddEvents({event});
|
internalAddEvents({event});
|
||||||
|
|
||||||
QString txn_id_qstr =
|
QString txn_id_qstr =
|
||||||
boost::apply_visitor([](const auto &e) -> QString { return eventId(e); }, event);
|
std::visit([](const auto &e) -> QString { return eventId(e); }, event);
|
||||||
beginInsertRows(QModelIndex(),
|
beginInsertRows(QModelIndex(),
|
||||||
static_cast<int>(this->eventOrder.size()),
|
static_cast<int>(this->eventOrder.size()),
|
||||||
static_cast<int>(this->eventOrder.size()));
|
static_cast<int>(this->eventOrder.size()));
|
||||||
|
@ -1423,22 +1422,22 @@ TimelineModel::saveMedia(QString eventId) const
|
||||||
{
|
{
|
||||||
mtx::events::collections::TimelineEvents event = events.value(eventId);
|
mtx::events::collections::TimelineEvents event = events.value(eventId);
|
||||||
|
|
||||||
if (auto e = boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) {
|
if (auto e =
|
||||||
|
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) {
|
||||||
event = decryptEvent(*e).event;
|
event = decryptEvent(*e).event;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString mxcUrl =
|
QString mxcUrl = std::visit([](const auto &e) -> QString { return eventUrl(e); }, event);
|
||||||
boost::apply_visitor([](const auto &e) -> QString { return eventUrl(e); }, event);
|
|
||||||
QString originalFilename =
|
QString originalFilename =
|
||||||
boost::apply_visitor([](const auto &e) -> QString { return eventFilename(e); }, event);
|
std::visit([](const auto &e) -> QString { return eventFilename(e); }, event);
|
||||||
QString mimeType =
|
QString mimeType =
|
||||||
boost::apply_visitor([](const auto &e) -> QString { return eventMimeType(e); }, event);
|
std::visit([](const auto &e) -> QString { return eventMimeType(e); }, event);
|
||||||
|
|
||||||
using EncF = boost::optional<mtx::crypto::EncryptedFile>;
|
using EncF = std::optional<mtx::crypto::EncryptedFile>;
|
||||||
EncF encryptionInfo =
|
EncF encryptionInfo =
|
||||||
boost::apply_visitor([](const auto &e) -> EncF { return eventEncryptionInfo(e); }, event);
|
std::visit([](const auto &e) -> EncF { return eventEncryptionInfo(e); }, event);
|
||||||
|
|
||||||
qml_mtx_events::EventType eventType = boost::apply_visitor(
|
qml_mtx_events::EventType eventType = std::visit(
|
||||||
[](const auto &e) -> qml_mtx_events::EventType { return toRoomEventType(e); }, event);
|
[](const auto &e) -> qml_mtx_events::EventType { return toRoomEventType(e); }, event);
|
||||||
|
|
||||||
QString dialogTitle;
|
QString dialogTitle;
|
||||||
|
@ -1500,18 +1499,18 @@ TimelineModel::cacheMedia(QString eventId)
|
||||||
{
|
{
|
||||||
mtx::events::collections::TimelineEvents event = events.value(eventId);
|
mtx::events::collections::TimelineEvents event = events.value(eventId);
|
||||||
|
|
||||||
if (auto e = boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) {
|
if (auto e =
|
||||||
|
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) {
|
||||||
event = decryptEvent(*e).event;
|
event = decryptEvent(*e).event;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString mxcUrl =
|
QString mxcUrl = std::visit([](const auto &e) -> QString { return eventUrl(e); }, event);
|
||||||
boost::apply_visitor([](const auto &e) -> QString { return eventUrl(e); }, event);
|
|
||||||
QString mimeType =
|
QString mimeType =
|
||||||
boost::apply_visitor([](const auto &e) -> QString { return eventMimeType(e); }, event);
|
std::visit([](const auto &e) -> QString { return eventMimeType(e); }, event);
|
||||||
|
|
||||||
using EncF = boost::optional<mtx::crypto::EncryptedFile>;
|
using EncF = std::optional<mtx::crypto::EncryptedFile>;
|
||||||
EncF encryptionInfo =
|
EncF encryptionInfo =
|
||||||
boost::apply_visitor([](const auto &e) -> EncF { return eventEncryptionInfo(e); }, event);
|
std::visit([](const auto &e) -> EncF { return eventEncryptionInfo(e); }, event);
|
||||||
|
|
||||||
// If the message is a link to a non mxcUrl, don't download it
|
// If the message is a link to a non mxcUrl, don't download it
|
||||||
if (!mxcUrl.startsWith("mxc://")) {
|
if (!mxcUrl.startsWith("mxc://")) {
|
||||||
|
|
|
@ -222,7 +222,7 @@ TimelineViewManager::queueEmoteMessage(const QString &msg)
|
||||||
void
|
void
|
||||||
TimelineViewManager::queueImageMessage(const QString &roomid,
|
TimelineViewManager::queueImageMessage(const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
const boost::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize,
|
uint64_t dsize,
|
||||||
|
@ -243,7 +243,7 @@ void
|
||||||
TimelineViewManager::queueFileMessage(
|
TimelineViewManager::queueFileMessage(
|
||||||
const QString &roomid,
|
const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
const boost::optional<mtx::crypto::EncryptedFile> &encryptedFile,
|
const std::optional<mtx::crypto::EncryptedFile> &encryptedFile,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize)
|
uint64_t dsize)
|
||||||
|
@ -260,7 +260,7 @@ TimelineViewManager::queueFileMessage(
|
||||||
void
|
void
|
||||||
TimelineViewManager::queueAudioMessage(const QString &roomid,
|
TimelineViewManager::queueAudioMessage(const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
const boost::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize)
|
uint64_t dsize)
|
||||||
|
@ -277,7 +277,7 @@ TimelineViewManager::queueAudioMessage(const QString &roomid,
|
||||||
void
|
void
|
||||||
TimelineViewManager::queueVideoMessage(const QString &roomid,
|
TimelineViewManager::queueVideoMessage(const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
const boost::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize)
|
uint64_t dsize)
|
||||||
|
|
|
@ -56,26 +56,26 @@ public slots:
|
||||||
void queueEmoteMessage(const QString &msg);
|
void queueEmoteMessage(const QString &msg);
|
||||||
void queueImageMessage(const QString &roomid,
|
void queueImageMessage(const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
const boost::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize,
|
uint64_t dsize,
|
||||||
const QSize &dimensions);
|
const QSize &dimensions);
|
||||||
void queueFileMessage(const QString &roomid,
|
void queueFileMessage(const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
const boost::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize);
|
uint64_t dsize);
|
||||||
void queueAudioMessage(const QString &roomid,
|
void queueAudioMessage(const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
const boost::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize);
|
uint64_t dsize);
|
||||||
void queueVideoMessage(const QString &roomid,
|
void queueVideoMessage(const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
const boost::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize);
|
uint64_t dsize);
|
||||||
|
|
Loading…
Reference in a new issue