From d6ecaaa344c2caec1108609ed6e3ecbb78aaf357 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 15 Nov 2024 22:42:29 -0500 Subject: [PATCH] RoomManager: Unify the resolveResource overloads Every time I look at how resource resolving works, I always trip over this unused overload. This behaves *different* than the other overload, which has special cases for handling invalid Uris. Now whether you pass in a Uri or a QString, it should behave the same. (cherry picked from commit 55362c5573d3cbd04a9d01f7e7795fcae85182c0) --- src/roommanager.cpp | 13 ++++++------- src/roommanager.h | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/roommanager.cpp b/src/roommanager.cpp index ada8e74f7..4f3833081 100644 --- a/src/roommanager.cpp +++ b/src/roommanager.cpp @@ -134,16 +134,15 @@ void RoomManager::activateUserModel() m_userListModel->activate(); } -UriResolveResult RoomManager::resolveResource(const Uri &uri) -{ - return UriResolverBase::visitResource(m_connection, uri); -} - void RoomManager::resolveResource(const QString &idOrUri, const QString &action) { - Uri uri{idOrUri}; + resolveResource(Uri{idOrUri}, action); +} + +void RoomManager::resolveResource(Uri uri, const QString &action) +{ if (!uri.isValid()) { - Q_EMIT showMessage(MessageType::Warning, i18n("Malformed or empty Matrix id
%1 is not a correct Matrix identifier", idOrUri)); + Q_EMIT showMessage(MessageType::Warning, i18n("Malformed or empty Matrix id
%1 is not a correct Matrix identifier", uri.toDisplayString())); return; } diff --git a/src/roommanager.h b/src/roommanager.h index 3fabf0a0e..7679f3fe3 100644 --- a/src/roommanager.h +++ b/src/roommanager.h @@ -168,16 +168,6 @@ public: UserListModel *userListModel() const; Q_INVOKABLE void activateUserModel(); - /** - * @brief Resolve the given URI resource. - * - * @note It's actually Quotient::UriResolverBase::visitResource() but with Q_INVOKABLE - * and the connection grabbed from RoomManager. - * - * @sa Quotient::UriResolverBase::visitResource() - */ - Q_INVOKABLE UriResolveResult resolveResource(const Uri &uri); - /** * @brief Resolve the given resource. * @@ -188,6 +178,16 @@ public: */ Q_INVOKABLE void resolveResource(const QString &idOrUri, const QString &action = {}); + /** + * @brief Resolve the given resource URI. + * + * @note It's actually Quotient::UriResolverBase::visitResource() but with Q_INVOKABLE + * and the connection grabbed from RoomManager. + * + * @sa Quotient::UriResolverBase::visitResource() + */ + Q_INVOKABLE void resolveResource(Uri uri, const QString &action = {}); + bool hasOpenRoom() const; /**