diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-13 15:37:09 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-14 10:02:45 +0900 |
commit | 93b170ceaced07a3de64708094bb68303a3d4440 (patch) | |
tree | f31f49f9bad24aaffb0852c1a37f1d76090c79a1 /room.h | |
parent | b9f4b655273481e64d7d7ead6a30dbf85a901063 (diff) | |
download | libquotient-93b170ceaced07a3de64708094bb68303a3d4440.tar.gz libquotient-93b170ceaced07a3de64708094bb68303a3d4440.zip |
RoomEvent-aware file up/downloads along with status tracking
Closes #121; closes #122.
Diffstat (limited to 'room.h')
-rw-r--r-- | room.h | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -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) |