aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/connection.cpp9
-rw-r--r--lib/room.cpp17
-rw-r--r--lib/room.h6
3 files changed, 31 insertions, 1 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 6d1763ee..22fa2f15 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -268,6 +268,9 @@ void Connection::reloadCapabilities()
}
Q_ASSERT(!d->capabilities.roomVersions.omitted());
emit capabilitiesLoaded();
+ for (auto* r: d->roomMap)
+ if (r->joinState() == JoinState::Join && r->successorId().isEmpty())
+ r->checkVersion();
});
}
@@ -383,8 +386,14 @@ void Connection::onSyncSuccess(SyncData &&data, bool fromCache) {
d->pendingStateRoomIds.removeOne(roomData.roomId);
r->updateData(std::move(roomData), fromCache);
if (d->firstTimeRooms.removeOne(r))
+ {
emit loadedRoomState(r);
+ if (!d->capabilities.roomVersions.omitted())
+ r->checkVersion();
+ // Otherwise, the version will be checked in reloadCapabilities()
+ }
}
+ // Let UI update itself after updating each room
QCoreApplication::processEvents();
}
for (auto&& accountEvent: data.takeAccountData())
diff --git a/lib/room.cpp b/lib/room.cpp
index af97dc11..580d04b8 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -1604,7 +1604,22 @@ bool isEchoEvent(const RoomEventPtr& le, const PendingEventItem& re)
bool Room::supportsCalls() const
{
- return joinedCount() == 2;
+ return joinedCount() == 2;
+}
+
+void Room::checkVersion()
+{
+ const auto defaultVersion = connection()->defaultRoomVersion();
+ const auto stableVersions = connection()->stableRoomVersions();
+ Q_ASSERT(!defaultVersion.isEmpty() && successorId().isEmpty());
+ if (!stableVersions.contains(version()))
+ {
+ qCDebug(MAIN) << this << "version is" << version()
+ << "which the server doesn't count as stable";
+ // TODO: m.room.power_levels
+ qCDebug(MAIN) << "The current user has enough privileges to fix it";
+ emit unstableVersion(defaultVersion, stableVersions);
+ }
}
void Room::inviteCall(const QString& callId, const int lifetime,
diff --git a/lib/room.h b/lib/room.h
index 137b383d..246206d4 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -377,6 +377,9 @@ namespace QMatrixClient
Q_INVOKABLE bool supportsCalls() const;
public slots:
+ /** Check whether the room should be upgraded */
+ void checkVersion();
+
QString postMessage(const QString& plainText, MessageEventType type);
QString postPlainText(const QString& plainText);
QString postHtmlMessage(const QString& plainText,
@@ -529,6 +532,9 @@ namespace QMatrixClient
void callEvent(Room* room, const RoomEvent* event);
+ /// The room's version is considered unstable; upgrade recommended
+ void unstableVersion(QString recommendedDefault,
+ QStringList stableVersions);
/// This room has been upgraded and won't receive updates anymore
void upgraded(QString serverMessage, QString successorId);