diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-03-24 21:44:25 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-03-24 21:44:25 +0900 |
commit | 26ab888cf732f768770138f791f1ed7a2bade7f3 (patch) | |
tree | 89e0f573cec03e64cf002f0768d5a6b0a160e891 | |
parent | 15ef0758ccb7e1637d3a0400f5903d4a7906cd93 (diff) | |
download | libquotient-26ab888cf732f768770138f791f1ed7a2bade7f3.tar.gz libquotient-26ab888cf732f768770138f791f1ed7a2bade7f3.zip |
Connection::joinRoom now returns a job object pointer
So now you can directly connect to signals emitted by the job, instead of making intermediate signals in Connection for the same thing.
-rw-r--r-- | connection.cpp | 6 | ||||
-rw-r--r-- | connection.h | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/connection.cpp b/connection.cpp index dff88bef..2fbcf686 100644 --- a/connection.cpp +++ b/connection.cpp @@ -199,14 +199,14 @@ PostReceiptJob* Connection::postReceipt(Room* room, Event* event) return job; } -void Connection::joinRoom(QString roomAlias) +JoinRoomJob* Connection::joinRoom(QString roomAlias) { - JoinRoomJob* job = new JoinRoomJob(d->data, roomAlias); + auto job = callApi<JoinRoomJob>(roomAlias); connect( job, &BaseJob::success, [=] () { if ( Room* r = provideRoom(job->roomId()) ) emit joinedRoom(r); }); - job->start(); + return job; } void Connection::leaveRoom(Room* room) diff --git a/connection.h b/connection.h index 1ce3e0de..55b688a2 100644 --- a/connection.h +++ b/connection.h @@ -34,6 +34,7 @@ namespace QMatrixClient class RoomMessagesJob; class PostReceiptJob; class MediaThumbnailJob; + class JoinRoomJob; class Connection: public QObject { Q_OBJECT @@ -53,9 +54,11 @@ namespace QMatrixClient Q_INVOKABLE virtual void logout(); Q_INVOKABLE virtual void sync(int timeout=-1); + /** @deprecated Use callApi<PostMessageJob>() or Room::postMessage() instead */ Q_INVOKABLE virtual void postMessage( Room* room, QString type, QString message ); + /** @deprecated Use callApi<PostReceiptJob>() or Room::postReceipt() instead */ Q_INVOKABLE virtual PostReceiptJob* postReceipt( Room* room, Event* event ); - Q_INVOKABLE virtual void joinRoom( QString roomAlias ); + Q_INVOKABLE virtual JoinRoomJob* joinRoom( QString roomAlias ); Q_INVOKABLE virtual void leaveRoom( Room* room ); Q_INVOKABLE virtual RoomMessagesJob* getMessages( Room* room, QString from ); virtual MediaThumbnailJob* getThumbnail( QUrl url, QSize requestedSize ); |