diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/room.cpp | 21 | ||||
-rw-r--r-- | lib/room.h | 4 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index e615060b..3467e301 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1195,6 +1195,27 @@ 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(), + [txnId] (const auto& evt) { return evt->transactionId() == txnId; }); + Q_ASSERT(it != d->unsyncedEvents.end()); + qDebug(EVENTS) << "Retrying transaction" << txnId; + it->resetStatus(); + return d->doSendEvent(it->event()); +} + +void Room::discardMessage(const QString& txnId) +{ + auto it = std::find_if(d->unsyncedEvents.begin(), d->unsyncedEvents.end(), + [txnId] (const auto& evt) { return evt->transactionId() == txnId; }); + Q_ASSERT(it != d->unsyncedEvents.end()); + qDebug(EVENTS) << "Discarding transaction" << txnId; + emit pendingEventAboutToDiscard(it - d->unsyncedEvents.begin()); + d->unsyncedEvents.erase(it); + emit pendingEventDiscarded(); +} + QString Room::postMessage(const QString& plainText, MessageEventType type) { return d->sendEvent<RoomMessageEvent>(plainText, type); @@ -318,6 +318,8 @@ namespace QMatrixClient /** @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 retryMessage(const QString& txnId); + void discardMessage(const QString& txnId); void setName(const QString& newName); void setCanonicalAlias(const QString& newAlias); void setTopic(const QString& newTopic); @@ -353,6 +355,8 @@ namespace QMatrixClient void pendingEventAboutToMerge(RoomEvent* serverEvent, int pendingEventIndex); void pendingEventMerged(); + void pendingEventAboutToDiscard(int pendingEventIndex); + void pendingEventDiscarded(); void pendingEventChanged(int pendingEventIndex); /** |