aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connection.cpp18
-rw-r--r--connection.h3
-rw-r--r--user.cpp4
-rw-r--r--user.h6
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();
diff --git a/user.cpp b/user.cpp
index 1b232ab8..2cc81fd9 100644
--- a/user.cpp
+++ b/user.cpp
@@ -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
+}
diff --git a/user.h b/user.h
index a34bd285..d0965ef3 100644
--- a/user.h
+++ b/user.h
@@ -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);