diff options
-rw-r--r-- | examples/qmc-example.cpp | 8 | ||||
-rw-r--r-- | lib/room.cpp | 23 | ||||
-rw-r--r-- | lib/room.h | 25 |
3 files changed, 31 insertions, 25 deletions
diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp index ce38e916..484cd027 100644 --- a/examples/qmc-example.cpp +++ b/examples/qmc-example.cpp @@ -88,7 +88,7 @@ void QMCTest::setup(const QString& testRoomName) c->sync(10000); else if (targetRoom) { - targetRoom->postMessage(origin % ": All tests finished"); + targetRoom->postPlainText(origin % ": All tests finished"); connect(targetRoom, &Room::pendingEventMerged, this, &QMCTest::leave); } else @@ -152,7 +152,7 @@ void QMCTest::sendMessage() { running.push_back("Message sending"); cout << "Sending a message" << endl; - auto txnId = targetRoom->postMessage("Hello, " % origin % " is here"); + auto txnId = targetRoom->postPlainText("Hello, " % origin % " is here"); auto& pending = targetRoom->pendingEvents(); if (pending.empty()) { @@ -233,7 +233,7 @@ void QMCTest::checkRedactionOutcome(const QString& evtIdToRedact, const auto msg = "The redacted event came in with the sync again, ignoring"; cout << msg << endl; - targetRoom->postMessage(msg); + targetRoom->postPlainText(msg); return; } cout << "The sync brought already redacted message" << endl; @@ -249,7 +249,7 @@ void QMCTest::checkRedactionOutcome(const QString& evtIdToRedact, const auto msg = "Warning: the redacted event came non-redacted with the sync!"; cout << msg << endl; - targetRoom->postMessage(msg); + targetRoom->postPlainText(msg); } cout << "Message came non-redacted with the sync, waiting for redaction" << endl; connect(targetRoom, &Room::replacedEvent, targetRoom, diff --git a/lib/room.cpp b/lib/room.cpp index a3f7bda2..e99f9235 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1197,11 +1197,6 @@ Room::PendingEvents::iterator Room::Private::findAsPending( return std::find_if(unsyncedEvents.begin(), unsyncedEvents.end(), comp); } -QString Room::postMessage(const QString& type, const QString& plainText) -{ - return d->sendEvent<RoomMessageEvent>(plainText, type); -} - QString Room::retryMessage(const QString& txnId) { auto it = std::find_if(d->unsyncedEvents.begin(), d->unsyncedEvents.end(), @@ -1228,14 +1223,24 @@ QString Room::postMessage(const QString& plainText, MessageEventType type) return d->sendEvent<RoomMessageEvent>(plainText, type); } -QString Room::postHtmlMessage(const QString& plainText, const QString& htmlText, +QString Room::postPlainText(const QString& plainText) +{ + return postMessage(plainText, MessageEventType::Text); +} + +QString Room::postHtmlMessage(const QString& plainText, const QString& html, MessageEventType type) { return d->sendEvent<RoomMessageEvent>(plainText, type, - new EventContent::TextContent(htmlText, QStringLiteral("text/html"))); + new EventContent::TextContent(html, QStringLiteral("text/html"))); +} + +QString Room::postHtmlText(const QString& plainText, const QString& html) +{ + return postHtmlMessage(plainText, html, MessageEventType::Text); } -QString Room::postMessage(RoomEvent* event) +QString Room::postEvent(RoomEvent* event) { if (usesEncryption()) { @@ -1245,7 +1250,7 @@ QString Room::postMessage(RoomEvent* event) return d->sendEvent(RoomEventPtr(event)); } -QString Room::postMessage(const QString& matrixType, +QString Room::postJson(const QString& matrixType, const QJsonObject& eventContent) { return d->sendEvent(loadEvent<RoomEvent>(basicEventJson(matrixType, eventContent))); @@ -306,18 +306,19 @@ namespace QMatrixClient void setJoinState( JoinState state ); public slots: - QString postMessage(const QString& plainText, - MessageEventType type = MessageEventType::Text); - QString postHtmlMessage( - const QString& plainText, const QString& htmlText, - MessageEventType type = MessageEventType::Text); - /** Post a pre-created room message event; takes ownership of the event */ - QString postMessage(RoomEvent* event); - QString postMessage(const QString& matrixType, - const QJsonObject& eventContent); - /** @deprecated If you have a custom event type, construct the event - * and pass it as a whole to postMessage() */ - QString postMessage(const QString& type, const QString& plainText); + QString postMessage(const QString& plainText, MessageEventType type); + QString postPlainText(const QString& plainText); + QString postHtmlMessage(const QString& plainText, + const QString& html, MessageEventType type); + QString postHtmlText(const QString& plainText, const QString& html); + /** Post a pre-created room message event + * + * Takes ownership of the event, deleting it once the matching one + * arrives with the sync + */ + QString postEvent(RoomEvent* event); + QString postJson(const QString& matrixType, + const QJsonObject& eventContent); QString retryMessage(const QString& txnId); void discardMessage(const QString& txnId); void setName(const QString& newName); |