2016-04-09 09:57:55 +04:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-09 09:57:55 +04:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-09 09:57:55 +04:00
|
|
|
*/
|
2017-03-04 13:23:56 +03:00
|
|
|
#include "storage/serialize_common.h"
|
2016-04-09 09:57:55 +04:00
|
|
|
|
|
|
|
namespace Serialize {
|
|
|
|
|
2018-07-13 19:49:46 +03: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 09:57:55 +04:00
|
|
|
}
|
|
|
|
|
2018-07-13 19:49:46 +03:00
|
|
|
StorageImageLocation readStorageImageLocation(
|
|
|
|
int streamAppVersion,
|
|
|
|
QDataStream &stream) {
|
2016-04-09 09:57:55 +04:00
|
|
|
qint32 width, height, dc, local;
|
|
|
|
quint64 volume, secret;
|
2018-07-13 19:49:46 +03:00
|
|
|
QByteArray fileReference;
|
2016-04-09 09:57:55 +04:00
|
|
|
stream >> width >> height >> dc >> volume >> local >> secret;
|
2018-07-16 22:43:44 +03:00
|
|
|
if (streamAppVersion >= 1003013) {
|
2018-07-13 19:49:46 +03:00
|
|
|
stream >> fileReference;
|
|
|
|
}
|
|
|
|
return StorageImageLocation(
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
dc,
|
|
|
|
volume,
|
|
|
|
local,
|
|
|
|
secret,
|
|
|
|
fileReference);
|
2016-04-09 09:57:55 +04:00
|
|
|
}
|
|
|
|
|
2018-07-13 19:49:46 +03: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 09:57:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Serialize
|