1
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-04-01 00:08:02 +00:00

Inline bot stickers done, but not tested yet.

This commit is contained in:
John Preston 2016-04-02 15:20:53 +04:00
parent f7dc832dfe
commit cf9a78a164
15 changed files with 940 additions and 754 deletions

View File

@ -1040,9 +1040,6 @@ void AppClass::checkMapVersion() {
}
}
}
if (cNeedConfigResave()) {
Local::writeUserSettings();
}
}
AppClass::~AppClass() {

View File

@ -1447,59 +1447,77 @@ void StickerPanInner::mouseReleaseEvent(QMouseEvent *e) {
}
LayoutInlineItem *item = _inlineRows.at(row).items.at(col);
PhotoData *photo = item->photo();
DocumentData *doc = item->document();
InlineResult *result = item->result();
if (doc) {
if (doc->loaded()) {
emit selected(doc);
} else if (doc->loading()) {
doc->cancel();
} else {
DocumentOpenClickHandler::doOpen(doc, ActionOnLoadNone);
PhotoData *photo = item->getPhoto();
DocumentData *document = item->getDocument();
InlineResult *inlineResult = item->getInlineResult();
using Type = InlineResult::Type;
auto getShownPhoto = [photo, inlineResult]() -> PhotoData* {
if (photo) {
return photo;
} else if (inlineResult && inlineResult->type == Type::Photo) {
return inlineResult->photo;
}
} else if (photo) {
if (photo->medium->loaded() || photo->thumb->loaded()) {
return nullptr;
};
auto getShownDocument = [document, inlineResult]() -> DocumentData* {
auto inlineResultIsFileType = [](InlineResult *inlineResult) {
return inlineResult->type == Type::Video ||
inlineResult->type == Type::Audio ||
inlineResult->type == Type::Sticker ||
inlineResult->type == Type::File ||
inlineResult->type == Type::Gif;
};
if (document) {
return document;
} else if (inlineResult && inlineResultIsFileType(inlineResult)) {
return inlineResult->document;
}
return nullptr;
};
auto sendInlineItem = [photo, document, inlineResult, this]() -> void {
if (photo) {
emit selected(photo);
} else if (!photo->medium->loading()) {
photo->thumb->loadEvenCancelled();
photo->medium->loadEvenCancelled();
} else if (document) {
emit selected(document);
} else if (inlineResult) {
emit selected(inlineResult, _inlineBot);
}
} else if (result) {
if (result->type == qstr("gif")) {
if (result->doc) {
if (result->doc->loaded()) {
emit selected(result, _inlineBot);
} else if (result->doc->loading()) {
result->doc->cancel();
} else {
DocumentOpenClickHandler::doOpen(result->doc, ActionOnLoadNone);
}
} else if (result->loaded()) {
emit selected(result, _inlineBot);
} else if (result->loading()) {
result->cancelFile();
};
if (PhotoData *shownPhoto = getShownPhoto()) {
if (shownPhoto->medium->loaded() || shownPhoto->thumb->loaded()) {
sendInlineItem();
} else if (!shownPhoto->medium->loading()) {
shownPhoto->thumb->loadEvenCancelled();
shownPhoto->medium->loadEvenCancelled();
}
} else if (DocumentData *shownDocument = getShownDocument()) {
if (shownDocument->loaded()) {
sendInlineItem();
} else if (shownDocument->loading()) {
shownDocument->cancel();
} else {
DocumentOpenClickHandler::doOpen(shownDocument, ActionOnLoadNone);
}
} else if (inlineResult) {
if (inlineResult->type == Type::Photo) {
if (inlineResult->thumb->loaded()) {
sendInlineItem();
} else if (!inlineResult->thumb->loading()) {
inlineResult->thumb->loadEvenCancelled();
Ui::repaintInlineItem(item);
}
} else if (inlineResult->type == Type::File) {
if (inlineResult->loaded()) {
sendInlineItem();
} else if (inlineResult->loading()) {
inlineResult->cancelFile();
Ui::repaintInlineItem(item);
} else {
result->saveFile(QString(), LoadFromCloudOrLocal, false);
Ui::repaintInlineItem(item);
}
} else if (result->type == qstr("photo")) {
if (result->photo) {
if (result->photo->medium->loaded() || result->photo->thumb->loaded()) {
emit selected(result, _inlineBot);
} else if (!result->photo->medium->loading()) {
result->photo->thumb->loadEvenCancelled();
result->photo->medium->loadEvenCancelled();
}
} else if (result->thumb->loaded()) {
emit selected(result, _inlineBot);
} else if (!result->thumb->loading()) {
result->thumb->loadEvenCancelled();
inlineResult->saveFile(QString(), LoadFromCloudOrLocal, false);
Ui::repaintInlineItem(item);
}
} else {
emit selected(result, _inlineBot);
sendInlineItem();
}
}
return;
@ -1616,14 +1634,14 @@ void StickerPanInner::hideFinish(bool completely) {
if (completely) {
clearInlineRows(false);
for (GifLayouts::const_iterator i = _gifLayouts.cbegin(), e = _gifLayouts.cend(); i != e; ++i) {
i.value()->document()->forget();
i.value()->getDocument()->forget();
}
for (InlineLayouts::const_iterator i = _inlineLayouts.cbegin(), e = _inlineLayouts.cend(); i != e; ++i) {
if (i.value()->result()->doc) {
i.value()->result()->doc->forget();
if (i.value()->getInlineResult()->document) {
i.value()->getInlineResult()->document->forget();
}
if (i.value()->result()->photo) {
i.value()->result()->photo->forget();
if (i.value()->getInlineResult()->photo) {
i.value()->getInlineResult()->photo->forget();
}
}
}
@ -1660,7 +1678,7 @@ void StickerPanInner::refreshStickers() {
}
bool StickerPanInner::inlineRowsAddItem(DocumentData *savedGif, InlineResult *result, InlineRow &row, int32 &sumWidth) {
LayoutInlineItem *layout = 0;
LayoutInlineItem *layout = nullptr;
if (savedGif) {
layout = layoutPrepareSavedGif(savedGif, (_inlineRows.size() * MatrixRowShift) + row.items.size());
} else if (result) {
@ -1751,7 +1769,7 @@ void StickerPanInner::clearInlineRows(bool resultsDeleted) {
LayoutInlineGif *StickerPanInner::layoutPrepareSavedGif(DocumentData *doc, int32 position) {
GifLayouts::const_iterator i = _gifLayouts.constFind(doc);
if (i == _gifLayouts.cend()) {
i = _gifLayouts.insert(doc, new LayoutInlineGif(0, doc, true));
i = _gifLayouts.insert(doc, new LayoutInlineGif(doc, true));
i.value()->initDimensions();
}
if (!i.value()->maxWidth()) return 0;
@ -1763,17 +1781,20 @@ LayoutInlineGif *StickerPanInner::layoutPrepareSavedGif(DocumentData *doc, int32
LayoutInlineItem *StickerPanInner::layoutPrepareInlineResult(InlineResult *result, int32 position) {
InlineLayouts::const_iterator i = _inlineLayouts.constFind(result);
if (i == _inlineLayouts.cend()) {
LayoutInlineItem *layout = 0;
if (result->type == qstr("gif")) {
layout = new LayoutInlineGif(result, 0, false);
} else if (result->type == qstr("photo")) {
layout = new LayoutInlinePhoto(result, 0);
} else if (result->type == qstr("video")) {
layout = new LayoutInlineWebVideo(result);
} else if (result->type == qstr("article")) {
layout = new LayoutInlineArticle(result, _inlineWithThumb);
LayoutInlineItem *layout = nullptr;
using Type = InlineResult::Type;
switch (result->type) {
case Type::Photo: layout = new LayoutInlinePhoto(result); break;
case Type::Video: layout = new LayoutInlineWebVideo(result); break;
case Type::Sticker: layout = new LayoutInlineSticker(result); break;
case Type::Audio:
case Type::File: //layout = new LayoutInlineFile(result); break;
case Type::Gif: layout = new LayoutInlineGif(result); break;
case Type::Article:
case Type::Contact:
case Type::Venue: layout = new LayoutInlineArticle(result, _inlineWithThumb); break;
}
if (!layout) return 0;
if (!layout) return nullptr;
i = _inlineLayouts.insert(result, layout);
layout->initDimensions();
@ -1959,7 +1980,7 @@ int32 StickerPanInner::refreshInlineRows(UserData *bot, const InlineResults &res
int32 StickerPanInner::validateExistingInlineRows(const InlineResults &results) {
int32 count = results.size(), until = 0, untilrow = 0, untilcol = 0;
for (; until < count;) {
if (untilrow >= _inlineRows.size() || _inlineRows.at(untilrow).items.at(untilcol)->result() != results.at(until)) {
if (untilrow >= _inlineRows.size() || _inlineRows.at(untilrow).items.at(untilcol)->getInlineResult() != results.at(until)) {
break;
}
++until;
@ -2239,8 +2260,8 @@ void StickerPanInner::updateSelected() {
}
if (_pressedSel >= 0 && _selected >= 0 && _pressedSel != _selected) {
_pressedSel = _selected;
if (row >= 0 && col >= 0 && _inlineRows.at(row).items.at(col)->document()) {
Ui::showStickerPreview(_inlineRows.at(row).items.at(col)->document());
if (row >= 0 && col >= 0 && _inlineRows.at(row).items.at(col)->getDocument()) {
Ui::showStickerPreview(_inlineRows.at(row).items.at(col)->getDocument());
}
}
}
@ -2339,8 +2360,8 @@ void StickerPanInner::onPreview() {
if (_pressedSel < 0) return;
if (_showingInlineItems) {
int32 row = _pressedSel / MatrixRowShift, col = _pressedSel % MatrixRowShift;
if (row < _inlineRows.size() && col < _inlineRows.at(row).items.size() && _inlineRows.at(row).items.at(col)->document() && _inlineRows.at(row).items.at(col)->document()->loaded()) {
Ui::showStickerPreview(_inlineRows.at(row).items.at(col)->document());
if (row < _inlineRows.size() && col < _inlineRows.at(row).items.size() && _inlineRows.at(row).items.at(col)->getDocument() && _inlineRows.at(row).items.at(col)->getDocument()->loaded()) {
Ui::showStickerPreview(_inlineRows.at(row).items.at(col)->getDocument());
_previewShown = true;
}
} else if (_pressedSel < MatrixRowShift * _sets.size()) {
@ -3646,28 +3667,26 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
if (count) {
it.value()->results.reserve(it.value()->results.size() + count);
}
auto inlineResultTypes = InlineResult::getTypesMap();
auto getInlineResultType = [&inlineResultTypes](const MTPBotInlineResult &inlineResult) -> InlineResult::Type {
QString type;
switch (inlineResult.type()) {
case mtpc_botInlineResult: type = qs(inlineResult.c_botInlineResult().vtype); break;
case mtpc_botInlineMediaResult: type = qs(inlineResult.c_botInlineMediaResult().vtype); break;
}
return inlineResultTypes.value(type, InlineResult::Type::Unknown);
};
for (int32 i = 0; i < count; ++i) {
InlineResult *result = new InlineResult(queryId);
const MTPBotInlineMessage *message = 0;
InlineResult::Type type = getInlineResultType(v.at(i));
if (type == InlineResult::Type::Unknown) continue;
UniquePointer<InlineResult> result = MakeUnique<InlineResult>(queryId, type);
const MTPBotInlineMessage *message = nullptr;
switch (v.at(i).type()) {
case mtpc_botInlineMediaResultPhoto: {
const MTPDbotInlineMediaResultPhoto &r(v.at(i).c_botInlineMediaResultPhoto());
result->id = qs(r.vid);
result->type = qs(r.vtype);
result->photo = App::feedPhoto(r.vphoto);
message = &r.vsend_message;
} break;
case mtpc_botInlineMediaResultDocument: {
const MTPDbotInlineMediaResultDocument &r(v.at(i).c_botInlineMediaResultDocument());
result->id = qs(r.vid);
result->type = qs(r.vtype);
result->doc = App::feedDocument(r.vdocument);
message = &r.vsend_message;
} break;
case mtpc_botInlineResult: {
const MTPDbotInlineResult &r(v.at(i).c_botInlineResult());
result->id = qs(r.vid);
result->type = qs(r.vtype);
result->title = r.has_title() ? qs(r.vtitle) : QString();
result->description = r.has_description() ? qs(r.vdescription) : QString();
result->url = r.has_url() ? qs(r.vurl) : QString();
@ -3682,24 +3701,56 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
}
message = &r.vsend_message;
} break;
case mtpc_botInlineMediaResult: {
const MTPDbotInlineMediaResult &r(v.at(i).c_botInlineMediaResult());
result->id = qs(r.vid);
if (r.has_photo()) result->photo = App::feedPhoto(r.vphoto);
if (r.has_document()) result->document = App::feedDocument(r.vdocument);
message = &r.vsend_message;
} break;
}
bool badAttachment = (result->photo && !result->photo->access) || (result->doc && !result->doc->access);
bool badAttachment = (result->photo && !result->photo->access) || (result->document && !result->document->access);
if (!message) {
delete result;
continue;
}
switch (message->type()) {
case mtpc_botInlineMessageMediaAuto: {
const MTPDbotInlineMessageMediaAuto &r(message->c_botInlineMessageMediaAuto());
result->caption = qs(r.vcaption);
if (result->type == InlineResult::Type::Photo) {
result->sendData.reset(new InlineResultSendPhoto(result->photo, result->content_url, qs(r.vcaption)));
} else {
result->sendData.reset(new InlineResultSendFile(result->document, result->content_url, qs(r.vcaption)));
}
} break;
case mtpc_botInlineMessageText: {
const MTPDbotInlineMessageText &r(message->c_botInlineMessageText());
result->message = qs(r.vmessage);
if (r.has_entities()) result->entities = entitiesFromMTP(r.ventities.c_vector().v);
result->noWebPage = r.is_no_webpage();
EntitiesInText entities = r.has_entities() ? entitiesFromMTP(r.ventities.c_vector().v) : EntitiesInText();
result->sendData.reset(new InlineResultSendText(qs(r.vmessage), entities, r.is_no_webpage()));
} break;
case mtpc_botInlineMessageMediaGeo: {
const MTPDbotInlineMessageMediaGeo &r(message->c_botInlineMessageMediaGeo());
if (r.vgeo.type() == mtpc_geoPoint) {
result->sendData.reset(new InlineResultSendGeo(r.vgeo.c_geoPoint()));
} else {
badAttachment = true;
}
} break;
case mtpc_botInlineMessageMediaVenue: {
const MTPDbotInlineMessageMediaVenue &r(message->c_botInlineMessageMediaVenue());
if (r.vgeo.type() == mtpc_geoPoint) {
result->sendData.reset(new InlineResultSendVenue(r.vgeo.c_geoPoint(), qs(r.vvenue_id), qs(r.vprovider), qs(r.vtitle), qs(r.vaddress)));
} else {
badAttachment = true;
}
} break;
case mtpc_botInlineMessageMediaContact: {
const MTPDbotInlineMessageMediaContact &r(message->c_botInlineMessageMediaContact());
result->sendData.reset(new InlineResultSendContact(qs(r.vfirst_name), qs(r.vlast_name), qs(r.vphone_number)));
} break;
default: {
@ -3707,13 +3758,12 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
} break;
}
bool canSend = (result->photo || result->doc || !result->message.isEmpty() || (!result->content_url.isEmpty() && (result->type == qstr("gif") || result->type == qstr("photo"))));
if (result->type.isEmpty() || badAttachment || !canSend) {
delete result;
} else {
++added;
it.value()->results.push_back(result);
if (badAttachment || !result->sendData || !result->sendData->isValid()) {
continue;
}
++added;
it.value()->results.push_back(result.release());
}
if (!added) {

View File

@ -279,17 +279,17 @@ namespace Notify {
}
#define DefineReadOnlyVar(Namespace, Type, Name) const Type &Name() { \
t_assert_full(Namespace##Data != 0, #Namespace "Data is null in " #Namespace "::" #Name, __FILE__, __LINE__); \
t_assert_full(Namespace##Data != 0, #Namespace "Data != nullptr in " #Namespace "::" #Name, __FILE__, __LINE__); \
return Namespace##Data->Name; \
}
#define DefineRefVar(Namespace, Type, Name) DefineReadOnlyVar(Namespace, Type, Name) \
Type &Ref##Name() { \
t_assert_full(Namespace##Data != 0, #Namespace "Data is null in Global::Ref" #Name, __FILE__, __LINE__); \
t_assert_full(Namespace##Data != 0, #Namespace "Data != nullptr in " #Namespace "::Ref" #Name, __FILE__, __LINE__); \
return Namespace##Data->Name; \
}
#define DefineVar(Namespace, Type, Name) DefineRefVar(Namespace, Type, Name) \
void Set##Name(const Type &Name) { \
t_assert_full(Namespace##Data != 0, #Namespace "Data is null in Global::Set" #Name, __FILE__, __LINE__); \
t_assert_full(Namespace##Data != 0, #Namespace "Data != nullptr in " #Namespace "::Set" #Name, __FILE__, __LINE__); \
Namespace##Data->Name = Name; \
}

View File

@ -560,6 +560,8 @@ struct LocationCoords {
}
LocationCoords(float64 lat, float64 lon) : lat(lat), lon(lon) {
}
LocationCoords(const MTPDgeoPoint &point) : lat(point.vlat.v), lon(point.vlong.v) {
}
float64 lat, lon;
};
inline bool operator==(const LocationCoords &a, const LocationCoords &b) {

View File

@ -6751,15 +6751,13 @@ void HistoryMessage::initMedia(const MTPMessageMedia *media, QString &currentTex
case mtpc_messageMediaGeo: {
const MTPGeoPoint &point(media->c_messageMediaGeo().vgeo);
if (point.type() == mtpc_geoPoint) {
const MTPDgeoPoint &d(point.c_geoPoint());
_media.reset(this, new HistoryLocation(LocationCoords(d.vlat.v, d.vlong.v)));
_media.reset(this, new HistoryLocation(LocationCoords(point.c_geoPoint())));
}
} break;
case mtpc_messageMediaVenue: {
const MTPDmessageMediaVenue &d(media->c_messageMediaVenue());
if (d.vgeo.type() == mtpc_geoPoint) {
const MTPDgeoPoint &g(d.vgeo.c_geoPoint());
_media.reset(this, new HistoryLocation(LocationCoords(g.vlat.v, g.vlong.v), qs(d.vtitle), qs(d.vaddress)));
_media.reset(this, new HistoryLocation(LocationCoords(d.vgeo.c_geoPoint()), qs(d.vtitle), qs(d.vaddress)));
}
} break;
case mtpc_messageMediaPhoto: {

View File

@ -3588,7 +3588,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
updateTopBarSelection();
if (_inlineBot) {
_inlineBot = 0;
_inlineBot = nullptr;
_emojiPan.clearInlineBot();
updateFieldPlaceholder();
}
@ -5358,7 +5358,7 @@ bool HistoryWidget::inlineBotResolveFail(QString name, const RPCError &error) {
_inlineBotResolveRequestId = 0;
// Notify::inlineBotRequesting(false);
if (name == _inlineBotUsername) {
_inlineBot = 0;
_inlineBot = nullptr;
onCheckMentionDropdown();
}
return true;
@ -6765,65 +6765,22 @@ void HistoryWidget::onInlineResultSend(InlineResult *result, UserData *bot) {
flags |= MTPDmessage::Flag::f_via_bot_id;
}
if (result->message.isEmpty()) {
if (result->doc) {
_history->addNewDocument(newId.msg, flags, bot ? peerToUser(bot->id) : 0, replyToId(), date(MTP_int(unixtime())), showFromName ? MTP::authedId() : 0, result->doc, result->caption);
} else if (result->photo) {
_history->addNewPhoto(newId.msg, flags, bot ? peerToUser(bot->id) : 0, replyToId(), date(MTP_int(unixtime())), showFromName ? MTP::authedId() : 0, result->photo, result->caption);
} else if (result->type == qstr("gif")) {
MTPPhotoSize thumbSize;
QPixmap thumb;
int32 tw = result->thumb->width(), th = result->thumb->height();
if (tw > 0 && th > 0 && tw < 20 * th && th < 20 * tw && result->thumb->loaded()) {
if (tw > th) {
if (tw > 90) {
th = th * 90 / tw;
tw = 90;
}
} else if (th > 90) {
tw = tw * 90 / th;
th = 90;
}
thumbSize = MTP_photoSize(MTP_string(""), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(tw), MTP_int(th), MTP_int(0));
thumb = result->thumb->pixNoCache(tw, th, ImagePixSmooth);
} else {
tw = th = 0;
thumbSize = MTP_photoSizeEmpty(MTP_string(""));
}
uint64 docId = rand_value<uint64>();
QVector<MTPDocumentAttribute> attributes(1, MTP_documentAttributeFilename(MTP_string((result->content_type == qstr("video/mp4") ? "animation.gif.mp4" : "animation.gif"))));
attributes.push_back(MTP_documentAttributeAnimated());
attributes.push_back(MTP_documentAttributeVideo(MTP_int(result->duration), MTP_int(result->width), MTP_int(result->height)));
MTPDocument document = MTP_document(MTP_long(docId), MTP_long(0), MTP_int(unixtime()), MTP_string(result->content_type), MTP_int(result->data().size()), thumbSize, MTP_int(MTP::maindc()), MTP_vector<MTPDocumentAttribute>(attributes));
if (tw > 0 && th > 0) {
App::feedDocument(document, thumb);
}
Local::writeStickerImage(mediaKey(DocumentFileLocation, MTP::maindc(), docId), result->data());
_history->addNewMessage(MTP_message(MTP_flags(flags), MTP_int(newId.msg), MTP_int(showFromName ? MTP::authedId() : 0), peerToMTP(_history->peer->id), MTPnullFwdHeader, MTP_int(bot ? peerToUser(bot->id) : 0), MTP_int(replyToId()), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaDocument(document, MTP_string(result->caption)), MTPnullMarkup, MTPnullEntities, MTP_int(1), MTPint()), NewMessageUnread);
} else if (result->type == qstr("photo")) {
QImage fileThumb(result->thumb->pix().toImage());
QVector<MTPPhotoSize> photoSizes;
QPixmap thumb = (fileThumb.width() > 100 || fileThumb.height() > 100) ? QPixmap::fromImage(fileThumb.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation), Qt::ColorOnly) : QPixmap::fromImage(fileThumb);
ImagePtr thumbPtr = ImagePtr(thumb, "JPG");
photoSizes.push_back(MTP_photoSize(MTP_string("s"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(thumb.width()), MTP_int(thumb.height()), MTP_int(0)));
QSize medium = resizeKeepAspect(result->width, result->height, 320, 320);
photoSizes.push_back(MTP_photoSize(MTP_string("m"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(medium.width()), MTP_int(medium.height()), MTP_int(0)));
photoSizes.push_back(MTP_photoSize(MTP_string("x"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(result->width), MTP_int(result->height), MTP_int(0)));
uint64 photoId = rand_value<uint64>();
PhotoData *ph = App::photoSet(photoId, 0, 0, unixtime(), thumbPtr, ImagePtr(medium.width(), medium.height()), ImagePtr(result->width, result->height));
MTPPhoto photo = MTP_photo(MTP_long(photoId), MTP_long(0), MTP_int(ph->date), MTP_vector<MTPPhotoSize>(photoSizes));
_history->addNewMessage(MTP_message(MTP_flags(flags), MTP_int(newId.msg), MTP_int(showFromName ? MTP::authedId() : 0), peerToMTP(_history->peer->id), MTPnullFwdHeader, MTP_int(bot ? peerToUser(bot->id) : 0), MTP_int(replyToId()), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaPhoto(photo, MTP_string(result->caption)), MTPnullMarkup, MTPnullEntities, MTP_int(1), MTPint()), NewMessageUnread);
}
UserId messageFromId = showFromName ? MTP::authedId() : 0;
MTPint messageDate = MTP_int(unixtime());
UserId messageViaBotId = bot ? peerToUser(bot->id) : 0;
MsgId messageId = newId.msg;
if (DocumentData *document = result->sendData->getSentDocument()) {
_history->addNewDocument(messageId, flags, messageViaBotId, replyToId(), date(messageDate), messageFromId, document, result->sendData->getSentCaption());
} else if (PhotoData *photo = result->sendData->getSentPhoto()) {
_history->addNewPhoto(messageId, flags, messageViaBotId, replyToId(), date(messageDate), messageFromId, photo, result->sendData->getSentCaption());
} else {
flags |= MTPDmessage::Flag::f_entities;
_history->addNewMessage(MTP_message(MTP_flags(flags), MTP_int(newId.msg), MTP_int(showFromName ? MTP::authedId() : 0), peerToMTP(_history->peer->id), MTPnullFwdHeader, MTP_int(bot ? peerToUser(bot->id) : 0), MTP_int(replyToId()), MTP_int(unixtime()), MTP_string(result->message), MTP_messageMediaEmpty(), MTPnullMarkup, linksToMTP(result->entities), MTP_int(1), MTPint()), NewMessageUnread);
InlineResultSendData::SentMTPMessageFields fields = result->sendData->getSentMessageFields(result);
if (!fields.entities.c_vector().v.isEmpty()) {
flags |= MTPDmessage::Flag::f_entities;
}
_history->addNewMessage(MTP_message(MTP_flags(flags), MTP_int(messageId), MTP_int(messageFromId), peerToMTP(_history->peer->id), MTPnullFwdHeader, MTP_int(messageViaBotId), MTP_int(replyToId()), messageDate, fields.text, fields.media, MTPnullMarkup, fields.entities, MTP_int(1), MTPint()), NewMessageUnread);
}
_history->sendRequestId = MTP::send(MTPmessages_SendInlineBotResult(MTP_flags(sendFlags), _peer->input, MTP_int(replyToId()), MTP_long(randomId), MTP_long(result->queryId), MTP_string(result->id)), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, _history->sendRequestId);
App::main()->finishForwarding(_history, _broadcast.checked(), _silent.checked());
cancelReply(lastKeyboardUsed);

View File

@ -1335,13 +1335,6 @@ LayoutOverviewLink::Link::Link(const QString &url, const QString &text)
, lnk(clickHandlerFromUrl(url)) {
}
LayoutInlineItem::LayoutInlineItem(InlineResult *result, DocumentData *doc, PhotoData *photo) : LayoutItem()
, _result(result)
, _doc(doc)
, _photo(photo)
, _position(0) {
}
void LayoutInlineItem::setPosition(int32 position) {
_position = position;
}
@ -1350,15 +1343,15 @@ int32 LayoutInlineItem::position() const {
return _position;
}
InlineResult *LayoutInlineItem::result() const {
InlineResult *LayoutInlineItem::getInlineResult() const {
return _result;
}
DocumentData *LayoutInlineItem::document() const {
DocumentData *LayoutInlineItem::getDocument() const {
return _doc;
}
PhotoData *LayoutInlineItem::photo() const {
PhotoData *LayoutInlineItem::getPhoto() const {
return _photo;
}
@ -1366,8 +1359,8 @@ void LayoutInlineItem::preload() {
if (_result) {
if (_result->photo) {
_result->photo->thumb->load();
} else if (_result->doc) {
_result->doc->thumb->load();
} else if (_result->document) {
_result->document->thumb->load();
} else if (!_result->thumb->isNull()) {
_result->thumb->load();
}
@ -1384,12 +1377,103 @@ void LayoutInlineItem::update() {
}
}
LayoutInlineGif::LayoutInlineGif(InlineResult *result, DocumentData *doc, bool saved) : LayoutInlineItem(result, doc, 0)
, _state(0)
, _gif(0)
, _send(new SendInlineItemClickHandler())
, _delete((doc && saved) ? new DeleteSavedGifClickHandler(doc) : nullptr)
, _animation(0) {
LayoutInlineAbstractFile::LayoutInlineAbstractFile(InlineResult *result) : LayoutInlineItem(result) {
}
LayoutInlineAbstractFile::LayoutInlineAbstractFile(DocumentData *document) : LayoutInlineItem(document) {
}
int LayoutInlineAbstractFile::content_width() const {
if (DocumentData *document = getShownDocument()) {
if (document->dimensions.width() > 0) {
return document->dimensions.width();
}
if (!document->thumb->isNull()) {
return convertScale(document->thumb->width());
}
} else if (_result) {
return _result->width;
}
return 0;
}
int LayoutInlineAbstractFile::content_height() const {
if (DocumentData *document = getShownDocument()) {
if (document->dimensions.height() > 0) {
return document->dimensions.height();
}
if (!document->thumb->isNull()) {
return convertScale(document->thumb->height());
}
} else if (_result) {
return _result->height;
}
return 0;
}
bool LayoutInlineAbstractFile::content_loading() const {
if (DocumentData *document = getShownDocument()) {
return document->loading();
}
return _result->loading();
}
bool LayoutInlineAbstractFile::content_displayLoading() const {
if (DocumentData *document = getShownDocument()) {
return document->displayLoading();
}
return _result->displayLoading();
}
bool LayoutInlineAbstractFile::content_loaded() const {
if (DocumentData *document = getShownDocument()) {
return document->loaded();
}
return _result->loaded();
}
float64 LayoutInlineAbstractFile::content_progress() const {
if (DocumentData *document = getShownDocument()) {
return document->progress();
}
return _result->progress();
}
void LayoutInlineAbstractFile::content_automaticLoad() const {
if (DocumentData *document = getShownDocument()) {
document->automaticLoad(nullptr);
} else {
_result->automaticLoadGif();
}
}
void LayoutInlineAbstractFile::content_forget() {
if (DocumentData *document = getShownDocument()) {
document->forget();
} else {
_result->forget();
}
}
FileLocation LayoutInlineAbstractFile::content_location() const {
if (DocumentData *document = getShownDocument()) {
return document->location();
}
return FileLocation();
}
QByteArray LayoutInlineAbstractFile::content_data() const {
if (DocumentData *document = getShownDocument()) {
return document->data();
}
return _result->data();
}
LayoutInlineGif::LayoutInlineGif(InlineResult *result) : LayoutInlineAbstractFile(result) {
}
LayoutInlineGif::LayoutInlineGif(DocumentData *document, bool hasDeleteButton) : LayoutInlineAbstractFile(document)
, _delete(hasDeleteButton ? new DeleteSavedGifClickHandler(document) : nullptr) {
}
void LayoutInlineGif::initDimensions() {
@ -1466,7 +1550,7 @@ void LayoutInlineGif::paint(Painter &p, const QRect &clip, uint32 selection, con
p.setOpacity((st::msgDateImgBg->c.alphaF() * (1 - over)) + (st::msgDateImgBgOver->c.alphaF() * over));
p.fillRect(r, st::black);
} else {
p.fillRect(r, (_state & StateOver) ? st::msgDateImgBgOver : st::msgDateImgBg);
p.fillRect(r, (_state & StateFlag::Over) ? st::msgDateImgBgOver : st::msgDateImgBg);
}
p.setOpacity(radialOpacity * p.opacity());
@ -1488,8 +1572,8 @@ void LayoutInlineGif::paint(Painter &p, const QRect &clip, uint32 selection, con
}
}
if (_delete && (_state & StateOver)) {
float64 deleteOver = _a_deleteOver.current(context->ms, (_state & StateDeleteOver) ? 1 : 0);
if (_delete && (_state & StateFlag::Over)) {
float64 deleteOver = _a_deleteOver.current(context->ms, (_state & StateFlag::DeleteOver) ? 1 : 0);
QPoint deletePos = QPoint(_width - st::stickerPanDelete.pxWidth(), 0);
p.setOpacity(deleteOver + (1 - deleteOver) * st::stickerPanDeleteOpacity);
p.drawSpriteLeft(deletePos, _width, st::stickerPanDelete);
@ -1511,20 +1595,20 @@ void LayoutInlineGif::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool a
if (!p) return;
if (_delete && p == _delete) {
bool wasactive = (_state & StateDeleteOver);
bool wasactive = (_state & StateFlag::DeleteOver);
if (active != wasactive) {
float64 from = active ? 0 : 1, to = active ? 1 : 0;
EnsureAnimation(_a_deleteOver, from, func(this, &LayoutInlineGif::update));
_a_deleteOver.start(to, st::stickersRowDuration);
if (active) {
_state |= StateDeleteOver;
_state |= StateFlag::DeleteOver;
} else {
_state &= ~StateDeleteOver;
_state &= ~StateFlag::DeleteOver;
}
}
}
if (p == _delete || p == _send) {
bool wasactive = (_state & StateOver);
bool wasactive = (_state & StateFlag::Over);
if (active != wasactive) {
if (!content_loaded()) {
ensureAnimation();
@ -1533,9 +1617,9 @@ void LayoutInlineGif::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool a
_animation->_a_over.start(to, st::stickersRowDuration);
}
if (active) {
_state |= StateOver;
_state |= StateFlag::Over;
} else {
_state &= ~StateOver;
_state &= ~StateFlag::Over;
}
}
}
@ -1579,22 +1663,25 @@ LayoutInlineGif::~LayoutInlineGif() {
}
void LayoutInlineGif::prepareThumb(int32 width, int32 height, const QSize &frame) const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
if (doc && !doc->thumb->isNull()) {
if (doc->thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
_thumb = doc->thumb->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), ImagePixSmooth, width, height);
if (DocumentData *document = getShownDocument()) {
if (!document->thumb->isNull()) {
if (document->thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
_thumb = document->thumb->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), ImagePixSmooth, width, height);
}
} else {
document->thumb->load();
}
} else {
doc->thumb->load();
}
} else if (_result && !_result->thumb_url.isEmpty()) {
if (_result->thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
_thumb = _result->thumb->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), ImagePixSmooth, width, height);
} else {
if (!_result->thumb_url.isEmpty()) {
if (_result->thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
_thumb = _result->thumb->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), ImagePixSmooth, width, height);
}
} else {
_result->thumb->load();
}
} else {
_result->thumb->load();
}
}
}
@ -1654,87 +1741,69 @@ void LayoutInlineGif::clipCallback(ClipReaderNotification notification) {
}
}
int32 LayoutInlineGif::content_width() const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
if (doc) {
if (doc->dimensions.width() > 0) {
return doc->dimensions.width();
}
if (!doc->thumb->isNull()) {
return convertScale(doc->thumb->width());
}
} else if (_result) {
return _result->width;
LayoutInlineSticker::LayoutInlineSticker(InlineResult *result) : LayoutInlineAbstractFile(result) {
}
void LayoutInlineSticker::initDimensions() {
_maxw = st::stickerPanSize.width();
_minh = st::stickerPanSize.height();
}
void LayoutInlineSticker::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const {
bool loaded = content_loaded();
prepareThumb();
if (!_thumb.isNull()) {
int w = _thumb.width() / cIntRetinaFactor(), h = _thumb.height() / cIntRetinaFactor();
QPoint pos = QPoint((st::stickerPanSize.width() - w) / 2, (st::stickerPanSize.height() - h) / 2);
p.drawPixmap(pos, _thumb);
}
return 0;
}
int32 LayoutInlineGif::content_height() const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
if (doc) {
if (doc->dimensions.height() > 0) {
return doc->dimensions.height();
}
if (!doc->thumb->isNull()) {
return convertScale(doc->thumb->height());
}
} else if (_result) {
return _result->height;
void LayoutInlineSticker::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int32 x, int32 y) const {
if (x >= 0 && x < _width && y >= 0 && y < st::inlineMediaHeight) {
link = _send;
}
return 0;
}
bool LayoutInlineGif::content_loading() const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
return doc ? doc->loading() : _result->loading();
QSize LayoutInlineSticker::getThumbSize() const {
int width = qMax(content_width(), 1), height = qMax(content_height(), 1);
float64 coefw = (st::stickerPanSize.width() - st::msgRadius * 2) / float64(width);
float64 coefh = (st::stickerPanSize.height() - st::msgRadius * 2) / float64(height);
float64 coef = qMin(qMin(coefw, coefh), 1.);
int w = qRound(coef * content_width()), h = qRound(coef * content_height());
return QSize(qMax(w, 1), qMax(h, 1));
}
bool LayoutInlineGif::content_displayLoading() const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
return doc ? doc->displayLoading() : _result->displayLoading();
}
void LayoutInlineSticker::prepareThumb() const {
if (DocumentData *document = getShownDocument()) {
bool goodThumb = !document->thumb->isNull() && ((document->thumb->width() >= 128) || (document->thumb->height() >= 128));
if (goodThumb) {
document->thumb->load();
} else {
document->checkSticker();
}
bool LayoutInlineGif::content_loaded() const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
return doc ? doc->loaded() : _result->loaded();
}
float64 LayoutInlineGif::content_progress() const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
return doc ? doc->progress() : _result->progress();
}
void LayoutInlineGif::content_automaticLoad() const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
if (doc) {
doc->automaticLoad(0);
ImagePtr sticker = goodThumb ? document->thumb : document->sticker()->img;
if (!_thumbLoaded && sticker->loaded()) {
QSize thumbSize = getThumbSize();
_thumb = sticker->pix(thumbSize.width(), thumbSize.height());
_thumbLoaded = true;
}
} else {
_result->automaticLoadGif();
if (_result->thumb->loaded()) {
if (!_thumbLoaded) {
QSize thumbSize = getThumbSize();
_thumb = _result->thumb->pix(thumbSize.width(), thumbSize.height());
_thumbLoaded = true;
}
} else {
_result->thumb->load();
}
}
}
void LayoutInlineGif::content_forget() {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
if (doc) {
doc->forget();
} else {
_result->forget();
}
}
FileLocation LayoutInlineGif::content_location() const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
return doc ? doc->location() : FileLocation();
}
QByteArray LayoutInlineGif::content_data() const {
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
return doc ? doc->data() : _result->data();
}
LayoutInlinePhoto::LayoutInlinePhoto(InlineResult *result, PhotoData *photo) : LayoutInlineItem(result, 0, photo)
, _send(new SendInlineItemClickHandler())
, _thumbLoaded(false) {
LayoutInlinePhoto::LayoutInlinePhoto(InlineResult *result) : LayoutInlineItem(result) {
}
void LayoutInlinePhoto::initDimensions() {
@ -1797,8 +1866,7 @@ QSize LayoutInlinePhoto::countFrameSize() const {
}
void LayoutInlinePhoto::prepareThumb(int32 width, int32 height, const QSize &frame) const {
PhotoData *photo = _photo ? _photo : (_result ? _result->photo : 0);
if (photo) {
if (PhotoData *photo = getShownPhoto()) {
if (photo->medium->loaded()) {
if (!_thumbLoaded || _thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
_thumb = photo->medium->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), ImagePixSmooth, width, height);
@ -1823,9 +1891,8 @@ void LayoutInlinePhoto::prepareThumb(int32 width, int32 height, const QSize &fra
}
}
int32 LayoutInlinePhoto::content_width() const {
PhotoData *photo = _photo ? _photo : (_result ? _result->photo : 0);
if (photo) {
int LayoutInlinePhoto::content_width() const {
if (PhotoData *photo = getShownPhoto()) {
return photo->full->width();
} else if (_result) {
return _result->width;
@ -1833,9 +1900,8 @@ int32 LayoutInlinePhoto::content_width() const {
return 0;
}
int32 LayoutInlinePhoto::content_height() const {
PhotoData *photo = _photo ? _photo : (_result ? _result->photo : 0);
if (photo) {
int LayoutInlinePhoto::content_height() const {
if (PhotoData *photo = getShownPhoto()) {
return photo->full->height();
} else if (_result) {
return _result->height;
@ -1844,21 +1910,21 @@ int32 LayoutInlinePhoto::content_height() const {
}
bool LayoutInlinePhoto::content_loaded() const {
PhotoData *photo = _photo ? _photo : (_result ? _result->photo : 0);
return photo ? photo->loaded() : _result->loaded();
if (PhotoData *photo = getShownPhoto()) {
return photo->loaded();
}
return _result->loaded();
}
void LayoutInlinePhoto::content_forget() {
PhotoData *photo = _photo ? _photo : (_result ? _result->photo : 0);
if (photo) {
if (PhotoData *photo = getShownPhoto()) {
photo->forget();
} else {
_result->forget();
}
}
LayoutInlineWebVideo::LayoutInlineWebVideo(InlineResult *result) : LayoutInlineItem(result, 0, 0)
, _send(new SendInlineItemClickHandler())
LayoutInlineWebVideo::LayoutInlineWebVideo(InlineResult *result) : LayoutInlineItem(result)
, _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip)
, _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) {
if (!result->content_url.isEmpty()) {
@ -1951,8 +2017,7 @@ void LayoutInlineWebVideo::prepareThumb(int32 width, int32 height) const {
}
}
LayoutInlineArticle::LayoutInlineArticle(InlineResult *result, bool withThumb) : LayoutInlineItem(result, 0, 0)
, _send(new SendInlineItemClickHandler())
LayoutInlineArticle::LayoutInlineArticle(InlineResult *result, bool withThumb) : LayoutInlineItem(result)
, _withThumb(withThumb)
, _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip)
, _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) {

View File

@ -471,10 +471,23 @@ public:
bool paused, lastRow;
};
// this type used as a flag, we dynamic_cast<> to it
class SendInlineItemClickHandler : public ClickHandler {
public:
void onClick(Qt::MouseButton) const override {
}
};
class LayoutInlineItem : public LayoutItem {
public:
LayoutInlineItem(InlineResult *result, DocumentData *doc, PhotoData *photo);
LayoutInlineItem(InlineResult *result) : _result(result) {
}
LayoutInlineItem(DocumentData *doc) : _doc(doc) {
}
// Not used anywhere currently.
//LayoutInlineItem(PhotoData *photo) : _photo(photo) {
//}
virtual void setPosition(int32 position);
int32 position() const;
@ -483,9 +496,9 @@ public:
return true;
}
InlineResult *result() const;
DocumentData *document() const;
PhotoData *photo() const;
InlineResult *getInlineResult() const;
DocumentData *getDocument() const;
PhotoData *getPhoto() const;
void preload();
void update();
@ -499,19 +512,43 @@ public:
}
protected:
InlineResult *_result;
DocumentData *_doc;
PhotoData *_photo;
InlineResult *_result = nullptr;
DocumentData *_doc = nullptr;
PhotoData *_photo = nullptr;
int32 _position; // < 0 means removed from layout
ClickHandlerPtr _send = ClickHandlerPtr{ new SendInlineItemClickHandler() };
int _position = 0; // < 0 means removed from layout
};
// this type used as a flag, we dynamic_cast<> to it
class SendInlineItemClickHandler : public ClickHandler {
class LayoutInlineAbstractFile : public LayoutInlineItem {
public:
void onClick(Qt::MouseButton) const override {
LayoutInlineAbstractFile(InlineResult *result);
// for saved gif layouts
LayoutInlineAbstractFile(DocumentData *doc);
protected:
DocumentData *getShownDocument() const {
if (DocumentData *result = getDocument()) {
return result;
} else if (InlineResult *result = getInlineResult()) {
return result->document;
}
return nullptr;
}
int content_width() const;
int content_height() const;
bool content_loading() const;
bool content_displayLoading() const;
bool content_loaded() const;
float64 content_progress() const;
void content_automaticLoad() const;
void content_forget();
FileLocation content_location() const;
QByteArray content_data() const;
};
class DeleteSavedGifClickHandler : public LeftButtonClickHandler {
@ -527,9 +564,10 @@ private:
};
class LayoutInlineGif : public LayoutInlineItem {
class LayoutInlineGif : public LayoutInlineAbstractFile {
public:
LayoutInlineGif(InlineResult *result, DocumentData *doc, bool saved);
LayoutInlineGif(InlineResult *result);
LayoutInlineGif(DocumentData *doc, bool hasDeleteButton);
void setPosition(int32 position) override;
void initDimensions() override;
@ -548,27 +586,21 @@ public:
~LayoutInlineGif();
private:
QSize countFrameSize() const;
int32 content_width() const;
int32 content_height() const;
bool content_loading() const;
bool content_displayLoading() const;
bool content_loaded() const;
float64 content_progress() const;
void content_automaticLoad() const;
void content_forget();
FileLocation content_location() const;
QByteArray content_data() const;
enum StateFlags {
StateOver = 0x01,
StateDeleteOver = 0x02,
enum class StateFlag {
Over = 0x01,
DeleteOver = 0x02,
};
int32 _state;
Q_DECLARE_FLAGS(StateFlags, StateFlag);
StateFlags _state;
friend inline StateFlags operator~(StateFlag flag) {
return ~StateFlags(flag);
}
ClipReader *_gif;
ClickHandlerPtr _send, _delete;
ClipReader *_gif = nullptr;
ClickHandlerPtr _delete;
bool gif() const {
return (!_gif || _gif == BadClipReader) ? false : true;
}
@ -590,14 +622,16 @@ private:
FloatAnimation _a_over;
RadialAnimation radial;
};
mutable AnimationData *_animation;
mutable AnimationData *_animation = nullptr;
mutable FloatAnimation _a_deleteOver;
};
class LayoutInlinePhoto : public LayoutInlineItem {
public:
LayoutInlinePhoto(InlineResult *result, PhotoData *photo);
LayoutInlinePhoto(InlineResult *result);
// Not used anywhere currently.
//LayoutInlinePhoto(PhotoData *photo);
void initDimensions() override;
@ -609,18 +643,50 @@ public:
void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int32 x, int32 y) const override;
private:
PhotoData *getShownPhoto() const {
if (PhotoData *result = getPhoto()) {
return result;
} else if (InlineResult *result = getInlineResult()) {
return result->photo;
}
return nullptr;
}
QSize countFrameSize() const;
int32 content_width() const;
int32 content_height() const;
int content_width() const;
int content_height() const;
bool content_loaded() const;
void content_forget();
ClickHandlerPtr _send;
mutable QPixmap _thumb;
mutable bool _thumbLoaded = false;
void prepareThumb(int32 width, int32 height, const QSize &frame) const;
};
class LayoutInlineSticker : public LayoutInlineAbstractFile {
public:
LayoutInlineSticker(InlineResult *result);
// Not used anywhere currently.
//LayoutInlineSticker(DocumentData *document);
void initDimensions() override;
bool fullLine() const override {
return false;
}
void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const override;
void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int32 x, int32 y) const override;
private:
QSize getThumbSize() const;
mutable QPixmap _thumb;
mutable bool _thumbLoaded;
void prepareThumb(int32 width, int32 height, const QSize &frame) const;
mutable bool _thumbLoaded = false;
void prepareThumb() const;
};
@ -635,7 +701,7 @@ public:
private:
ClickHandlerPtr _send, _link;
ClickHandlerPtr _link;
mutable QPixmap _thumb;
Text _title, _description;
@ -646,6 +712,27 @@ private:
};
class LayoutInlineFile : public LayoutInlineAbstractFile {
public:
LayoutInlineFile(InlineResult *result);
void initDimensions() override;
int32 resizeGetHeight(int32 width) override;
void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const override;
void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int32 x, int32 y) const override;
private:
mutable QPixmap _thumb;
Text _title, _description;
QString _letter, _urlText;
int32 _urlWidth;
void prepareThumb(int32 width, int32 height) const;
};
class LayoutInlineArticle : public LayoutInlineItem {
public:
LayoutInlineArticle(InlineResult *result, bool withThumb);
@ -658,7 +745,7 @@ public:
private:
ClickHandlerPtr _send, _url, _link;
ClickHandlerPtr _url, _link;
bool _withThumb;
mutable QPixmap _thumb;

View File

@ -639,8 +639,6 @@ inputBotInlineMessageMediaVenue#8ab91f84 geo_point:InputGeoPoint title:string ad
inputBotInlineMessageMediaContact#52971c52 phone_number:string first_name:string last_name:string = InputBotInlineMessage;
inputBotInlineResult#2cbbe15a flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb_url:flags.4?string content_url:flags.5?string content_type:flags.5?string w:flags.6?int h:flags.6?int duration:flags.7?int send_message:InputBotInlineMessage = InputBotInlineResult;
inputBotInlineResultPhoto#243edc26 flags:# id:string type:string photo:InputPhoto send_message:InputBotInlineMessage = InputBotInlineResult;
inputBotInlineResultDocument#11af9bcc flags:# id:string type:string title:flags.1?string description:flags.2?string document:flags.5?InputDocument send_message:InputBotInlineMessage = InputBotInlineResult;
botInlineMessageMediaAuto#fc56e87d caption:string = BotInlineMessage;
botInlineMessageText#a56197a9 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector<MessageEntity> = BotInlineMessage;
@ -648,9 +646,8 @@ botInlineMessageMediaGeo#59d1ff36 geo:GeoPoint = BotInlineMessage;
botInlineMessageMediaVenue#6fa16678 geo:GeoPoint title:string address:string provider:string venue_id:string = BotInlineMessage;
botInlineMessageMediaContact#89202361 phone_number:string first_name:string last_name:string = BotInlineMessage;
botInlineMediaResultDocument#f897d33e id:string type:string document:Document send_message:BotInlineMessage = BotInlineResult;
botInlineMediaResultPhoto#c5528587 id:string type:string photo:Photo send_message:BotInlineMessage = BotInlineResult;
botInlineResult#9bebaeb9 flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb_url:flags.4?string content_url:flags.5?string content_type:flags.5?string w:flags.6?int h:flags.6?int duration:flags.7?int send_message:BotInlineMessage = BotInlineResult;
botInlineMediaResult#17db940b flags:# id:string type:string photo:flags.0?Photo document:flags.1?Document title:flags.2?string description:flags.3?string send_message:BotInlineMessage = BotInlineResult;
messages.botResults#1170b0a3 flags:# gallery:flags.0?true query_id:long next_offset:flags.1?string results:Vector<BotInlineResult> = messages.BotResults;

View File

@ -5205,44 +5205,6 @@ void _serialize_inputBotInlineResult(MTPStringLogger &to, int32 stage, int32 lev
}
}
void _serialize_inputBotInlineResultPhoto(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 iflag) {
if (stage) {
to.add(",\n").addSpaces(lev);
} else {
to.add("{ inputBotInlineResultPhoto");
to.add("\n").addSpaces(lev);
}
switch (stage) {
case 0: to.add(" flags: "); ++stages.back(); if (start >= end) throw Exception("start >= end in flags"); else flags.back() = *start; types.push_back(mtpc_flags); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 1: to.add(" id: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 2: to.add(" type: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 3: to.add(" photo: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 4: to.add(" send_message: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
}
}
void _serialize_inputBotInlineResultDocument(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 iflag) {
MTPDinputBotInlineResultDocument::Flags flag(iflag);
if (stage) {
to.add(",\n").addSpaces(lev);
} else {
to.add("{ inputBotInlineResultDocument");
to.add("\n").addSpaces(lev);
}
switch (stage) {
case 0: to.add(" flags: "); ++stages.back(); if (start >= end) throw Exception("start >= end in flags"); else flags.back() = *start; types.push_back(mtpc_flags); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 1: to.add(" id: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 2: to.add(" type: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 3: to.add(" title: "); ++stages.back(); if (flag & MTPDinputBotInlineResultDocument::Flag::f_title) { types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 1 IN FIELD flags ]"); } break;
case 4: to.add(" description: "); ++stages.back(); if (flag & MTPDinputBotInlineResultDocument::Flag::f_description) { types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 2 IN FIELD flags ]"); } break;
case 5: to.add(" document: "); ++stages.back(); if (flag & MTPDinputBotInlineResultDocument::Flag::f_document) { types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 5 IN FIELD flags ]"); } break;
case 6: to.add(" send_message: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
}
}
void _serialize_botInlineMessageMediaAuto(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 iflag) {
if (stage) {
to.add(",\n").addSpaces(lev);
@ -5319,38 +5281,6 @@ void _serialize_botInlineMessageMediaContact(MTPStringLogger &to, int32 stage, i
}
}
void _serialize_botInlineMediaResultDocument(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 iflag) {
if (stage) {
to.add(",\n").addSpaces(lev);
} else {
to.add("{ botInlineMediaResultDocument");
to.add("\n").addSpaces(lev);
}
switch (stage) {
case 0: to.add(" id: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 1: to.add(" type: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 2: to.add(" document: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 3: to.add(" send_message: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
}
}
void _serialize_botInlineMediaResultPhoto(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 iflag) {
if (stage) {
to.add(",\n").addSpaces(lev);
} else {
to.add("{ botInlineMediaResultPhoto");
to.add("\n").addSpaces(lev);
}
switch (stage) {
case 0: to.add(" id: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 1: to.add(" type: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 2: to.add(" photo: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 3: to.add(" send_message: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
}
}
void _serialize_botInlineResult(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 iflag) {
MTPDbotInlineResult::Flags flag(iflag);
@ -5378,6 +5308,28 @@ void _serialize_botInlineResult(MTPStringLogger &to, int32 stage, int32 lev, Typ
}
}
void _serialize_botInlineMediaResult(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 iflag) {
MTPDbotInlineMediaResult::Flags flag(iflag);
if (stage) {
to.add(",\n").addSpaces(lev);
} else {
to.add("{ botInlineMediaResult");
to.add("\n").addSpaces(lev);
}
switch (stage) {
case 0: to.add(" flags: "); ++stages.back(); if (start >= end) throw Exception("start >= end in flags"); else flags.back() = *start; types.push_back(mtpc_flags); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 1: to.add(" id: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 2: to.add(" type: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 3: to.add(" photo: "); ++stages.back(); if (flag & MTPDbotInlineMediaResult::Flag::f_photo) { types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break;
case 4: to.add(" document: "); ++stages.back(); if (flag & MTPDbotInlineMediaResult::Flag::f_document) { types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 1 IN FIELD flags ]"); } break;
case 5: to.add(" title: "); ++stages.back(); if (flag & MTPDbotInlineMediaResult::Flag::f_title) { types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 2 IN FIELD flags ]"); } break;
case 6: to.add(" description: "); ++stages.back(); if (flag & MTPDbotInlineMediaResult::Flag::f_description) { types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 3 IN FIELD flags ]"); } break;
case 7: to.add(" send_message: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
}
}
void _serialize_messages_botResults(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 iflag) {
MTPDmessages_botResults::Flags flag(iflag);
@ -8437,16 +8389,13 @@ namespace {
_serializers.insert(mtpc_inputBotInlineMessageMediaVenue, _serialize_inputBotInlineMessageMediaVenue);
_serializers.insert(mtpc_inputBotInlineMessageMediaContact, _serialize_inputBotInlineMessageMediaContact);
_serializers.insert(mtpc_inputBotInlineResult, _serialize_inputBotInlineResult);
_serializers.insert(mtpc_inputBotInlineResultPhoto, _serialize_inputBotInlineResultPhoto);
_serializers.insert(mtpc_inputBotInlineResultDocument, _serialize_inputBotInlineResultDocument);
_serializers.insert(mtpc_botInlineMessageMediaAuto, _serialize_botInlineMessageMediaAuto);
_serializers.insert(mtpc_botInlineMessageText, _serialize_botInlineMessageText);
_serializers.insert(mtpc_botInlineMessageMediaGeo, _serialize_botInlineMessageMediaGeo);
_serializers.insert(mtpc_botInlineMessageMediaVenue, _serialize_botInlineMessageMediaVenue);
_serializers.insert(mtpc_botInlineMessageMediaContact, _serialize_botInlineMessageMediaContact);
_serializers.insert(mtpc_botInlineMediaResultDocument, _serialize_botInlineMediaResultDocument);
_serializers.insert(mtpc_botInlineMediaResultPhoto, _serialize_botInlineMediaResultPhoto);
_serializers.insert(mtpc_botInlineResult, _serialize_botInlineResult);
_serializers.insert(mtpc_botInlineMediaResult, _serialize_botInlineMediaResult);
_serializers.insert(mtpc_messages_botResults, _serialize_messages_botResults);
_serializers.insert(mtpc_exportedMessageLink, _serialize_exportedMessageLink);
_serializers.insert(mtpc_messageFwdHeader, _serialize_messageFwdHeader);

View File

@ -461,16 +461,13 @@ enum {
mtpc_inputBotInlineMessageMediaVenue = 0x8ab91f84,
mtpc_inputBotInlineMessageMediaContact = 0x52971c52,
mtpc_inputBotInlineResult = 0x2cbbe15a,
mtpc_inputBotInlineResultPhoto = 0x243edc26,
mtpc_inputBotInlineResultDocument = 0x11af9bcc,
mtpc_botInlineMessageMediaAuto = 0xfc56e87d,
mtpc_botInlineMessageText = 0xa56197a9,
mtpc_botInlineMessageMediaGeo = 0x59d1ff36,
mtpc_botInlineMessageMediaVenue = 0x6fa16678,
mtpc_botInlineMessageMediaContact = 0x89202361,
mtpc_botInlineMediaResultDocument = 0xf897d33e,
mtpc_botInlineMediaResultPhoto = 0xc5528587,
mtpc_botInlineResult = 0x9bebaeb9,
mtpc_botInlineMediaResult = 0x17db940b,
mtpc_messages_botResults = 0x1170b0a3,
mtpc_exportedMessageLink = 0x1f486803,
mtpc_messageFwdHeader = 0xc786ddcb,
@ -1270,8 +1267,6 @@ class MTPDinputBotInlineMessageMediaContact;
class MTPinputBotInlineResult;
class MTPDinputBotInlineResult;
class MTPDinputBotInlineResultPhoto;
class MTPDinputBotInlineResultDocument;
class MTPbotInlineMessage;
class MTPDbotInlineMessageMediaAuto;
@ -1281,9 +1276,8 @@ class MTPDbotInlineMessageMediaVenue;
class MTPDbotInlineMessageMediaContact;
class MTPbotInlineResult;
class MTPDbotInlineMediaResultDocument;
class MTPDbotInlineMediaResultPhoto;
class MTPDbotInlineResult;
class MTPDbotInlineMediaResult;
class MTPmessages_botResults;
class MTPDmessages_botResults;
@ -8744,64 +8738,32 @@ typedef MTPBoxed<MTPinputBotInlineMessage> MTPInputBotInlineMessage;
class MTPinputBotInlineResult : private mtpDataOwner {
public:
MTPinputBotInlineResult() : mtpDataOwner(0), _type(0) {
}
MTPinputBotInlineResult(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) : mtpDataOwner(0), _type(0) {
MTPinputBotInlineResult();
MTPinputBotInlineResult(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_inputBotInlineResult) : mtpDataOwner(0) {
read(from, end, cons);
}
MTPDinputBotInlineResult &_inputBotInlineResult() {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_inputBotInlineResult) throw mtpErrorWrongTypeId(_type, mtpc_inputBotInlineResult);
split();
return *(MTPDinputBotInlineResult*)data;
}
const MTPDinputBotInlineResult &c_inputBotInlineResult() const {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_inputBotInlineResult) throw mtpErrorWrongTypeId(_type, mtpc_inputBotInlineResult);
return *(const MTPDinputBotInlineResult*)data;
}
MTPDinputBotInlineResultPhoto &_inputBotInlineResultPhoto() {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_inputBotInlineResultPhoto) throw mtpErrorWrongTypeId(_type, mtpc_inputBotInlineResultPhoto);
split();
return *(MTPDinputBotInlineResultPhoto*)data;
}
const MTPDinputBotInlineResultPhoto &c_inputBotInlineResultPhoto() const {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_inputBotInlineResultPhoto) throw mtpErrorWrongTypeId(_type, mtpc_inputBotInlineResultPhoto);
return *(const MTPDinputBotInlineResultPhoto*)data;
}
MTPDinputBotInlineResultDocument &_inputBotInlineResultDocument() {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_inputBotInlineResultDocument) throw mtpErrorWrongTypeId(_type, mtpc_inputBotInlineResultDocument);
split();
return *(MTPDinputBotInlineResultDocument*)data;
}
const MTPDinputBotInlineResultDocument &c_inputBotInlineResultDocument() const {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_inputBotInlineResultDocument) throw mtpErrorWrongTypeId(_type, mtpc_inputBotInlineResultDocument);
return *(const MTPDinputBotInlineResultDocument*)data;
}
uint32 innerLength() const;
mtpTypeId type() const;
void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons);
void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_inputBotInlineResult);
void write(mtpBuffer &to) const;
typedef void ResponseType;
private:
explicit MTPinputBotInlineResult(mtpTypeId type);
explicit MTPinputBotInlineResult(MTPDinputBotInlineResult *_data);
explicit MTPinputBotInlineResult(MTPDinputBotInlineResultPhoto *_data);
explicit MTPinputBotInlineResult(MTPDinputBotInlineResultDocument *_data);
friend class MTP::internal::TypeCreator;
mtpTypeId _type;
};
typedef MTPBoxed<MTPinputBotInlineResult> MTPInputBotInlineResult;
@ -8902,30 +8864,6 @@ public:
read(from, end, cons);
}
MTPDbotInlineMediaResultDocument &_botInlineMediaResultDocument() {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_botInlineMediaResultDocument) throw mtpErrorWrongTypeId(_type, mtpc_botInlineMediaResultDocument);
split();
return *(MTPDbotInlineMediaResultDocument*)data;
}
const MTPDbotInlineMediaResultDocument &c_botInlineMediaResultDocument() const {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_botInlineMediaResultDocument) throw mtpErrorWrongTypeId(_type, mtpc_botInlineMediaResultDocument);
return *(const MTPDbotInlineMediaResultDocument*)data;
}
MTPDbotInlineMediaResultPhoto &_botInlineMediaResultPhoto() {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_botInlineMediaResultPhoto) throw mtpErrorWrongTypeId(_type, mtpc_botInlineMediaResultPhoto);
split();
return *(MTPDbotInlineMediaResultPhoto*)data;
}
const MTPDbotInlineMediaResultPhoto &c_botInlineMediaResultPhoto() const {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_botInlineMediaResultPhoto) throw mtpErrorWrongTypeId(_type, mtpc_botInlineMediaResultPhoto);
return *(const MTPDbotInlineMediaResultPhoto*)data;
}
MTPDbotInlineResult &_botInlineResult() {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_botInlineResult) throw mtpErrorWrongTypeId(_type, mtpc_botInlineResult);
@ -8938,6 +8876,18 @@ public:
return *(const MTPDbotInlineResult*)data;
}
MTPDbotInlineMediaResult &_botInlineMediaResult() {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_botInlineMediaResult) throw mtpErrorWrongTypeId(_type, mtpc_botInlineMediaResult);
split();
return *(MTPDbotInlineMediaResult*)data;
}
const MTPDbotInlineMediaResult &c_botInlineMediaResult() const {
if (!data) throw mtpErrorUninitialized();
if (_type != mtpc_botInlineMediaResult) throw mtpErrorWrongTypeId(_type, mtpc_botInlineMediaResult);
return *(const MTPDbotInlineMediaResult*)data;
}
uint32 innerLength() const;
mtpTypeId type() const;
void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons);
@ -8947,9 +8897,8 @@ public:
private:
explicit MTPbotInlineResult(mtpTypeId type);
explicit MTPbotInlineResult(MTPDbotInlineMediaResultDocument *_data);
explicit MTPbotInlineResult(MTPDbotInlineMediaResultPhoto *_data);
explicit MTPbotInlineResult(MTPDbotInlineResult *_data);
explicit MTPbotInlineResult(MTPDbotInlineMediaResult *_data);
friend class MTP::internal::TypeCreator;
@ -13496,56 +13445,6 @@ public:
MTPInputBotInlineMessage vsend_message;
};
class MTPDinputBotInlineResultPhoto : public mtpDataImpl<MTPDinputBotInlineResultPhoto> {
public:
enum class Flag : int32 {
MAX_FIELD = (1 << 0),
};
Q_DECLARE_FLAGS(Flags, Flag);
friend inline Flags operator~(Flag v) { return QFlag(~static_cast<int32>(v)); }
MTPDinputBotInlineResultPhoto() {
}
MTPDinputBotInlineResultPhoto(const MTPflags<MTPDinputBotInlineResultPhoto::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPInputPhoto &_photo, const MTPInputBotInlineMessage &_send_message) : vflags(_flags), vid(_id), vtype(_type), vphoto(_photo), vsend_message(_send_message) {
}
MTPflags<MTPDinputBotInlineResultPhoto::Flags> vflags;
MTPstring vid;
MTPstring vtype;
MTPInputPhoto vphoto;
MTPInputBotInlineMessage vsend_message;
};
class MTPDinputBotInlineResultDocument : public mtpDataImpl<MTPDinputBotInlineResultDocument> {
public:
enum class Flag : int32 {
f_title = (1 << 1),
f_description = (1 << 2),
f_document = (1 << 5),
MAX_FIELD = (1 << 5),
};
Q_DECLARE_FLAGS(Flags, Flag);
friend inline Flags operator~(Flag v) { return QFlag(~static_cast<int32>(v)); }
bool has_title() const { return vflags.v & Flag::f_title; }
bool has_description() const { return vflags.v & Flag::f_description; }
bool has_document() const { return vflags.v & Flag::f_document; }
MTPDinputBotInlineResultDocument() {
}
MTPDinputBotInlineResultDocument(const MTPflags<MTPDinputBotInlineResultDocument::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPInputDocument &_document, const MTPInputBotInlineMessage &_send_message) : vflags(_flags), vid(_id), vtype(_type), vtitle(_title), vdescription(_description), vdocument(_document), vsend_message(_send_message) {
}
MTPflags<MTPDinputBotInlineResultDocument::Flags> vflags;
MTPstring vid;
MTPstring vtype;
MTPstring vtitle;
MTPstring vdescription;
MTPInputDocument vdocument;
MTPInputBotInlineMessage vsend_message;
};
class MTPDbotInlineMessageMediaAuto : public mtpDataImpl<MTPDbotInlineMessageMediaAuto> {
public:
MTPDbotInlineMessageMediaAuto() {
@ -13616,32 +13515,6 @@ public:
MTPstring vlast_name;
};
class MTPDbotInlineMediaResultDocument : public mtpDataImpl<MTPDbotInlineMediaResultDocument> {
public:
MTPDbotInlineMediaResultDocument() {
}
MTPDbotInlineMediaResultDocument(const MTPstring &_id, const MTPstring &_type, const MTPDocument &_document, const MTPBotInlineMessage &_send_message) : vid(_id), vtype(_type), vdocument(_document), vsend_message(_send_message) {
}
MTPstring vid;
MTPstring vtype;
MTPDocument vdocument;
MTPBotInlineMessage vsend_message;
};
class MTPDbotInlineMediaResultPhoto : public mtpDataImpl<MTPDbotInlineMediaResultPhoto> {
public:
MTPDbotInlineMediaResultPhoto() {
}
MTPDbotInlineMediaResultPhoto(const MTPstring &_id, const MTPstring &_type, const MTPPhoto &_photo, const MTPBotInlineMessage &_send_message) : vid(_id), vtype(_type), vphoto(_photo), vsend_message(_send_message) {
}
MTPstring vid;
MTPstring vtype;
MTPPhoto vphoto;
MTPBotInlineMessage vsend_message;
};
class MTPDbotInlineResult : public mtpDataImpl<MTPDbotInlineResult> {
public:
enum class Flag : int32 {
@ -13690,6 +13563,39 @@ public:
MTPBotInlineMessage vsend_message;
};
class MTPDbotInlineMediaResult : public mtpDataImpl<MTPDbotInlineMediaResult> {
public:
enum class Flag : int32 {
f_photo = (1 << 0),
f_document = (1 << 1),
f_title = (1 << 2),
f_description = (1 << 3),
MAX_FIELD = (1 << 3),
};
Q_DECLARE_FLAGS(Flags, Flag);
friend inline Flags operator~(Flag v) { return QFlag(~static_cast<int32>(v)); }
bool has_photo() const { return vflags.v & Flag::f_photo; }
bool has_document() const { return vflags.v & Flag::f_document; }
bool has_title() const { return vflags.v & Flag::f_title; }
bool has_description() const { return vflags.v & Flag::f_description; }
MTPDbotInlineMediaResult() {
}
MTPDbotInlineMediaResult(const MTPflags<MTPDbotInlineMediaResult::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPPhoto &_photo, const MTPDocument &_document, const MTPstring &_title, const MTPstring &_description, const MTPBotInlineMessage &_send_message) : vflags(_flags), vid(_id), vtype(_type), vphoto(_photo), vdocument(_document), vtitle(_title), vdescription(_description), vsend_message(_send_message) {
}
MTPflags<MTPDbotInlineMediaResult::Flags> vflags;
MTPstring vid;
MTPstring vtype;
MTPPhoto vphoto;
MTPDocument vdocument;
MTPstring vtitle;
MTPstring vdescription;
MTPBotInlineMessage vsend_message;
};
class MTPDmessages_botResults : public mtpDataImpl<MTPDmessages_botResults> {
public:
enum class Flag : int32 {
@ -22769,12 +22675,6 @@ public:
inline static MTPinputBotInlineResult new_inputBotInlineResult(const MTPflags<MTPDinputBotInlineResult::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_url, const MTPstring &_thumb_url, const MTPstring &_content_url, const MTPstring &_content_type, MTPint _w, MTPint _h, MTPint _duration, const MTPInputBotInlineMessage &_send_message) {
return MTPinputBotInlineResult(new MTPDinputBotInlineResult(_flags, _id, _type, _title, _description, _url, _thumb_url, _content_url, _content_type, _w, _h, _duration, _send_message));
}
inline static MTPinputBotInlineResult new_inputBotInlineResultPhoto(const MTPflags<MTPDinputBotInlineResultPhoto::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPInputPhoto &_photo, const MTPInputBotInlineMessage &_send_message) {
return MTPinputBotInlineResult(new MTPDinputBotInlineResultPhoto(_flags, _id, _type, _photo, _send_message));
}
inline static MTPinputBotInlineResult new_inputBotInlineResultDocument(const MTPflags<MTPDinputBotInlineResultDocument::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPInputDocument &_document, const MTPInputBotInlineMessage &_send_message) {
return MTPinputBotInlineResult(new MTPDinputBotInlineResultDocument(_flags, _id, _type, _title, _description, _document, _send_message));
}
inline static MTPbotInlineMessage new_botInlineMessageMediaAuto(const MTPstring &_caption) {
return MTPbotInlineMessage(new MTPDbotInlineMessageMediaAuto(_caption));
}
@ -22790,15 +22690,12 @@ public:
inline static MTPbotInlineMessage new_botInlineMessageMediaContact(const MTPstring &_phone_number, const MTPstring &_first_name, const MTPstring &_last_name) {
return MTPbotInlineMessage(new MTPDbotInlineMessageMediaContact(_phone_number, _first_name, _last_name));
}
inline static MTPbotInlineResult new_botInlineMediaResultDocument(const MTPstring &_id, const MTPstring &_type, const MTPDocument &_document, const MTPBotInlineMessage &_send_message) {
return MTPbotInlineResult(new MTPDbotInlineMediaResultDocument(_id, _type, _document, _send_message));
}
inline static MTPbotInlineResult new_botInlineMediaResultPhoto(const MTPstring &_id, const MTPstring &_type, const MTPPhoto &_photo, const MTPBotInlineMessage &_send_message) {
return MTPbotInlineResult(new MTPDbotInlineMediaResultPhoto(_id, _type, _photo, _send_message));
}
inline static MTPbotInlineResult new_botInlineResult(const MTPflags<MTPDbotInlineResult::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_url, const MTPstring &_thumb_url, const MTPstring &_content_url, const MTPstring &_content_type, MTPint _w, MTPint _h, MTPint _duration, const MTPBotInlineMessage &_send_message) {
return MTPbotInlineResult(new MTPDbotInlineResult(_flags, _id, _type, _title, _description, _url, _thumb_url, _content_url, _content_type, _w, _h, _duration, _send_message));
}
inline static MTPbotInlineResult new_botInlineMediaResult(const MTPflags<MTPDbotInlineMediaResult::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPPhoto &_photo, const MTPDocument &_document, const MTPstring &_title, const MTPstring &_description, const MTPBotInlineMessage &_send_message) {
return MTPbotInlineResult(new MTPDbotInlineMediaResult(_flags, _id, _type, _photo, _document, _title, _description, _send_message));
}
inline static MTPmessages_botResults new_messages_botResults(const MTPflags<MTPDmessages_botResults::Flags> &_flags, const MTPlong &_query_id, const MTPstring &_next_offset, const MTPVector<MTPBotInlineResult> &_results) {
return MTPmessages_botResults(new MTPDmessages_botResults(_flags, _query_id, _next_offset, _results));
}
@ -33077,133 +32974,57 @@ inline MTPinputBotInlineMessage MTP_inputBotInlineMessageMediaContact(const MTPs
return MTP::internal::TypeCreator::new_inputBotInlineMessageMediaContact(_phone_number, _first_name, _last_name);
}
inline MTPinputBotInlineResult::MTPinputBotInlineResult() : mtpDataOwner(new MTPDinputBotInlineResult()) {
}
inline uint32 MTPinputBotInlineResult::innerLength() const {
switch (_type) {
case mtpc_inputBotInlineResult: {
const MTPDinputBotInlineResult &v(c_inputBotInlineResult());
return v.vflags.innerLength() + v.vid.innerLength() + v.vtype.innerLength() + (v.has_title() ? v.vtitle.innerLength() : 0) + (v.has_description() ? v.vdescription.innerLength() : 0) + (v.has_url() ? v.vurl.innerLength() : 0) + (v.has_thumb_url() ? v.vthumb_url.innerLength() : 0) + (v.has_content_url() ? v.vcontent_url.innerLength() : 0) + (v.has_content_type() ? v.vcontent_type.innerLength() : 0) + (v.has_w() ? v.vw.innerLength() : 0) + (v.has_h() ? v.vh.innerLength() : 0) + (v.has_duration() ? v.vduration.innerLength() : 0) + v.vsend_message.innerLength();
}
case mtpc_inputBotInlineResultPhoto: {
const MTPDinputBotInlineResultPhoto &v(c_inputBotInlineResultPhoto());
return v.vflags.innerLength() + v.vid.innerLength() + v.vtype.innerLength() + v.vphoto.innerLength() + v.vsend_message.innerLength();
}
case mtpc_inputBotInlineResultDocument: {
const MTPDinputBotInlineResultDocument &v(c_inputBotInlineResultDocument());
return v.vflags.innerLength() + v.vid.innerLength() + v.vtype.innerLength() + (v.has_title() ? v.vtitle.innerLength() : 0) + (v.has_description() ? v.vdescription.innerLength() : 0) + (v.has_document() ? v.vdocument.innerLength() : 0) + v.vsend_message.innerLength();
}
}
return 0;
const MTPDinputBotInlineResult &v(c_inputBotInlineResult());
return v.vflags.innerLength() + v.vid.innerLength() + v.vtype.innerLength() + (v.has_title() ? v.vtitle.innerLength() : 0) + (v.has_description() ? v.vdescription.innerLength() : 0) + (v.has_url() ? v.vurl.innerLength() : 0) + (v.has_thumb_url() ? v.vthumb_url.innerLength() : 0) + (v.has_content_url() ? v.vcontent_url.innerLength() : 0) + (v.has_content_type() ? v.vcontent_type.innerLength() : 0) + (v.has_w() ? v.vw.innerLength() : 0) + (v.has_h() ? v.vh.innerLength() : 0) + (v.has_duration() ? v.vduration.innerLength() : 0) + v.vsend_message.innerLength();
}
inline mtpTypeId MTPinputBotInlineResult::type() const {
if (!_type) throw mtpErrorUninitialized();
return _type;
return mtpc_inputBotInlineResult;
}
inline void MTPinputBotInlineResult::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) {
if (cons != _type) setData(0);
switch (cons) {
case mtpc_inputBotInlineResult: _type = cons; {
if (!data) setData(new MTPDinputBotInlineResult());
MTPDinputBotInlineResult &v(_inputBotInlineResult());
v.vflags.read(from, end);
v.vid.read(from, end);
v.vtype.read(from, end);
if (v.has_title()) { v.vtitle.read(from, end); } else { v.vtitle = MTPstring(); }
if (v.has_description()) { v.vdescription.read(from, end); } else { v.vdescription = MTPstring(); }
if (v.has_url()) { v.vurl.read(from, end); } else { v.vurl = MTPstring(); }
if (v.has_thumb_url()) { v.vthumb_url.read(from, end); } else { v.vthumb_url = MTPstring(); }
if (v.has_content_url()) { v.vcontent_url.read(from, end); } else { v.vcontent_url = MTPstring(); }
if (v.has_content_type()) { v.vcontent_type.read(from, end); } else { v.vcontent_type = MTPstring(); }
if (v.has_w()) { v.vw.read(from, end); } else { v.vw = MTPint(); }
if (v.has_h()) { v.vh.read(from, end); } else { v.vh = MTPint(); }
if (v.has_duration()) { v.vduration.read(from, end); } else { v.vduration = MTPint(); }
v.vsend_message.read(from, end);
} break;
case mtpc_inputBotInlineResultPhoto: _type = cons; {
if (!data) setData(new MTPDinputBotInlineResultPhoto());
MTPDinputBotInlineResultPhoto &v(_inputBotInlineResultPhoto());
v.vflags.read(from, end);
v.vid.read(from, end);
v.vtype.read(from, end);
v.vphoto.read(from, end);
v.vsend_message.read(from, end);
} break;
case mtpc_inputBotInlineResultDocument: _type = cons; {
if (!data) setData(new MTPDinputBotInlineResultDocument());
MTPDinputBotInlineResultDocument &v(_inputBotInlineResultDocument());
v.vflags.read(from, end);
v.vid.read(from, end);
v.vtype.read(from, end);
if (v.has_title()) { v.vtitle.read(from, end); } else { v.vtitle = MTPstring(); }
if (v.has_description()) { v.vdescription.read(from, end); } else { v.vdescription = MTPstring(); }
if (v.has_document()) { v.vdocument.read(from, end); } else { v.vdocument = MTPInputDocument(); }
v.vsend_message.read(from, end);
} break;
default: throw mtpErrorUnexpected(cons, "MTPinputBotInlineResult");
}
if (cons != mtpc_inputBotInlineResult) throw mtpErrorUnexpected(cons, "MTPinputBotInlineResult");
if (!data) setData(new MTPDinputBotInlineResult());
MTPDinputBotInlineResult &v(_inputBotInlineResult());
v.vflags.read(from, end);
v.vid.read(from, end);
v.vtype.read(from, end);
if (v.has_title()) { v.vtitle.read(from, end); } else { v.vtitle = MTPstring(); }
if (v.has_description()) { v.vdescription.read(from, end); } else { v.vdescription = MTPstring(); }
if (v.has_url()) { v.vurl.read(from, end); } else { v.vurl = MTPstring(); }
if (v.has_thumb_url()) { v.vthumb_url.read(from, end); } else { v.vthumb_url = MTPstring(); }
if (v.has_content_url()) { v.vcontent_url.read(from, end); } else { v.vcontent_url = MTPstring(); }
if (v.has_content_type()) { v.vcontent_type.read(from, end); } else { v.vcontent_type = MTPstring(); }
if (v.has_w()) { v.vw.read(from, end); } else { v.vw = MTPint(); }
if (v.has_h()) { v.vh.read(from, end); } else { v.vh = MTPint(); }
if (v.has_duration()) { v.vduration.read(from, end); } else { v.vduration = MTPint(); }
v.vsend_message.read(from, end);
}
inline void MTPinputBotInlineResult::write(mtpBuffer &to) const {
switch (_type) {
case mtpc_inputBotInlineResult: {
const MTPDinputBotInlineResult &v(c_inputBotInlineResult());
v.vflags.write(to);
v.vid.write(to);
v.vtype.write(to);
if (v.has_title()) v.vtitle.write(to);
if (v.has_description()) v.vdescription.write(to);
if (v.has_url()) v.vurl.write(to);
if (v.has_thumb_url()) v.vthumb_url.write(to);
if (v.has_content_url()) v.vcontent_url.write(to);
if (v.has_content_type()) v.vcontent_type.write(to);
if (v.has_w()) v.vw.write(to);
if (v.has_h()) v.vh.write(to);
if (v.has_duration()) v.vduration.write(to);
v.vsend_message.write(to);
} break;
case mtpc_inputBotInlineResultPhoto: {
const MTPDinputBotInlineResultPhoto &v(c_inputBotInlineResultPhoto());
v.vflags.write(to);
v.vid.write(to);
v.vtype.write(to);
v.vphoto.write(to);
v.vsend_message.write(to);
} break;
case mtpc_inputBotInlineResultDocument: {
const MTPDinputBotInlineResultDocument &v(c_inputBotInlineResultDocument());
v.vflags.write(to);
v.vid.write(to);
v.vtype.write(to);
if (v.has_title()) v.vtitle.write(to);
if (v.has_description()) v.vdescription.write(to);
if (v.has_document()) v.vdocument.write(to);
v.vsend_message.write(to);
} break;
}
const MTPDinputBotInlineResult &v(c_inputBotInlineResult());
v.vflags.write(to);
v.vid.write(to);
v.vtype.write(to);
if (v.has_title()) v.vtitle.write(to);
if (v.has_description()) v.vdescription.write(to);
if (v.has_url()) v.vurl.write(to);
if (v.has_thumb_url()) v.vthumb_url.write(to);
if (v.has_content_url()) v.vcontent_url.write(to);
if (v.has_content_type()) v.vcontent_type.write(to);
if (v.has_w()) v.vw.write(to);
if (v.has_h()) v.vh.write(to);
if (v.has_duration()) v.vduration.write(to);
v.vsend_message.write(to);
}
inline MTPinputBotInlineResult::MTPinputBotInlineResult(mtpTypeId type) : mtpDataOwner(0), _type(type) {
switch (type) {
case mtpc_inputBotInlineResult: setData(new MTPDinputBotInlineResult()); break;
case mtpc_inputBotInlineResultPhoto: setData(new MTPDinputBotInlineResultPhoto()); break;
case mtpc_inputBotInlineResultDocument: setData(new MTPDinputBotInlineResultDocument()); break;
default: throw mtpErrorBadTypeId(type, "MTPinputBotInlineResult");
}
}
inline MTPinputBotInlineResult::MTPinputBotInlineResult(MTPDinputBotInlineResult *_data) : mtpDataOwner(_data), _type(mtpc_inputBotInlineResult) {
}
inline MTPinputBotInlineResult::MTPinputBotInlineResult(MTPDinputBotInlineResultPhoto *_data) : mtpDataOwner(_data), _type(mtpc_inputBotInlineResultPhoto) {
}
inline MTPinputBotInlineResult::MTPinputBotInlineResult(MTPDinputBotInlineResultDocument *_data) : mtpDataOwner(_data), _type(mtpc_inputBotInlineResultDocument) {
inline MTPinputBotInlineResult::MTPinputBotInlineResult(MTPDinputBotInlineResult *_data) : mtpDataOwner(_data) {
}
Q_DECLARE_OPERATORS_FOR_FLAGS(MTPDinputBotInlineResult::Flags)
inline MTPinputBotInlineResult MTP_inputBotInlineResult(const MTPflags<MTPDinputBotInlineResult::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_url, const MTPstring &_thumb_url, const MTPstring &_content_url, const MTPstring &_content_type, MTPint _w, MTPint _h, MTPint _duration, const MTPInputBotInlineMessage &_send_message) {
return MTP::internal::TypeCreator::new_inputBotInlineResult(_flags, _id, _type, _title, _description, _url, _thumb_url, _content_url, _content_type, _w, _h, _duration, _send_message);
}
inline MTPinputBotInlineResult MTP_inputBotInlineResultPhoto(const MTPflags<MTPDinputBotInlineResultPhoto::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPInputPhoto &_photo, const MTPInputBotInlineMessage &_send_message) {
return MTP::internal::TypeCreator::new_inputBotInlineResultPhoto(_flags, _id, _type, _photo, _send_message);
}
Q_DECLARE_OPERATORS_FOR_FLAGS(MTPDinputBotInlineResultDocument::Flags)
inline MTPinputBotInlineResult MTP_inputBotInlineResultDocument(const MTPflags<MTPDinputBotInlineResultDocument::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPInputDocument &_document, const MTPInputBotInlineMessage &_send_message) {
return MTP::internal::TypeCreator::new_inputBotInlineResultDocument(_flags, _id, _type, _title, _description, _document, _send_message);
}
inline uint32 MTPbotInlineMessage::innerLength() const {
switch (_type) {
@ -33344,18 +33165,14 @@ inline MTPbotInlineMessage MTP_botInlineMessageMediaContact(const MTPstring &_ph
inline uint32 MTPbotInlineResult::innerLength() const {
switch (_type) {
case mtpc_botInlineMediaResultDocument: {
const MTPDbotInlineMediaResultDocument &v(c_botInlineMediaResultDocument());
return v.vid.innerLength() + v.vtype.innerLength() + v.vdocument.innerLength() + v.vsend_message.innerLength();
}
case mtpc_botInlineMediaResultPhoto: {
const MTPDbotInlineMediaResultPhoto &v(c_botInlineMediaResultPhoto());
return v.vid.innerLength() + v.vtype.innerLength() + v.vphoto.innerLength() + v.vsend_message.innerLength();
}
case mtpc_botInlineResult: {
const MTPDbotInlineResult &v(c_botInlineResult());
return v.vflags.innerLength() + v.vid.innerLength() + v.vtype.innerLength() + (v.has_title() ? v.vtitle.innerLength() : 0) + (v.has_description() ? v.vdescription.innerLength() : 0) + (v.has_url() ? v.vurl.innerLength() : 0) + (v.has_thumb_url() ? v.vthumb_url.innerLength() : 0) + (v.has_content_url() ? v.vcontent_url.innerLength() : 0) + (v.has_content_type() ? v.vcontent_type.innerLength() : 0) + (v.has_w() ? v.vw.innerLength() : 0) + (v.has_h() ? v.vh.innerLength() : 0) + (v.has_duration() ? v.vduration.innerLength() : 0) + v.vsend_message.innerLength();
}
case mtpc_botInlineMediaResult: {
const MTPDbotInlineMediaResult &v(c_botInlineMediaResult());
return v.vflags.innerLength() + v.vid.innerLength() + v.vtype.innerLength() + (v.has_photo() ? v.vphoto.innerLength() : 0) + (v.has_document() ? v.vdocument.innerLength() : 0) + (v.has_title() ? v.vtitle.innerLength() : 0) + (v.has_description() ? v.vdescription.innerLength() : 0) + v.vsend_message.innerLength();
}
}
return 0;
}
@ -33366,22 +33183,6 @@ inline mtpTypeId MTPbotInlineResult::type() const {
inline void MTPbotInlineResult::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) {
if (cons != _type) setData(0);
switch (cons) {
case mtpc_botInlineMediaResultDocument: _type = cons; {
if (!data) setData(new MTPDbotInlineMediaResultDocument());
MTPDbotInlineMediaResultDocument &v(_botInlineMediaResultDocument());
v.vid.read(from, end);
v.vtype.read(from, end);
v.vdocument.read(from, end);
v.vsend_message.read(from, end);
} break;
case mtpc_botInlineMediaResultPhoto: _type = cons; {
if (!data) setData(new MTPDbotInlineMediaResultPhoto());
MTPDbotInlineMediaResultPhoto &v(_botInlineMediaResultPhoto());
v.vid.read(from, end);
v.vtype.read(from, end);
v.vphoto.read(from, end);
v.vsend_message.read(from, end);
} break;
case mtpc_botInlineResult: _type = cons; {
if (!data) setData(new MTPDbotInlineResult());
MTPDbotInlineResult &v(_botInlineResult());
@ -33399,25 +33200,23 @@ inline void MTPbotInlineResult::read(const mtpPrime *&from, const mtpPrime *end,
if (v.has_duration()) { v.vduration.read(from, end); } else { v.vduration = MTPint(); }
v.vsend_message.read(from, end);
} break;
case mtpc_botInlineMediaResult: _type = cons; {
if (!data) setData(new MTPDbotInlineMediaResult());
MTPDbotInlineMediaResult &v(_botInlineMediaResult());
v.vflags.read(from, end);
v.vid.read(from, end);
v.vtype.read(from, end);
if (v.has_photo()) { v.vphoto.read(from, end); } else { v.vphoto = MTPPhoto(); }
if (v.has_document()) { v.vdocument.read(from, end); } else { v.vdocument = MTPDocument(); }
if (v.has_title()) { v.vtitle.read(from, end); } else { v.vtitle = MTPstring(); }
if (v.has_description()) { v.vdescription.read(from, end); } else { v.vdescription = MTPstring(); }
v.vsend_message.read(from, end);
} break;
default: throw mtpErrorUnexpected(cons, "MTPbotInlineResult");
}
}
inline void MTPbotInlineResult::write(mtpBuffer &to) const {
switch (_type) {
case mtpc_botInlineMediaResultDocument: {
const MTPDbotInlineMediaResultDocument &v(c_botInlineMediaResultDocument());
v.vid.write(to);
v.vtype.write(to);
v.vdocument.write(to);
v.vsend_message.write(to);
} break;
case mtpc_botInlineMediaResultPhoto: {
const MTPDbotInlineMediaResultPhoto &v(c_botInlineMediaResultPhoto());
v.vid.write(to);
v.vtype.write(to);
v.vphoto.write(to);
v.vsend_message.write(to);
} break;
case mtpc_botInlineResult: {
const MTPDbotInlineResult &v(c_botInlineResult());
v.vflags.write(to);
@ -33434,32 +33233,38 @@ inline void MTPbotInlineResult::write(mtpBuffer &to) const {
if (v.has_duration()) v.vduration.write(to);
v.vsend_message.write(to);
} break;
case mtpc_botInlineMediaResult: {
const MTPDbotInlineMediaResult &v(c_botInlineMediaResult());
v.vflags.write(to);
v.vid.write(to);
v.vtype.write(to);
if (v.has_photo()) v.vphoto.write(to);
if (v.has_document()) v.vdocument.write(to);
if (v.has_title()) v.vtitle.write(to);
if (v.has_description()) v.vdescription.write(to);
v.vsend_message.write(to);
} break;
}
}
inline MTPbotInlineResult::MTPbotInlineResult(mtpTypeId type) : mtpDataOwner(0), _type(type) {
switch (type) {
case mtpc_botInlineMediaResultDocument: setData(new MTPDbotInlineMediaResultDocument()); break;
case mtpc_botInlineMediaResultPhoto: setData(new MTPDbotInlineMediaResultPhoto()); break;
case mtpc_botInlineResult: setData(new MTPDbotInlineResult()); break;
case mtpc_botInlineMediaResult: setData(new MTPDbotInlineMediaResult()); break;
default: throw mtpErrorBadTypeId(type, "MTPbotInlineResult");
}
}
inline MTPbotInlineResult::MTPbotInlineResult(MTPDbotInlineMediaResultDocument *_data) : mtpDataOwner(_data), _type(mtpc_botInlineMediaResultDocument) {
}
inline MTPbotInlineResult::MTPbotInlineResult(MTPDbotInlineMediaResultPhoto *_data) : mtpDataOwner(_data), _type(mtpc_botInlineMediaResultPhoto) {
}
inline MTPbotInlineResult::MTPbotInlineResult(MTPDbotInlineResult *_data) : mtpDataOwner(_data), _type(mtpc_botInlineResult) {
}
inline MTPbotInlineResult MTP_botInlineMediaResultDocument(const MTPstring &_id, const MTPstring &_type, const MTPDocument &_document, const MTPBotInlineMessage &_send_message) {
return MTP::internal::TypeCreator::new_botInlineMediaResultDocument(_id, _type, _document, _send_message);
}
inline MTPbotInlineResult MTP_botInlineMediaResultPhoto(const MTPstring &_id, const MTPstring &_type, const MTPPhoto &_photo, const MTPBotInlineMessage &_send_message) {
return MTP::internal::TypeCreator::new_botInlineMediaResultPhoto(_id, _type, _photo, _send_message);
inline MTPbotInlineResult::MTPbotInlineResult(MTPDbotInlineMediaResult *_data) : mtpDataOwner(_data), _type(mtpc_botInlineMediaResult) {
}
Q_DECLARE_OPERATORS_FOR_FLAGS(MTPDbotInlineResult::Flags)
inline MTPbotInlineResult MTP_botInlineResult(const MTPflags<MTPDbotInlineResult::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_url, const MTPstring &_thumb_url, const MTPstring &_content_url, const MTPstring &_content_type, MTPint _w, MTPint _h, MTPint _duration, const MTPBotInlineMessage &_send_message) {
return MTP::internal::TypeCreator::new_botInlineResult(_flags, _id, _type, _title, _description, _url, _thumb_url, _content_url, _content_type, _w, _h, _duration, _send_message);
}
Q_DECLARE_OPERATORS_FOR_FLAGS(MTPDbotInlineMediaResult::Flags)
inline MTPbotInlineResult MTP_botInlineMediaResult(const MTPflags<MTPDbotInlineMediaResult::Flags> &_flags, const MTPstring &_id, const MTPstring &_type, const MTPPhoto &_photo, const MTPDocument &_document, const MTPstring &_title, const MTPstring &_description, const MTPBotInlineMessage &_send_message) {
return MTP::internal::TypeCreator::new_botInlineMediaResult(_flags, _id, _type, _photo, _document, _title, _description, _send_message);
}
inline MTPmessages_botResults::MTPmessages_botResults() : mtpDataOwner(new MTPDmessages_botResults()) {
}

View File

@ -78,8 +78,6 @@ bool gAskDownloadPath = false;
QString gDownloadPath;
QByteArray gDownloadPathBookmark;
bool gNeedConfigResave = false;
bool gCtrlEnter = false;
QPixmapPointer gChatBackground = 0;

View File

@ -99,7 +99,6 @@ DeclareSetting(bool, TileBackground);
DeclareSetting(bool, SoundNotify);
DeclareSetting(bool, IncludeMuted);
DeclareSetting(bool, NeedConfigResave);
DeclareSetting(bool, DesktopNotify);
DeclareSetting(DBINotifyView, NotifyView);
DeclareSetting(bool, AutoUpdate);

View File

@ -1442,8 +1442,100 @@ WebPageData::WebPageData(const WebPageId &id, WebPageType type, const QString &u
, pendingTill(pendingTill) {
}
InlineResultSendData::SentMTPMessageFields InlineResultSendText::getSentMessageFields(InlineResult*) const {
SentMTPMessageFields result;
result.text = MTP_string(_message);
result.entities = linksToMTP(_entities);
return result;
}
InlineResultSendData::SentMTPMessageFields InlineResultSendGeo::getSentMessageFields(InlineResult*) const {
SentMTPMessageFields result;
result.media = MTP_messageMediaGeo(MTP_geoPoint(MTP_double(_location.lon), MTP_double(_location.lat)));
return result;
}
InlineResultSendData::SentMTPMessageFields InlineResultSendVenue::getSentMessageFields(InlineResult*) const {
SentMTPMessageFields result;
result.media = MTP_messageMediaVenue(MTP_geoPoint(MTP_double(_location.lon), MTP_double(_location.lat)), MTP_string(_title), MTP_string(_address), MTP_string(_provider), MTP_string(_venueId));
return result;
}
InlineResultSendData::SentMTPMessageFields InlineResultSendContact::getSentMessageFields(InlineResult*) const {
SentMTPMessageFields result;
result.media = MTP_messageMediaContact(MTP_string(_phoneNumber), MTP_string(_firstName), MTP_string(_lastName), MTP_int(0));
return result;
}
InlineResultSendData::SentMTPMessageFields InlineResultSendPhoto::getSentMessageFields(InlineResult *owner) const {
SentMTPMessageFields result;
QImage fileThumb(owner->thumb->pix().toImage());
QVector<MTPPhotoSize> photoSizes;
QPixmap thumb = (fileThumb.width() > 100 || fileThumb.height() > 100) ? QPixmap::fromImage(fileThumb.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation), Qt::ColorOnly) : QPixmap::fromImage(fileThumb);
ImagePtr thumbPtr = ImagePtr(thumb, "JPG");
photoSizes.push_back(MTP_photoSize(MTP_string("s"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(thumb.width()), MTP_int(thumb.height()), MTP_int(0)));
QSize medium = resizeKeepAspect(owner->width, owner->height, 320, 320);
photoSizes.push_back(MTP_photoSize(MTP_string("m"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(medium.width()), MTP_int(medium.height()), MTP_int(0)));
photoSizes.push_back(MTP_photoSize(MTP_string("x"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(owner->width), MTP_int(owner->height), MTP_int(0)));
uint64 photoId = rand_value<uint64>();
PhotoData *ph = App::photoSet(photoId, 0, 0, unixtime(), thumbPtr, ImagePtr(medium.width(), medium.height()), ImagePtr(owner->width, owner->height));
MTPPhoto photo = MTP_photo(MTP_long(photoId), MTP_long(0), MTP_int(ph->date), MTP_vector<MTPPhotoSize>(photoSizes));
result.media = MTP_messageMediaPhoto(photo, MTP_string(_caption));
return result;
}
InlineResultSendData::SentMTPMessageFields InlineResultSendFile::getSentMessageFields(InlineResult *owner) const {
SentMTPMessageFields result;
MTPPhotoSize thumbSize;
QPixmap thumb;
int32 tw = owner->thumb->width(), th = owner->thumb->height();
if (tw > 0 && th > 0 && tw < 20 * th && th < 20 * tw && owner->thumb->loaded()) {
if (tw > th) {
if (tw > 90) {
th = th * 90 / tw;
tw = 90;
}
} else if (th > 90) {
tw = tw * 90 / th;
th = 90;
}
thumbSize = MTP_photoSize(MTP_string(""), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(tw), MTP_int(th), MTP_int(0));
thumb = owner->thumb->pixNoCache(tw, th, ImagePixSmooth);
} else {
tw = th = 0;
thumbSize = MTP_photoSizeEmpty(MTP_string(""));
}
uint64 docId = rand_value<uint64>();
QVector<MTPDocumentAttribute> attributes;
using Type = InlineResult::Type;
if (owner->type == Type::Gif) {
attributes.push_back(MTP_documentAttributeFilename(MTP_string((owner->content_type == qstr("video/mp4") ? "animation.gif.mp4" : "animation.gif"))));
attributes.push_back(MTP_documentAttributeAnimated());
attributes.push_back(MTP_documentAttributeVideo(MTP_int(owner->duration), MTP_int(owner->width), MTP_int(owner->height)));
}
MTPDocument document = MTP_document(MTP_long(docId), MTP_long(0), MTP_int(unixtime()), MTP_string(owner->content_type), MTP_int(owner->data().size()), thumbSize, MTP_int(MTP::maindc()), MTP_vector<MTPDocumentAttribute>(attributes));
if (tw > 0 && th > 0) {
App::feedDocument(document, thumb);
}
Local::writeStickerImage(mediaKey(DocumentFileLocation, MTP::maindc(), docId), owner->data());
result.media = MTP_messageMediaDocument(document, MTP_string(_caption));
return result;
}
void InlineResult::automaticLoadGif() {
if (loaded() || type != qstr("gif") || (content_type != qstr("video/mp4") && content_type != "image/gif")) return;
if (loaded() || type != Type::Gif || (content_type != qstr("video/mp4") && content_type != "image/gif")) return;
if (_loader != CancelledWebFileLoader) {
// if load at least anywhere

View File

@ -1026,13 +1026,13 @@ public:
ImagePtr makeReplyPreview();
StickerData *sticker() {
return (type == StickerDocument) ? static_cast<StickerData*>(_additional) : 0;
return (type == StickerDocument) ? static_cast<StickerData*>(_additional) : nullptr;
}
void checkSticker() {
StickerData *s = sticker();
if (!s) return;
automaticLoad(0);
automaticLoad(nullptr);
if (s->img->isNull() && loaded()) {
if (_data.isEmpty()) {
const FileLocation &loc(location(true));
@ -1046,16 +1046,16 @@ public:
}
}
SongData *song() {
return (type == SongDocument) ? static_cast<SongData*>(_additional) : 0;
return (type == SongDocument) ? static_cast<SongData*>(_additional) : nullptr;
}
const SongData *song() const {
return (type == SongDocument) ? static_cast<const SongData*>(_additional) : 0;
return (type == SongDocument) ? static_cast<const SongData*>(_additional) : nullptr;
}
VoiceData *voice() {
return (type == VoiceDocument) ? static_cast<VoiceData*>(_additional) : 0;
return (type == VoiceDocument) ? static_cast<VoiceData*>(_additional) : nullptr;
}
const VoiceData *voice() const {
return (type == VoiceDocument) ? static_cast<const VoiceData*>(_additional) : 0;
return (type == VoiceDocument) ? static_cast<const VoiceData*>(_additional) : nullptr;
}
bool isAnimation() const {
return (type == AnimatedDocument) || !mime.compare(qstr("image/gif"), Qt::CaseInsensitive);
@ -1246,30 +1246,220 @@ struct WebPageData {
};
class InlineResult;
// Abstract class describing the message that will be
// sent if the user chooses this inline bot result.
// For each type of message that can be sent there will be a subclass.
class InlineResultSendData {
public:
InlineResultSendData() = default;
InlineResultSendData(const InlineResultSendData &other) = delete;
InlineResultSendData &operator=(const InlineResultSendData &other) = delete;
virtual ~InlineResultSendData() = default;
virtual bool isValid() const = 0;
virtual DocumentData *getSentDocument() const {
return nullptr;
}
virtual PhotoData *getSentPhoto() const {
return nullptr;
}
virtual QString getSentCaption() const {
return QString();
}
struct SentMTPMessageFields {
MTPString text = MTP_string("");
MTPVector<MTPMessageEntity> entities = MTPnullEntities;
MTPMessageMedia media = MTP_messageMediaEmpty();
};
virtual SentMTPMessageFields getSentMessageFields(InlineResult *owner) const = 0;
};
// Plain text message.
class InlineResultSendText : public InlineResultSendData {
public:
InlineResultSendText(const QString &message, const EntitiesInText &entities, bool noWebPage)
: _message(message)
, _entities(entities)
, _noWebPage(noWebPage) {
}
bool isValid() const override {
return !_message.isEmpty();
}
SentMTPMessageFields getSentMessageFields(InlineResult *owner) const override;
private:
QString _message;
EntitiesInText _entities;
bool _noWebPage;
};
// Message with geo location point media.
class InlineResultSendGeo : public InlineResultSendData {
public:
InlineResultSendGeo(const MTPDgeoPoint &point) : _location(point) {
}
bool isValid() const override {
return true;
}
SentMTPMessageFields getSentMessageFields(InlineResult *owner) const override;
private:
LocationCoords _location;
};
// Message with venue media.
class InlineResultSendVenue : public InlineResultSendData {
public:
InlineResultSendVenue(const MTPDgeoPoint &point, const QString &venueId,
const QString &provider, const QString &title, const QString &address)
: _location(point)
, _venueId(venueId)
, _provider(provider)
, _title(title)
, _address(address) {
}
bool isValid() const override {
return true;
}
SentMTPMessageFields getSentMessageFields(InlineResult *owner) const override;
private:
LocationCoords _location;
QString _venueId, _provider, _title, _address;
};
// Message with shared contact media.
class InlineResultSendContact : public InlineResultSendData {
public:
InlineResultSendContact(const QString &firstName, const QString &lastName, const QString &phoneNumber)
: _firstName(firstName)
, _lastName(lastName)
, _phoneNumber(phoneNumber) {
}
bool isValid() const override {
return (!_firstName.isEmpty() || !_lastName.isEmpty()) && !_phoneNumber.isEmpty();
}
SentMTPMessageFields getSentMessageFields(InlineResult *owner) const override;
private:
QString _firstName, _lastName, _phoneNumber;
};
// Message with photo.
class InlineResultSendPhoto : public InlineResultSendData {
public:
InlineResultSendPhoto(PhotoData *photo, const QString &url, const QString &caption)
: _photo(photo)
, _url(url)
, _caption(caption) {
}
bool isValid() const override {
return _photo || !_url.isEmpty();
}
PhotoData *getSentPhoto() const override {
return _photo;
}
QString getSentCaption() const override {
return _caption;
}
SentMTPMessageFields getSentMessageFields(InlineResult *owner) const override;
private:
PhotoData *_photo;
QString _url, _caption;
};
// Message with file.
class InlineResultSendFile : public InlineResultSendData {
public:
InlineResultSendFile(DocumentData *document, const QString &url, const QString &caption)
: _document(document)
, _url(url)
, _caption(caption) {
}
bool isValid() const override {
return _document || !_url.isEmpty();
}
DocumentData *getSentDocument() const override {
return _document;
}
QString getSentCaption() const override {
return _caption;
}
SentMTPMessageFields getSentMessageFields(InlineResult *owner) const override;
private:
DocumentData *_document;
QString _url, _caption;
};
class InlineResult {
public:
InlineResult(uint64 queryId)
: queryId(queryId)
, doc(0)
, photo(0)
, width(0)
, height(0)
, duration(0)
, noWebPage(false)
, _loader(0) {
enum class Type {
Unknown,
Photo,
Video,
Audio,
Sticker,
File,
Gif,
Article,
Contact,
Venue,
};
static QMap<QString, Type> getTypesMap() {
QMap<QString, Type> result;
result.insert(qsl("photo"), Type::Photo);
result.insert(qsl("video"), Type::Video);
result.insert(qsl("audio"), Type::Audio);
result.insert(qsl("sticker"), Type::Sticker);
result.insert(qsl("file"), Type::File);
result.insert(qsl("gif"), Type::Gif);
result.insert(qsl("article"), Type::Article);
result.insert(qsl("contact"), Type::Contact);
result.insert(qsl("venue"), Type::Venue);
return result;
}
InlineResult(uint64 queryId, Type type) : queryId(queryId), type(type) {
}
InlineResult(const InlineResult &other) = delete;
InlineResult &operator=(const InlineResult &other) = delete;
uint64 queryId;
QString id, type;
DocumentData *doc;
PhotoData *photo;
QString id;
Type type;
DocumentData *document = nullptr;
PhotoData *photo = nullptr;
QString title, description, url, thumb_url;
QString content_type, content_url;
int32 width, height, duration;
int width = 0;
int height = 0;
int duration = 0;
QString message; // botContextMessageText
bool noWebPage; //currently not used
EntitiesInText entities;
QString caption; // if message.isEmpty() use botContextMessageMediaAuto
UniquePointer<InlineResultSendData> sendData;
ImagePtr thumb;
@ -1289,7 +1479,7 @@ public:
private:
QByteArray _data;
mutable webFileLoader *_loader;
mutable webFileLoader *_loader = nullptr;
};
typedef QList<InlineResult*> InlineResults;