diff options
-rw-r--r-- | lib/room.cpp | 29 | ||||
-rw-r--r-- | lib/room.h | 17 |
2 files changed, 24 insertions, 22 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index dc60445d..4b349f44 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -199,12 +199,12 @@ class Room::Private void markMessagesAsRead(rev_iter_t upToMarker); - void sendEvent(RoomEventPtr&& event); + QString sendEvent(RoomEventPtr&& event); template <typename EventT, typename... ArgTs> - void sendEvent(ArgTs&&... eventArgs) + QString sendEvent(ArgTs&&... eventArgs) { - sendEvent(makeEvent<EventT>(std::forward<ArgTs>(eventArgs)...)); + return sendEvent(makeEvent<EventT>(std::forward<ArgTs>(eventArgs)...)); } template <typename EvT> @@ -1102,7 +1102,7 @@ void Room::updateData(SyncRoomData&& data) } } -void Room::Private::sendEvent(RoomEventPtr&& event) +QString Room::Private::sendEvent(RoomEventPtr&& event) { auto* pEvent = rawPtr(event); emit q->pendingEventAboutToAdd(); @@ -1127,39 +1127,40 @@ void Room::Private::sendEvent(RoomEventPtr&& event) pEvent->addId(call->eventId()); emit q->pendingEventChanged(it - unsyncedEvents.begin()); }); + return pEvent->transactionId(); } -void Room::postMessage(const QString& type, const QString& plainText) +QString Room::postMessage(const QString& type, const QString& plainText) { - d->sendEvent<RoomMessageEvent>(plainText, type); + return d->sendEvent<RoomMessageEvent>(plainText, type); } -void Room::postMessage(const QString& plainText, MessageEventType type) +QString Room::postMessage(const QString& plainText, MessageEventType type) { - d->sendEvent<RoomMessageEvent>(plainText, type); + return d->sendEvent<RoomMessageEvent>(plainText, type); } -void Room::postHtmlMessage(const QString& plainText, const QString& htmlText, +QString Room::postHtmlMessage(const QString& plainText, const QString& htmlText, MessageEventType type) { - d->sendEvent<RoomMessageEvent>(plainText, type, + return d->sendEvent<RoomMessageEvent>(plainText, type, new EventContent::TextContent(htmlText, QStringLiteral("text/html"))); } -void Room::postMessage(RoomEvent* event) +QString Room::postMessage(RoomEvent* event) { if (usesEncryption()) { qCCritical(MAIN) << "Room" << displayName() << "enforces encryption; sending encrypted messages is not supported yet"; } - d->sendEvent(RoomEventPtr(event)); + return d->sendEvent(RoomEventPtr(event)); } -void Room::postMessage(const QString& matrixType, +QString Room::postMessage(const QString& matrixType, const QJsonObject& eventContent) { - d->sendEvent(loadEvent<RoomEvent>(basicEventJson(matrixType, eventContent))); + return d->sendEvent(loadEvent<RoomEvent>(basicEventJson(matrixType, eventContent))); } void Room::setName(const QString& newName) @@ -347,17 +347,18 @@ namespace QMatrixClient void setJoinState( JoinState state ); public slots: - void postMessage(const QString& plainText, - MessageEventType type = MessageEventType::Text); - void postHtmlMessage(const QString& plainText, const QString& htmlText, - MessageEventType type = MessageEventType::Text); + 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 */ - void postMessage(RoomEvent* event); - void postMessage(const QString& matrixType, - const QJsonObject& eventContent); + 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() */ - void postMessage(const QString& type, const QString& plainText); + QString postMessage(const QString& type, const QString& plainText); void setName(const QString& newName); void setCanonicalAlias(const QString& newAlias); void setTopic(const QString& newTopic); |