2016-04-09 05:57:55 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-09 05:57:55 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-09 05:57:55 +00:00
|
|
|
*/
|
2017-03-04 10:23:56 +00:00
|
|
|
#include "storage/serialize_common.h"
|
2016-04-09 05:57:55 +00:00
|
|
|
|
|
|
|
namespace Serialize {
|
|
|
|
|
2018-07-13 16:49:46 +00:00
|
|
|
void writeStorageImageLocation(
|
|
|
|
QDataStream &stream,
|
|
|
|
const StorageImageLocation &location) {
|
|
|
|
stream
|
|
|
|
<< qint32(location.width())
|
|
|
|
<< qint32(location.height())
|
|
|
|
<< qint32(location.dc())
|
|
|
|
<< quint64(location.volume())
|
|
|
|
<< qint32(location.local())
|
|
|
|
<< quint64(location.secret());
|
|
|
|
stream << location.fileReference();
|
2016-04-09 05:57:55 +00:00
|
|
|
}
|
|
|
|
|
2018-07-13 16:49:46 +00:00
|
|
|
StorageImageLocation readStorageImageLocation(
|
|
|
|
int streamAppVersion,
|
|
|
|
QDataStream &stream) {
|
2016-04-09 05:57:55 +00:00
|
|
|
qint32 width, height, dc, local;
|
|
|
|
quint64 volume, secret;
|
2018-07-13 16:49:46 +00:00
|
|
|
QByteArray fileReference;
|
2016-04-09 05:57:55 +00:00
|
|
|
stream >> width >> height >> dc >> volume >> local >> secret;
|
2018-07-13 21:25:47 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
if (streamAppVersion >= 1003013 || true) { // #TODO testing
|
|
|
|
#else
|
|
|
|
#error "test"
|
|
|
|
#endif
|
2018-07-13 16:49:46 +00:00
|
|
|
stream >> fileReference;
|
|
|
|
}
|
|
|
|
return StorageImageLocation(
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
dc,
|
|
|
|
volume,
|
|
|
|
local,
|
|
|
|
secret,
|
|
|
|
fileReference);
|
2016-04-09 05:57:55 +00:00
|
|
|
}
|
|
|
|
|
2018-07-13 16:49:46 +00:00
|
|
|
int storageImageLocationSize(const StorageImageLocation &location) {
|
|
|
|
// width + height + dc + volume + local + secret + fileReference
|
|
|
|
return sizeof(qint32)
|
|
|
|
+ sizeof(qint32)
|
|
|
|
+ sizeof(qint32)
|
|
|
|
+ sizeof(quint64)
|
|
|
|
+ sizeof(qint32)
|
|
|
|
+ sizeof(quint64)
|
|
|
|
+ bytearraySize(location.fileReference());
|
2016-04-09 05:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Serialize
|