From 3524342faacd12b00fa4c3a3ebe6a68782975eac Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 8 Mar 2017 20:28:41 +0900 Subject: Room::getPreviousContent() gets a number of messages + Room::postMessage() Also, Room now uses callApi() instead of postReceipt() (to allow further removal of postReceipt() from Connection) --- room.cpp | 21 +++++++++++++++------ room.h | 3 ++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/room.cpp b/room.cpp index 2378ecf4..7b3a49ae 100644 --- a/room.cpp +++ b/room.cpp @@ -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(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(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(id, prevBatch, limit); connect( roomMessagesJob, &RoomMessagesJob::result, [=]() { if( !roomMessagesJob->error() ) { diff --git a/room.h b/room.h index 60b59bb3..ff76b25a 100644 --- a/room.h +++ b/room.h @@ -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: -- cgit v1.2.3