mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-05-09 16:09:49 +00:00
added support for old packages
This commit is contained in:
parent
3230d0a688
commit
3a270d9fac
@ -27,7 +27,10 @@ bool Package::isValid() const {
|
|||||||
if (hdr.size > maximumSize())
|
if (hdr.size > maximumSize())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return calcHash() == hdr.hash;
|
if ( calcHash() == hdr.hash)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return calcHashOld() == hdr.hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Package::reset() {
|
void Package::reset() {
|
||||||
|
@ -38,7 +38,12 @@ bool AbstractData::toPackage(Package &package,
|
|||||||
package.hdr.command = cmd();
|
package.hdr.command = cmd();
|
||||||
package.hdr.triggerHash = triggerHash;
|
package.hdr.triggerHash = triggerHash;
|
||||||
package.hdr.size = package.data.size();
|
package.hdr.size = package.data.size();
|
||||||
package.hdr.hash = package.calcHash();
|
|
||||||
|
if (isOldPackage()) {
|
||||||
|
package.hdr.hash = package.calcHashOld();
|
||||||
|
} else {
|
||||||
|
package.hdr.hash = package.calcHash();
|
||||||
|
}
|
||||||
|
|
||||||
return package.isValid();
|
return package.isValid();
|
||||||
}
|
}
|
||||||
@ -66,6 +71,10 @@ AbstractData::~AbstractData() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QH::PKG::AbstractData::isOldPackage() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual unsigned int localCode() const = 0;
|
virtual unsigned int localCode() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief isOldPackage This method mark package as a old, old pacakges use the Package::calcHashOld method for calculation hash sum of packages.
|
||||||
|
* @return true if the pacakge is old.
|
||||||
|
*/
|
||||||
|
virtual bool isOldPackage() const;
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief checkCmd This method check QH_PACKAGE macross.
|
* @brief checkCmd This method check QH_PACKAGE macross.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user