diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/connection.cpp | 4 | ||||
-rw-r--r-- | lib/connection.h | 15 |
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index 8107393d..2881f7f4 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -243,10 +243,12 @@ void Connection::Private::connectWithToken(const QString& user, const QString& deviceId) { userId = user; + q->user(); // Creates a User object for the local user data->setToken(accessToken.toLatin1()); data->setDeviceId(deviceId); qCDebug(MAIN) << "Using server" << data->baseUrl().toDisplayString() << "by user" << userId << "from device" << deviceId; + emit q->stateChanged(); emit q->connected(); } @@ -281,6 +283,8 @@ void Connection::logout() auto job = callApi<LogoutJob>(); connect( job, &LogoutJob::success, this, [this] { stopSync(); + d->data->setToken({}); + emit stateChanged(); emit loggedOut(); }); } diff --git a/lib/connection.h b/lib/connection.h index aec67972..c7e28282 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -61,10 +61,10 @@ namespace QMatrixClient /** Whether or not the rooms state should be cached locally * \sa loadState(), saveState() */ - Q_PROPERTY(User* localUser READ user CONSTANT) - Q_PROPERTY(QString localUserId READ userId CONSTANT) - Q_PROPERTY(QString deviceId READ deviceId CONSTANT) - Q_PROPERTY(QByteArray accessToken READ accessToken CONSTANT) + Q_PROPERTY(User* localUser READ user NOTIFY stateChanged) + Q_PROPERTY(QString localUserId READ userId NOTIFY stateChanged) + Q_PROPERTY(QString deviceId READ deviceId NOTIFY stateChanged) + Q_PROPERTY(QByteArray accessToken READ accessToken NOTIFY stateChanged) Q_PROPERTY(QUrl homeserver READ homeserver WRITE setHomeserver NOTIFY homeserverChanged) Q_PROPERTY(bool cacheState READ cacheState WRITE setCacheState NOTIFY cacheStateChanged) public: @@ -431,6 +431,13 @@ namespace QMatrixClient void connected(); void reconnected(); //< \deprecated Use connected() instead void loggedOut(); + /** Login data or state have changed + * + * This is a common change signal for userId, deviceId and + * accessToken - these properties normally only change at + * a successful login and logout and are constant at other times. + */ + void stateChanged(); void loginError(QString message, QByteArray details); /** A network request (job) failed |