From 93b170ceaced07a3de64708094bb68303a3d4440 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 13 Jan 2018 15:37:09 +0900 Subject: RoomEvent-aware file up/downloads along with status tracking Closes #121; closes #122. --- room.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'room.h') diff --git a/room.h b/room.h index f863d41b..f5bf0839 100644 --- a/room.h +++ b/room.h @@ -70,6 +70,30 @@ namespace QMatrixClient return d; } + class FileTransferInfo + { + Q_GADGET + Q_PROPERTY(bool active READ active CONSTANT) + Q_PROPERTY(bool completed READ completed CONSTANT) + Q_PROPERTY(bool failed READ failed CONSTANT) + Q_PROPERTY(int progress MEMBER progress CONSTANT) + Q_PROPERTY(int total MEMBER total CONSTANT) + Q_PROPERTY(QUrl localDir MEMBER localDir CONSTANT) + Q_PROPERTY(QUrl localPath MEMBER localPath CONSTANT) + public: + enum Status { None, Started, Completed, Failed }; + Status status = None; + int progress = 0; + int total = -1; + QUrl localDir { }; + QUrl localPath { }; + + bool active() const + { return status == Started || status == Completed; } + bool completed() const { return status == Completed; } + bool failed() const { return status == Failed; } + }; + class Room: public QObject { Q_OBJECT @@ -166,6 +190,8 @@ namespace QMatrixClient Q_INVOKABLE int highlightCount() const; Q_INVOKABLE void resetHighlightCount(); + Q_INVOKABLE FileTransferInfo fileTransferInfo(const QString& id) const; + MemberSorter memberSorter() const; QJsonObject toJson() const; @@ -191,6 +217,13 @@ namespace QMatrixClient void redactEvent(const QString& eventId, const QString& reason = {}); + void uploadFile(const QString& id, const QUrl& localFilename, + const QString& overrideContentType = {}); + // If localFilename is empty a temporary file is created + void downloadFile(const QString& eventId, + const QUrl& localFilename = {}); + void cancelFileTransfer(const QString& id); + /** Mark all messages in the room as read */ void markAllMessagesAsRead(); @@ -219,9 +252,16 @@ namespace QMatrixClient void lastReadEventChanged(User* user); void readMarkerMoved(); void unreadMessagesChanged(Room* room); + void replacedEvent(const RoomEvent* newEvent, const RoomEvent* oldEvent); + void newFileTransfer(QString id, QUrl localFile); + void fileTransferProgress(QString id, qint64 progress, qint64 total); + void fileTransferCompleted(QString id, QUrl localFile, QUrl mxcUrl); + void fileTransferFailed(QString id, QString errorMessage = {}); + void fileTransferCancelled(QString id); + protected: virtual void processStateEvents(const RoomEvents& events); virtual void processEphemeralEvent(EventPtr event); @@ -253,3 +293,4 @@ namespace QMatrixClient const Room* room; }; } // namespace QMatrixClient +Q_DECLARE_METATYPE(QMatrixClient::FileTransferInfo) -- cgit v1.2.3