mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Speed up compilation a bit
This commit is contained in:
parent
3f5c8929c3
commit
99a3e8bcf2
42 changed files with 320 additions and 257 deletions
|
@ -595,7 +595,7 @@ if(USE_BUNDLED_MTXCLIENT)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
MatrixClient
|
MatrixClient
|
||||||
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
||||||
GIT_TAG f878e29420c037f45b575fbd29a11cabce3c010a
|
GIT_TAG 9876a75f46cc829beaa630d49dc8c5279a940b0d
|
||||||
)
|
)
|
||||||
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
||||||
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
||||||
|
|
|
@ -214,7 +214,7 @@ modules:
|
||||||
buildsystem: cmake-ninja
|
buildsystem: cmake-ninja
|
||||||
name: mtxclient
|
name: mtxclient
|
||||||
sources:
|
sources:
|
||||||
- commit: 6e01c75fccc2724fcdfe7a7b1a13547522eb8753
|
- commit: 9876a75f46cc829beaa630d49dc8c5279a940b0d
|
||||||
#tag: v0.9.2
|
#tag: v0.9.2
|
||||||
type: git
|
type: git
|
||||||
url: https://github.com/Nheko-Reborn/mtxclient.git
|
url: https://github.com/Nheko-Reborn/mtxclient.git
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include <mtx/responses/common.hpp>
|
#include <mtx/responses/common.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
#include <mtx/events/canonical_alias.hpp>
|
#include <mtx/events/canonical_alias.hpp>
|
||||||
|
|
||||||
#include "CacheStructs.h"
|
|
||||||
|
|
||||||
class FetchPublishedAliasesJob final : public QObject
|
class FetchPublishedAliasesJob final : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -6,14 +6,10 @@
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "AvatarProvider.h"
|
#include "AvatarProvider.h"
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Logging.h"
|
|
||||||
#include "MatrixClient.h"
|
|
||||||
#include "MxcImageProvider.h"
|
#include "MxcImageProvider.h"
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
static QPixmapCache avatar_cache;
|
static QPixmapCache avatar_cache;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using AvatarCallback = std::function<void(QPixmap)>;
|
using AvatarCallback = std::function<void(QPixmap)>;
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
#include "BlurhashProvider.h"
|
#include "BlurhashProvider.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "blurhash.hpp"
|
#include "blurhash.hpp"
|
||||||
|
|
245
src/Cache.cpp
245
src/Cache.cpp
|
@ -24,6 +24,8 @@
|
||||||
#include <qt6keychain/keychain.h>
|
#include <qt6keychain/keychain.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <mtx/responses/common.hpp>
|
#include <mtx/responses/common.hpp>
|
||||||
#include <mtx/responses/messages.hpp>
|
#include <mtx/responses/messages.hpp>
|
||||||
|
|
||||||
|
@ -532,8 +534,8 @@ Cache::loadSecretsFromStore(
|
||||||
name,
|
name,
|
||||||
toLoad,
|
toLoad,
|
||||||
job,
|
job,
|
||||||
name_ = name_,
|
name__ = name_,
|
||||||
internal = internal,
|
internal_ = internal,
|
||||||
callback,
|
callback,
|
||||||
databaseReadyOnFinished](QKeychain::Job *) mutable {
|
databaseReadyOnFinished](QKeychain::Job *) mutable {
|
||||||
nhlog::db()->debug("Finished reading '{}'", toLoad.begin()->first);
|
nhlog::db()->debug("Finished reading '{}'", toLoad.begin()->first);
|
||||||
|
@ -549,7 +551,7 @@ Cache::loadSecretsFromStore(
|
||||||
if (secret.isEmpty()) {
|
if (secret.isEmpty()) {
|
||||||
nhlog::db()->debug("Restored empty secret '{}'.", name.toStdString());
|
nhlog::db()->debug("Restored empty secret '{}'.", name.toStdString());
|
||||||
} else {
|
} else {
|
||||||
callback(name_, internal, secret.toStdString());
|
callback(name__, internal_, secret.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// load next secret
|
// load next secret
|
||||||
|
@ -2042,6 +2044,213 @@ isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallHangUp> &)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::optional<mtx::events::StateEvent<T>>
|
||||||
|
Cache::getStateEvent(lmdb::txn &txn, const std::string &room_id, std::string_view state_key)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
constexpr auto type = mtx::events::state_content_to_type<T>;
|
||||||
|
static_assert(type != mtx::events::EventType::Unsupported,
|
||||||
|
"Not a supported type in state events.");
|
||||||
|
|
||||||
|
if (room_id.empty())
|
||||||
|
return std::nullopt;
|
||||||
|
const auto typeStr = to_string(type);
|
||||||
|
|
||||||
|
std::string_view value;
|
||||||
|
if (state_key.empty()) {
|
||||||
|
auto db = getStatesDb(txn, room_id);
|
||||||
|
if (!db.get(txn, typeStr, value)) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
auto db = getStatesKeyDb(txn, room_id);
|
||||||
|
// we can search using state key, since the compare functions defaults to the whole
|
||||||
|
// string, when there is no nullbyte
|
||||||
|
std::string_view data = state_key;
|
||||||
|
std::string_view typeStrV = typeStr;
|
||||||
|
|
||||||
|
auto cursor = lmdb::cursor::open(txn, db);
|
||||||
|
if (!cursor.get(typeStrV, data, MDB_GET_BOTH))
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto eventsDb = getEventsDb(txn, room_id);
|
||||||
|
auto eventid = data;
|
||||||
|
if (auto sep = data.rfind('\0'); sep != std::string_view::npos) {
|
||||||
|
if (!eventsDb.get(txn, eventid.substr(sep + 1), value))
|
||||||
|
return std::nullopt;
|
||||||
|
} else {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (std::exception &) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nlohmann::json::parse(value).get<mtx::events::StateEvent<T>>();
|
||||||
|
} catch (std::exception &) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::vector<mtx::events::StateEvent<T>>
|
||||||
|
Cache::getStateEventsWithType(lmdb::txn &txn,
|
||||||
|
const std::string &room_id,
|
||||||
|
mtx::events::EventType type)
|
||||||
|
|
||||||
|
{
|
||||||
|
if (room_id.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
std::vector<mtx::events::StateEvent<T>> events;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto db = getStatesKeyDb(txn, room_id);
|
||||||
|
auto eventsDb = getEventsDb(txn, room_id);
|
||||||
|
const auto typeStr = to_string(type);
|
||||||
|
std::string_view typeStrV = typeStr;
|
||||||
|
std::string_view data;
|
||||||
|
std::string_view value;
|
||||||
|
|
||||||
|
auto cursor = lmdb::cursor::open(txn, db);
|
||||||
|
bool first = true;
|
||||||
|
if (cursor.get(typeStrV, data, MDB_SET)) {
|
||||||
|
while (cursor.get(typeStrV, data, first ? MDB_FIRST_DUP : MDB_NEXT_DUP)) {
|
||||||
|
first = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto eventid = data;
|
||||||
|
if (auto sep = data.rfind('\0'); sep != std::string_view::npos) {
|
||||||
|
if (eventsDb.get(txn, eventid.substr(sep + 1), value))
|
||||||
|
events.push_back(
|
||||||
|
nlohmann::json::parse(value).get<mtx::events::StateEvent<T>>());
|
||||||
|
}
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
nhlog::db()->warn("Failed to parse state event: {}", e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
Cache::saveStateEvents(lmdb::txn &txn,
|
||||||
|
lmdb::dbi &statesdb,
|
||||||
|
lmdb::dbi &stateskeydb,
|
||||||
|
lmdb::dbi &membersdb,
|
||||||
|
lmdb::dbi &eventsDb,
|
||||||
|
const std::string &room_id,
|
||||||
|
const std::vector<T> &events)
|
||||||
|
{
|
||||||
|
for (const auto &e : events)
|
||||||
|
saveStateEvent(txn, statesdb, stateskeydb, membersdb, eventsDb, room_id, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
Cache::saveStateEvent(lmdb::txn &txn,
|
||||||
|
lmdb::dbi &statesdb,
|
||||||
|
lmdb::dbi &stateskeydb,
|
||||||
|
lmdb::dbi &membersdb,
|
||||||
|
lmdb::dbi &eventsDb,
|
||||||
|
const std::string &room_id,
|
||||||
|
const T &event)
|
||||||
|
{
|
||||||
|
using namespace mtx::events;
|
||||||
|
using namespace mtx::events::state;
|
||||||
|
|
||||||
|
if (auto e = std::get_if<StateEvent<Member>>(&event); e != nullptr) {
|
||||||
|
switch (e->content.membership) {
|
||||||
|
//
|
||||||
|
// We only keep users with invite or join membership.
|
||||||
|
//
|
||||||
|
case Membership::Invite:
|
||||||
|
case Membership::Join: {
|
||||||
|
auto display_name =
|
||||||
|
e->content.display_name.empty() ? e->state_key : e->content.display_name;
|
||||||
|
|
||||||
|
std::string inviter = "";
|
||||||
|
if (e->content.membership == mtx::events::state::Membership::Invite) {
|
||||||
|
inviter = e->sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lightweight representation of a member.
|
||||||
|
MemberInfo tmp{
|
||||||
|
display_name,
|
||||||
|
e->content.avatar_url,
|
||||||
|
inviter,
|
||||||
|
e->content.reason,
|
||||||
|
e->content.is_direct,
|
||||||
|
};
|
||||||
|
|
||||||
|
membersdb.put(txn, e->state_key, nlohmann::json(tmp).dump());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
membersdb.del(txn, e->state_key, "");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (auto encr = std::get_if<StateEvent<Encryption>>(&event)) {
|
||||||
|
if (!encr->state_key.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
setEncryptedRoom(txn, room_id);
|
||||||
|
|
||||||
|
std::string_view temp;
|
||||||
|
// ensure we don't replace the event in the db
|
||||||
|
if (statesdb.get(txn, to_string(encr->type), temp)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::visit(
|
||||||
|
[&txn, &statesdb, &stateskeydb, &eventsDb, &membersdb](const auto &e) {
|
||||||
|
if constexpr (isStateEvent_<decltype(e)>) {
|
||||||
|
eventsDb.put(txn, e.event_id, nlohmann::json(e).dump());
|
||||||
|
|
||||||
|
if (e.type != EventType::Unsupported) {
|
||||||
|
if (std::is_same_v<std::remove_cv_t<std::remove_reference_t<decltype(e)>>,
|
||||||
|
StateEvent<mtx::events::msg::Redacted>>) {
|
||||||
|
// apply the redaction event
|
||||||
|
if (e.type == EventType::RoomMember) {
|
||||||
|
// membership is not revoked, but names are yeeted (so we set the name
|
||||||
|
// to the mxid)
|
||||||
|
MemberInfo tmp{e.state_key, ""};
|
||||||
|
membersdb.put(txn, e.state_key, nlohmann::json(tmp).dump());
|
||||||
|
} else if (e.state_key.empty()) {
|
||||||
|
// strictly speaking some stuff in those events can be redacted, but
|
||||||
|
// this is close enough. Ref:
|
||||||
|
// https://spec.matrix.org/v1.6/rooms/v10/#redactions
|
||||||
|
if (e.type != EventType::RoomCreate &&
|
||||||
|
e.type != EventType::RoomJoinRules &&
|
||||||
|
e.type != EventType::RoomPowerLevels &&
|
||||||
|
e.type != EventType::RoomHistoryVisibility)
|
||||||
|
statesdb.del(txn, to_string(e.type));
|
||||||
|
} else
|
||||||
|
stateskeydb.del(txn, to_string(e.type), e.state_key + '\0' + e.event_id);
|
||||||
|
} else if (e.state_key.empty()) {
|
||||||
|
statesdb.put(txn, to_string(e.type), nlohmann::json(e).dump());
|
||||||
|
} else {
|
||||||
|
auto data = e.state_key + '\0' + e.event_id;
|
||||||
|
auto key = to_string(e.type);
|
||||||
|
|
||||||
|
// Work around https://bugs.openldap.org/show_bug.cgi?id=8447
|
||||||
|
stateskeydb.del(txn, key, data);
|
||||||
|
stateskeydb.put(txn, key, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cache::saveState(const mtx::responses::Sync &res)
|
Cache::saveState(const mtx::responses::Sync &res)
|
||||||
{
|
{
|
||||||
|
@ -6004,3 +6213,33 @@ secret(const std::string &name)
|
||||||
return instance_->secret(name);
|
return instance_->secret(name);
|
||||||
}
|
}
|
||||||
} // namespace cache
|
} // namespace cache
|
||||||
|
|
||||||
|
#define NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(Content) \
|
||||||
|
template std::optional<mtx::events::StateEvent<Content>> Cache::getStateEvent( \
|
||||||
|
lmdb::txn &txn, const std::string &room_id, std::string_view state_key); \
|
||||||
|
\
|
||||||
|
template std::vector<mtx::events::StateEvent<Content>> Cache::getStateEventsWithType( \
|
||||||
|
lmdb::txn &txn, const std::string &room_id, mtx::events::EventType type);
|
||||||
|
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::Aliases)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::Avatar)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::CanonicalAlias)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::Create)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::Encryption)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::GuestAccess)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::HistoryVisibility)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::JoinRules)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::Member)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::Name)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::PinnedEvents)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::PowerLevels)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::Tombstone)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::ServerAcl)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::Topic)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::Widget)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::policy_rule::UserRule)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::policy_rule::RoomRule)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::policy_rule::ServerRule)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::space::Child)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::space::Parent)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::msc2545::ImagePack)
|
||||||
|
|
221
src/Cache_p.h
221
src/Cache_p.h
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
@ -15,8 +14,8 @@
|
||||||
#else
|
#else
|
||||||
#include <lmdb++.h>
|
#include <lmdb++.h>
|
||||||
#endif
|
#endif
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
|
#include <mtx/events/collections.hpp>
|
||||||
#include <mtx/responses/notifications.hpp>
|
#include <mtx/responses/notifications.hpp>
|
||||||
#include <mtx/responses/sync.hpp>
|
#include <mtx/responses/sync.hpp>
|
||||||
#include <mtxclient/crypto/types.hpp>
|
#include <mtxclient/crypto/types.hpp>
|
||||||
|
@ -24,7 +23,6 @@
|
||||||
|
|
||||||
#include "CacheCryptoStructs.h"
|
#include "CacheCryptoStructs.h"
|
||||||
#include "CacheStructs.h"
|
#include "CacheStructs.h"
|
||||||
#include "Logging.h"
|
|
||||||
|
|
||||||
namespace mtx::responses {
|
namespace mtx::responses {
|
||||||
struct Messages;
|
struct Messages;
|
||||||
|
@ -364,8 +362,6 @@ private:
|
||||||
mtx::events::collections::TimelineEvents e,
|
mtx::events::collections::TimelineEvents e,
|
||||||
const std::string &room_id);
|
const std::string &room_id);
|
||||||
|
|
||||||
//! Remove a room from the cache.
|
|
||||||
// void removeLeftRoom(lmdb::txn &txn, const std::string &room_id);
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void saveStateEvents(lmdb::txn &txn,
|
void saveStateEvents(lmdb::txn &txn,
|
||||||
lmdb::dbi &statesdb,
|
lmdb::dbi &statesdb,
|
||||||
|
@ -373,11 +369,7 @@ private:
|
||||||
lmdb::dbi &membersdb,
|
lmdb::dbi &membersdb,
|
||||||
lmdb::dbi &eventsDb,
|
lmdb::dbi &eventsDb,
|
||||||
const std::string &room_id,
|
const std::string &room_id,
|
||||||
const std::vector<T> &events)
|
const std::vector<T> &events);
|
||||||
{
|
|
||||||
for (const auto &e : events)
|
|
||||||
saveStateEvent(txn, statesdb, stateskeydb, membersdb, eventsDb, room_id, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void saveStateEvent(lmdb::txn &txn,
|
void saveStateEvent(lmdb::txn &txn,
|
||||||
|
@ -386,191 +378,18 @@ private:
|
||||||
lmdb::dbi &membersdb,
|
lmdb::dbi &membersdb,
|
||||||
lmdb::dbi &eventsDb,
|
lmdb::dbi &eventsDb,
|
||||||
const std::string &room_id,
|
const std::string &room_id,
|
||||||
const T &event)
|
const T &event);
|
||||||
{
|
|
||||||
using namespace mtx::events;
|
|
||||||
using namespace mtx::events::state;
|
|
||||||
|
|
||||||
if (auto e = std::get_if<StateEvent<Member>>(&event); e != nullptr) {
|
|
||||||
switch (e->content.membership) {
|
|
||||||
//
|
|
||||||
// We only keep users with invite or join membership.
|
|
||||||
//
|
|
||||||
case Membership::Invite:
|
|
||||||
case Membership::Join: {
|
|
||||||
auto display_name =
|
|
||||||
e->content.display_name.empty() ? e->state_key : e->content.display_name;
|
|
||||||
|
|
||||||
std::string inviter = "";
|
|
||||||
if (e->content.membership == mtx::events::state::Membership::Invite) {
|
|
||||||
inviter = e->sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lightweight representation of a member.
|
|
||||||
MemberInfo tmp{
|
|
||||||
display_name,
|
|
||||||
e->content.avatar_url,
|
|
||||||
inviter,
|
|
||||||
e->content.reason,
|
|
||||||
e->content.is_direct,
|
|
||||||
};
|
|
||||||
|
|
||||||
membersdb.put(txn, e->state_key, nlohmann::json(tmp).dump());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
membersdb.del(txn, e->state_key, "");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (auto encr = std::get_if<StateEvent<Encryption>>(&event)) {
|
|
||||||
if (!encr->state_key.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
setEncryptedRoom(txn, room_id);
|
|
||||||
|
|
||||||
std::string_view temp;
|
|
||||||
// ensure we don't replace the event in the db
|
|
||||||
if (statesdb.get(txn, to_string(encr->type), temp)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::visit(
|
|
||||||
[&txn, &statesdb, &stateskeydb, &eventsDb, &membersdb](const auto &e) {
|
|
||||||
if constexpr (isStateEvent_<decltype(e)>) {
|
|
||||||
eventsDb.put(txn, e.event_id, nlohmann::json(e).dump());
|
|
||||||
|
|
||||||
if (e.type != EventType::Unsupported) {
|
|
||||||
if (std::is_same_v<std::remove_cv_t<std::remove_reference_t<decltype(e)>>,
|
|
||||||
StateEvent<mtx::events::msg::Redacted>>) {
|
|
||||||
// apply the redaction event
|
|
||||||
if (e.type == EventType::RoomMember) {
|
|
||||||
// membership is not revoked, but names are yeeted (so we set the name
|
|
||||||
// to the mxid)
|
|
||||||
MemberInfo tmp{e.state_key, ""};
|
|
||||||
membersdb.put(txn, e.state_key, nlohmann::json(tmp).dump());
|
|
||||||
} else if (e.state_key.empty()) {
|
|
||||||
// strictly speaking some stuff in those events can be redacted, but
|
|
||||||
// this is close enough. Ref:
|
|
||||||
// https://spec.matrix.org/v1.6/rooms/v10/#redactions
|
|
||||||
if (e.type != EventType::RoomCreate &&
|
|
||||||
e.type != EventType::RoomJoinRules &&
|
|
||||||
e.type != EventType::RoomPowerLevels &&
|
|
||||||
e.type != EventType::RoomHistoryVisibility)
|
|
||||||
statesdb.del(txn, to_string(e.type));
|
|
||||||
} else
|
|
||||||
stateskeydb.del(
|
|
||||||
txn, to_string(e.type), e.state_key + '\0' + e.event_id);
|
|
||||||
} else if (e.state_key.empty()) {
|
|
||||||
statesdb.put(txn, to_string(e.type), nlohmann::json(e).dump());
|
|
||||||
} else {
|
|
||||||
auto data = e.state_key + '\0' + e.event_id;
|
|
||||||
auto key = to_string(e.type);
|
|
||||||
|
|
||||||
// Work around https://bugs.openldap.org/show_bug.cgi?id=8447
|
|
||||||
stateskeydb.del(txn, key, data);
|
|
||||||
stateskeydb.put(txn, key, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
event);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::optional<mtx::events::StateEvent<T>>
|
std::optional<mtx::events::StateEvent<T>>
|
||||||
getStateEvent(lmdb::txn &txn, const std::string &room_id, std::string_view state_key = "")
|
getStateEvent(lmdb::txn &txn, const std::string &room_id, std::string_view state_key = "");
|
||||||
{
|
|
||||||
try {
|
|
||||||
constexpr auto type = mtx::events::state_content_to_type<T>;
|
|
||||||
static_assert(type != mtx::events::EventType::Unsupported,
|
|
||||||
"Not a supported type in state events.");
|
|
||||||
|
|
||||||
if (room_id.empty())
|
|
||||||
return std::nullopt;
|
|
||||||
const auto typeStr = to_string(type);
|
|
||||||
|
|
||||||
std::string_view value;
|
|
||||||
if (state_key.empty()) {
|
|
||||||
auto db = getStatesDb(txn, room_id);
|
|
||||||
if (!db.get(txn, typeStr, value)) {
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
auto db = getStatesKeyDb(txn, room_id);
|
|
||||||
// we can search using state key, since the compare functions defaults to the whole
|
|
||||||
// string, when there is no nullbyte
|
|
||||||
std::string_view data = state_key;
|
|
||||||
std::string_view typeStrV = typeStr;
|
|
||||||
|
|
||||||
auto cursor = lmdb::cursor::open(txn, db);
|
|
||||||
if (!cursor.get(typeStrV, data, MDB_GET_BOTH))
|
|
||||||
return std::nullopt;
|
|
||||||
|
|
||||||
try {
|
|
||||||
auto eventsDb = getEventsDb(txn, room_id);
|
|
||||||
auto eventid = data;
|
|
||||||
if (auto sep = data.rfind('\0'); sep != std::string_view::npos) {
|
|
||||||
if (!eventsDb.get(txn, eventid.substr(sep + 1), value))
|
|
||||||
return std::nullopt;
|
|
||||||
} else {
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (std::exception &) {
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nlohmann::json::parse(value).get<mtx::events::StateEvent<T>>();
|
|
||||||
} catch (std::exception &) {
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::vector<mtx::events::StateEvent<T>>
|
std::vector<mtx::events::StateEvent<T>>
|
||||||
getStateEventsWithType(lmdb::txn &txn,
|
getStateEventsWithType(lmdb::txn &txn,
|
||||||
const std::string &room_id,
|
const std::string &room_id,
|
||||||
mtx::events::EventType type = mtx::events::state_content_to_type<T>)
|
mtx::events::EventType type = mtx::events::state_content_to_type<T>);
|
||||||
|
|
||||||
{
|
|
||||||
if (room_id.empty())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
std::vector<mtx::events::StateEvent<T>> events;
|
|
||||||
|
|
||||||
{
|
|
||||||
auto db = getStatesKeyDb(txn, room_id);
|
|
||||||
auto eventsDb = getEventsDb(txn, room_id);
|
|
||||||
const auto typeStr = to_string(type);
|
|
||||||
std::string_view typeStrV = typeStr;
|
|
||||||
std::string_view data;
|
|
||||||
std::string_view value;
|
|
||||||
|
|
||||||
auto cursor = lmdb::cursor::open(txn, db);
|
|
||||||
bool first = true;
|
|
||||||
if (cursor.get(typeStrV, data, MDB_SET)) {
|
|
||||||
while (cursor.get(typeStrV, data, first ? MDB_FIRST_DUP : MDB_NEXT_DUP)) {
|
|
||||||
first = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
auto eventid = data;
|
|
||||||
if (auto sep = data.rfind('\0'); sep != std::string_view::npos) {
|
|
||||||
if (eventsDb.get(txn, eventid.substr(sep + 1), value))
|
|
||||||
events.push_back(
|
|
||||||
nlohmann::json::parse(value).get<mtx::events::StateEvent<T>>());
|
|
||||||
}
|
|
||||||
} catch (std::exception &e) {
|
|
||||||
nhlog::db()->warn("Failed to parse state event: {}", e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
void
|
void
|
||||||
saveInvites(lmdb::txn &txn, const std::map<std::string, mtx::responses::InvitedRoom> &rooms);
|
saveInvites(lmdb::txn &txn, const std::map<std::string, mtx::responses::InvitedRoom> &rooms);
|
||||||
|
|
||||||
|
@ -723,3 +542,33 @@ namespace cache {
|
||||||
Cache *
|
Cache *
|
||||||
client();
|
client();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define NHEKO_CACHE_GET_STATE_EVENT_FORWARD(Content) \
|
||||||
|
extern template std::optional<mtx::events::StateEvent<Content>> Cache::getStateEvent( \
|
||||||
|
lmdb::txn &txn, const std::string &room_id, std::string_view state_key); \
|
||||||
|
\
|
||||||
|
extern template std::vector<mtx::events::StateEvent<Content>> Cache::getStateEventsWithType( \
|
||||||
|
lmdb::txn &txn, const std::string &room_id, mtx::events::EventType type);
|
||||||
|
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::Aliases)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::Avatar)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::CanonicalAlias)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::Create)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::Encryption)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::GuestAccess)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::HistoryVisibility)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::JoinRules)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::Member)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::Name)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::PinnedEvents)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::PowerLevels)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::Tombstone)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::ServerAcl)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::Topic)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::Widget)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::policy_rule::UserRule)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::policy_rule::RoomRule)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::policy_rule::ServerRule)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::space::Child)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::state::space::Parent)
|
||||||
|
NHEKO_CACHE_GET_STATE_EVENT_FORWARD(mtx::events::msc2545::ImagePack)
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <mtx/responses.hpp>
|
#include <mtx/responses.hpp>
|
||||||
|
|
||||||
#include "AvatarProvider.h"
|
#include "AvatarProvider.h"
|
||||||
|
@ -282,8 +284,8 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mtx::events::collections::TimelineEvents te{event};
|
mtx::events::collections::TimelineEvents te{event};
|
||||||
std::visit([room_id = room_id](auto &event_) { event_.room_id = room_id; },
|
std::visit(
|
||||||
te);
|
[room_id_ = room_id](auto &event_) { event_.room_id = room_id_; }, te);
|
||||||
|
|
||||||
if (auto encryptedEvent =
|
if (auto encryptedEvent =
|
||||||
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
||||||
|
@ -342,14 +344,14 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
|
||||||
roomModel->roomAvatarUrl(),
|
roomModel->roomAvatarUrl(),
|
||||||
96,
|
96,
|
||||||
this,
|
this,
|
||||||
[this, te = te, room_id = room_id, actions = actions](QPixmap image) {
|
[this, te_ = te, room_id_ = room_id, actions_ = actions](QPixmap image) {
|
||||||
notificationsManager->postNotification(
|
notificationsManager->postNotification(
|
||||||
mtx::responses::Notification{
|
mtx::responses::Notification{
|
||||||
.actions = actions,
|
.actions = actions_,
|
||||||
.event = std::move(te),
|
.event = std::move(te_),
|
||||||
.read = false,
|
.read = false,
|
||||||
.profile_tag = "",
|
.profile_tag = "",
|
||||||
.room_id = room_id,
|
.room_id = room_id_,
|
||||||
.ts = 0,
|
.ts = 0,
|
||||||
},
|
},
|
||||||
image.toImage());
|
image.toImage());
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "CompletionModelRoles.h"
|
#include "CompletionModelRoles.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
||||||
int max_mistakes,
|
int max_mistakes,
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <concepts>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "InviteesModel.h"
|
#include "InviteesModel.h"
|
||||||
|
|
||||||
#include "Cache.h"
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
#include "mtx/responses/profile.hpp"
|
#include "mtx/responses/profile.hpp"
|
||||||
|
|
|
@ -12,10 +12,7 @@
|
||||||
|
|
||||||
#include <mtxclient/crypto/client.hpp>
|
#include <mtxclient/crypto/client.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
|
||||||
#include "Utils.h"
|
|
||||||
#include "jdenticoninterface.h"
|
#include "jdenticoninterface.h"
|
||||||
|
|
||||||
namespace Jdenticon {
|
namespace Jdenticon {
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
#include <mtx/common.hpp>
|
#include <mtx/common.hpp>
|
||||||
|
|
||||||
#include "jdenticoninterface.h"
|
|
||||||
|
|
||||||
class JdenticonRunnable final
|
class JdenticonRunnable final
|
||||||
: public QObject
|
: public QObject
|
||||||
, public QRunnable
|
, public QRunnable
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "spdlog/sinks/rotating_file_sink.h"
|
#include "spdlog/sinks/rotating_file_sink.h"
|
||||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include <mtx/responses/login.hpp>
|
#include <mtx/responses/login.hpp>
|
||||||
#include <mtx/responses/version.hpp>
|
#include <mtx/responses/version.hpp>
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "LoginPage.h"
|
#include "LoginPage.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
#include "dock/Dock.h"
|
#include "dock/Dock.h"
|
||||||
|
|
||||||
#include "jdenticoninterface.h"
|
|
||||||
|
|
||||||
class ChatPage;
|
class ChatPage;
|
||||||
class RegisterPage;
|
class RegisterPage;
|
||||||
class WelcomePage;
|
class WelcomePage;
|
||||||
|
|
|
@ -5,14 +5,12 @@
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "nlohmann/json.hpp"
|
|
||||||
#include <mtx/responses.hpp>
|
#include <mtx/responses.hpp>
|
||||||
|
|
||||||
namespace http {
|
namespace http {
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
#include "Config.h"
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "Utils.h"
|
|
||||||
#include "timeline/TimelineViewManager.h"
|
#include "timeline/TimelineViewManager.h"
|
||||||
|
|
||||||
MemberListBackend::MemberListBackend(const QString &room_id, QObject *parent)
|
MemberListBackend::MemberListBackend(const QString &room_id, QObject *parent)
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
#include <mtx/events/event_type.hpp>
|
||||||
#include <mtx/events/power_levels.hpp>
|
#include <mtx/events/power_levels.hpp>
|
||||||
|
|
||||||
#include "CacheStructs.h"
|
|
||||||
|
|
||||||
class PowerlevelsTypeListModel final : public QAbstractListModel
|
class PowerlevelsTypeListModel final : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <mtx/responses/well-known.hpp>
|
#include <mtx/responses/well-known.hpp>
|
||||||
#include <mtxclient/http/client.hpp>
|
#include <mtxclient/http/client.hpp>
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "LoginPage.h"
|
#include "LoginPage.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "Cache.h"
|
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "CompletionModelRoles.h"
|
#include "CompletionModelRoles.h"
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <mtx/responses/media.hpp>
|
#include <mtx/responses/media.hpp>
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include <mtx/responses/users.hpp>
|
#include <mtx/responses/users.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "CompletionModelRoles.h"
|
#include "CompletionModelRoles.h"
|
||||||
|
#include "Logging.h"
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
|
|
||||||
UsersModel::UsersModel(const std::string &roomId, QObject *parent)
|
UsersModel::UsersModel(const std::string &roomId, QObject *parent)
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <cmath>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
@ -20,14 +25,12 @@
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
#include <array>
|
#include <nlohmann/json.hpp>
|
||||||
#include <cmath>
|
|
||||||
#include <mtx/responses/messages.hpp>
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <variant>
|
|
||||||
|
|
||||||
#include <cmark.h>
|
#include <cmark.h>
|
||||||
|
|
||||||
|
#include <mtx/responses/messages.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
|
@ -36,7 +39,6 @@
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
#include "timeline/Permissions.h"
|
|
||||||
|
|
||||||
template<class T, class Event>
|
template<class T, class Event>
|
||||||
static DescInfo
|
static DescInfo
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <variant>
|
|
||||||
|
|
||||||
#include <CacheStructs.h>
|
#include <CacheStructs.h>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include "Cache.h"
|
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
|
|
@ -4,6 +4,13 @@
|
||||||
|
|
||||||
#include "DeviceVerificationFlow.h"
|
#include "DeviceVerificationFlow.h"
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
|
@ -11,11 +18,6 @@
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "timeline/TimelineModel.h"
|
#include "timeline/TimelineModel.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <iostream>
|
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
static constexpr int TIMEOUT = 2 * 60 * 1000; // 2 minutes
|
static constexpr int TIMEOUT = 2 * 60 * 1000; // 2 minutes
|
||||||
|
|
||||||
static mtx::events::msg::KeyVerificationMac
|
static mtx::events::msg::KeyVerificationMac
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "CacheCryptoStructs.h"
|
#include "CacheCryptoStructs.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
#include "Olm.h"
|
|
||||||
#include "timeline/TimelineModel.h"
|
#include "timeline/TimelineModel.h"
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
auto client_ = std::make_unique<mtx::crypto::OlmClient>();
|
auto client_ = std::make_unique<mtx::crypto::OlmClient>();
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <mtx/events.hpp>
|
#include <mtx/events.hpp>
|
||||||
#include <mtx/events/encrypted.hpp>
|
#include <mtx/events/encrypted.hpp>
|
||||||
#include <mtxclient/crypto/client.hpp>
|
#include <mtxclient/crypto/client.hpp>
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
#include <mtx/responses/common.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
|
@ -16,8 +20,6 @@
|
||||||
#include "timeline/TimelineViewManager.h"
|
#include "timeline/TimelineViewManager.h"
|
||||||
#include "ui/UIA.h"
|
#include "ui/UIA.h"
|
||||||
|
|
||||||
#include <mtx/responses/common.hpp>
|
|
||||||
|
|
||||||
SelfVerificationStatus::SelfVerificationStatus(QObject *o)
|
SelfVerificationStatus::SelfVerificationStatus(QObject *o)
|
||||||
: QObject(o)
|
: QObject(o)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "EventAccessors.h"
|
#include "EventAccessors.h"
|
||||||
#include "Logging.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
QString
|
QString
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <mtx/responses/common.hpp>
|
#include <mtx/responses/common.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
|
|
|
@ -14,20 +14,20 @@
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTextBoundaryFinder>
|
#include <QTextBoundaryFinder>
|
||||||
#include <QVideoFrame>
|
#include <QVideoFrame>
|
||||||
#include <QVideoSink>
|
#include <QVideoSink>
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <mtx/responses/common.hpp>
|
#include <mtx/responses/common.hpp>
|
||||||
#include <mtx/responses/media.hpp>
|
#include <mtx/responses/media.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
#include "CombinedImagePackModel.h"
|
|
||||||
#include "Config.h"
|
|
||||||
#include "EventAccessors.h"
|
#include "EventAccessors.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
@ -17,7 +18,8 @@
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <utility>
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QVideoSink>
|
#include <QVideoSink>
|
||||||
|
|
||||||
#include "Logging.h"
|
|
||||||
|
|
||||||
class TimelineModel;
|
class TimelineModel;
|
||||||
|
|
||||||
// I failed to get my own buffer into the MediaPlayer in qml, so just make our own. For that we just
|
// I failed to get my own buffer into the MediaPlayer in qml, so just make our own. For that we just
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
#include "timeline/TimelineModel.h"
|
#include "timeline/TimelineModel.h"
|
||||||
#include "timeline/TimelineViewManager.h"
|
#include "timeline/TimelineViewManager.h"
|
||||||
|
|
||||||
#include "Logging.h"
|
|
||||||
|
|
||||||
NhekoDropArea::NhekoDropArea(QQuickItem *parent)
|
NhekoDropArea::NhekoDropArea(QQuickItem *parent)
|
||||||
: QQuickItem(parent)
|
: QQuickItem(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "Config.h"
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
Loading…
Reference in a new issue