diff options
-rw-r--r-- | jobs/postmessagejob.cpp | 18 | ||||
-rw-r--r-- | jobs/postmessagejob.h | 9 | ||||
-rw-r--r-- | room.cpp | 10 | ||||
-rw-r--r-- | room.h | 4 |
4 files changed, 33 insertions, 8 deletions
diff --git a/jobs/postmessagejob.cpp b/jobs/postmessagejob.cpp index 23c2214c..69cc814d 100644 --- a/jobs/postmessagejob.cpp +++ b/jobs/postmessagejob.cpp @@ -31,12 +31,24 @@ class PostMessageJob::Private QString eventId; // unused yet }; -PostMessageJob::PostMessageJob(ConnectionData* connection, QString roomId, - QString type, QString message) +PostMessageJob::PostMessageJob(ConnectionData* connection, const QString& roomId, + const QString& type, const QString& plainText) : BaseJob(connection, HttpVerb::Post, "PostMessageJob", QString("_matrix/client/r0/rooms/%1/send/m.room.message").arg(roomId), Query(), - Data({ { "msgtype", type }, { "body", message } })) + Data({ { "msgtype", type }, { "body", plainText } }) ) + , d(new Private) +{ } + +PostMessageJob::PostMessageJob(ConnectionData* connection, const QString& roomId, + const QString& type, const QString& plainText, + const QString& richText) + : BaseJob(connection, HttpVerb::Post, "PostMessageJob", + QStringLiteral("_matrix/client/r0/rooms/%1/send/m.room.message").arg(roomId), + Query(), + Data({ { "msgtype", type }, { "body", plainText } + , { "format", QStringLiteral("org.matrix.custom.html") } + , { "formatted_body", richText } }) ) , d(new Private) { } diff --git a/jobs/postmessagejob.h b/jobs/postmessagejob.h index eba3da51..14de52f0 100644 --- a/jobs/postmessagejob.h +++ b/jobs/postmessagejob.h @@ -25,8 +25,13 @@ namespace QMatrixClient class PostMessageJob: public BaseJob { public: - PostMessageJob(ConnectionData* connection, QString roomId, - QString type, QString message); + /** Constructs a plain text message job */ + PostMessageJob(ConnectionData* connection, const QString& roomId, + const QString& type, const QString& plainText); + /** Constructs a rich text message job */ + PostMessageJob(ConnectionData* connection, const QString& roomId, + const QString& type, const QString& plainText, + const QString& richText); virtual ~PostMessageJob(); //bool success(); @@ -535,9 +535,15 @@ void Room::updateData(SyncRoomData& data) } } -void Room::postMessage(QString type, QString content) +void Room::postMessage(const QString& type, const QString& plainText) { - connection()->callApi<PostMessageJob>(id(), type, content); + connection()->callApi<PostMessageJob>(id(), type, plainText); +} + +void Room::postMessage(const QString& type, const QString& plainText, + const QString& richText) +{ + connection()->callApi<PostMessageJob>(id(), type, plainText, richText); } void Room::getPreviousContent(int limit) @@ -139,7 +139,9 @@ namespace QMatrixClient MemberSorter memberSorter() const; public slots: - void postMessage(QString msgType, QString msgContent); + void postMessage(const QString& type, const QString& plainText); + void postMessage(const QString& type, const QString& plainText, + const QString& richText); void getPreviousContent(int limit = 10); void userRenamed(User* user, QString oldName); |