mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-28 09:32:56 +00:00
Update API scheme to layer 92.
This commit is contained in:
parent
1f8626b383
commit
47edb71a68
@ -294,6 +294,7 @@ photo#9c477dd8 flags:# has_stickers:flags.0?true id:long access_hash:long file_r
|
||||
photoSizeEmpty#e17e23c type:string = PhotoSize;
|
||||
photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize;
|
||||
photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
|
||||
photoStrippedSize#e0b0bc2e type:string bytes:bytes = PhotoSize;
|
||||
|
||||
geoPointEmpty#1117dd5f = GeoPoint;
|
||||
geoPoint#296f104 long:double lat:double access_hash:long = GeoPoint;
|
||||
@ -352,7 +353,7 @@ messages.dialogsSlice#71e094f3 count:int dialogs:Vector<Dialog> messages:Vector<
|
||||
messages.dialogsNotModified#f0e3e596 count:int = messages.Dialogs;
|
||||
|
||||
messages.messages#8c718e87 messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
|
||||
messages.messagesSlice#b446ae3 count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
|
||||
messages.messagesSlice#a6c47aaa flags:# inexact:flags.1?true count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
|
||||
messages.channelMessages#99262e37 flags:# inexact:flags.1?true pts:int count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
|
||||
messages.messagesNotModified#74535f21 count:int = messages.Messages;
|
||||
|
||||
@ -1407,4 +1408,4 @@ langpack.getDifference#9d51e814 lang_code:string from_version:int = LangPackDiff
|
||||
langpack.getLanguages#42c6978f lang_pack:string = Vector<LangPackLanguage>;
|
||||
langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLanguage;
|
||||
|
||||
// LAYER 91
|
||||
// LAYER 92
|
||||
|
@ -524,17 +524,60 @@ namespace App {
|
||||
l.vfile_reference.v),
|
||||
bytes);
|
||||
} else if (d.vlocation.type() == mtpc_fileLocationUnavailable) {
|
||||
auto bytes = qba(d.vbytes);
|
||||
return Images::Create(
|
||||
StorageImageLocation(
|
||||
d.vw.v,
|
||||
d.vh.v,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{}),
|
||||
bytes);
|
||||
const auto bytes = qba(d.vbytes);
|
||||
if (auto image = App::readImage(bytes); !image.isNull()) {
|
||||
return Images::Create(std::move(image), "JPG");
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case mtpc_photoStrippedSize: {
|
||||
const auto &d = size.c_photoStrippedSize();
|
||||
auto bytes = qba(d.vbytes);
|
||||
if (bytes.size() >= 3 && bytes[0] == '\x01') {
|
||||
const char header[] = "\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49"
|
||||
"\x46\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb\x00\x43\x00\x28\x1c"
|
||||
"\x1e\x23\x1e\x19\x28\x23\x21\x23\x2d\x2b\x28\x30\x3c\x64\x41\x3c\x37\x37"
|
||||
"\x3c\x7b\x58\x5d\x49\x64\x91\x80\x99\x96\x8f\x80\x8c\x8a\xa0\xb4\xe6\xc3"
|
||||
"\xa0\xaa\xda\xad\x8a\x8c\xc8\xff\xcb\xda\xee\xf5\xff\xff\xff\x9b\xc1\xff"
|
||||
"\xff\xff\xfa\xff\xe6\xfd\xff\xf8\xff\xdb\x00\x43\x01\x2b\x2d\x2d\x3c\x35"
|
||||
"\x3c\x76\x41\x41\x76\xf8\xa5\x8c\xa5\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8"
|
||||
"\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8"
|
||||
"\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8"
|
||||
"\xf8\xf8\xf8\xf8\xf8\xff\xc0\x00\x11\x08\x00\x00\x00\x00\x03\x01\x22\x00"
|
||||
"\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x1f\x00\x00\x01\x05\x01\x01\x01\x01"
|
||||
"\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08"
|
||||
"\x09\x0a\x0b\xff\xc4\x00\xb5\x10\x00\x02\x01\x03\x03\x02\x04\x03\x05\x05"
|
||||
"\x04\x04\x00\x00\x01\x7d\x01\x02\x03\x00\x04\x11\x05\x12\x21\x31\x41\x06"
|
||||
"\x13\x51\x61\x07\x22\x71\x14\x32\x81\x91\xa1\x08\x23\x42\xb1\xc1\x15\x52"
|
||||
"\xd1\xf0\x24\x33\x62\x72\x82\x09\x0a\x16\x17\x18\x19\x1a\x25\x26\x27\x28"
|
||||
"\x29\x2a\x34\x35\x36\x37\x38\x39\x3a\x43\x44\x45\x46\x47\x48\x49\x4a\x53"
|
||||
"\x54\x55\x56\x57\x58\x59\x5a\x63\x64\x65\x66\x67\x68\x69\x6a\x73\x74\x75"
|
||||
"\x76\x77\x78\x79\x7a\x83\x84\x85\x86\x87\x88\x89\x8a\x92\x93\x94\x95\x96"
|
||||
"\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xb2\xb3\xb4\xb5\xb6"
|
||||
"\xb7\xb8\xb9\xba\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4\xd5\xd6"
|
||||
"\xd7\xd8\xd9\xda\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf1\xf2\xf3\xf4"
|
||||
"\xf5\xf6\xf7\xf8\xf9\xfa\xff\xc4\x00\x1f\x01\x00\x03\x01\x01\x01\x01\x01"
|
||||
"\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08"
|
||||
"\x09\x0a\x0b\xff\xc4\x00\xb5\x11\x00\x02\x01\x02\x04\x04\x03\x04\x07\x05"
|
||||
"\x04\x04\x00\x01\x02\x77\x00\x01\x02\x03\x11\x04\x05\x21\x31\x06\x12\x41"
|
||||
"\x51\x07\x61\x71\x13\x22\x32\x81\x08\x14\x42\x91\xa1\xb1\xc1\x09\x23\x33"
|
||||
"\x52\xf0\x15\x62\x72\xd1\x0a\x16\x24\x34\xe1\x25\xf1\x17\x18\x19\x1a\x26"
|
||||
"\x27\x28\x29\x2a\x35\x36\x37\x38\x39\x3a\x43\x44\x45\x46\x47\x48\x49\x4a"
|
||||
"\x53\x54\x55\x56\x57\x58\x59\x5a\x63\x64\x65\x66\x67\x68\x69\x6a\x73\x74"
|
||||
"\x75\x76\x77\x78\x79\x7a\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x92\x93\x94"
|
||||
"\x95\x96\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xb2\xb3\xb4"
|
||||
"\xb5\xb6\xb7\xb8\xb9\xba\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4"
|
||||
"\xd5\xd6\xd7\xd8\xd9\xda\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf2\xf3\xf4"
|
||||
"\xf5\xf6\xf7\xf8\xf9\xfa\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00"
|
||||
"\x3f\x00";
|
||||
const char footer[] = "\xff\xd9";
|
||||
auto real = QByteArray(header, sizeof(header) - 1);
|
||||
real[164] = bytes[1];
|
||||
real[166] = bytes[2];
|
||||
bytes = real + bytes.mid(3) + QByteArray::fromRawData(footer, sizeof(footer) - 1);
|
||||
if (auto image = App::readImage(bytes); !image.isNull()) {
|
||||
return Images::Create(std::move(image), "JPG");
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ struct FileReferenceAccumulator {
|
||||
});
|
||||
}
|
||||
void push(const MTPPhotoSize &data) {
|
||||
data.match([](const MTPDphotoSizeEmpty &data) {
|
||||
data.match([](const MTPDphotoSizeEmpty &) {
|
||||
}, [](const MTPDphotoStrippedSize &) {
|
||||
}, [&](const auto &data) {
|
||||
push(data.vlocation);
|
||||
});
|
||||
|
@ -426,6 +426,9 @@ bool MediaPhoto::updateSentMedia(const MTPMessageMedia &media) {
|
||||
};
|
||||
}, [](const MTPDphotoSizeEmpty &) {
|
||||
return SizeData();
|
||||
}, [](const MTPDphotoStrippedSize &data) {
|
||||
// No need to save stripped images to local cache.
|
||||
return SizeData();
|
||||
});
|
||||
if (!size.location || size.location->type() != mtpc_fileLocation) {
|
||||
continue;
|
||||
|
@ -53,9 +53,9 @@ using ViewElement = HistoryView::Element;
|
||||
// b: crop 320x320
|
||||
// c: crop 640x640
|
||||
// d: crop 1280x1280
|
||||
const auto ThumbLevels = QByteArray::fromRawData("sambcxydw", 9);
|
||||
const auto MediumLevels = QByteArray::fromRawData("mbcxasydw", 9);
|
||||
const auto FullLevels = QByteArray::fromRawData("yxwmsdcba", 9);
|
||||
const auto ThumbLevels = QByteArray::fromRawData("isambcxydw", 10);
|
||||
const auto MediumLevels = QByteArray::fromRawData("mbcxasydwi", 10);
|
||||
const auto FullLevels = QByteArray::fromRawData("yxwmsdcbai", 10);
|
||||
|
||||
void UpdateImage(ImagePtr &old, ImagePtr now) {
|
||||
if (now->isNull()) {
|
||||
@ -1752,20 +1752,11 @@ void Session::photoApplyFields(
|
||||
auto mediumLevel = -1;
|
||||
auto fullLevel = -1;
|
||||
for (const auto &sizeData : data.vsizes.v) {
|
||||
const auto sizeLetter = [&] {
|
||||
switch (sizeData.type()) {
|
||||
case mtpc_photoSizeEmpty: return char(0);
|
||||
case mtpc_photoSize: {
|
||||
const auto &data = sizeData.c_photoSize();
|
||||
return data.vtype.v.isEmpty() ? char(0) : data.vtype.v[0];
|
||||
} break;
|
||||
case mtpc_photoCachedSize: {
|
||||
const auto &data = sizeData.c_photoCachedSize();
|
||||
return data.vtype.v.isEmpty() ? char(0) : data.vtype.v[0];
|
||||
} break;
|
||||
}
|
||||
Unexpected("Type in photo size.");
|
||||
}();
|
||||
const auto sizeLetter = sizeData.match([](MTPDphotoSizeEmpty) {
|
||||
return char(0);
|
||||
}, [](const auto &size) {
|
||||
return size.vtype.v.isEmpty() ? char(0) : size.vtype.v[0];
|
||||
});
|
||||
if (!sizeLetter) continue;
|
||||
|
||||
const auto newThumbLevel = ThumbLevels.indexOf(sizeLetter);
|
||||
@ -3016,42 +3007,41 @@ void Session::setWallpapers(const QVector<MTPWallPaper> &data) {
|
||||
});
|
||||
for (const auto &paper : data) {
|
||||
paper.match([&](const MTPDwallPaper &paper) {
|
||||
const auto &sizes = paper.vsizes.v;
|
||||
const MTPPhotoSize *thumb = 0, *full = 0;
|
||||
int32 thumbLevel = -1, fullLevel = -1;
|
||||
for (auto j = sizes.cbegin(), e = sizes.cend(); j != e; ++j) {
|
||||
char size = 0;
|
||||
int32 w = 0, h = 0;
|
||||
switch (j->type()) {
|
||||
case mtpc_photoSize: {
|
||||
auto &s = j->c_photoSize().vtype.v;
|
||||
if (s.size()) size = s[0];
|
||||
w = j->c_photoSize().vw.v;
|
||||
h = j->c_photoSize().vh.v;
|
||||
} break;
|
||||
|
||||
case mtpc_photoCachedSize: {
|
||||
auto &s = j->c_photoCachedSize().vtype.v;
|
||||
if (s.size()) size = s[0];
|
||||
w = j->c_photoCachedSize().vw.v;
|
||||
h = j->c_photoCachedSize().vh.v;
|
||||
} break;
|
||||
const MTPPhotoSize *thumb = nullptr;
|
||||
const MTPPhotoSize *full = nullptr;
|
||||
auto thumbLevel = -1;
|
||||
auto fullLevel = -1;
|
||||
for (const auto &photoSize : paper.vsizes.v) {
|
||||
auto size = char(0);
|
||||
auto w = 0;
|
||||
auto h = 0;
|
||||
photoSize.match([](const MTPDphotoSizeEmpty &) {
|
||||
LOG(("API Error: photoSizeEmpty in wallpapers."));
|
||||
}, [](const MTPDphotoStrippedSize &) {
|
||||
LOG(("API Error: photoStrippedSize in wallpapers."));
|
||||
}, [&](const auto &photoSize) {
|
||||
if (photoSize.vtype.v.size()) {
|
||||
size = photoSize.vtype.v[0];
|
||||
}
|
||||
w = photoSize.vw.v;
|
||||
h = photoSize.vh.v;
|
||||
});
|
||||
if (!size || !w || !h) {
|
||||
continue;
|
||||
}
|
||||
if (!size || !w || !h) continue;
|
||||
|
||||
const auto newThumbLevel = qAbs(
|
||||
(st::backgroundSize.width() * cIntRetinaFactor()) - w);
|
||||
const auto newThumbLevel = qAbs((st::backgroundSize.width() * cIntRetinaFactor()) - w);
|
||||
const auto newFullLevel = qAbs(2560 - w);
|
||||
if (thumbLevel < 0 || newThumbLevel < thumbLevel) {
|
||||
thumbLevel = newThumbLevel;
|
||||
thumb = &(*j);
|
||||
thumb = &photoSize;
|
||||
}
|
||||
if (fullLevel < 0 || newFullLevel < fullLevel) {
|
||||
fullLevel = newFullLevel;
|
||||
full = &(*j);
|
||||
full = &photoSize;
|
||||
}
|
||||
}
|
||||
if (thumb && full && full->type() != mtpc_photoSizeEmpty) {
|
||||
if (thumb && full) {
|
||||
_wallpapers.push_back({
|
||||
paper.vid.v ? paper.vid.v : INT_MAX,
|
||||
App::image(*thumb),
|
||||
|
@ -233,6 +233,8 @@ Image ParseMaxImage(
|
||||
auto maxArea = int64(0);
|
||||
for (const auto &size : data.v) {
|
||||
size.match([](const MTPDphotoSizeEmpty &) {
|
||||
}, [](const MTPDphotoStrippedSize &) {
|
||||
// Max image size should not be a stripped image.
|
||||
}, [&](const auto &data) {
|
||||
const auto area = data.vw.v * int64(data.vh.v);
|
||||
if (area > maxArea) {
|
||||
@ -427,6 +429,9 @@ Document ParseDocument(
|
||||
|
||||
result.thumb = data.vthumb.match([](const MTPDphotoSizeEmpty &) {
|
||||
return Image();
|
||||
}, [](const MTPDphotoStrippedSize &) {
|
||||
// For now stripped images are used only in photos.
|
||||
return Image();
|
||||
}, [&](const auto &data) {
|
||||
auto result = Image();
|
||||
result.width = data.vw.v;
|
||||
|
@ -1024,7 +1024,7 @@ void History::applyServiceChanges(
|
||||
case mtpc_photoCachedSize: bigLoc = &bigSize.c_photoCachedSize().vlocation; break;
|
||||
}
|
||||
if (smallLoc && bigLoc) {
|
||||
const auto newPhotoId = photo ? photo->id : 0;
|
||||
const auto newPhotoId = photo ? photo->id : PhotoId();
|
||||
if (const auto chat = peer->asChat()) {
|
||||
chat->setPhoto(newPhotoId, MTP_chatPhoto(*smallLoc, *bigLoc));
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
|
Loading…
Reference in New Issue
Block a user