aboutsummaryrefslogtreecommitdiff
path: root/connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'connection.cpp')
-rw-r--r--connection.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/connection.cpp b/connection.cpp
index a9b9a534..cf08321c 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -144,19 +144,17 @@ void Connection::reconnect()
void Connection::disconnectFromServer()
{
- if (d->syncJob)
- {
- d->syncJob->abandon();
- d->syncJob = nullptr;
- }
+ stopSync();
d->isConnected = false;
}
void Connection::logout()
{
- auto job = new LogoutJob(d->data);
- connect( job, &LogoutJob::success, this, &Connection::loggedOut);
- job->start();
+ auto job = callApi<LogoutJob>();
+ connect( job, &LogoutJob::success, [=] {
+ stopSync();
+ emit loggedOut();
+ });
}
void Connection::sync(int timeout)
@@ -186,6 +184,15 @@ void Connection::sync(int timeout)
});
}
+void Connection::stopSync()
+{
+ if (d->syncJob)
+ {
+ d->syncJob->abandon();
+ d->syncJob = nullptr;
+ }
+}
+
void Connection::postMessage(Room* room, QString type, QString message)
{
PostMessageJob* job = new PostMessageJob(d->data, room->id(), type, message);