From fa3e0145adcfd570fbb768d9e6d69b0fec4b6df3 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Thu, 4 Jul 2013 14:31:47 +0200 Subject: [PATCH] Package version checks --- daemon/networkpackage.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/daemon/networkpackage.cpp b/daemon/networkpackage.cpp index 379fc9b6b..82b7d546f 100644 --- a/daemon/networkpackage.cpp +++ b/daemon/networkpackage.cpp @@ -29,11 +29,13 @@ #include #include +const static int CURRENT_PACKAGE_VERSION = 1; + NetworkPackage::NetworkPackage(QString type) { mId = time(NULL); mType = type; - mVersion = 1; + mVersion = CURRENT_PACKAGE_VERSION; } QByteArray NetworkPackage::serialize() const @@ -65,6 +67,11 @@ void NetworkPackage::unserialize(QByteArray a, NetworkPackage* np) np->setVersion(-1); } + if (np->version() > CURRENT_PACKAGE_VERSION) { + qDebug() << "Warning: package version " << np->version() << " greater than supported version " << CURRENT_PACKAGE_VERSION; + } + + //QVariant -> Object //NetworkPackage np; //QJSon json(a);