Package version checks
This commit is contained in:
parent
17d0fd4902
commit
fa3e0145ad
1 changed files with 8 additions and 1 deletions
|
@ -29,11 +29,13 @@
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <qjson/qobjecthelper.h>
|
#include <qjson/qobjecthelper.h>
|
||||||
|
|
||||||
|
const static int CURRENT_PACKAGE_VERSION = 1;
|
||||||
|
|
||||||
NetworkPackage::NetworkPackage(QString type)
|
NetworkPackage::NetworkPackage(QString type)
|
||||||
{
|
{
|
||||||
mId = time(NULL);
|
mId = time(NULL);
|
||||||
mType = type;
|
mType = type;
|
||||||
mVersion = 1;
|
mVersion = CURRENT_PACKAGE_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray NetworkPackage::serialize() const
|
QByteArray NetworkPackage::serialize() const
|
||||||
|
@ -65,6 +67,11 @@ void NetworkPackage::unserialize(QByteArray a, NetworkPackage* np)
|
||||||
np->setVersion(-1);
|
np->setVersion(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (np->version() > CURRENT_PACKAGE_VERSION) {
|
||||||
|
qDebug() << "Warning: package version " << np->version() << " greater than supported version " << CURRENT_PACKAGE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//QVariant -> Object
|
//QVariant -> Object
|
||||||
//NetworkPackage np;
|
//NetworkPackage np;
|
||||||
//QJSon json(a);
|
//QJSon json(a);
|
||||||
|
|
Loading…
Reference in a new issue