From 1c89c319ae8b61111e893969a40d740a9d76c945 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 26 May 2017 17:56:11 +0900 Subject: Enable creation and usage of Event and RoomEvent objects locally, including QML This includes RoomEvent gaining transactionId property and addId() method so that it could gain ids when being/having been sent. --- events/event.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'events/event.cpp') diff --git a/events/event.cpp b/events/event.cpp index bd7e1b03..653396bd 100644 --- a/events/event.cpp +++ b/events/event.cpp @@ -95,6 +95,7 @@ RoomEvent::RoomEvent(Type type, const QJsonObject& rep) , _serverTimestamp(toTimestamp(rep["origin_server_ts"])) , _roomId(rep["room_id"].toString()) , _senderId(rep["sender"].toString()) + , _txnId(rep["unsigned"].toObject().value("transactionId").toString()) { if (_id.isEmpty()) { @@ -103,14 +104,22 @@ RoomEvent::RoomEvent(Type type, const QJsonObject& rep) } if (!rep.contains("origin_server_ts")) { - qCWarning(EVENTS) << "Event: can't find server timestamp in a room event"; + qCWarning(EVENTS) << "Can't find server timestamp in a room event"; qCWarning(EVENTS) << formatJson << rep; } if (_senderId.isEmpty()) { - qCWarning(EVENTS) << "user_id not found in a room event"; + qCWarning(EVENTS) << "Can't find sender in a room event"; qCWarning(EVENTS) << formatJson << rep; } + if (!_txnId.isEmpty()) + qCDebug(EVENTS) << "Event transactionId:" << _txnId; +} + +void RoomEvent::addId(const QString& id) +{ + Q_ASSERT(_id.isEmpty()); Q_ASSERT(!id.isEmpty()); + _id = id; } RoomEvent* RoomEvent::fromJson(const QJsonObject& obj) -- cgit v1.2.3