diff options
-rw-r--r-- | connection.cpp | 17 | ||||
-rw-r--r-- | connection.h | 5 |
2 files changed, 19 insertions, 3 deletions
diff --git a/connection.cpp b/connection.cpp index 85d310cc..e7646b82 100644 --- a/connection.cpp +++ b/connection.cpp @@ -297,9 +297,24 @@ RoomMessagesJob* Connection::getMessages(Room* room, const QString& from) const return callApi<RoomMessagesJob>(room->id(), from); } +inline auto splitMediaId(const QString& mediaId) +{ + auto idParts = mediaId.split('/'); + Q_ASSERT_X(idParts.size() == 2, __FUNCTION__, + "mediaId should have a form 'serverName/localMediaId' (without apostrophes)"); + return idParts; +} + +MediaThumbnailJob* Connection::getThumbnail(const QString& mediaId, QSize requestedSize) const +{ + auto idParts = splitMediaId(mediaId); + return callApi<MediaThumbnailJob>(idParts.front(), idParts.back(), + requestedSize); +} + MediaThumbnailJob* Connection::getThumbnail(const QUrl& url, QSize requestedSize) const { - return callApi<MediaThumbnailJob>(url, requestedSize); + return getThumbnail(url.authority() + url.path(), requestedSize); } MediaThumbnailJob* Connection::getThumbnail(const QUrl& url, int requestedWidth, diff --git a/connection.h b/connection.h index 8dda2bbf..1d483fe8 100644 --- a/connection.h +++ b/connection.h @@ -174,9 +174,11 @@ namespace QMatrixClient void sync(int timeout = -1); void stopSync(); - virtual MediaThumbnailJob* getThumbnail(const QUrl& url, + virtual MediaThumbnailJob* getThumbnail(const QString& mediaId, QSize requestedSize) const; MediaThumbnailJob* getThumbnail(const QUrl& url, + QSize requestedSize) const; + MediaThumbnailJob* getThumbnail(const QUrl& url, int requestedWidth, int requestedHeight) const; @@ -297,7 +299,6 @@ namespace QMatrixClient */ Room* provideRoom(const QString& roomId, JoinState joinState); - /** * Completes loading sync data. */ |