X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fevent.cpp;h=b933fa6472fc99db15ecb7d096d103ae62147e76;hb=ab7ef4d24f62b5848b628482b7762ebfc0b53e1a;hp=2306adc97f7a9c66ab451342236c62631e41ce9f;hpb=e50ae7a06fc4e5d3a911c361d30953410deab609;p=quassel.git diff --git a/src/common/event.cpp b/src/common/event.cpp index 2306adc9..b933fa64 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,8 @@ #include "ircevent.h" #include "networkevent.h" #include "messageevent.h" +#include "peer.h" +#include "signalproxy.h" Event::Event(EventManager::EventType type) : _type(type) @@ -40,16 +42,33 @@ Event::Event(EventManager::EventType type, QVariantMap &map) return; } + Q_ASSERT(SignalProxy::current()); + Q_ASSERT(SignalProxy::current()->sourcePeer()); + setFlags(static_cast(map.take("flags").toInt())); // TODO sanity check? - setTimestamp(QDateTime::fromTime_t(map.take("timestamp").toUInt())); + + if (SignalProxy::current()->sourcePeer()->hasFeature(Quassel::Feature::LongTime)) { + // timestamp is a qint64, signed rather than unsigned + setTimestamp(QDateTime::fromMSecsSinceEpoch(map.take("timestamp").toLongLong())); + } else { + setTimestamp(QDateTime::fromTime_t(map.take("timestamp").toUInt())); + } } void Event::toVariantMap(QVariantMap &map) const { + Q_ASSERT(SignalProxy::current()); + Q_ASSERT(SignalProxy::current()->targetPeer()); + map["type"] = static_cast(type()); map["flags"] = static_cast(flags()); - map["timestamp"] = timestamp().toTime_t(); + if (SignalProxy::current()->targetPeer()->hasFeature(Quassel::Feature::LongTime)) { + // toMSecs returns a qint64, signed rather than unsigned + map["timestamp"] = timestamp().toMSecsSinceEpoch(); + } else { + map["timestamp"] = timestamp().toTime_t(); + } }