diff --git a/resources/langs/nheko_de.ts b/resources/langs/nheko_de.ts
index e8d71f27..60deb89f 100644
--- a/resources/langs/nheko_de.ts
+++ b/resources/langs/nheko_de.ts
@@ -142,7 +142,7 @@
<context>
<name>LoginPage</name>
<message>
- <location filename="../../src/LoginPage.cpp" line="+79"/>
+ <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source>
<translation>Matrix-ID</translation>
</message>
@@ -167,17 +167,17 @@
<translation>ANMELDEN</translation>
</message>
<message>
- <location line="+83"/>
+ <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+4"/>
+ <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+20"/>
+ <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation>
</message>
@@ -275,6 +275,14 @@
</message>
</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>
<name>RoomInfoListItem</name>
<message>
<location filename="../../src/RoomInfoListItem.cpp" line="+92"/>
@@ -803,6 +811,11 @@ Medien-Größe: %2
<translation type="unfinished"></translation>
</message>
<message>
+ <location line="+10"/>
+ <source>Room Version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location line="+4"/>
<source>Notifications</source>
<translation>Benachrichtigungen</translation>
@@ -878,7 +891,7 @@ Medien-Größe: %2
</translation>
</message>
<message>
- <location line="+70"/>
+ <location line="+71"/>
<source>ESC</source>
<translation type="unfinished"></translation>
</message>
diff --git a/resources/langs/nheko_el.ts b/resources/langs/nheko_el.ts
index 276d25f0..5a6be4cb 100644
--- a/resources/langs/nheko_el.ts
+++ b/resources/langs/nheko_el.ts
@@ -142,7 +142,7 @@
<context>
<name>LoginPage</name>
<message>
- <location filename="../../src/LoginPage.cpp" line="+79"/>
+ <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source>
<translation>Matrix ID</translation>
</message>
@@ -167,17 +167,17 @@
<translation>ΕΙΣΟΔΟΣ</translation>
</message>
<message>
- <location line="+83"/>
+ <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+4"/>
+ <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+20"/>
+ <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation>
</message>
@@ -275,6 +275,14 @@
</message>
</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>
<name>RoomInfoListItem</name>
<message>
<location filename="../../src/RoomInfoListItem.cpp" line="+92"/>
@@ -801,6 +809,11 @@ Media size: %2
<translation type="unfinished"></translation>
</message>
<message>
+ <location line="+10"/>
+ <source>Room Version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location line="+4"/>
<source>Notifications</source>
<translation>Ειδοποιήσεις</translation>
@@ -876,7 +889,7 @@ Media size: %2
</translation>
</message>
<message>
- <location line="+70"/>
+ <location line="+71"/>
<source>ESC</source>
<translation type="unfinished"></translation>
</message>
diff --git a/resources/langs/nheko_en.ts b/resources/langs/nheko_en.ts
index ffca0843..f0aa0c35 100644
--- a/resources/langs/nheko_en.ts
+++ b/resources/langs/nheko_en.ts
@@ -142,7 +142,7 @@
<context>
<name>LoginPage</name>
<message>
- <location filename="../../src/LoginPage.cpp" line="+79"/>
+ <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source>
<translation type="unfinished"></translation>
</message>
@@ -167,17 +167,17 @@
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+83"/>
+ <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+4"/>
+ <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+20"/>
+ <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation>
</message>
@@ -275,6 +275,14 @@
</message>
</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>
<name>RoomInfoListItem</name>
<message>
<location filename="../../src/RoomInfoListItem.cpp" line="+92"/>
@@ -801,6 +809,11 @@ Media size: %2
<translation type="unfinished"></translation>
</message>
<message>
+ <location line="+10"/>
+ <source>Room Version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location line="+4"/>
<source>Notifications</source>
<translation type="unfinished"></translation>
@@ -876,7 +889,7 @@ Media size: %2
</translation>
</message>
<message>
- <location line="+70"/>
+ <location line="+71"/>
<source>ESC</source>
<translation type="unfinished"></translation>
</message>
diff --git a/resources/langs/nheko_fr.ts b/resources/langs/nheko_fr.ts
index 0826acad..beab8752 100644
--- a/resources/langs/nheko_fr.ts
+++ b/resources/langs/nheko_fr.ts
@@ -142,7 +142,7 @@
<context>
<name>LoginPage</name>
<message>
- <location filename="../../src/LoginPage.cpp" line="+79"/>
+ <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source>
<translation>Identifiant Matrix</translation>
</message>
@@ -167,17 +167,17 @@
<translation>CONNEXION</translation>
</message>
<message>
- <location line="+83"/>
+ <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+4"/>
+ <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+20"/>
+ <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation>
</message>
@@ -276,6 +276,14 @@
</message>
</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>
<name>RoomInfoListItem</name>
<message>
<location filename="../../src/RoomInfoListItem.cpp" line="+92"/>
@@ -804,6 +812,11 @@ Taille du média : %2
<translation type="unfinished"></translation>
</message>
<message>
+ <location line="+10"/>
+ <source>Room Version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location line="+4"/>
<source>Notifications</source>
<translation>Notifications</translation>
@@ -879,7 +892,7 @@ Taille du média : %2
</translation>
</message>
<message>
- <location line="+70"/>
+ <location line="+71"/>
<source>ESC</source>
<translation type="unfinished"></translation>
</message>
diff --git a/resources/langs/nheko_nl.ts b/resources/langs/nheko_nl.ts
index d91e883d..4c81ec76 100644
--- a/resources/langs/nheko_nl.ts
+++ b/resources/langs/nheko_nl.ts
@@ -142,7 +142,7 @@
<context>
<name>LoginPage</name>
<message>
- <location filename="../../src/LoginPage.cpp" line="+79"/>
+ <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source>
<translation>Matrix-id</translation>
</message>
@@ -167,17 +167,17 @@
<translation>INLOGGEN</translation>
</message>
<message>
- <location line="+83"/>
+ <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+4"/>
+ <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+20"/>
+ <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation type="unfinished"></translation>
</message>
@@ -275,6 +275,14 @@
</message>
</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>
<name>RoomInfoListItem</name>
<message>
<location filename="../../src/RoomInfoListItem.cpp" line="+92"/>
@@ -803,6 +811,11 @@ Mediagrootte: %2
<translation type="unfinished"></translation>
</message>
<message>
+ <location line="+10"/>
+ <source>Room Version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location line="+4"/>
<source>Notifications</source>
<translation>Meldingen</translation>
@@ -878,7 +891,7 @@ Mediagrootte: %2
</translation>
</message>
<message>
- <location line="+70"/>
+ <location line="+71"/>
<source>ESC</source>
<translation type="unfinished"></translation>
</message>
diff --git a/resources/langs/nheko_pl.ts b/resources/langs/nheko_pl.ts
index 358f97a9..edea85b9 100644
--- a/resources/langs/nheko_pl.ts
+++ b/resources/langs/nheko_pl.ts
@@ -142,7 +142,7 @@
<context>
<name>LoginPage</name>
<message>
- <location filename="../../src/LoginPage.cpp" line="+79"/>
+ <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source>
<translation>ID Matrixa</translation>
</message>
@@ -167,17 +167,17 @@
<translation>ZALOGUJ</translation>
</message>
<message>
- <location line="+83"/>
+ <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+4"/>
+ <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+20"/>
+ <location line="+24"/>
<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>
</message>
@@ -275,6 +275,14 @@
</message>
</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>
<name>RoomInfoListItem</name>
<message>
<location filename="../../src/RoomInfoListItem.cpp" line="+92"/>
@@ -803,6 +811,11 @@ Rozmiar multimediów: %2
<translation>Wewnętrzne ID</translation>
</message>
<message>
+ <location line="+10"/>
+ <source>Room Version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location line="+4"/>
<source>Notifications</source>
<translation>Powiadomienia</translation>
@@ -881,7 +894,7 @@ Rozmiar multimediów: %2
</translation>
</message>
<message>
- <location line="+70"/>
+ <location line="+71"/>
<source>ESC</source>
<translation type="unfinished"></translation>
</message>
diff --git a/resources/langs/nheko_ru.ts b/resources/langs/nheko_ru.ts
index b6651c84..4c157884 100644
--- a/resources/langs/nheko_ru.ts
+++ b/resources/langs/nheko_ru.ts
@@ -142,7 +142,7 @@
<context>
<name>LoginPage</name>
<message>
- <location filename="../../src/LoginPage.cpp" line="+79"/>
+ <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source>
<translation>Идентификатор Matrix</translation>
</message>
@@ -167,17 +167,17 @@
<translation>ВОЙТИ</translation>
</message>
<message>
- <location line="+83"/>
+ <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+4"/>
+ <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+20"/>
+ <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation>Необходимые конечные точки не найдены. Возможно, это не сервер Matrix.</translation>
</message>
@@ -275,6 +275,14 @@
</message>
</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>
<name>RoomInfoListItem</name>
<message>
<location filename="../../src/RoomInfoListItem.cpp" line="+92"/>
@@ -804,6 +812,11 @@ Media size: %2
<translation>Внутренний ID</translation>
</message>
<message>
+ <location line="+10"/>
+ <source>Room Version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location line="+4"/>
<source>Notifications</source>
<translation>Уведомления</translation>
@@ -880,7 +893,7 @@ Media size: %2
</translation>
</message>
<message>
- <location line="+70"/>
+ <location line="+71"/>
<source>ESC</source>
<translation></translation>
</message>
diff --git a/resources/langs/nheko_zh_CN.ts b/resources/langs/nheko_zh_CN.ts
index 634867a5..ca7c6e22 100644
--- a/resources/langs/nheko_zh_CN.ts
+++ b/resources/langs/nheko_zh_CN.ts
@@ -142,7 +142,7 @@
<context>
<name>LoginPage</name>
<message>
- <location filename="../../src/LoginPage.cpp" line="+79"/>
+ <location filename="../../src/LoginPage.cpp" line="+80"/>
<source>Matrix ID</source>
<translation></translation>
</message>
@@ -167,17 +167,17 @@
<translation>登录</translation>
</message>
<message>
- <location line="+83"/>
+ <location line="+84"/>
<source>Autodiscovery failed. Received malformed response.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+4"/>
+ <location line="+6"/>
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+20"/>
+ <location line="+24"/>
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
<translation>没找到要求的终端。可能不是一个 Matrix 服务器。</translation>
</message>
@@ -275,6 +275,14 @@
</message>
</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>
<name>RoomInfoListItem</name>
<message>
<location filename="../../src/RoomInfoListItem.cpp" line="+92"/>
@@ -803,6 +811,11 @@ Media size: %2
<translation>内部 ID</translation>
</message>
<message>
+ <location line="+10"/>
+ <source>Room Version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location line="+4"/>
<source>Notifications</source>
<translation>通知</translation>
@@ -879,7 +892,7 @@ Media size: %2
</translation>
</message>
<message>
- <location line="+70"/>
+ <location line="+71"/>
<source>ESC</source>
<translation type="unfinished"></translation>
</message>
diff --git a/src/Cache.cpp b/src/Cache.cpp
index 81054ddc..5aad89ed 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -19,6 +19,7 @@
#include <stdexcept>
#include <QByteArray>
+#include <QCoreApplication>
#include <QFile>
#include <QHash>
#include <QSettings>
@@ -958,6 +959,7 @@ Cache::saveState(const mtx::responses::Sync &res)
updatedInfo.avatar_url =
getRoomAvatarUrl(txn, statesdb, membersdb, QString::fromStdString(room.first))
.toStdString();
+ updatedInfo.version = getRoomVersion(txn, statesdb).toStdString();
// Process the account_data associated with this room
bool has_new_tags = false;
@@ -1552,6 +1554,32 @@ Cache::getRoomTopic(lmdb::txn &txn, lmdb::dbi &statesdb)
}
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
Cache::getInviteRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb)
{
using namespace mtx::events;
@@ -2148,3 +2176,39 @@ Cache::clearUserColors()
{
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>>();
+}
diff --git a/src/Cache.h b/src/Cache.h
index b9cf0aeb..65c5263d 100644
--- a/src/Cache.h
+++ b/src/Cache.h
@@ -106,6 +106,8 @@ struct RoomInfo
std::string topic;
//! The calculated avatar url of the room.
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.
bool is_invite = false;
//! Total number of members in the room.
@@ -119,39 +121,11 @@ struct RoomInfo
std::vector<std::string> tags;
};
-inline void
-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)
- j["member_count"] = info.member_count;
-
- if (info.tags.size() != 0)
- j["tags"] = info.tags;
-}
+void
+to_json(json &j, const RoomInfo &info);
-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>>();
-}
+void
+from_json(const json &j, RoomInfo &info);
//! Basic information per member;
struct MemberInfo
@@ -322,6 +296,8 @@ public:
lmdb::dbi &statesdb,
lmdb::dbi &membersdb,
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.
std::vector<RoomMember> getMembers(const std::string &room_id,
diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp
index f9b7e913..a34b44f0 100644
--- a/src/dialogs/RoomSettings.cpp
+++ b/src/dialogs/RoomSettings.cpp
@@ -199,6 +199,16 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
Qt::AlignBottom | Qt::AlignLeft);
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 notifCombo = new QComboBox(this);
notifCombo->setDisabled(true);
@@ -400,6 +410,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
layout->addLayout(keyRequestsLayout);
layout->addWidget(infoLabel, Qt::AlignLeft);
layout->addLayout(roomIdLayout);
+ layout->addLayout(roomVersionLayout);
layout->addWidget(errorLabel_);
layout->addLayout(buttonLayout);
layout->addLayout(spinnerLayout);
|