aboutsummaryrefslogtreecommitdiff
path: root/connection.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-03-09 13:13:48 +0900
committerGitHub <noreply@github.com>2017-03-09 13:13:48 +0900
commitaf8f95fa0446bf377321d9f285b0e55c08fd91da (patch)
treecdd07d0df71e2f7baa87d1be73fb4e3c3473d3eb /connection.cpp
parentba5ca3c88a20926f2be06872f530d9da12d5a062 (diff)
parent3524342faacd12b00fa4c3a3ebe6a68782975eac (diff)
downloadlibquotient-af8f95fa0446bf377321d9f285b0e55c08fd91da.tar.gz
libquotient-af8f95fa0446bf377321d9f285b0e55c08fd91da.zip
Merge pull request #54 from Fxrh/kitsune-call-server
Connection::callApi + Room::getPreviousMessages(limit)
Diffstat (limited to 'connection.cpp')
-rw-r--r--connection.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/connection.cpp b/connection.cpp
index 0f115e3a..dff88bef 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -58,8 +58,6 @@ class Connection::Private
QString userId;
SyncJob* syncJob;
-
- SyncJob* startSyncJob(const QString& filter, int timeout);
};
Connection::Connection(QUrl server, QObject* parent)
@@ -167,7 +165,8 @@ void Connection::sync(int timeout)
return;
const QString filter = "{\"room\": { \"timeline\": { \"limit\": 100 } } }";
- auto job = d->startSyncJob(filter, timeout);
+ auto job = d->syncJob =
+ callApi<SyncJob>(d->data->lastEvent(), filter, timeout);
connect( job, &SyncJob::success, [=] () {
d->data->setLastEvent(job->nextBatch());
for( auto& roomData: job->roomData() )
@@ -187,17 +186,9 @@ void Connection::sync(int timeout)
});
}
-SyncJob* Connection::Private::startSyncJob(const QString& filter, int timeout)
-{
- syncJob = new SyncJob(data, data->lastEvent(), filter, timeout);
- syncJob->start();
- return syncJob;
-
-}
-
void Connection::postMessage(Room* room, QString type, QString message)
{
- PostMessageJob* job = new PostMessageJob(d->data, room, type, message);
+ PostMessageJob* job = new PostMessageJob(d->data, room->id(), type, message);
job->start();
}
@@ -226,7 +217,7 @@ void Connection::leaveRoom(Room* room)
RoomMessagesJob* Connection::getMessages(Room* room, QString from)
{
- RoomMessagesJob* job = new RoomMessagesJob(d->data, room, from);
+ RoomMessagesJob* job = new RoomMessagesJob(d->data, room->id(), from);
job->start();
return job;
}