diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-03-08 20:28:41 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-03-08 20:30:41 +0900 |
commit | 3524342faacd12b00fa4c3a3ebe6a68782975eac (patch) | |
tree | cdd07d0df71e2f7baa87d1be73fb4e3c3473d3eb | |
parent | de9448a65655451e1310947955dd6b341479dc23 (diff) | |
download | libquotient-3524342faacd12b00fa4c3a3ebe6a68782975eac.tar.gz libquotient-3524342faacd12b00fa4c3a3ebe6a68782975eac.zip |
Room::getPreviousContent() gets a number of messages + Room::postMessage()
Also, Room now uses callApi<PostReceiptJob>() instead of postReceipt()
(to allow further removal of postReceipt() from Connection)
-rw-r--r-- | room.cpp | 21 | ||||
-rw-r--r-- | room.h | 3 |
2 files changed, 17 insertions, 7 deletions
@@ -36,7 +36,9 @@ #include "events/roommemberevent.h" #include "events/typingevent.h" #include "events/receiptevent.h" +#include "jobs/postmessagejob.h" #include "jobs/roommessagesjob.h" +#include "jobs/postreceiptjob.h" using namespace QMatrixClient; @@ -90,7 +92,7 @@ class Room::Private void renameMember(User* u, QString oldName); void removeMember(User* u); - void getPreviousContent(); + void getPreviousContent(int limit = 10); bool isEventNotable(const Event* e) const; @@ -269,7 +271,8 @@ void Room::markMessagesAsRead(QString uptoEventId) { if ((*markers.second)->senderId() != connection()->userId()) { - connection()->postReceipt(this, *markers.second); + connection()->callApi<PostReceiptJob>(this->id(), + (*markers.second)->id()); break; } } @@ -490,16 +493,22 @@ void Room::updateData(SyncRoomData& data) } } -void Room::getPreviousContent() +void Room::postMessage(QString type, QString content) { - d->getPreviousContent(); + connection()->callApi<PostMessageJob>(id(), type, content); } -void Room::Private::getPreviousContent() +void Room::getPreviousContent(int limit) +{ + d->getPreviousContent(limit); +} + +void Room::Private::getPreviousContent(int limit) { if( !roomMessagesJob ) { - roomMessagesJob = connection->getMessages(q, prevBatch); + roomMessagesJob = + connection->callApi<RoomMessagesJob>(id, prevBatch, limit); connect( roomMessagesJob, &RoomMessagesJob::result, [=]() { if( !roomMessagesJob->error() ) { @@ -93,7 +93,8 @@ namespace QMatrixClient MemberSorter memberSorter() const; public slots: - void getPreviousContent(); + void postMessage(QString msgType, QString msgContent); + void getPreviousContent(int limit = 10); void userRenamed(User* user, QString oldName); signals: |