Show room version in settings

This commit is contained in:
Nicolas Werner 2019-06-27 20:53:44 +02:00
parent 5a0a9c96b2
commit 713f9dbe89
11 changed files with 227 additions and 72 deletions

View file

@ -142,7 +142,7 @@
<context> <context>
<name>LoginPage</name> <name>LoginPage</name>
<message> <message>
<location filename="../../src/LoginPage.cpp" line="+79"/> <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source> <source>Matrix ID</source>
<translation>Matrix-ID</translation> <translation>Matrix-ID</translation>
</message> </message>
@ -167,17 +167,17 @@
<translation>ANMELDEN</translation> <translation>ANMELDEN</translation>
</message> </message>
<message> <message>
<location line="+83"/> <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source> <source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+4"/> <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source> <source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+20"/> <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source> <source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -274,6 +274,14 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>RoomInfo</name>
<message>
<location filename="../../src/Cache.cpp" line="+2204"/>
<source>no version stored</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RoomInfoListItem</name> <name>RoomInfoListItem</name>
<message> <message>
@ -802,6 +810,11 @@ Medien-Größe: %2
<source>Internal ID</source> <source>Internal ID</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location line="+10"/>
<source>Room Version</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location line="+4"/> <location line="+4"/>
<source>Notifications</source> <source>Notifications</source>
@ -878,7 +891,7 @@ Medien-Größe: %2
</translation> </translation>
</message> </message>
<message> <message>
<location line="+70"/> <location line="+71"/>
<source>ESC</source> <source>ESC</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -142,7 +142,7 @@
<context> <context>
<name>LoginPage</name> <name>LoginPage</name>
<message> <message>
<location filename="../../src/LoginPage.cpp" line="+79"/> <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source> <source>Matrix ID</source>
<translation>Matrix ID</translation> <translation>Matrix ID</translation>
</message> </message>
@ -167,17 +167,17 @@
<translation>ΕΙΣΟΔΟΣ</translation> <translation>ΕΙΣΟΔΟΣ</translation>
</message> </message>
<message> <message>
<location line="+83"/> <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source> <source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+4"/> <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source> <source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+20"/> <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source> <source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -274,6 +274,14 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>RoomInfo</name>
<message>
<location filename="../../src/Cache.cpp" line="+2204"/>
<source>no version stored</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RoomInfoListItem</name> <name>RoomInfoListItem</name>
<message> <message>
@ -800,6 +808,11 @@ Media size: %2
<source>Internal ID</source> <source>Internal ID</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location line="+10"/>
<source>Room Version</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location line="+4"/> <location line="+4"/>
<source>Notifications</source> <source>Notifications</source>
@ -876,7 +889,7 @@ Media size: %2
</translation> </translation>
</message> </message>
<message> <message>
<location line="+70"/> <location line="+71"/>
<source>ESC</source> <source>ESC</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -142,7 +142,7 @@
<context> <context>
<name>LoginPage</name> <name>LoginPage</name>
<message> <message>
<location filename="../../src/LoginPage.cpp" line="+79"/> <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source> <source>Matrix ID</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -167,17 +167,17 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+83"/> <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source> <source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+4"/> <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source> <source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+20"/> <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source> <source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -274,6 +274,14 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>RoomInfo</name>
<message>
<location filename="../../src/Cache.cpp" line="+2204"/>
<source>no version stored</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RoomInfoListItem</name> <name>RoomInfoListItem</name>
<message> <message>
@ -800,6 +808,11 @@ Media size: %2
<source>Internal ID</source> <source>Internal ID</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location line="+10"/>
<source>Room Version</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location line="+4"/> <location line="+4"/>
<source>Notifications</source> <source>Notifications</source>
@ -876,7 +889,7 @@ Media size: %2
</translation> </translation>
</message> </message>
<message> <message>
<location line="+70"/> <location line="+71"/>
<source>ESC</source> <source>ESC</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -142,7 +142,7 @@
<context> <context>
<name>LoginPage</name> <name>LoginPage</name>
<message> <message>
<location filename="../../src/LoginPage.cpp" line="+79"/> <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source> <source>Matrix ID</source>
<translation>Identifiant Matrix</translation> <translation>Identifiant Matrix</translation>
</message> </message>
@ -167,17 +167,17 @@
<translation>CONNEXION</translation> <translation>CONNEXION</translation>
</message> </message>
<message> <message>
<location line="+83"/> <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source> <source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+4"/> <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source> <source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+20"/> <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source> <source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -275,6 +275,14 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>RoomInfo</name>
<message>
<location filename="../../src/Cache.cpp" line="+2204"/>
<source>no version stored</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RoomInfoListItem</name> <name>RoomInfoListItem</name>
<message> <message>
@ -803,6 +811,11 @@ Taille du média : %2
<source>Internal ID</source> <source>Internal ID</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location line="+10"/>
<source>Room Version</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location line="+4"/> <location line="+4"/>
<source>Notifications</source> <source>Notifications</source>
@ -879,7 +892,7 @@ Taille du média : %2
</translation> </translation>
</message> </message>
<message> <message>
<location line="+70"/> <location line="+71"/>
<source>ESC</source> <source>ESC</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -142,7 +142,7 @@
<context> <context>
<name>LoginPage</name> <name>LoginPage</name>
<message> <message>
<location filename="../../src/LoginPage.cpp" line="+79"/> <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source> <source>Matrix ID</source>
<translation>Matrix-id</translation> <translation>Matrix-id</translation>
</message> </message>
@ -167,17 +167,17 @@
<translation>INLOGGEN</translation> <translation>INLOGGEN</translation>
</message> </message>
<message> <message>
<location line="+83"/> <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source> <source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+4"/> <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source> <source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+20"/> <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source> <source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -274,6 +274,14 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>RoomInfo</name>
<message>
<location filename="../../src/Cache.cpp" line="+2204"/>
<source>no version stored</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RoomInfoListItem</name> <name>RoomInfoListItem</name>
<message> <message>
@ -802,6 +810,11 @@ Mediagrootte: %2
<source>Internal ID</source> <source>Internal ID</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location line="+10"/>
<source>Room Version</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location line="+4"/> <location line="+4"/>
<source>Notifications</source> <source>Notifications</source>
@ -878,7 +891,7 @@ Mediagrootte: %2
</translation> </translation>
</message> </message>
<message> <message>
<location line="+70"/> <location line="+71"/>
<source>ESC</source> <source>ESC</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -142,7 +142,7 @@
<context> <context>
<name>LoginPage</name> <name>LoginPage</name>
<message> <message>
<location filename="../../src/LoginPage.cpp" line="+79"/> <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source> <source>Matrix ID</source>
<translation>ID Matrixa</translation> <translation>ID Matrixa</translation>
</message> </message>
@ -167,17 +167,17 @@
<translation>ZALOGUJ</translation> <translation>ZALOGUJ</translation>
</message> </message>
<message> <message>
<location line="+83"/> <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source> <source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+4"/> <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source> <source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+20"/> <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source> <source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation>Nie odnaleziono wymaganych punktów końcowych. To może nie być serwer Matriksa.</translation> <translation>Nie odnaleziono wymaganych punktów końcowych. To może nie być serwer Matriksa.</translation>
</message> </message>
@ -274,6 +274,14 @@
<translation type="unfinished">Wyloguj</translation> <translation type="unfinished">Wyloguj</translation>
</message> </message>
</context> </context>
<context>
<name>RoomInfo</name>
<message>
<location filename="../../src/Cache.cpp" line="+2204"/>
<source>no version stored</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RoomInfoListItem</name> <name>RoomInfoListItem</name>
<message> <message>
@ -802,6 +810,11 @@ Rozmiar multimediów: %2
<source>Internal ID</source> <source>Internal ID</source>
<translation>Wewnętrzne ID</translation> <translation>Wewnętrzne ID</translation>
</message> </message>
<message>
<location line="+10"/>
<source>Room Version</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location line="+4"/> <location line="+4"/>
<source>Notifications</source> <source>Notifications</source>
@ -881,7 +894,7 @@ Rozmiar multimediów: %2
</translation> </translation>
</message> </message>
<message> <message>
<location line="+70"/> <location line="+71"/>
<source>ESC</source> <source>ESC</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -142,7 +142,7 @@
<context> <context>
<name>LoginPage</name> <name>LoginPage</name>
<message> <message>
<location filename="../../src/LoginPage.cpp" line="+79"/> <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source> <source>Matrix ID</source>
<translation>Идентификатор Matrix</translation> <translation>Идентификатор Matrix</translation>
</message> </message>
@ -167,17 +167,17 @@
<translation>ВОЙТИ</translation> <translation>ВОЙТИ</translation>
</message> </message>
<message> <message>
<location line="+83"/> <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source> <source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+4"/> <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source> <source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+20"/> <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source> <source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation>Необходимые конечные точки не найдены. Возможно, это не сервер Matrix.</translation> <translation>Необходимые конечные точки не найдены. Возможно, это не сервер Matrix.</translation>
</message> </message>
@ -274,6 +274,14 @@
<translation type="unfinished">Выйти</translation> <translation type="unfinished">Выйти</translation>
</message> </message>
</context> </context>
<context>
<name>RoomInfo</name>
<message>
<location filename="../../src/Cache.cpp" line="+2204"/>
<source>no version stored</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RoomInfoListItem</name> <name>RoomInfoListItem</name>
<message> <message>
@ -803,6 +811,11 @@ Media size: %2
<source>Internal ID</source> <source>Internal ID</source>
<translation>Внутренний ID</translation> <translation>Внутренний ID</translation>
</message> </message>
<message>
<location line="+10"/>
<source>Room Version</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location line="+4"/> <location line="+4"/>
<source>Notifications</source> <source>Notifications</source>
@ -880,7 +893,7 @@ Media size: %2
</translation> </translation>
</message> </message>
<message> <message>
<location line="+70"/> <location line="+71"/>
<source>ESC</source> <source>ESC</source>
<translation></translation> <translation></translation>
</message> </message>

View file

@ -142,7 +142,7 @@
<context> <context>
<name>LoginPage</name> <name>LoginPage</name>
<message> <message>
<location filename="../../src/LoginPage.cpp" line="+79"/> <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source> <source>Matrix ID</source>
<translation></translation> <translation></translation>
</message> </message>
@ -167,17 +167,17 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location line="+83"/> <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source> <source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+4"/> <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source> <source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+20"/> <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source> <source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation> Matrix </translation> <translation> Matrix </translation>
</message> </message>
@ -274,6 +274,14 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>RoomInfo</name>
<message>
<location filename="../../src/Cache.cpp" line="+2204"/>
<source>no version stored</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RoomInfoListItem</name> <name>RoomInfoListItem</name>
<message> <message>
@ -802,6 +810,11 @@ Media size: %2
<source>Internal ID</source> <source>Internal ID</source>
<translation> ID</translation> <translation> ID</translation>
</message> </message>
<message>
<location line="+10"/>
<source>Room Version</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location line="+4"/> <location line="+4"/>
<source>Notifications</source> <source>Notifications</source>
@ -879,7 +892,7 @@ Media size: %2
</translation> </translation>
</message> </message>
<message> <message>
<location line="+70"/> <location line="+71"/>
<source>ESC</source> <source>ESC</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -19,6 +19,7 @@
#include <stdexcept> #include <stdexcept>
#include <QByteArray> #include <QByteArray>
#include <QCoreApplication>
#include <QFile> #include <QFile>
#include <QHash> #include <QHash>
#include <QSettings> #include <QSettings>
@ -958,6 +959,7 @@ Cache::saveState(const mtx::responses::Sync &res)
updatedInfo.avatar_url = updatedInfo.avatar_url =
getRoomAvatarUrl(txn, statesdb, membersdb, QString::fromStdString(room.first)) getRoomAvatarUrl(txn, statesdb, membersdb, QString::fromStdString(room.first))
.toStdString(); .toStdString();
updatedInfo.version = getRoomVersion(txn, statesdb).toStdString();
// Process the account_data associated with this room // Process the account_data associated with this room
bool has_new_tags = false; bool has_new_tags = false;
@ -1551,6 +1553,32 @@ Cache::getRoomTopic(lmdb::txn &txn, lmdb::dbi &statesdb)
return QString(); return QString();
} }
QString
Cache::getRoomVersion(lmdb::txn &txn, lmdb::dbi &statesdb)
{
using namespace mtx::events;
using namespace mtx::events::state;
lmdb::val event;
bool res = lmdb::dbi_get(
txn, statesdb, lmdb::val(to_string(mtx::events::EventType::RoomCreate)), event);
if (res) {
try {
StateEvent<Create> msg =
json::parse(std::string(event.data(), event.size()));
if (!msg.content.room_version.empty())
return QString::fromStdString(msg.content.room_version);
} catch (const json::exception &e) {
nhlog::db()->warn("failed to parse m.room.create event: {}", e.what());
}
}
nhlog::db()->warn("m.room.create event is missing room version, assuming version \"1\"");
return QString("1");
}
QString QString
Cache::getInviteRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb) Cache::getInviteRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb)
{ {
@ -2148,3 +2176,39 @@ Cache::clearUserColors()
{ {
UserColors.clear(); UserColors.clear();
} }
void
to_json(json &j, const RoomInfo &info)
{
j["name"] = info.name;
j["topic"] = info.topic;
j["avatar_url"] = info.avatar_url;
j["version"] = info.version;
j["is_invite"] = info.is_invite;
j["join_rule"] = info.join_rule;
j["guest_access"] = info.guest_access;
if (info.member_count != 0)
j["member_count"] = info.member_count;
if (info.tags.size() != 0)
j["tags"] = info.tags;
}
void
from_json(const json &j, RoomInfo &info)
{
info.name = j.at("name");
info.topic = j.at("topic");
info.avatar_url = j.at("avatar_url");
info.version = j.value("version", QCoreApplication::translate("RoomInfo", "no version stored").toStdString());
info.is_invite = j.at("is_invite");
info.join_rule = j.at("join_rule");
info.guest_access = j.at("guest_access");
if (j.count("member_count"))
info.member_count = j.at("member_count");
if (j.count("tags"))
info.tags = j.at("tags").get<std::vector<std::string>>();
}

View file

@ -106,6 +106,8 @@ struct RoomInfo
std::string topic; std::string topic;
//! The calculated avatar url of the room. //! The calculated avatar url of the room.
std::string avatar_url; std::string avatar_url;
//! The calculated version of this room set at creation time.
std::string version;
//! Whether or not the room is an invite. //! Whether or not the room is an invite.
bool is_invite = false; bool is_invite = false;
//! Total number of members in the room. //! Total number of members in the room.
@ -119,39 +121,11 @@ struct RoomInfo
std::vector<std::string> tags; std::vector<std::string> tags;
}; };
inline void void
to_json(json &j, const RoomInfo &info) to_json(json &j, const RoomInfo &info);
{
j["name"] = info.name;
j["topic"] = info.topic;
j["avatar_url"] = info.avatar_url;
j["is_invite"] = info.is_invite;
j["join_rule"] = info.join_rule;
j["guest_access"] = info.guest_access;
if (info.member_count != 0) void
j["member_count"] = info.member_count; from_json(const json &j, RoomInfo &info);
if (info.tags.size() != 0)
j["tags"] = info.tags;
}
inline void
from_json(const json &j, RoomInfo &info)
{
info.name = j.at("name");
info.topic = j.at("topic");
info.avatar_url = j.at("avatar_url");
info.is_invite = j.at("is_invite");
info.join_rule = j.at("join_rule");
info.guest_access = j.at("guest_access");
if (j.count("member_count"))
info.member_count = j.at("member_count");
if (j.count("tags"))
info.tags = j.at("tags").get<std::vector<std::string>>();
}
//! Basic information per member; //! Basic information per member;
struct MemberInfo struct MemberInfo
@ -322,6 +296,8 @@ public:
lmdb::dbi &statesdb, lmdb::dbi &statesdb,
lmdb::dbi &membersdb, lmdb::dbi &membersdb,
const QString &room_id); const QString &room_id);
//! Retrieve the version of the room if any.
QString getRoomVersion(lmdb::txn &txn, lmdb::dbi &statesdb);
//! Retrieve member info from a room. //! Retrieve member info from a room.
std::vector<RoomMember> getMembers(const std::string &room_id, std::vector<RoomMember> getMembers(const std::string &room_id,

View file

@ -199,6 +199,16 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
Qt::AlignBottom | Qt::AlignLeft); Qt::AlignBottom | Qt::AlignLeft);
roomIdLayout->addWidget(roomIdLabel, 0, Qt::AlignBottom | Qt::AlignRight); roomIdLayout->addWidget(roomIdLabel, 0, Qt::AlignBottom | Qt::AlignRight);
auto roomVersionLabel = new QLabel(QString::fromStdString(info_.version), this);
roomVersionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
roomVersionLabel->setFont(monospaceFont);
auto roomVersionLayout = new QHBoxLayout;
roomVersionLayout->setMargin(0);
roomVersionLayout->addWidget(new QLabel(tr("Room Version"), this),
Qt::AlignBottom | Qt::AlignLeft);
roomVersionLayout->addWidget(roomVersionLabel, 0, Qt::AlignBottom | Qt::AlignRight);
auto notifLabel = new QLabel(tr("Notifications"), this); auto notifLabel = new QLabel(tr("Notifications"), this);
auto notifCombo = new QComboBox(this); auto notifCombo = new QComboBox(this);
notifCombo->setDisabled(true); notifCombo->setDisabled(true);
@ -400,6 +410,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
layout->addLayout(keyRequestsLayout); layout->addLayout(keyRequestsLayout);
layout->addWidget(infoLabel, Qt::AlignLeft); layout->addWidget(infoLabel, Qt::AlignLeft);
layout->addLayout(roomIdLayout); layout->addLayout(roomIdLayout);
layout->addLayout(roomVersionLayout);
layout->addWidget(errorLabel_); layout->addWidget(errorLabel_);
layout->addLayout(buttonLayout); layout->addLayout(buttonLayout);
layout->addLayout(spinnerLayout); layout->addLayout(spinnerLayout);