aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connection.cpp2
-rw-r--r--connection.h1
-rw-r--r--jobs/leaveroomjob.cpp6
-rw-r--r--jobs/leaveroomjob.h6
-rw-r--r--room.cpp6
-rw-r--r--room.h2
6 files changed, 14 insertions, 9 deletions
diff --git a/connection.cpp b/connection.cpp
index 8d5ff2fa..0c73e22d 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -208,7 +208,7 @@ JoinRoomJob* Connection::joinRoom(const QString& roomAlias)
void Connection::leaveRoom(Room* room)
{
- callApi<LeaveRoomJob>(room);
+ callApi<LeaveRoomJob>(room->id());
}
RoomMessagesJob* Connection::getMessages(Room* room, const QString& from) const
diff --git a/connection.h b/connection.h
index 8fc4a6b3..7ca1ccd6 100644
--- a/connection.h
+++ b/connection.h
@@ -61,6 +61,7 @@ namespace QMatrixClient
/** @deprecated Use callApi<PostReceiptJob>() or Room::postReceipt() instead */
Q_INVOKABLE virtual PostReceiptJob* postReceipt( Room* room, Event* event ) const;
Q_INVOKABLE virtual JoinRoomJob* joinRoom(const QString& roomAlias);
+ /** @deprecated Use callApi<LeaveRoomJob>() or Room::leaveRoom() instead */
Q_INVOKABLE virtual void leaveRoom( Room* room );
Q_INVOKABLE virtual RoomMessagesJob* getMessages(Room* room,
const QString& from) const;
diff --git a/jobs/leaveroomjob.cpp b/jobs/leaveroomjob.cpp
index 5557b8e4..f73919ac 100644
--- a/jobs/leaveroomjob.cpp
+++ b/jobs/leaveroomjob.cpp
@@ -18,11 +18,9 @@
#include "leaveroomjob.h"
-#include "../room.h"
-
using namespace QMatrixClient;
-LeaveRoomJob::LeaveRoomJob(const ConnectionData* data, Room* room)
+LeaveRoomJob::LeaveRoomJob(const ConnectionData* data, const QString& roomId)
: BaseJob(data, HttpVerb::Post, "LeaveRoomJob",
- QString("_matrix/client/r0/rooms/%1/leave").arg(room->id()))
+ QStringLiteral("_matrix/client/r0/rooms/%1/leave").arg(roomId))
{ }
diff --git a/jobs/leaveroomjob.h b/jobs/leaveroomjob.h
index 03851f4c..70883b68 100644
--- a/jobs/leaveroomjob.h
+++ b/jobs/leaveroomjob.h
@@ -22,11 +22,9 @@
namespace QMatrixClient
{
- class Room;
-
class LeaveRoomJob: public BaseJob
{
public:
- LeaveRoomJob(const ConnectionData* data, Room* room);
+ LeaveRoomJob(const ConnectionData* data, const QString& roomId);
};
-}
+} // namespace QMatrixClient
diff --git a/room.cpp b/room.cpp
index 5159cafd..af39da52 100644
--- a/room.cpp
+++ b/room.cpp
@@ -39,6 +39,7 @@
#include "jobs/postmessagejob.h"
#include "jobs/roommessagesjob.h"
#include "jobs/postreceiptjob.h"
+#include "jobs/leaveroomjob.h"
using namespace QMatrixClient;
@@ -577,6 +578,11 @@ void Room::Private::getPreviousContent(int limit)
}
}
+void Room::leaveRoom() const
+{
+ connection()->callApi<LeaveRoomJob>(id());
+}
+
void Room::Private::dropDuplicateEvents(Events* events) const
{
// Collect all duplicate events at the end of the container
diff --git a/room.h b/room.h
index e277a3f9..689a99b0 100644
--- a/room.h
+++ b/room.h
@@ -147,6 +147,8 @@ namespace QMatrixClient
void postMessage(const QString& type, const QString& plainText,
const QString& richText);
void getPreviousContent(int limit = 10);
+
+ void leaveRoom() const;
void userRenamed(User* user, QString oldName);
signals: