diff options
author | David A Roberts <d@vidr.cc> | 2016-04-22 12:44:19 +1000 |
---|---|---|
committer | David A Roberts <d@vidr.cc> | 2016-04-22 12:44:19 +1000 |
commit | deda947801d536dba9b59370867f205fe8aabaa8 (patch) | |
tree | 8e3b8c3d5b360421ad0f3a143dc72b6a7b2d73be | |
parent | da90b601b06512e23ac66d0b301e1eafaf2b7bc2 (diff) | |
download | libquotient-deda947801d536dba9b59370867f205fe8aabaa8.tar.gz libquotient-deda947801d536dba9b59370867f205fe8aabaa8.zip |
Allow login with token.
-rw-r--r-- | connection.cpp | 18 | ||||
-rw-r--r-- | connection.h | 3 | ||||
-rw-r--r-- | user.cpp | 4 | ||||
-rw-r--r-- | user.h | 6 |
4 files changed, 26 insertions, 5 deletions
diff --git a/connection.cpp b/connection.cpp index d9802f5f..e04de7aa 100644 --- a/connection.cpp +++ b/connection.cpp @@ -68,6 +68,14 @@ void Connection::connectToServer(QString user, QString password) d->password = password; } +void Connection::connectWithToken(QString userId, QString token) +{ + d->isConnected = true; + d->userId = userId; + d->data->setToken(token); + emit connected(); +} + void Connection::reconnect() { PasswordLogin* loginJob = new PasswordLogin(d->data, d->username, d->password ); @@ -149,6 +157,16 @@ User *Connection::user() return user(d->userId); } +QString Connection::userId() +{ + return d->userId; +} + +QString Connection::token() +{ + return d->data->token(); +} + QHash< QString, Room* > Connection::roomMap() const { return d->roomMap; diff --git a/connection.h b/connection.h index dc056fd8..9f3d23f3 100644 --- a/connection.h +++ b/connection.h @@ -46,6 +46,7 @@ namespace QMatrixClient Q_INVOKABLE virtual void resolveServer( QString domain ); Q_INVOKABLE virtual void connectToServer( QString user, QString password ); + Q_INVOKABLE virtual void connectWithToken( QString userId, QString token ); Q_INVOKABLE virtual void reconnect(); Q_INVOKABLE virtual SyncJob* sync(int timeout=-1); Q_INVOKABLE virtual void postMessage( Room* room, QString type, QString message ); @@ -58,6 +59,8 @@ namespace QMatrixClient Q_INVOKABLE virtual User* user(QString userId); Q_INVOKABLE virtual User* user(); + Q_INVOKABLE virtual QString userId(); + Q_INVOKABLE virtual QString token(); signals: void connected(); @@ -50,7 +50,7 @@ class User::Private: public QObject }; User::User(QString userId, Connection* connection) - : d(new Private) + : QObject(connection), d(new Private) { d->q = this; d->connection = connection; @@ -147,4 +147,4 @@ void User::Private::gotAvatar(KJob* job) Qt::KeepAspectRatio, Qt::SmoothTransformation); scaledMap.clear(); emit q->avatarChanged(q); -}
\ No newline at end of file +} @@ -36,17 +36,17 @@ namespace QMatrixClient /** * Returns the id of the user */ - QString id() const; + Q_INVOKABLE QString id() const; /** * Returns the name chosen by the user */ - QString name() const; + Q_INVOKABLE QString name() const; /** * Returns the name that should be used to display the user. */ - QString displayname() const; + Q_INVOKABLE QString displayname() const; QPixmap avatar(int requestedWidth, int requestedHeight); |