aboutsummaryrefslogtreecommitdiff
path: root/lib/events
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events')
-rw-r--r--lib/events/event.cpp5
-rw-r--r--lib/events/event.h10
-rw-r--r--lib/events/stateevent.cpp8
-rw-r--r--lib/events/stateevent.h2
4 files changed, 25 insertions, 0 deletions
diff --git a/lib/events/event.cpp b/lib/events/event.cpp
index fd6e3939..c98dfbb6 100644
--- a/lib/events/event.cpp
+++ b/lib/events/event.cpp
@@ -77,3 +77,8 @@ const QJsonObject Event::unsignedJson() const
{
return fullJson()[UnsignedKeyL].toObject();
}
+
+void Event::dumpTo(QDebug dbg) const
+{
+ dbg << QJsonDocument(contentJson()).toJson(QJsonDocument::Compact);
+}
diff --git a/lib/events/event.h b/lib/events/event.h
index 5b33628f..76e77cf6 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -257,8 +257,18 @@ namespace QMatrixClient
return fromJson<T>(contentJson()[key]);
}
+ friend QDebug operator<<(QDebug dbg, const Event& e)
+ {
+ QDebugStateSaver _dss { dbg };
+ dbg.noquote().nospace()
+ << e.matrixType() << '(' << e.type() << "): ";
+ e.dumpTo(dbg);
+ return dbg;
+ }
+
virtual bool isStateEvent() const { return false; }
virtual bool isCallEvent() const { return false; }
+ virtual void dumpTo(QDebug dbg) const;
protected:
QJsonObject& editJson() { return _json; }
diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp
index fd5d2642..ea7533c5 100644
--- a/lib/events/stateevent.cpp
+++ b/lib/events/stateevent.cpp
@@ -28,3 +28,11 @@ bool StateEventBase::repeatsState() const
const auto prevContentJson = unsignedJson().value(PrevContentKeyL);
return fullJson().value(ContentKeyL) == prevContentJson;
}
+
+void StateEventBase::dumpTo(QDebug dbg) const
+{
+ if (unsignedJson().contains(PrevContentKeyL))
+ dbg << QJsonDocument(unsignedJson()[PrevContentKeyL].toObject())
+ .toJson(QJsonDocument::Compact) << " -> ";
+ RoomEvent::dumpTo(dbg);
+}
diff --git a/lib/events/stateevent.h b/lib/events/stateevent.h
index 6032132e..e499bdff 100644
--- a/lib/events/stateevent.h
+++ b/lib/events/stateevent.h
@@ -30,6 +30,8 @@ namespace QMatrixClient {
~StateEventBase() override = default;
bool isStateEvent() const override { return true; }
+ void dumpTo(QDebug dbg) const override;
+
virtual bool repeatsState() const;
};
using StateEventPtr = event_ptr_tt<StateEventBase>;