mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Merge matrix-structs into the client lib
This commit is contained in:
parent
d0e31c43a6
commit
990a3a97c7
14 changed files with 121 additions and 131 deletions
|
@ -5,6 +5,9 @@ option(ASAN "Compile with address sanitizers" OFF)
|
|||
|
||||
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 Qt basic functions
|
||||
|
@ -230,9 +233,20 @@ set(SRC_FILES
|
|||
# ExternalProject dependencies
|
||||
set(EXTERNAL_PROJECT_DEPS "")
|
||||
|
||||
set(Boost_USE_STATIC_LIBS OFF)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
find_package(Boost 1.66 REQUIRED
|
||||
COMPONENTS atomic
|
||||
chrono
|
||||
date_time
|
||||
iostreams
|
||||
random
|
||||
regex
|
||||
system
|
||||
thread)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(MatrixStructs 0.1.0 REQUIRED)
|
||||
find_package(MatrixClient 0.1.0 REQUIRED)
|
||||
find_package(Olm 2 REQUIRED)
|
||||
find_package(spdlog 1.0.0 CONFIG REQUIRED)
|
||||
|
@ -259,6 +273,7 @@ include_directories(SYSTEM ${TWEENY_INCLUDE_DIR})
|
|||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/config)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
|
||||
qt5_wrap_cpp(MOC_HEADERS
|
||||
# Dialogs
|
||||
|
@ -342,8 +357,8 @@ include(Translations)
|
|||
set(TRANSLATION_DEPS ${LANG_QRC} ${QRC} ${QM_SRC})
|
||||
|
||||
set(COMMON_LIBS
|
||||
MatrixStructs::MatrixStructs
|
||||
MatrixClient::MatrixClient
|
||||
${Boost_LIBRARIES}
|
||||
Qt5::Widgets
|
||||
Qt5::Svg
|
||||
Qt5::Concurrent
|
||||
|
|
|
@ -86,7 +86,6 @@ sudo port install nheko
|
|||
Freetype, which is essential to properly support emoji.
|
||||
- CMake 3.1 or greater.
|
||||
- [mtxclient](https://github.com/mujx/mtxclient)
|
||||
- [matrix-structs](https://github.com/mujx/matrix-structs)
|
||||
- [LMDB](https://symas.com/lightning-memory-mapped-database/)
|
||||
- Boost 1.66 or greater.
|
||||
- [libolm](https://git.matrix.org/git/olm)
|
||||
|
|
29
deps/CMakeLists.txt
vendored
29
deps/CMakeLists.txt
vendored
|
@ -26,8 +26,6 @@ option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog." ${USE_BUNDLED})
|
|||
option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${USE_BUNDLED})
|
||||
option(USE_BUNDLED_TWEENY "Use the bundled version of Tweeny." ${USE_BUNDLED})
|
||||
option(USE_BUNDLED_LMDBXX "Use the bundled version of lmdbxx." ${USE_BUNDLED})
|
||||
option(USE_BUNDLED_MATRIX_STRUCTS "Use the bundled version of matrix-structs."
|
||||
${USE_BUNDLED})
|
||||
option(USE_BUNDLED_MATRIX_CLIENT "Use the bundled version of mtxclient."
|
||||
${USE_BUNDLED})
|
||||
|
||||
|
@ -38,19 +36,12 @@ set(BOOST_URL
|
|||
set(BOOST_SHA256
|
||||
5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9)
|
||||
|
||||
set(
|
||||
MATRIX_STRUCTS_URL
|
||||
https://github.com/mujx/matrix-structs/archive/8de04afea34e95c14d1dde82af390592dfde90dd.tar.gz
|
||||
)
|
||||
set(MATRIX_STRUCTS_HASH
|
||||
255a82a9e463261858cd7da18f34fd60d19882ab507d214e47ea47ff78ae68b6)
|
||||
|
||||
set(
|
||||
MTXCLIENT_URL
|
||||
https://github.com/mujx/mtxclient/archive/10894678e982bc037a0aa4cf650b89a566ccbc52.tar.gz
|
||||
https://github.com/mujx/mtxclient/archive/343cf4b1589b380443dd7f34f381d655ba9cc87c.tar.gz
|
||||
)
|
||||
set(MTXCLIENT_HASH
|
||||
9bbb4613e6ed7c9886575221e1820c4aeda302ff29703e9040e53a2d0236c8ea)
|
||||
68d4f7be55bb62a59e8698ecb04705e7422b63d5caccede26e2e0153f17ccda9)
|
||||
|
||||
set(
|
||||
TWEENY_URL
|
||||
|
@ -69,9 +60,17 @@ set(LMDBXX_HASH
|
|||
set(OLM_URL https://git.matrix.org/git/olm.git)
|
||||
set(OLM_TAG 4065c8e11a33ba41133a086ed3de4da94dcb6bae)
|
||||
|
||||
set(SPDLOG_URL https://github.com/gabime/spdlog/archive/v1.0.0.tar.gz)
|
||||
set(SPDLOG_URL https://github.com/gabime/spdlog/archive/v1.1.0.tar.gz)
|
||||
set(SPDLOG_HASH
|
||||
90d5365121bcd2c41ce94dfe6a460e89507a2dfef6133fe5fad5bb35ac4ef0a1)
|
||||
3dbcbfd8c07e25f5e0d662b194d3a7772ef214358c49ada23c044c4747ce8b19)
|
||||
|
||||
set(JSON_HEADER_URL
|
||||
https://github.com/nlohmann/json/releases/download/v3.2.0/json.hpp)
|
||||
set(JSON_HEADER_HASH
|
||||
ce6b5610a051ec6795fa11c33854abebb086f0fd67c311f5921c3c07f9531b44)
|
||||
|
||||
file(DOWNLOAD ${JSON_HEADER_URL} ${DEPS_INSTALL_DIR}/include/json.hpp
|
||||
EXPECTED_HASH SHA256=${JSON_HEADER_HASH})
|
||||
|
||||
if(USE_BUNDLED_BOOST)
|
||||
include(Boost)
|
||||
|
@ -85,10 +84,6 @@ if(USE_BUNDLED_OLM)
|
|||
include(Olm)
|
||||
endif()
|
||||
|
||||
if(USE_BUNDLED_MATRIX_STRUCTS)
|
||||
include(MatrixStructs)
|
||||
endif()
|
||||
|
||||
if(USE_BUNDLED_TWEENY)
|
||||
include(Tweeny)
|
||||
endif()
|
||||
|
|
24
deps/cmake/MatrixStructs.cmake
vendored
24
deps/cmake/MatrixStructs.cmake
vendored
|
@ -1,24 +0,0 @@
|
|||
set(WINDOWS_FLAGS "")
|
||||
|
||||
if(MSVC)
|
||||
set(WINDOWS_FLAGS "-DCMAKE_GENERATOR_PLATFORM=x64")
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(
|
||||
MatrixStructs
|
||||
|
||||
URL ${MATRIX_STRUCTS_URL}
|
||||
URL_HASH SHA256=${MATRIX_STRUCTS_HASH}
|
||||
|
||||
BUILD_IN_SOURCE 1
|
||||
SOURCE_DIR ${DEPS_BUILD_DIR}/matrix_structs
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
${DEPS_BUILD_DIR}/matrix_structs
|
||||
${WINDOWS_FLAGS}
|
||||
BUILD_COMMAND ${CMAKE_COMMAND}
|
||||
--build ${DEPS_BUILD_DIR}/matrix_structs
|
||||
--config Release)
|
||||
|
||||
list(APPEND THIRD_PARTY_DEPS MatrixStructs)
|
1
deps/cmake/SpdLog.cmake
vendored
1
deps/cmake/SpdLog.cmake
vendored
|
@ -15,6 +15,7 @@ ExternalProject_Add(
|
|||
CONFIGURE_COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
|
||||
-DSPDLOG_BUILD_EXAMPLES=0
|
||||
-DSPDLOG_BUILD_BENCH=0
|
||||
-DSPDLOG_BUILD_TESTING=0
|
||||
${DEPS_BUILD_DIR}/spdlog
|
||||
${WINDOWS_FLAGS})
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <mtx/responses/common.hpp>
|
||||
#include <variant.hpp>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "Utils.h"
|
||||
|
@ -918,8 +918,8 @@ Cache::saveInvite(lmdb::txn &txn,
|
|||
using namespace mtx::events::state;
|
||||
|
||||
for (const auto &e : room.invite_state) {
|
||||
if (mpark::holds_alternative<StrippedEvent<Member>>(e)) {
|
||||
auto msg = mpark::get<StrippedEvent<Member>>(e);
|
||||
if (boost::get<StrippedEvent<Member>>(&e) != nullptr) {
|
||||
auto msg = boost::get<StrippedEvent<Member>>(e);
|
||||
|
||||
auto display_name = msg.content.display_name.empty()
|
||||
? msg.state_key
|
||||
|
@ -930,7 +930,7 @@ Cache::saveInvite(lmdb::txn &txn,
|
|||
lmdb::dbi_put(
|
||||
txn, membersdb, lmdb::val(msg.state_key), lmdb::val(json(tmp).dump()));
|
||||
} else {
|
||||
mpark::visit(
|
||||
boost::apply_visitor(
|
||||
[&txn, &statesdb](auto msg) {
|
||||
bool res = lmdb::dbi_put(txn,
|
||||
statesdb,
|
||||
|
@ -1744,7 +1744,7 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
|
|||
if (isStateEvent(e))
|
||||
continue;
|
||||
|
||||
if (mpark::holds_alternative<RedactionEvent<msg::Redaction>>(e))
|
||||
if (boost::get<RedactionEvent<msg::Redaction>>(&e) != nullptr)
|
||||
continue;
|
||||
|
||||
json obj = json::object();
|
||||
|
|
50
src/Cache.h
50
src/Cache.h
|
@ -486,8 +486,8 @@ private:
|
|||
using namespace mtx::events;
|
||||
using namespace mtx::events::state;
|
||||
|
||||
if (mpark::holds_alternative<StateEvent<Member>>(event)) {
|
||||
const auto e = mpark::get<StateEvent<Member>>(event);
|
||||
if (boost::get<StateEvent<Member>>(&event) != nullptr) {
|
||||
const auto e = boost::get<StateEvent<Member>>(event);
|
||||
|
||||
switch (e.content.membership) {
|
||||
//
|
||||
|
@ -531,7 +531,7 @@ private:
|
|||
}
|
||||
|
||||
return;
|
||||
} else if (mpark::holds_alternative<StateEvent<Encryption>>(event)) {
|
||||
} else if (boost::get<StateEvent<Encryption>>(&event) != nullptr) {
|
||||
setEncryptedRoom(txn, room_id);
|
||||
return;
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ private:
|
|||
if (!isStateEvent(event))
|
||||
return;
|
||||
|
||||
mpark::visit(
|
||||
boost::apply_visitor(
|
||||
[&txn, &statesdb](auto e) {
|
||||
lmdb::dbi_put(
|
||||
txn, statesdb, lmdb::val(to_string(e.type)), lmdb::val(json(e).dump()));
|
||||
|
@ -553,17 +553,17 @@ private:
|
|||
using namespace mtx::events;
|
||||
using namespace mtx::events::state;
|
||||
|
||||
return mpark::holds_alternative<StateEvent<Aliases>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<state::Avatar>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<CanonicalAlias>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<Create>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<GuestAccess>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<HistoryVisibility>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<JoinRules>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<Name>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<Member>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<PowerLevels>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<Topic>>(e);
|
||||
return boost::get<StateEvent<Aliases>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<state::Avatar>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<CanonicalAlias>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<Create>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<GuestAccess>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<HistoryVisibility>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<JoinRules>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<Name>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<Member>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<PowerLevels>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<Topic>>(&e) != nullptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
@ -572,11 +572,11 @@ private:
|
|||
using namespace mtx::events;
|
||||
using namespace mtx::events::state;
|
||||
|
||||
return mpark::holds_alternative<StateEvent<state::Avatar>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<CanonicalAlias>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<Name>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<Member>>(e) ||
|
||||
mpark::holds_alternative<StateEvent<Topic>>(e);
|
||||
return boost::get<StateEvent<state::Avatar>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<CanonicalAlias>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<Name>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<Member>>(&e) != nullptr ||
|
||||
boost::get<StateEvent<Topic>>(&e) != nullptr;
|
||||
}
|
||||
|
||||
bool containsStateUpdates(const mtx::events::collections::StrippedEvents &e)
|
||||
|
@ -584,11 +584,11 @@ private:
|
|||
using namespace mtx::events;
|
||||
using namespace mtx::events::state;
|
||||
|
||||
return mpark::holds_alternative<StrippedEvent<state::Avatar>>(e) ||
|
||||
mpark::holds_alternative<StrippedEvent<CanonicalAlias>>(e) ||
|
||||
mpark::holds_alternative<StrippedEvent<Name>>(e) ||
|
||||
mpark::holds_alternative<StrippedEvent<Member>>(e) ||
|
||||
mpark::holds_alternative<StrippedEvent<Topic>>(e);
|
||||
return boost::get<StrippedEvent<state::Avatar>>(&e) != nullptr ||
|
||||
boost::get<StrippedEvent<CanonicalAlias>>(&e) != nullptr ||
|
||||
boost::get<StrippedEvent<Name>>(&e) != nullptr ||
|
||||
boost::get<StrippedEvent<Member>>(&e) != nullptr ||
|
||||
boost::get<StrippedEvent<Topic>>(&e) != nullptr;
|
||||
}
|
||||
|
||||
void saveInvites(lmdb::txn &txn,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
|
@ -249,8 +250,8 @@ ChatPage::getMemberships(const std::vector<Collection> &collection) const
|
|||
using Member = mtx::events::StateEvent<mtx::events::state::Member>;
|
||||
|
||||
for (const auto &event : collection) {
|
||||
if (mpark::holds_alternative<Member>(event)) {
|
||||
auto member = mpark::get<Member>(event);
|
||||
if (boost::get<Member>(event) != nullptr) {
|
||||
auto member = boost::get<Member>(event);
|
||||
memberships.emplace(member.state_key, member);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <boost/variant.hpp>
|
||||
|
||||
#include "Olm.h"
|
||||
|
||||
#include "Cache.h"
|
||||
|
@ -288,14 +290,14 @@ request_keys(const std::string &room_id, const std::string &event_id)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!mpark::holds_alternative<EncryptedEvent<msg::Encrypted>>(res)) {
|
||||
if (boost::get<EncryptedEvent<msg::Encrypted>>(&res) == nullptr) {
|
||||
nhlog::net()->info(
|
||||
"retrieved event is not encrypted: {} from {}", event_id, room_id);
|
||||
return;
|
||||
}
|
||||
|
||||
olm::send_key_request_for(room_id,
|
||||
mpark::get<EncryptedEvent<msg::Encrypted>>(res));
|
||||
boost::get<EncryptedEvent<msg::Encrypted>>(res));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
|
||||
#include <variant.hpp>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "Config.h"
|
||||
#include "RoomInfoListItem.h"
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
#include <QStyleOption>
|
||||
#include <QtConcurrent>
|
||||
|
||||
#include <variant.hpp>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "ChatPage.h"
|
||||
#include "Config.h"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <QSettings>
|
||||
#include <cmath>
|
||||
|
||||
#include <variant.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
using TimelineEvent = mtx::events::collections::TimelineEvents;
|
||||
|
||||
|
@ -89,24 +89,24 @@ utils::getMessageDescription(const TimelineEvent &event,
|
|||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
||||
|
||||
if (mpark::holds_alternative<Audio>(event)) {
|
||||
if (boost::get<Audio>(&event) != nullptr) {
|
||||
return createDescriptionInfo<Audio>(event, localUser, room_id);
|
||||
} else if (mpark::holds_alternative<Emote>(event)) {
|
||||
} else if (boost::get<Emote>(&event) != nullptr) {
|
||||
return createDescriptionInfo<Emote>(event, localUser, room_id);
|
||||
} else if (mpark::holds_alternative<File>(event)) {
|
||||
} else if (boost::get<File>(&event) != nullptr) {
|
||||
return createDescriptionInfo<File>(event, localUser, room_id);
|
||||
} else if (mpark::holds_alternative<Image>(event)) {
|
||||
} else if (boost::get<Image>(&event) != nullptr) {
|
||||
return createDescriptionInfo<Image>(event, localUser, room_id);
|
||||
} else if (mpark::holds_alternative<Notice>(event)) {
|
||||
} else if (boost::get<Notice>(&event) != nullptr) {
|
||||
return createDescriptionInfo<Notice>(event, localUser, room_id);
|
||||
} else if (mpark::holds_alternative<Text>(event)) {
|
||||
} else if (boost::get<Text>(&event) != nullptr) {
|
||||
return createDescriptionInfo<Text>(event, localUser, room_id);
|
||||
} else if (mpark::holds_alternative<Video>(event)) {
|
||||
} else if (boost::get<Video>(&event) != nullptr) {
|
||||
return createDescriptionInfo<Video>(event, localUser, room_id);
|
||||
} else if (mpark::holds_alternative<mtx::events::Sticker>(event)) {
|
||||
} else if (boost::get<mtx::events::Sticker>(&event) != nullptr) {
|
||||
return createDescriptionInfo<mtx::events::Sticker>(event, localUser, room_id);
|
||||
} else if (mpark::holds_alternative<Encrypted>(event)) {
|
||||
const auto msg = mpark::get<Encrypted>(event);
|
||||
} else if (boost::get<Encrypted>(&event) != nullptr) {
|
||||
const auto msg = boost::get<Encrypted>(event);
|
||||
const auto sender = QString::fromStdString(msg.sender);
|
||||
|
||||
const auto username = Cache::displayName(room_id, sender);
|
||||
|
@ -193,21 +193,21 @@ utils::event_body(const mtx::events::collections::TimelineEvents &event)
|
|||
using namespace mtx::events;
|
||||
using namespace mtx::events::msg;
|
||||
|
||||
if (mpark::holds_alternative<RoomEvent<Audio>>(event)) {
|
||||
if (boost::get<RoomEvent<Audio>>(&event) != nullptr) {
|
||||
return message_body<RoomEvent<Audio>>(event);
|
||||
} else if (mpark::holds_alternative<RoomEvent<Emote>>(event)) {
|
||||
} else if (boost::get<RoomEvent<Emote>>(&event) != nullptr) {
|
||||
return message_body<RoomEvent<Emote>>(event);
|
||||
} else if (mpark::holds_alternative<RoomEvent<File>>(event)) {
|
||||
} else if (boost::get<RoomEvent<File>>(&event) != nullptr) {
|
||||
return message_body<RoomEvent<File>>(event);
|
||||
} else if (mpark::holds_alternative<RoomEvent<Image>>(event)) {
|
||||
} else if (boost::get<RoomEvent<Image>>(&event) != nullptr) {
|
||||
return message_body<RoomEvent<Image>>(event);
|
||||
} else if (mpark::holds_alternative<RoomEvent<Notice>>(event)) {
|
||||
} else if (boost::get<RoomEvent<Notice>>(&event) != nullptr) {
|
||||
return message_body<RoomEvent<Notice>>(event);
|
||||
} else if (mpark::holds_alternative<Sticker>(event)) {
|
||||
} else if (boost::get<Sticker>(&event) != nullptr) {
|
||||
return message_body<Sticker>(event);
|
||||
} else if (mpark::holds_alternative<RoomEvent<Text>>(event)) {
|
||||
} else if (boost::get<RoomEvent<Text>>(&event) != nullptr) {
|
||||
return message_body<RoomEvent<Text>>(event);
|
||||
} else if (mpark::holds_alternative<RoomEvent<Video>>(event)) {
|
||||
} else if (boost::get<RoomEvent<Video>>(&event) != nullptr) {
|
||||
return message_body<RoomEvent<Video>>(event);
|
||||
}
|
||||
|
||||
|
|
17
src/Utils.h
17
src/Utils.h
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "RoomInfoListItem.h"
|
||||
#include "timeline/widgets/AudioItem.h"
|
||||
|
@ -96,7 +98,7 @@ createDescriptionInfo(const Event &event, const QString &localUser, const QStrin
|
|||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||
using Emote = mtx::events::RoomEvent<mtx::events::msg::Emote>;
|
||||
|
||||
const auto msg = mpark::get<T>(event);
|
||||
const auto msg = boost::get<T>(event);
|
||||
const auto sender = QString::fromStdString(msg.sender);
|
||||
|
||||
const auto username = Cache::displayName(room_id, sender);
|
||||
|
@ -135,25 +137,25 @@ erase_if(ContainerT &items, const PredicateT &predicate)
|
|||
inline uint64_t
|
||||
event_timestamp(const mtx::events::collections::TimelineEvents &event)
|
||||
{
|
||||
return mpark::visit([](auto msg) { return msg.origin_server_ts; }, event);
|
||||
return boost::apply_visitor([](auto msg) { return msg.origin_server_ts; }, event);
|
||||
}
|
||||
|
||||
inline nlohmann::json
|
||||
serialize_event(const mtx::events::collections::TimelineEvents &event)
|
||||
{
|
||||
return mpark::visit([](auto msg) { return json(msg); }, event);
|
||||
return boost::apply_visitor([](auto msg) { return json(msg); }, event);
|
||||
}
|
||||
|
||||
inline mtx::events::EventType
|
||||
event_type(const mtx::events::collections::TimelineEvents &event)
|
||||
{
|
||||
return mpark::visit([](auto msg) { return msg.type; }, event);
|
||||
return boost::apply_visitor([](auto msg) { return msg.type; }, event);
|
||||
}
|
||||
|
||||
inline std::string
|
||||
event_id(const mtx::events::collections::TimelineEvents &event)
|
||||
{
|
||||
return mpark::visit([](auto msg) { return msg.event_id; }, event);
|
||||
return boost::apply_visitor([](auto msg) { return msg.event_id; }, event);
|
||||
}
|
||||
|
||||
inline QString
|
||||
|
@ -165,14 +167,15 @@ eventId(const mtx::events::collections::TimelineEvents &event)
|
|||
inline QString
|
||||
event_sender(const mtx::events::collections::TimelineEvents &event)
|
||||
{
|
||||
return mpark::visit([](auto msg) { return QString::fromStdString(msg.sender); }, event);
|
||||
return boost::apply_visitor([](auto msg) { return QString::fromStdString(msg.sender); },
|
||||
event);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
QString
|
||||
message_body(const mtx::events::collections::TimelineEvents &event)
|
||||
{
|
||||
return QString::fromStdString(mpark::get<T>(event).content.body);
|
||||
return QString::fromStdString(boost::get<T>(event).content.body);
|
||||
}
|
||||
|
||||
//! Calculate the Levenshtein distance between two strings with character skipping.
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileInfo>
|
||||
#include <QTimer>
|
||||
|
@ -223,8 +225,8 @@ TimelineView::parseMessageEvent(const mtx::events::collections::TimelineEvents &
|
|||
using TextEvent = RoomEvent<msg::Text>;
|
||||
using VideoEvent = RoomEvent<msg::Video>;
|
||||
|
||||
if (mpark::holds_alternative<RedactionEvent<msg::Redaction>>(event)) {
|
||||
auto redaction_event = mpark::get<RedactionEvent<msg::Redaction>>(event);
|
||||
if (boost::get<RedactionEvent<msg::Redaction>>(&event) != nullptr) {
|
||||
auto redaction_event = boost::get<RedactionEvent<msg::Redaction>>(event);
|
||||
const auto event_id = QString::fromStdString(redaction_event.redacts);
|
||||
|
||||
QTimer::singleShot(0, this, [event_id, this]() {
|
||||
|
@ -233,8 +235,8 @@ TimelineView::parseMessageEvent(const mtx::events::collections::TimelineEvents &
|
|||
});
|
||||
|
||||
return nullptr;
|
||||
} else if (mpark::holds_alternative<StateEvent<state::Encryption>>(event)) {
|
||||
auto msg = mpark::get<StateEvent<state::Encryption>>(event);
|
||||
} else if (boost::get<StateEvent<state::Encryption>>(&event) != nullptr) {
|
||||
auto msg = boost::get<StateEvent<state::Encryption>>(event);
|
||||
auto event_id = QString::fromStdString(msg.event_id);
|
||||
|
||||
if (eventIds_.contains(event_id))
|
||||
|
@ -248,32 +250,32 @@ TimelineView::parseMessageEvent(const mtx::events::collections::TimelineEvents &
|
|||
saveMessageInfo("", msg.origin_server_ts, direction);
|
||||
|
||||
return item;
|
||||
} else if (mpark::holds_alternative<RoomEvent<msg::Audio>>(event)) {
|
||||
auto audio = mpark::get<RoomEvent<msg::Audio>>(event);
|
||||
} else if (boost::get<RoomEvent<msg::Audio>>(&event) != nullptr) {
|
||||
auto audio = boost::get<RoomEvent<msg::Audio>>(event);
|
||||
return processMessageEvent<AudioEvent, AudioItem>(audio, direction);
|
||||
} else if (mpark::holds_alternative<RoomEvent<msg::Emote>>(event)) {
|
||||
auto emote = mpark::get<RoomEvent<msg::Emote>>(event);
|
||||
} else if (boost::get<RoomEvent<msg::Emote>>(&event) != nullptr) {
|
||||
auto emote = boost::get<RoomEvent<msg::Emote>>(event);
|
||||
return processMessageEvent<EmoteEvent>(emote, direction);
|
||||
} else if (mpark::holds_alternative<RoomEvent<msg::File>>(event)) {
|
||||
auto file = mpark::get<RoomEvent<msg::File>>(event);
|
||||
} else if (boost::get<RoomEvent<msg::File>>(&event) != nullptr) {
|
||||
auto file = boost::get<RoomEvent<msg::File>>(event);
|
||||
return processMessageEvent<FileEvent, FileItem>(file, direction);
|
||||
} else if (mpark::holds_alternative<RoomEvent<msg::Image>>(event)) {
|
||||
auto image = mpark::get<RoomEvent<msg::Image>>(event);
|
||||
} else if (boost::get<RoomEvent<msg::Image>>(&event) != nullptr) {
|
||||
auto image = boost::get<RoomEvent<msg::Image>>(event);
|
||||
return processMessageEvent<ImageEvent, ImageItem>(image, direction);
|
||||
} else if (mpark::holds_alternative<RoomEvent<msg::Notice>>(event)) {
|
||||
auto notice = mpark::get<RoomEvent<msg::Notice>>(event);
|
||||
} else if (boost::get<RoomEvent<msg::Notice>>(&event) != nullptr) {
|
||||
auto notice = boost::get<RoomEvent<msg::Notice>>(event);
|
||||
return processMessageEvent<NoticeEvent>(notice, direction);
|
||||
} else if (mpark::holds_alternative<RoomEvent<msg::Text>>(event)) {
|
||||
auto text = mpark::get<RoomEvent<msg::Text>>(event);
|
||||
} else if (boost::get<RoomEvent<msg::Text>>(&event) != nullptr) {
|
||||
auto text = boost::get<RoomEvent<msg::Text>>(event);
|
||||
return processMessageEvent<TextEvent>(text, direction);
|
||||
} else if (mpark::holds_alternative<RoomEvent<msg::Video>>(event)) {
|
||||
auto video = mpark::get<RoomEvent<msg::Video>>(event);
|
||||
} else if (boost::get<RoomEvent<msg::Video>>(&event) != nullptr) {
|
||||
auto video = boost::get<RoomEvent<msg::Video>>(event);
|
||||
return processMessageEvent<VideoEvent, VideoItem>(video, direction);
|
||||
} else if (mpark::holds_alternative<Sticker>(event)) {
|
||||
return processMessageEvent<Sticker, StickerItem>(mpark::get<Sticker>(event),
|
||||
} else if (boost::get<Sticker>(&event) != nullptr) {
|
||||
return processMessageEvent<Sticker, StickerItem>(boost::get<Sticker>(event),
|
||||
direction);
|
||||
} else if (mpark::holds_alternative<EncryptedEvent<msg::Encrypted>>(event)) {
|
||||
auto res = parseEncryptedEvent(mpark::get<EncryptedEvent<msg::Encrypted>>(event));
|
||||
} else if (boost::get<EncryptedEvent<msg::Encrypted>>(&event) != nullptr) {
|
||||
auto res = parseEncryptedEvent(boost::get<EncryptedEvent<msg::Encrypted>>(event));
|
||||
auto widget = parseMessageEvent(res.event, direction);
|
||||
|
||||
if (widget == nullptr)
|
||||
|
|
Loading…
Reference in a new issue