From 26ab888cf732f768770138f791f1ed7a2bade7f3 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 24 Mar 2017 21:44:25 +0900 Subject: 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. --- connection.cpp | 6 +++--- 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(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() or Room::postMessage() instead */ Q_INVOKABLE virtual void postMessage( Room* room, QString type, QString message ); + /** @deprecated Use callApi() 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 ); -- cgit v1.2.3