aboutsummaryrefslogtreecommitdiff
path: root/events
diff options
context:
space:
mode:
Diffstat (limited to 'events')
-rw-r--r--events/event.cpp37
-rw-r--r--events/roomaliasesevent.cpp3
-rw-r--r--events/typingevent.cpp2
-rw-r--r--events/unknownevent.cpp7
4 files changed, 29 insertions, 20 deletions
diff --git a/events/event.cpp b/events/event.cpp
index 9a48108c..d05d666f 100644
--- a/events/event.cpp
+++ b/events/event.cpp
@@ -23,6 +23,7 @@
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
+#include "../logging_util.h"
#include "roommessageevent.h"
#include "roomnameevent.h"
#include "roomaliasesevent.h"
@@ -110,36 +111,38 @@ Event* Event::fromJson(const QJsonObject& obj)
}
if( obj.value("type").toString() == "m.typing" )
{
- qDebug() << "m.typing...";
return TypingEvent::fromJson(obj);
}
if( obj.value("type").toString() == "m.receipt" )
{
return ReceiptEvent::fromJson(obj);
}
- //qDebug() << "Unknown event";
return UnknownEvent::fromJson(obj);
}
bool Event::parseJson(const QJsonObject& obj)
{
d->originalJson = QString::fromUtf8(QJsonDocument(obj).toJson());
- bool correct = true;
- if( obj.contains("event_id") )
+ bool correct = (d->type != EventType::Unknown);
+ if ( d->type != EventType::Unknown && d->type != EventType::Typing )
{
- d->id = obj.value("event_id").toString();
- } else {
- correct = false;
- qDebug() << "Event: can't find event_id";
- }
- if( obj.contains("origin_server_ts") )
- {
- d->timestamp = QDateTime::fromMSecsSinceEpoch(
- static_cast<qint64>(obj.value("origin_server_ts").toDouble()), Qt::UTC );
- } else {
- correct = false;
- qDebug() << "Event: can't find ts";
- //qDebug() << obj;
+ if( obj.contains("event_id") )
+ {
+ d->id = obj.value("event_id").toString();
+ } else {
+ correct = false;
+ qDebug() << "Event: can't find event_id";
+ qDebug() << formatJson << obj;
+ }
+ if( obj.contains("origin_server_ts") )
+ {
+ d->timestamp = QDateTime::fromMSecsSinceEpoch(
+ static_cast<qint64>(obj.value("origin_server_ts").toDouble()), Qt::UTC );
+ } else {
+ correct = false;
+ qDebug() << "Event: can't find ts";
+ qDebug() << formatJson << obj;
+ }
}
if( obj.contains("room_id") )
{
diff --git a/events/roomaliasesevent.cpp b/events/roomaliasesevent.cpp
index 54fb5682..15b4c54e 100644
--- a/events/roomaliasesevent.cpp
+++ b/events/roomaliasesevent.cpp
@@ -64,7 +64,6 @@ QStringList RoomAliasesEvent::aliases() const
RoomAliasesEvent* RoomAliasesEvent::fromJson(const QJsonObject& obj)
{
- qDebug() << "RoomAliasesEvent::fromJson";
RoomAliasesEvent* e = new RoomAliasesEvent();
e->parseJson(obj);
const QJsonObject contents = obj.value("content").toObject();
@@ -73,6 +72,6 @@ RoomAliasesEvent* RoomAliasesEvent::fromJson(const QJsonObject& obj)
{
e->d->aliases << alias.toString();
}
- qDebug() << e->d->aliases;
+ qDebug() << "RoomAliasesEvent:" << e->d->aliases;
return e;
}
diff --git a/events/typingevent.cpp b/events/typingevent.cpp
index 242094e1..36a7e693 100644
--- a/events/typingevent.cpp
+++ b/events/typingevent.cpp
@@ -19,6 +19,7 @@
#include "typingevent.h"
#include <QtCore/QJsonArray>
+#include <QtCore/QDebug>
using namespace QMatrixClient;
@@ -53,5 +54,6 @@ TypingEvent* TypingEvent::fromJson(const QJsonObject& obj)
{
e->d->users << user.toString();
}
+ qDebug() << "Typing:" << e->d->users;
return e;
}
diff --git a/events/unknownevent.cpp b/events/unknownevent.cpp
index 758d0ec8..90551409 100644
--- a/events/unknownevent.cpp
+++ b/events/unknownevent.cpp
@@ -19,6 +19,9 @@
#include "unknownevent.h"
#include <QtCore/QJsonDocument>
+#include <QtCore/QDebug>
+
+#include "../logging_util.h"
using namespace QMatrixClient;
@@ -56,5 +59,7 @@ UnknownEvent* UnknownEvent::fromJson(const QJsonObject& obj)
e->parseJson(obj);
e->d->type = obj.value("type").toString();
e->d->content = QString::fromUtf8(QJsonDocument(obj).toJson());
+ qDebug() << "UnknownEvent, JSON follows:";
+ qDebug() << formatJson << obj;
return e;
-} \ No newline at end of file
+}