aboutsummaryrefslogtreecommitdiff
path: root/events/event.cpp
diff options
context:
space:
mode:
authorKitsuneRal <KitsuneRal@users.noreply.github.com>2016-06-01 20:58:25 +0900
committerKitsuneRal <KitsuneRal@users.noreply.github.com>2016-06-01 20:58:25 +0900
commit43ecbf3135687b2e5a5a604a902f992139cce428 (patch)
treed717d85e8b5d340050c317418e26addf1766a826 /events/event.cpp
parentd5df4568d34487aea519ae97dd1666927dcfb62b (diff)
parent46050cd59a7af8cc7d616fab1a80db95dc8b5b35 (diff)
downloadlibquotient-43ecbf3135687b2e5a5a604a902f992139cce428.tar.gz
libquotient-43ecbf3135687b2e5a5a604a902f992139cce428.zip
Merge pull request #9 from Fxrh/code-tweaks
Code tweaks
Diffstat (limited to 'events/event.cpp')
-rw-r--r--events/event.cpp37
1 files changed, 20 insertions, 17 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") )
{