diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-25 14:46:18 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-25 14:46:18 +0900 |
commit | cbfe29b3435fbe47fee268facbe6a82000fce0ad (patch) | |
tree | e922f1a1505ff1d0a3cdaca56ed5fd151c3aa410 /connection.cpp | |
parent | b1dd0e7ea87842fb5ff9deb14beb3474136b06f3 (diff) | |
parent | a4a1129385731c3999a6d5986a24fc069938245c (diff) | |
download | libquotient-cbfe29b3435fbe47fee268facbe6a82000fce0ad.tar.gz libquotient-cbfe29b3435fbe47fee268facbe6a82000fce0ad.zip |
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'connection.cpp')
-rw-r--r-- | connection.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/connection.cpp b/connection.cpp index be4a712a..1f554974 100644 --- a/connection.cpp +++ b/connection.cpp @@ -23,8 +23,8 @@ #include "room.h" #include "jobs/generated/login.h" #include "jobs/generated/logout.h" +#include "jobs/generated/receipts.h" #include "jobs/sendeventjob.h" -#include "jobs/postreceiptjob.h" #include "jobs/joinroomjob.h" #include "jobs/roommessagesjob.h" #include "jobs/syncjob.h" @@ -164,7 +164,6 @@ void Connection::doConnectToServer(const QString& user, const QString& password, deviceId, initialDeviceName); connect(loginJob, &BaseJob::success, this, [=] { - setHomeserver(loginJob->homeServer()); d->connectWithToken(loginJob->userId(), loginJob->accessToken(), loginJob->deviceId()); }); @@ -223,7 +222,7 @@ void Connection::checkAndConnect(const QString& userId, void Connection::logout() { auto job = callApi<LogoutJob>(); - connect( job, &LogoutJob::success, [=] { + connect( job, &LogoutJob::success, this, [=] { stopSync(); emit loggedOut(); }); @@ -279,12 +278,15 @@ void Connection::postMessage(Room* room, const QString& type, const QString& mes PostReceiptJob* Connection::postReceipt(Room* room, RoomEvent* event) const { - return callApi<PostReceiptJob>(room->id(), event->id()); + return callApi<PostReceiptJob>(room->id(), "m.read", event->id()); } JoinRoomJob* Connection::joinRoom(const QString& roomAlias) { - return callApi<JoinRoomJob>(roomAlias); + auto job = callApi<JoinRoomJob>(roomAlias); + connect(job, &JoinRoomJob::success, + this, [=] { provideRoom(job->roomId(), JoinState::Join); }); + return job; } void Connection::leaveRoom(Room* room) @@ -382,7 +384,7 @@ QString Connection::token() const return accessToken(); } -QString Connection::accessToken() const +QByteArray Connection::accessToken() const { return d->data->accessToken(); } @@ -444,7 +446,6 @@ Room* Connection::provideRoom(const QString& id, JoinState joinState) return nullptr; } d->roomMap.insert(roomKey, room); - qCDebug(MAIN) << "Created Room" << id << ", invited:" << roomKey.second; emit newRoom(room); } if (joinState == JoinState::Invite) @@ -487,11 +488,11 @@ QByteArray Connection::generateTxnId() void Connection::setHomeserver(const QUrl& url) { - if (d->data->baseUrl() == url) + if (homeserver() == url) return; d->data->setBaseUrl(url); - emit homeserverChanged(url); + emit homeserverChanged(homeserver()); } static constexpr int CACHE_VERSION_MAJOR = 1; |