diff --git a/Telegram/SourceFiles/boxes/photosendbox.cpp b/Telegram/SourceFiles/boxes/photosendbox.cpp index 6c7885291..d451841ad 100644 --- a/Telegram/SourceFiles/boxes/photosendbox.cpp +++ b/Telegram/SourceFiles/boxes/photosendbox.cpp @@ -266,11 +266,7 @@ void PhotoSendBox::showAll() { _cancel.show(); if (_file && _file->type == PreparePhoto) { _compressed.show(); - if (_compressed.checked()) { - _caption.show(); - } else { - _caption.hide(); - } + _caption.show(); } else { _caption.hide(); _compressed.hide(); @@ -300,7 +296,7 @@ void PhotoSendBox::onSend(bool ctrlShiftEnter) { } } if (!_caption.isHidden()) { - _file->photoCaption = prepareText(_caption.getLastText(), true); + _file->caption = prepareText(_caption.getLastText(), true); } App::main()->onSendFileConfirm(_file, ctrlShiftEnter); } else { diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index c01d7f6f8..7e046fdf6 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -90,7 +90,7 @@ namespace { inline const TextParseOptions &itemTextOptions(HistoryItem *item) { return itemTextOptions(item->history(), item->from()); } - inline const TextParseOptions &itemTextNoMonoOptions(HistoryItem *item) { + inline const TextParseOptions &itemTextNoMonoOptions(const HistoryItem *item) { return itemTextNoMonoOptions(item->history(), item->from()); } } @@ -1347,8 +1347,6 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPMessage &msg, boo return result; } - bool hasNotForwardedDocument = false; - switch (msg.type()) { case mtpc_messageEmpty: result = new HistoryServiceMsg(this, block, msg.c_messageEmpty().vid.v, date(), lang(lng_message_empty)); @@ -1397,7 +1395,7 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPMessage &msg, boo break; case mtpc_messageMediaDocument: switch (m.vmedia.c_messageMediaDocument().vdocument.type()) { - case mtpc_document: hasNotForwardedDocument = true; break; + case mtpc_document: break; case mtpc_documentEmpty: badMedia = 2; break; default: badMedia = 1; break; } @@ -1416,11 +1414,9 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPMessage &msg, boo } if (badMedia) { result = new HistoryServiceMsg(this, block, m.vid.v, date(m.vdate), lang((badMedia == 2) ? lng_message_empty : lng_media_unsupported), m.vflags.v, 0, m.has_from_id() ? m.vfrom_id.v : 0); - hasNotForwardedDocument = false; } else { if ((m.has_fwd_date() && m.vfwd_date.v > 0) || (m.has_fwd_from_id() && peerFromMTP(m.vfwd_from_id) != 0)) { result = new HistoryForwarded(this, block, m); - hasNotForwardedDocument = false; } else if (m.has_reply_to_msg_id() && m.vreply_to_msg_id.v > 0) { result = new HistoryReply(this, block, m); } else { @@ -1566,13 +1562,13 @@ HistoryItem *History::createItemForwarded(HistoryBlock *block, MsgId id, QDateTi return regItem(new HistoryForwarded(this, block, id, date, from, msg)); } -HistoryItem *History::createItemDocument(HistoryBlock *block, MsgId id, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc) { +HistoryItem *History::createItemDocument(HistoryBlock *block, MsgId id, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc, const QString &caption) { HistoryItem *result = 0; if (flags & MTPDmessage::flag_reply_to_msg_id && replyTo > 0) { - result = new HistoryReply(this, block, id, flags, replyTo, date, from, doc); + result = new HistoryReply(this, block, id, flags, replyTo, date, from, doc, caption); } else { - result = new HistoryMessage(this, block, id, flags, date, from, doc); + result = new HistoryMessage(this, block, id, flags, date, from, doc, caption); } return regItem(result); @@ -1638,7 +1634,7 @@ HistoryItem *History::addNewForwarded(MsgId id, QDateTime date, int32 from, Hist return addNewItem(to, newBlock, createItemForwarded(to, id, date, from, item), true); } -HistoryItem *History::addNewDocument(MsgId id, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc) { +HistoryItem *History::addNewDocument(MsgId id, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc, const QString &caption) { HistoryBlock *to = 0; bool newBlock = blocks.isEmpty(); if (newBlock) { @@ -1646,7 +1642,7 @@ HistoryItem *History::addNewDocument(MsgId id, int32 flags, MsgId replyTo, QDate } else { to = blocks.back(); } - return addNewItem(to, newBlock, createItemDocument(to, id, flags, replyTo, date, from, doc), true); + return addNewItem(to, newBlock, createItemDocument(to, id, flags, replyTo, date, from, doc, caption), true); } void History::createInitialDateBlock(const QDateTime &date) { @@ -3420,6 +3416,7 @@ void HistoryPhoto::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x bool inText = false; _caption.getState(lnk, inText, x - st::msgPadding.left(), y - height, captionw); state = inText ? HistoryInTextCursorState : HistoryDefaultCursorState; + return; } height -= st::mediaCaptionSkip; } @@ -3989,16 +3986,21 @@ bool HistoryAudio::updateStatusText(const HistoryItem *parent) const { return showPause; } -HistoryDocument::HistoryDocument(DocumentData *document) : HistoryFileMedia() +HistoryDocument::HistoryDocument(DocumentData *document, const QString &caption, const HistoryItem *parent) : HistoryFileMedia() , _data(document) , _linksavel(new DocumentSaveLink(_data)) , _linkcancell(new DocumentCancelLink(_data)) , _name(documentName(_data)) -, _namew(st::semiboldFont->width(_name)) { +, _namew(st::semiboldFont->width(_name)) +, _caption(st::msgFileMinWidth - st::msgPadding.left() - st::msgPadding.right()) { setLinks(new DocumentOpenLink(_data), new DocumentSaveLink(_data), new DocumentCancelLink(_data)); setStatusSize(FileStatusSizeReady); + if (!caption.isEmpty()) { + _caption.setText(st::msgFont, caption + parent->skipBlock(), itemTextNoMonoOptions(parent)); + } + if (withThumb()) { _data->thumb->load(); int32 tw = _data->thumb->width(), th = _data->thumb->height(); @@ -4025,6 +4027,10 @@ HistoryDocument::HistoryDocument(const HistoryDocument &other) : HistoryFileMedi } void HistoryDocument::initDimensions(const HistoryItem *parent) { + if (_caption.hasSkipBlock()) { + _caption.setSkipBlock(parent->skipBlockWidth(), parent->skipBlockHeight()); + } + _maxw = st::msgFileMinWidth; int32 tleft = 0, tright = 0; @@ -4047,7 +4053,29 @@ void HistoryDocument::initDimensions(const HistoryItem *parent) { } else { _minh = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom(); } - _height = _minh; + + if (_caption.isEmpty()) { + _height = _minh; + } else { + _minh += _caption.countHeight(_maxw - st::msgPadding.left() - st::msgPadding.right()) + st::msgPadding.bottom(); + } +} + +int32 HistoryDocument::resize(int32 width, const HistoryItem *parent) { + if (_caption.isEmpty()) { + return HistoryFileMedia::resize(width, parent); + } + + _width = qMin(width, _maxw); + bool wthumb = withThumb(); + if (wthumb) { + _height = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom(); + } else { + _height = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom(); + } + _height += _caption.countHeight(_width - st::msgPadding.left() - st::msgPadding.right()) + st::msgPadding.bottom(); + + return _height; } void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r, bool selected, uint64 ms) const { @@ -4056,6 +4084,8 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r _data->automaticLoad(parent); bool loaded = _data->loaded(), displayLoading = _data->displayLoading(); + int32 captionw = _width - st::msgPadding.left() - st::msgPadding.right(); + bool out = parent->out(), fromChannel = parent->fromChannel(), outbg = out && !fromChannel; if (displayLoading) { @@ -4067,7 +4097,7 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r bool showPause = updateStatusText(parent); bool radial = isRadialAnimation(ms); - int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0; + int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0, bottom = 0; bool wthumb = withThumb(); if (wthumb) { nameleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right(); @@ -4075,7 +4105,8 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r nameright = st::msgFileThumbPadding.left(); statustop = st::msgFileThumbStatusTop; linktop = st::msgFileThumbLinkTop; - + bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom(); + QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, _width)); if (_data->thumb->loaded()) { QPixmap thumb = loaded ? _data->thumb->pixSingle(_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize) : _data->thumb->pixBlurredSingle(_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize); @@ -4136,6 +4167,7 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r nametop = st::msgFileNameTop; nameright = st::msgFilePadding.left(); statustop = st::msgFileStatusTop; + bottom = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom(); QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); p.setPen(Qt::NoPen); @@ -4191,6 +4223,11 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r p.setFont(st::normalFont); p.setPen(status); p.drawTextLeft(nameleft, statustop, _width, _statusText); + + if (!_caption.isEmpty()) { + p.setPen(st::black); + _caption.draw(p, st::msgPadding.left(), bottom, captionw); + } } void HistoryDocument::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent) const { @@ -4201,11 +4238,12 @@ void HistoryDocument::getState(TextLinkPtr &lnk, HistoryCursorState &state, int3 bool showPause = updateStatusText(parent); - int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0; + int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0, bottom = 0; bool wthumb = withThumb(); if (wthumb) { nameleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right(); linktop = st::msgFileThumbLinkTop; + bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom(); QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, _width)); @@ -4221,13 +4259,26 @@ void HistoryDocument::getState(TextLinkPtr &lnk, HistoryCursorState &state, int3 } } } else { + bottom = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom(); + QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); if ((_data->loading() || _data->uploading() || !loaded) && inner.contains(x, y)) { lnk = (_data->loading() || _data->uploading()) ? _cancell : _savel; return; } } - if (x >= 0 && y >= 0 && x < _width && y < _height && !_data->loading() && !_data->uploading() && _data->access) { + + int32 height = _height; + if (!_caption.isEmpty()) { + if (y >= bottom) { + bool inText = false; + _caption.getState(lnk, inText, st::msgPadding.left(), y - bottom, _width - st::msgPadding.left() - st::msgPadding.right()); + state = inText ? HistoryInTextCursorState : HistoryDefaultCursorState; + return; + } + height -= _caption.countHeight(_width - st::msgPadding.left() - st::msgPadding.right()) + st::msgPadding.bottom(); + } + if (x >= 0 && y >= 0 && x < _width && y < height && !_data->loading() && !_data->uploading() && _data->access) { lnk = _openl; return; } @@ -4317,15 +4368,20 @@ ImagePtr HistoryDocument::replyPreview() { return _data->makeReplyPreview(); } -HistoryGif::HistoryGif(DocumentData *document) : HistoryFileMedia() +HistoryGif::HistoryGif(DocumentData *document, const QString &caption, const HistoryItem *parent) : HistoryFileMedia() , _data(document) , _thumbw(1) , _thumbh(1) +, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) , _gif(0) { setLinks(new GifOpenLink(_data), new GifOpenLink(_data), new DocumentCancelLink(_data)); setStatusSize(FileStatusSizeReady); + if (!caption.isEmpty()) { + _caption.setText(st::msgFont, caption + parent->skipBlock(), itemTextNoMonoOptions(parent)); + } + _data->thumb->load(); } @@ -4340,6 +4396,10 @@ HistoryGif::HistoryGif(const HistoryGif &other) : HistoryFileMedia() } void HistoryGif::initDimensions(const HistoryItem *parent) { + if (_caption.hasSkipBlock()) { + _caption.setSkipBlock(parent->skipBlockWidth(), parent->skipBlockHeight()); + } + bool bubble = parent->hasBubble(); int32 tw = 0, th = 0; if (gif() && _gif->state() == ClipError) { @@ -4383,6 +4443,9 @@ void HistoryGif::initDimensions(const HistoryItem *parent) { if (bubble) { _maxw += st::mediaPadding.left() + st::mediaPadding.right(); _minh += st::mediaPadding.top() + st::mediaPadding.bottom(); + if (!_caption.isEmpty()) { + _minh += st::mediaCaptionSkip + _caption.countHeight(_maxw - st::msgPadding.left() - st::msgPadding.right()) + st::msgPadding.bottom(); + } } } @@ -4435,6 +4498,9 @@ int32 HistoryGif::resize(int32 width, const HistoryItem *parent) { if (bubble) { _width += st::mediaPadding.left() + st::mediaPadding.right(); _height += st::mediaPadding.top() + st::mediaPadding.bottom(); + if (!_caption.isEmpty()) { + _height += st::mediaCaptionSkip + _caption.countHeight(_width - st::msgPadding.left() - st::msgPadding.right()) + st::msgPadding.bottom(); + } } return _height; @@ -4454,6 +4520,8 @@ void HistoryGif::draw(Painter &p, const HistoryItem *parent, const QRect &r, boo bool bubble = parent->hasBubble(); bool out = parent->out(), fromChannel = parent->fromChannel(), outbg = out && !fromChannel; + int32 captionw = width - st::msgPadding.left() - st::msgPadding.right(); + bool animating = (gif() && _gif->started()); if (!animating || _data->uploading()) { @@ -4473,6 +4541,9 @@ void HistoryGif::draw(Painter &p, const HistoryItem *parent, const QRect &r, boo width -= st::mediaPadding.left() + st::mediaPadding.right(); height -= skipy + st::mediaPadding.bottom(); + if (!_caption.isEmpty()) { + height -= st::mediaCaptionSkip + _caption.countHeight(captionw) + st::msgPadding.bottom(); + } } else { App::roundShadow(p, 0, 0, width, _height, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners); } @@ -4534,12 +4605,17 @@ void HistoryGif::draw(Painter &p, const HistoryItem *parent, const QRect &r, boo p.drawTextLeft(statusX, statusY, _width, _statusText, statusW - 2 * st::msgDateImgPadding.x()); // date - if (parent->getMedia() == this) { + if (_caption.isEmpty() && parent->getMedia() == this) { int32 fullRight = skipx + width, fullBottom = skipy + height; parent->drawInfo(p, fullRight, fullBottom, 2 * skipx + width, selected, InfoDisplayOverImage); } } } + + if (!_caption.isEmpty()) { + p.setPen(st::black); + _caption.draw(p, st::msgPadding.left(), skipy + height + st::mediaPadding.bottom() + st::mediaCaptionSkip, captionw); + } } void HistoryGif::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent) const { @@ -4550,6 +4626,17 @@ void HistoryGif::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, if (bubble) { skipx = st::mediaPadding.left(); skipy = st::mediaPadding.top(); + if (!_caption.isEmpty()) { + int32 captionw = width - st::msgPadding.left() - st::msgPadding.right(); + height -= _caption.countHeight(captionw) + st::msgPadding.bottom(); + if (x >= st::msgPadding.left() && y >= height && x < st::msgPadding.left() + captionw && y < _height) { + bool inText = false; + _caption.getState(lnk, inText, x - st::msgPadding.left(), y - height, captionw); + state = inText ? HistoryInTextCursorState : HistoryDefaultCursorState; + return; + } + height -= st::mediaCaptionSkip; + } width -= st::mediaPadding.left() + st::mediaPadding.right(); height -= skipy + st::mediaPadding.bottom(); } @@ -5058,9 +5145,9 @@ void HistoryWebPage::initDimensions(const HistoryItem *parent) { if (_data->doc->sticker()) { _attach = new HistorySticker(_data->doc); } else if (_data->doc->isAnimation()) { - _attach = new HistoryGif(_data->doc); + _attach = new HistoryGif(_data->doc, QString(), parent); } else { - _attach = new HistoryDocument(_data->doc); + _attach = new HistoryDocument(_data->doc, QString(), parent); } } else if (_data->photo) { _attach = new HistoryPhoto(_data->photo); @@ -5900,7 +5987,7 @@ HistoryItem(history, block, msgId, flags, date, from) setText(msg, entities); } -HistoryMessage::HistoryMessage(History *history, HistoryBlock *block, MsgId msgId, int32 flags, QDateTime date, int32 from, DocumentData *doc) : +HistoryMessage::HistoryMessage(History *history, HistoryBlock *block, MsgId msgId, int32 flags, QDateTime date, int32 from, DocumentData *doc, const QString &caption) : HistoryItem(history, block, msgId, flags, date, from) , _text(st::msgMinWidth) , _textWidth(0) @@ -5909,7 +5996,7 @@ HistoryItem(history, block, msgId, flags, date, from) , _views(fromChannel() ? 1 : -1) { initTime(); - initMediaFromDocument(doc); + initMediaFromDocument(doc, caption); setText(QString(), EntitiesInText()); } @@ -5981,8 +6068,7 @@ void HistoryMessage::initMedia(const MTPMessageMedia *media, QString ¤tTex case mtpc_messageMediaDocument: { const MTPDocument &document(media->c_messageMediaDocument().vdocument); if (document.type() == mtpc_document) { - DocumentData *doc = App::feedDocument(document); - return initMediaFromDocument(doc); + return initMediaFromDocument(App::feedDocument(document), qs(media->c_messageMediaDocument().vcaption)); } } break; case mtpc_messageMediaWebPage: { @@ -5990,8 +6076,7 @@ void HistoryMessage::initMedia(const MTPMessageMedia *media, QString ¤tTex switch (d.type()) { case mtpc_webPageEmpty: break; case mtpc_webPagePending: { - WebPageData *webPage = App::feedWebPage(d.c_webPagePending()); - _media = new HistoryWebPage(webPage); + _media = new HistoryWebPage(App::feedWebPage(d.c_webPagePending())); } break; case mtpc_webPage: { _media = new HistoryWebPage(App::feedWebPage(d.c_webPage())); @@ -6003,13 +6088,13 @@ void HistoryMessage::initMedia(const MTPMessageMedia *media, QString ¤tTex if (_media) _media->regItem(this); } -void HistoryMessage::initMediaFromDocument(DocumentData *doc) { +void HistoryMessage::initMediaFromDocument(DocumentData *doc, const QString &caption) { if (doc->sticker()) { _media = new HistorySticker(doc); } else if (doc->isAnimation()) { - _media = new HistoryGif(doc); + _media = new HistoryGif(doc, caption, this); } else { - _media = new HistoryDocument(doc); + _media = new HistoryDocument(doc, caption, this); } _media->regItem(this); } @@ -6727,7 +6812,8 @@ HistoryReply::HistoryReply(History *history, HistoryBlock *block, const MTPDmess } } -HistoryReply::HistoryReply(History *history, HistoryBlock *block, MsgId msgId, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc) : HistoryMessage(history, block, msgId, flags, date, from, doc) +HistoryReply::HistoryReply(History *history, HistoryBlock *block, MsgId msgId, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc, const QString &caption) +: HistoryMessage(history, block, msgId, flags, date, from, doc, caption) , replyToMsgId(replyTo) , replyToMsg(0) , replyToVersion(0) diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index 6342883df..97d39d640 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -196,13 +196,13 @@ public: HistoryItem *createItem(HistoryBlock *block, const MTPMessage &msg, bool applyServiceAction); HistoryItem *createItemForwarded(HistoryBlock *block, MsgId id, QDateTime date, int32 from, HistoryMessage *msg); - HistoryItem *createItemDocument(HistoryBlock *block, MsgId id, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc); + HistoryItem *createItemDocument(HistoryBlock *block, MsgId id, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc, const QString &caption); HistoryItem *addNewService(MsgId msgId, QDateTime date, const QString &text, int32 flags = 0, HistoryMedia *media = 0, bool newMsg = true); HistoryItem *addNewMessage(const MTPMessage &msg, NewMessageType type); HistoryItem *addToHistory(const MTPMessage &msg); HistoryItem *addNewForwarded(MsgId id, QDateTime date, int32 from, HistoryMessage *item); - HistoryItem *addNewDocument(MsgId id, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc); + HistoryItem *addNewDocument(MsgId id, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc, const QString &caption); void addOlderSlice(const QVector &slice, const QVector *collapsed); void addNewerSlice(const QVector &slice, const QVector *collapsed); @@ -1475,7 +1475,7 @@ private: class HistoryDocument : public HistoryFileMedia { public: - HistoryDocument(DocumentData *document); + HistoryDocument(DocumentData *document, const QString &caption, const HistoryItem *parent); HistoryDocument(const HistoryDocument &other); HistoryMediaType type() const { return MediaTypeDocument; @@ -1485,6 +1485,7 @@ public: } void initDimensions(const HistoryItem *parent); + int32 resize(int32 width, const HistoryItem *parent); void draw(Painter &p, const HistoryItem *parent, const QRect &r, bool selected, uint64 ms) const; void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent) const; @@ -1514,6 +1515,9 @@ public: } ImagePtr replyPreview(); + QString getCaption() const { + return _caption.original(); + } bool needsBubble(const HistoryItem *parent) const { return true; } @@ -1551,6 +1555,8 @@ private: mutable int32 _linkw; mutable QString _link; + Text _caption; + void setStatusSize(int32 newSize, qint64 realDuration = 0) const; bool updateStatusText(const HistoryItem *parent) const; // returns showPause @@ -1559,7 +1565,7 @@ private: class HistoryGif : public HistoryFileMedia { public: - HistoryGif(DocumentData *document); + HistoryGif(DocumentData *document, const QString &caption, const HistoryItem *parent); HistoryGif(const HistoryGif &other); HistoryMediaType type() const { return MediaTypeGif; @@ -1598,11 +1604,14 @@ public: } ImagePtr replyPreview(); + QString getCaption() const { + return _caption.original(); + } bool needsBubble(const HistoryItem *parent) const { - return parent->toHistoryReply(); + return !_caption.isEmpty() || parent->toHistoryReply(); } bool customInfoLayout() const { - return true; + return _caption.isEmpty(); } bool hideFromName() const { return true; @@ -1629,6 +1638,8 @@ private: DocumentData *_data; int32 _thumbw, _thumbh; + Text _caption; + ClipReader *_gif; ClipReader *gif() { return (_gif == BadClipReader) ? 0 : _gif; @@ -1935,11 +1946,11 @@ public: HistoryMessage(History *history, HistoryBlock *block, const MTPDmessage &msg); HistoryMessage(History *history, HistoryBlock *block, MsgId msgId, int32 flags, QDateTime date, int32 from, const QString &msg, const EntitiesInText &entities, HistoryMedia *media); // local forwarded - HistoryMessage(History *history, HistoryBlock *block, MsgId msgId, int32 flags, QDateTime date, int32 from, DocumentData *doc); // local sticker and reply sticker + HistoryMessage(History *history, HistoryBlock *block, MsgId msgId, int32 flags, QDateTime date, int32 from, DocumentData *doc, const QString &caption); // local sticker and reply sticker void initTime(); void initMedia(const MTPMessageMedia *media, QString ¤tText); - void initMediaFromDocument(DocumentData *doc); + void initMediaFromDocument(DocumentData *doc, const QString &caption); void initDimensions(); void fromNameUpdated() const; @@ -2121,7 +2132,7 @@ class HistoryReply : public HistoryMessage { public: HistoryReply(History *history, HistoryBlock *block, const MTPDmessage &msg); - HistoryReply(History *history, HistoryBlock *block, MsgId msgId, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc); + HistoryReply(History *history, HistoryBlock *block, MsgId msgId, int32 flags, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc, const QString &caption); void initDimensions(); diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 3e0b70b5c..412028bd3 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -5397,9 +5397,9 @@ void HistoryWidget::confirmSendFile(const FileLoadResultPtr &file, bool ctrlShif flags |= MTPDmessage::flag_from_id; } if (file->type == PreparePhoto) { - h->addNewMessage(MTP_message(MTP_int(flags), MTP_int(newId.msg), MTP_int(fromChannelName ? 0 : MTP::authedId()), peerToMTP(file->to.peer), MTPPeer(), MTPint(), MTP_int(file->to.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaPhoto(file->photo, MTP_string(file->photoCaption)), MTPnullMarkup, MTPnullEntities, MTP_int(1)), NewMessageUnread); + h->addNewMessage(MTP_message(MTP_int(flags), MTP_int(newId.msg), MTP_int(fromChannelName ? 0 : MTP::authedId()), peerToMTP(file->to.peer), MTPPeer(), MTPint(), MTP_int(file->to.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaPhoto(file->photo, MTP_string(file->caption)), MTPnullMarkup, MTPnullEntities, MTP_int(1)), NewMessageUnread); } else if (file->type == PrepareDocument) { - h->addNewMessage(MTP_message(MTP_int(flags), MTP_int(newId.msg), MTP_int(fromChannelName ? 0 : MTP::authedId()), peerToMTP(file->to.peer), MTPPeer(), MTPint(), MTP_int(file->to.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaDocument(file->document), MTPnullMarkup, MTPnullEntities, MTP_int(1)), NewMessageUnread); + h->addNewMessage(MTP_message(MTP_int(flags), MTP_int(newId.msg), MTP_int(fromChannelName ? 0 : MTP::authedId()), peerToMTP(file->to.peer), MTPPeer(), MTPint(), MTP_int(file->to.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaDocument(file->document, MTP_string(file->caption)), MTPnullMarkup, MTPnullEntities, MTP_int(1)), NewMessageUnread); } else if (file->type == PrepareAudio) { if (!h->peer->isChannel()) { flags |= MTPDmessage::flag_media_unread; @@ -5500,7 +5500,7 @@ void HistoryWidget::onDocumentUploaded(const FullMsgId &newId, const MTPInputFil if (fromChannelName) { sendFlags |= MTPmessages_SendMedia::flag_broadcast; } - hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedDocument(file, MTP_string(document->mime), _composeDocumentAttributes(document)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId); + hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedDocument(file, MTP_string(document->mime), _composeDocumentAttributes(document), MTP_string("")), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId); } } } @@ -5524,7 +5524,7 @@ void HistoryWidget::onThumbDocumentUploaded(const FullMsgId &newId, const MTPInp if (fromChannelName) { sendFlags |= MTPmessages_SendMedia::flag_broadcast; } - hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedThumbDocument(file, thumb, MTP_string(document->mime), _composeDocumentAttributes(document)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId); + hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedThumbDocument(file, thumb, MTP_string(document->mime), _composeDocumentAttributes(document), MTP_string("")), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId); } } } @@ -6242,9 +6242,9 @@ void HistoryWidget::onStickerSend(DocumentData *sticker) { } else { flags |= MTPDmessage::flag_from_id; } - _history->addNewDocument(newId.msg, flags, replyToId(), date(MTP_int(unixtime())), fromChannelName ? 0 : MTP::authedId(), sticker); + _history->addNewDocument(newId.msg, flags, replyToId(), date(MTP_int(unixtime())), fromChannelName ? 0 : MTP::authedId(), sticker, QString()); - _history->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), _peer->input, MTP_int(replyToId()), MTP_inputMediaDocument(MTP_inputDocument(MTP_long(sticker->id), MTP_long(sticker->access))), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, _history->sendRequestId); + _history->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), _peer->input, MTP_int(replyToId()), MTP_inputMediaDocument(MTP_inputDocument(MTP_long(sticker->id), MTP_long(sticker->access)), MTP_string("")), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, _history->sendRequestId); App::main()->finishForwarding(_history, _broadcast.checked()); cancelReply(lastKeyboardUsed); diff --git a/Telegram/SourceFiles/localimageloader.h b/Telegram/SourceFiles/localimageloader.h index eace95819..47ef7441f 100644 --- a/Telegram/SourceFiles/localimageloader.h +++ b/Telegram/SourceFiles/localimageloader.h @@ -207,7 +207,7 @@ struct FileLoadResult { MTPDocument document; PreparedPhotoThumbs photoThumbs; - QString photoCaption; + QString caption; QString originalText; // when pasted had an image mime save text mime here to insert if image send was cancelled diff --git a/Telegram/SourceFiles/mtproto/mtpScheme.cpp b/Telegram/SourceFiles/mtproto/mtpScheme.cpp index 4fa0d5eb3..53a603bdb 100644 --- a/Telegram/SourceFiles/mtproto/mtpScheme.cpp +++ b/Telegram/SourceFiles/mtproto/mtpScheme.cpp @@ -734,6 +734,7 @@ void _serialize_inputMediaUploadedDocument(MTPStringLogger &to, int32 stage, int case 0: to.add(" file: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 1: to.add(" mime_type: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 2: to.add(" attributes: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 3: to.add(" caption: "); ++stages.back(); types.push_back(mtpc_string); 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; } } @@ -750,6 +751,7 @@ void _serialize_inputMediaUploadedThumbDocument(MTPStringLogger &to, int32 stage case 1: to.add(" thumb: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 2: to.add(" mime_type: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 3: to.add(" attributes: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 4: to.add(" caption: "); ++stages.back(); types.push_back(mtpc_string); 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; } } @@ -763,6 +765,7 @@ void _serialize_inputMediaDocument(MTPStringLogger &to, int32 stage, int32 lev, } switch (stage) { case 0: to.add(" id: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" caption: "); ++stages.back(); types.push_back(mtpc_string); 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; } } @@ -798,6 +801,23 @@ void _serialize_inputMediaGifExternal(MTPStringLogger &to, int32 stage, int32 le } } +void _serialize_inputMediaContextBotResult(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { + if (stage) { + to.add(",\n").addSpaces(lev); + } else { + to.add("{ inputMediaContextBotResult"); + 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_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" media: "); ++stages.back(); if (flag & MTPDinputMediaContextBotResult::flag_media) { to.add("YES [ BY BIT 0 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break; + case 2: to.add(" bot: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 3: to.add(" url: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 4: to.add(" query_id: "); ++stages.back(); types.push_back(mtpc_long); 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_inputChatPhotoEmpty(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { to.add("{ inputChatPhotoEmpty }"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); } @@ -1141,6 +1161,7 @@ void _serialize_user(MTPStringLogger &to, int32 stage, int32 lev, Types &types, case 17: to.add(" status: "); ++stages.back(); if (flag & MTPDuser::flag_status) { types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 6 IN FIELD flags ]"); } break; case 18: to.add(" bot_info_version: "); ++stages.back(); if (flag & MTPDuser::flag_bot_info_version) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 14 IN FIELD flags ]"); } break; case 19: to.add(" restriction_reason: "); ++stages.back(); if (flag & MTPDuser::flag_restriction_reason) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 18 IN FIELD flags ]"); } break; + case 20: to.add(" bot_context_placeholder: "); ++stages.back(); if (flag & MTPDuser::flag_bot_context_placeholder) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 19 IN FIELD flags ]"); } break; default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; } } @@ -1579,6 +1600,7 @@ void _serialize_messageMediaDocument(MTPStringLogger &to, int32 stage, int32 lev } switch (stage) { case 0: to.add(" document: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" caption: "); ++stages.back(); types.push_back(mtpc_string); 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; } } @@ -3047,6 +3069,22 @@ void _serialize_updateSavedGifs(MTPStringLogger &to, int32 stage, int32 lev, Typ to.add("{ updateSavedGifs }"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); } +void _serialize_updateBotContextQuery(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { + if (stage) { + to.add(",\n").addSpaces(lev); + } else { + to.add("{ updateBotContextQuery"); + to.add("\n").addSpaces(lev); + } + switch (stage) { + case 0: to.add(" query_id: "); ++stages.back(); types.push_back(mtpc_long); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" user_id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 2: to.add(" query: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 3: to.add(" offset: "); ++stages.back(); types.push_back(mtpc_string); 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_updates_state(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { if (stage) { to.add(",\n").addSpaces(lev); @@ -5134,6 +5172,62 @@ void _serialize_messages_savedGifs(MTPStringLogger &to, int32 stage, int32 lev, } } +void _serialize_inputBotContextResult(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { + if (stage) { + to.add(",\n").addSpaces(lev); + } else { + to.add("{ inputBotContextResult"); + 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_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" hide_url: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_hide_url) { to.add("YES [ BY BIT 20 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 20 IN FIELD flags ]"); } break; + case 2: to.add(" url: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 3: to.add(" type: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_type) { types.push_back(mtpc_string); 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(" title: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_title) { types.push_back(mtpc_string); 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(" description: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_description) { types.push_back(mtpc_string); 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(" thumb_url: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_thumb_url) { types.push_back(mtpc_string); 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(" content_url: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_content_url) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break; + case 8: to.add(" content_type: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_content_type) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break; + case 9: to.add(" w: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_w) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 5 IN FIELD flags ]"); } break; + case 10: to.add(" h: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_h) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 5 IN FIELD flags ]"); } break; + case 11: to.add(" duration: "); ++stages.back(); if (flag & MTPDinputBotContextResult::flag_duration) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 6 IN FIELD flags ]"); } break; + default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; + } +} + +void _serialize_botContextResult(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { + if (stage) { + to.add(",\n").addSpaces(lev); + } else { + to.add("{ botContextResult"); + 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_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" hide_url: "); ++stages.back(); if (flag & MTPDbotContextResult::flag_hide_url) { to.add("YES [ BY BIT 0 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break; + case 2: to.add(" webpage: "); ++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 flag) { + if (stage) { + to.add(",\n").addSpaces(lev); + } else { + to.add("{ messages_botResults"); + 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_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" media: "); ++stages.back(); if (flag & MTPDmessages_botResults::flag_media) { to.add("YES [ BY BIT 0 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break; + case 2: to.add(" query_id: "); ++stages.back(); types.push_back(mtpc_long); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 3: to.add(" next_offset: "); ++stages.back(); if (flag & MTPDmessages_botResults::flag_next_offset) { types.push_back(mtpc_string); 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(" results: "); ++stages.back(); types.push_back(00); 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_req_pq(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { if (stage) { to.add(",\n").addSpaces(lev); @@ -5662,6 +5756,25 @@ void _serialize_messages_saveGif(MTPStringLogger &to, int32 stage, int32 lev, Ty } } +void _serialize_messages_setContextBotResults(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { + if (stage) { + to.add(",\n").addSpaces(lev); + } else { + to.add("{ messages_setContextBotResults"); + 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_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" media: "); ++stages.back(); if (flag & MTPmessages_setContextBotResults::flag_media) { to.add("YES [ BY BIT 0 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break; + case 2: to.add(" private: "); ++stages.back(); if (flag & MTPmessages_setContextBotResults::flag_private) { to.add("YES [ BY BIT 1 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 1 IN FIELD flags ]"); } break; + case 3: to.add(" query_id: "); ++stages.back(); types.push_back(mtpc_long); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 4: to.add(" results: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 5: to.add(" cache_time: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 6: to.add(" next_offset: "); ++stages.back(); if (flag & MTPmessages_setContextBotResults::flag_next_offset) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 2 IN FIELD flags ]"); } break; + default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; + } +} + void _serialize_upload_saveFilePart(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { if (stage) { to.add(",\n").addSpaces(lev); @@ -7152,6 +7265,21 @@ void _serialize_messages_getSavedGifs(MTPStringLogger &to, int32 stage, int32 le } } +void _serialize_messages_getContextBotResults(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { + if (stage) { + to.add(",\n").addSpaces(lev); + } else { + to.add("{ messages_getContextBotResults"); + to.add("\n").addSpaces(lev); + } + switch (stage) { + case 0: to.add(" bot: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 1: to.add(" query: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; + case 2: to.add(" offset: "); ++stages.back(); types.push_back(mtpc_string); 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_updates_getState(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { to.add("{ updates_getState }"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); } @@ -7457,6 +7585,7 @@ namespace { _serializers.insert(mtpc_inputMediaDocument, _serialize_inputMediaDocument); _serializers.insert(mtpc_inputMediaVenue, _serialize_inputMediaVenue); _serializers.insert(mtpc_inputMediaGifExternal, _serialize_inputMediaGifExternal); + _serializers.insert(mtpc_inputMediaContextBotResult, _serialize_inputMediaContextBotResult); _serializers.insert(mtpc_inputChatPhotoEmpty, _serialize_inputChatPhotoEmpty); _serializers.insert(mtpc_inputChatUploadedPhoto, _serialize_inputChatUploadedPhoto); _serializers.insert(mtpc_inputChatPhoto, _serialize_inputChatPhoto); @@ -7642,6 +7771,7 @@ namespace { _serializers.insert(mtpc_updateStickerSetsOrder, _serialize_updateStickerSetsOrder); _serializers.insert(mtpc_updateStickerSets, _serialize_updateStickerSets); _serializers.insert(mtpc_updateSavedGifs, _serialize_updateSavedGifs); + _serializers.insert(mtpc_updateBotContextQuery, _serialize_updateBotContextQuery); _serializers.insert(mtpc_updates_state, _serialize_updates_state); _serializers.insert(mtpc_updates_differenceEmpty, _serialize_updates_differenceEmpty); _serializers.insert(mtpc_updates_difference, _serialize_updates_difference); @@ -7812,6 +7942,9 @@ namespace { _serializers.insert(mtpc_messages_foundGifs, _serialize_messages_foundGifs); _serializers.insert(mtpc_messages_savedGifsNotModified, _serialize_messages_savedGifsNotModified); _serializers.insert(mtpc_messages_savedGifs, _serialize_messages_savedGifs); + _serializers.insert(mtpc_inputBotContextResult, _serialize_inputBotContextResult); + _serializers.insert(mtpc_botContextResult, _serialize_botContextResult); + _serializers.insert(mtpc_messages_botResults, _serialize_messages_botResults); _serializers.insert(mtpc_req_pq, _serialize_req_pq); _serializers.insert(mtpc_req_DH_params, _serialize_req_DH_params); @@ -7853,6 +7986,7 @@ namespace { _serializers.insert(mtpc_messages_editChatAdmin, _serialize_messages_editChatAdmin); _serializers.insert(mtpc_messages_reorderStickerSets, _serialize_messages_reorderStickerSets); _serializers.insert(mtpc_messages_saveGif, _serialize_messages_saveGif); + _serializers.insert(mtpc_messages_setContextBotResults, _serialize_messages_setContextBotResults); _serializers.insert(mtpc_upload_saveFilePart, _serialize_upload_saveFilePart); _serializers.insert(mtpc_upload_saveBigFilePart, _serialize_upload_saveBigFilePart); _serializers.insert(mtpc_help_saveAppLog, _serialize_help_saveAppLog); @@ -7962,6 +8096,7 @@ namespace { _serializers.insert(mtpc_messages_getDocumentByHash, _serialize_messages_getDocumentByHash); _serializers.insert(mtpc_messages_searchGifs, _serialize_messages_searchGifs); _serializers.insert(mtpc_messages_getSavedGifs, _serialize_messages_getSavedGifs); + _serializers.insert(mtpc_messages_getContextBotResults, _serialize_messages_getContextBotResults); _serializers.insert(mtpc_updates_getState, _serialize_updates_getState); _serializers.insert(mtpc_updates_getDifference, _serialize_updates_getDifference); _serializers.insert(mtpc_updates_getChannelDifference, _serialize_updates_getChannelDifference); diff --git a/Telegram/SourceFiles/mtproto/mtpScheme.h b/Telegram/SourceFiles/mtproto/mtpScheme.h index 2e3909c79..7deb0b400 100644 --- a/Telegram/SourceFiles/mtproto/mtpScheme.h +++ b/Telegram/SourceFiles/mtproto/mtpScheme.h @@ -92,11 +92,12 @@ enum { mtpc_inputMediaVideo = 0x936a4ebd, mtpc_inputMediaUploadedAudio = 0x4e498cab, mtpc_inputMediaAudio = 0x89938781, - mtpc_inputMediaUploadedDocument = 0xffe76b78, - mtpc_inputMediaUploadedThumbDocument = 0x41481486, - mtpc_inputMediaDocument = 0xd184e841, + mtpc_inputMediaUploadedDocument = 0x1d89306d, + mtpc_inputMediaUploadedThumbDocument = 0xad613491, + mtpc_inputMediaDocument = 0x1a77f29c, mtpc_inputMediaVenue = 0x2827a81a, mtpc_inputMediaGifExternal = 0x4843b0fd, + mtpc_inputMediaContextBotResult = 0x48720fe8, mtpc_inputChatPhotoEmpty = 0x1ca48f57, mtpc_inputChatUploadedPhoto = 0x94254732, mtpc_inputChatPhoto = 0xb2e1bf08, @@ -130,7 +131,7 @@ enum { mtpc_fileLocationUnavailable = 0x7c596b46, mtpc_fileLocation = 0x53d69076, mtpc_userEmpty = 0x200250ba, - mtpc_user = 0x603539b4, + mtpc_user = 0xcb574c74, mtpc_userProfilePhotoEmpty = 0x4f11bae1, mtpc_userProfilePhoto = 0xd559d8c8, mtpc_userStatusEmpty = 0x9d05049, @@ -162,7 +163,7 @@ enum { mtpc_messageMediaGeo = 0x56e0d474, mtpc_messageMediaContact = 0x5e7d2f39, mtpc_messageMediaUnsupported = 0x9f84f49e, - mtpc_messageMediaDocument = 0x2fda2204, + mtpc_messageMediaDocument = 0xf3e02ea8, mtpc_messageMediaAudio = 0xc6b68300, mtpc_messageMediaWebPage = 0xa32dd600, mtpc_messageMediaVenue = 0x7912b71f, @@ -282,6 +283,7 @@ enum { mtpc_updateStickerSetsOrder = 0xf0dfb451, mtpc_updateStickerSets = 0x43ae3dec, mtpc_updateSavedGifs = 0x9375341e, + mtpc_updateBotContextQuery = 0x934bca16, mtpc_updates_state = 0xa56c2a3e, mtpc_updates_differenceEmpty = 0x5d75a138, mtpc_updates_difference = 0xf49ca0, @@ -452,6 +454,9 @@ enum { mtpc_messages_foundGifs = 0x450a1c0a, mtpc_messages_savedGifsNotModified = 0xe8025ca2, mtpc_messages_savedGifs = 0x2e0709a5, + mtpc_inputBotContextResult = 0xa47850c5, + mtpc_botContextResult = 0xea0b7eec, + mtpc_messages_botResults = 0x772740b1, mtpc_invokeAfterMsg = 0xcb9f372d, mtpc_invokeAfterMsgs = 0x3dc4b4f0, mtpc_initConnection = 0x69796de9, @@ -565,6 +570,8 @@ enum { mtpc_messages_searchGifs = 0xbf9a776b, mtpc_messages_getSavedGifs = 0x83bf3d52, mtpc_messages_saveGif = 0x327a30cb, + mtpc_messages_getContextBotResults = 0x36e7d06c, + mtpc_messages_setContextBotResults = 0xd7f2de0f, mtpc_updates_getState = 0xedd4882a, mtpc_updates_getDifference = 0xa041495, mtpc_updates_getChannelDifference = 0xbb32d7c0, @@ -719,6 +726,7 @@ class MTPDinputMediaUploadedThumbDocument; class MTPDinputMediaDocument; class MTPDinputMediaVenue; class MTPDinputMediaGifExternal; +class MTPDinputMediaContextBotResult; class MTPinputChatPhoto; class MTPDinputChatUploadedPhoto; @@ -964,6 +972,7 @@ class MTPDupdateChatAdmins; class MTPDupdateChatParticipantAdmin; class MTPDupdateNewStickerSet; class MTPDupdateStickerSetsOrder; +class MTPDupdateBotContextQuery; class MTPupdates_state; class MTPDupdates_state; @@ -1238,6 +1247,15 @@ class MTPDmessages_foundGifs; class MTPmessages_savedGifs; class MTPDmessages_savedGifs; +class MTPinputBotContextResult; +class MTPDinputBotContextResult; + +class MTPbotContextResult; +class MTPDbotContextResult; + +class MTPmessages_botResults; +class MTPDmessages_botResults; + // Boxed types definitions typedef MTPBoxed MTPResPQ; @@ -1400,6 +1418,9 @@ typedef MTPBoxed MTPhelp_TermsOfService; typedef MTPBoxed MTPFoundGif; typedef MTPBoxed MTPmessages_FoundGifs; typedef MTPBoxed MTPmessages_SavedGifs; +typedef MTPBoxed MTPInputBotContextResult; +typedef MTPBoxed MTPBotContextResult; +typedef MTPBoxed MTPmessages_BotResults; // Type classes definitions @@ -2638,6 +2659,18 @@ public: return *(const MTPDinputMediaGifExternal*)data; } + MTPDinputMediaContextBotResult &_inputMediaContextBotResult() { + if (!data) throw mtpErrorUninitialized(); + if (_type != mtpc_inputMediaContextBotResult) throw mtpErrorWrongTypeId(_type, mtpc_inputMediaContextBotResult); + split(); + return *(MTPDinputMediaContextBotResult*)data; + } + const MTPDinputMediaContextBotResult &c_inputMediaContextBotResult() const { + if (!data) throw mtpErrorUninitialized(); + if (_type != mtpc_inputMediaContextBotResult) throw mtpErrorWrongTypeId(_type, mtpc_inputMediaContextBotResult); + return *(const MTPDinputMediaContextBotResult*)data; + } + uint32 innerLength() const; mtpTypeId type() const; void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons); @@ -2661,6 +2694,7 @@ private: explicit MTPinputMedia(MTPDinputMediaDocument *_data); explicit MTPinputMedia(MTPDinputMediaVenue *_data); explicit MTPinputMedia(MTPDinputMediaGifExternal *_data); + explicit MTPinputMedia(MTPDinputMediaContextBotResult *_data); friend MTPinputMedia MTP_inputMediaEmpty(); friend MTPinputMedia MTP_inputMediaUploadedPhoto(const MTPInputFile &_file, const MTPstring &_caption); @@ -2672,11 +2706,12 @@ private: friend MTPinputMedia MTP_inputMediaVideo(const MTPInputVideo &_id, const MTPstring &_caption); friend MTPinputMedia MTP_inputMediaUploadedAudio(const MTPInputFile &_file, MTPint _duration, const MTPstring &_mime_type); friend MTPinputMedia MTP_inputMediaAudio(const MTPInputAudio &_id); - friend MTPinputMedia MTP_inputMediaUploadedDocument(const MTPInputFile &_file, const MTPstring &_mime_type, const MTPVector &_attributes); - friend MTPinputMedia MTP_inputMediaUploadedThumbDocument(const MTPInputFile &_file, const MTPInputFile &_thumb, const MTPstring &_mime_type, const MTPVector &_attributes); - friend MTPinputMedia MTP_inputMediaDocument(const MTPInputDocument &_id); + friend MTPinputMedia MTP_inputMediaUploadedDocument(const MTPInputFile &_file, const MTPstring &_mime_type, const MTPVector &_attributes, const MTPstring &_caption); + friend MTPinputMedia MTP_inputMediaUploadedThumbDocument(const MTPInputFile &_file, const MTPInputFile &_thumb, const MTPstring &_mime_type, const MTPVector &_attributes, const MTPstring &_caption); + friend MTPinputMedia MTP_inputMediaDocument(const MTPInputDocument &_id, const MTPstring &_caption); friend MTPinputMedia MTP_inputMediaVenue(const MTPInputGeoPoint &_geo_point, const MTPstring &_title, const MTPstring &_address, const MTPstring &_provider, const MTPstring &_venue_id); friend MTPinputMedia MTP_inputMediaGifExternal(const MTPstring &_url, const MTPstring &_q); + friend MTPinputMedia MTP_inputMediaContextBotResult(MTPint _flags, const MTPInputUser &_bot, const MTPstring &_url, const MTPlong &_query_id); mtpTypeId _type; }; @@ -3204,7 +3239,7 @@ private: explicit MTPuser(MTPDuser *_data); friend MTPuser MTP_userEmpty(MTPint _id); - friend MTPuser MTP_user(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_first_name, const MTPstring &_last_name, const MTPstring &_username, const MTPstring &_phone, const MTPUserProfilePhoto &_photo, const MTPUserStatus &_status, MTPint _bot_info_version, const MTPstring &_restriction_reason); + friend MTPuser MTP_user(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_first_name, const MTPstring &_last_name, const MTPstring &_username, const MTPstring &_phone, const MTPUserProfilePhoto &_photo, const MTPUserStatus &_status, MTPint _bot_info_version, const MTPstring &_restriction_reason, const MTPstring &_bot_context_placeholder); mtpTypeId _type; }; @@ -3794,7 +3829,7 @@ private: friend MTPmessageMedia MTP_messageMediaGeo(const MTPGeoPoint &_geo); friend MTPmessageMedia MTP_messageMediaContact(const MTPstring &_phone_number, const MTPstring &_first_name, const MTPstring &_last_name, MTPint _user_id); friend MTPmessageMedia MTP_messageMediaUnsupported(); - friend MTPmessageMedia MTP_messageMediaDocument(const MTPDocument &_document); + friend MTPmessageMedia MTP_messageMediaDocument(const MTPDocument &_document, const MTPstring &_caption); friend MTPmessageMedia MTP_messageMediaAudio(const MTPAudio &_audio); friend MTPmessageMedia MTP_messageMediaWebPage(const MTPWebPage &_webpage); friend MTPmessageMedia MTP_messageMediaVenue(const MTPGeoPoint &_geo, const MTPstring &_title, const MTPstring &_address, const MTPstring &_provider, const MTPstring &_venue_id); @@ -5690,6 +5725,18 @@ public: return *(const MTPDupdateStickerSetsOrder*)data; } + MTPDupdateBotContextQuery &_updateBotContextQuery() { + if (!data) throw mtpErrorUninitialized(); + if (_type != mtpc_updateBotContextQuery) throw mtpErrorWrongTypeId(_type, mtpc_updateBotContextQuery); + split(); + return *(MTPDupdateBotContextQuery*)data; + } + const MTPDupdateBotContextQuery &c_updateBotContextQuery() const { + if (!data) throw mtpErrorUninitialized(); + if (_type != mtpc_updateBotContextQuery) throw mtpErrorWrongTypeId(_type, mtpc_updateBotContextQuery); + return *(const MTPDupdateBotContextQuery*)data; + } + uint32 innerLength() const; mtpTypeId type() const; void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons); @@ -5738,6 +5785,7 @@ private: explicit MTPupdate(MTPDupdateChatParticipantAdmin *_data); explicit MTPupdate(MTPDupdateNewStickerSet *_data); explicit MTPupdate(MTPDupdateStickerSetsOrder *_data); + explicit MTPupdate(MTPDupdateBotContextQuery *_data); friend MTPupdate MTP_updateNewMessage(const MTPMessage &_message, MTPint _pts, MTPint _pts_count); friend MTPupdate MTP_updateMessageID(MTPint _id, const MTPlong &_random_id); @@ -5780,6 +5828,7 @@ private: friend MTPupdate MTP_updateStickerSetsOrder(const MTPVector &_order); friend MTPupdate MTP_updateStickerSets(); friend MTPupdate MTP_updateSavedGifs(); + friend MTPupdate MTP_updateBotContextQuery(const MTPlong &_query_id, MTPint _user_id, const MTPstring &_query, const MTPstring &_offset); mtpTypeId _type; }; @@ -9063,6 +9112,99 @@ private: }; typedef MTPBoxed MTPmessages_SavedGifs; +class MTPinputBotContextResult : private mtpDataOwner { +public: + MTPinputBotContextResult(); + MTPinputBotContextResult(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_inputBotContextResult) : mtpDataOwner(0) { + read(from, end, cons); + } + + MTPDinputBotContextResult &_inputBotContextResult() { + if (!data) throw mtpErrorUninitialized(); + split(); + return *(MTPDinputBotContextResult*)data; + } + const MTPDinputBotContextResult &c_inputBotContextResult() const { + if (!data) throw mtpErrorUninitialized(); + return *(const MTPDinputBotContextResult*)data; + } + + uint32 innerLength() const; + mtpTypeId type() const; + void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_inputBotContextResult); + void write(mtpBuffer &to) const; + + typedef void ResponseType; + +private: + explicit MTPinputBotContextResult(MTPDinputBotContextResult *_data); + + friend MTPinputBotContextResult MTP_inputBotContextResult(MTPint _flags, const MTPstring &_url, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_thumb_url, const MTPstring &_content_url, const MTPstring &_content_type, MTPint _w, MTPint _h, MTPint _duration); +}; +typedef MTPBoxed MTPInputBotContextResult; + +class MTPbotContextResult : private mtpDataOwner { +public: + MTPbotContextResult(); + MTPbotContextResult(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_botContextResult) : mtpDataOwner(0) { + read(from, end, cons); + } + + MTPDbotContextResult &_botContextResult() { + if (!data) throw mtpErrorUninitialized(); + split(); + return *(MTPDbotContextResult*)data; + } + const MTPDbotContextResult &c_botContextResult() const { + if (!data) throw mtpErrorUninitialized(); + return *(const MTPDbotContextResult*)data; + } + + uint32 innerLength() const; + mtpTypeId type() const; + void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_botContextResult); + void write(mtpBuffer &to) const; + + typedef void ResponseType; + +private: + explicit MTPbotContextResult(MTPDbotContextResult *_data); + + friend MTPbotContextResult MTP_botContextResult(MTPint _flags, const MTPWebPage &_webpage); +}; +typedef MTPBoxed MTPBotContextResult; + +class MTPmessages_botResults : private mtpDataOwner { +public: + MTPmessages_botResults(); + MTPmessages_botResults(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_botResults) : mtpDataOwner(0) { + read(from, end, cons); + } + + MTPDmessages_botResults &_messages_botResults() { + if (!data) throw mtpErrorUninitialized(); + split(); + return *(MTPDmessages_botResults*)data; + } + const MTPDmessages_botResults &c_messages_botResults() const { + if (!data) throw mtpErrorUninitialized(); + return *(const MTPDmessages_botResults*)data; + } + + uint32 innerLength() const; + mtpTypeId type() const; + void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_botResults); + void write(mtpBuffer &to) const; + + typedef void ResponseType; + +private: + explicit MTPmessages_botResults(MTPDmessages_botResults *_data); + + friend MTPmessages_botResults MTP_messages_botResults(MTPint _flags, const MTPlong &_query_id, const MTPstring &_next_offset, const MTPVector &_results); +}; +typedef MTPBoxed MTPmessages_BotResults; + // Type constructors with data class MTPDresPQ : public mtpDataImpl { @@ -9589,35 +9731,38 @@ class MTPDinputMediaUploadedDocument : public mtpDataImpl &_attributes) : vfile(_file), vmime_type(_mime_type), vattributes(_attributes) { + MTPDinputMediaUploadedDocument(const MTPInputFile &_file, const MTPstring &_mime_type, const MTPVector &_attributes, const MTPstring &_caption) : vfile(_file), vmime_type(_mime_type), vattributes(_attributes), vcaption(_caption) { } MTPInputFile vfile; MTPstring vmime_type; MTPVector vattributes; + MTPstring vcaption; }; class MTPDinputMediaUploadedThumbDocument : public mtpDataImpl { public: MTPDinputMediaUploadedThumbDocument() { } - MTPDinputMediaUploadedThumbDocument(const MTPInputFile &_file, const MTPInputFile &_thumb, const MTPstring &_mime_type, const MTPVector &_attributes) : vfile(_file), vthumb(_thumb), vmime_type(_mime_type), vattributes(_attributes) { + MTPDinputMediaUploadedThumbDocument(const MTPInputFile &_file, const MTPInputFile &_thumb, const MTPstring &_mime_type, const MTPVector &_attributes, const MTPstring &_caption) : vfile(_file), vthumb(_thumb), vmime_type(_mime_type), vattributes(_attributes), vcaption(_caption) { } MTPInputFile vfile; MTPInputFile vthumb; MTPstring vmime_type; MTPVector vattributes; + MTPstring vcaption; }; class MTPDinputMediaDocument : public mtpDataImpl { public: MTPDinputMediaDocument() { } - MTPDinputMediaDocument(const MTPInputDocument &_id) : vid(_id) { + MTPDinputMediaDocument(const MTPInputDocument &_id, const MTPstring &_caption) : vid(_id), vcaption(_caption) { } MTPInputDocument vid; + MTPstring vcaption; }; class MTPDinputMediaVenue : public mtpDataImpl { @@ -9645,6 +9790,25 @@ public: MTPstring vq; }; +class MTPDinputMediaContextBotResult : public mtpDataImpl { +public: + MTPDinputMediaContextBotResult() { + } + MTPDinputMediaContextBotResult(MTPint _flags, const MTPInputUser &_bot, const MTPstring &_url, const MTPlong &_query_id) : vflags(_flags), vbot(_bot), vurl(_url), vquery_id(_query_id) { + } + + MTPint vflags; + MTPInputUser vbot; + MTPstring vurl; + MTPlong vquery_id; + + enum { + flag_media = (1 << 0), + }; + + bool is_media() const { return vflags.v & flag_media; } +}; + class MTPDinputChatUploadedPhoto : public mtpDataImpl { public: MTPDinputChatUploadedPhoto() { @@ -9850,7 +10014,7 @@ class MTPDuser : public mtpDataImpl { public: MTPDuser() { } - MTPDuser(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_first_name, const MTPstring &_last_name, const MTPstring &_username, const MTPstring &_phone, const MTPUserProfilePhoto &_photo, const MTPUserStatus &_status, MTPint _bot_info_version, const MTPstring &_restriction_reason) : vflags(_flags), vid(_id), vaccess_hash(_access_hash), vfirst_name(_first_name), vlast_name(_last_name), vusername(_username), vphone(_phone), vphoto(_photo), vstatus(_status), vbot_info_version(_bot_info_version), vrestriction_reason(_restriction_reason) { + MTPDuser(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_first_name, const MTPstring &_last_name, const MTPstring &_username, const MTPstring &_phone, const MTPUserProfilePhoto &_photo, const MTPUserStatus &_status, MTPint _bot_info_version, const MTPstring &_restriction_reason, const MTPstring &_bot_context_placeholder) : vflags(_flags), vid(_id), vaccess_hash(_access_hash), vfirst_name(_first_name), vlast_name(_last_name), vusername(_username), vphone(_phone), vphoto(_photo), vstatus(_status), vbot_info_version(_bot_info_version), vrestriction_reason(_restriction_reason), vbot_context_placeholder(_bot_context_placeholder) { } MTPint vflags; @@ -9864,6 +10028,7 @@ public: MTPUserStatus vstatus; MTPint vbot_info_version; MTPstring vrestriction_reason; + MTPstring vbot_context_placeholder; enum { flag_self = (1 << 10), @@ -9884,6 +10049,7 @@ public: flag_status = (1 << 6), flag_bot_info_version = (1 << 14), flag_restriction_reason = (1 << 18), + flag_bot_context_placeholder = (1 << 19), }; bool is_self() const { return vflags.v & flag_self; } @@ -9904,6 +10070,7 @@ public: bool has_status() const { return vflags.v & flag_status; } bool has_bot_info_version() const { return vflags.v & flag_bot_info_version; } bool has_restriction_reason() const { return vflags.v & flag_restriction_reason; } + bool has_bot_context_placeholder() const { return vflags.v & flag_bot_context_placeholder; } }; class MTPDuserProfilePhoto : public mtpDataImpl { @@ -10318,10 +10485,11 @@ class MTPDmessageMediaDocument : public mtpDataImpl { public: MTPDmessageMediaDocument() { } - MTPDmessageMediaDocument(const MTPDocument &_document) : vdocument(_document) { + MTPDmessageMediaDocument(const MTPDocument &_document, const MTPstring &_caption) : vdocument(_document), vcaption(_caption) { } MTPDocument vdocument; + MTPstring vcaption; }; class MTPDmessageMediaAudio : public mtpDataImpl { @@ -11410,6 +11578,19 @@ public: MTPVector vorder; }; +class MTPDupdateBotContextQuery : public mtpDataImpl { +public: + MTPDupdateBotContextQuery() { + } + MTPDupdateBotContextQuery(const MTPlong &_query_id, MTPint _user_id, const MTPstring &_query, const MTPstring &_offset) : vquery_id(_query_id), vuser_id(_user_id), vquery(_query), voffset(_offset) { + } + + MTPlong vquery_id; + MTPint vuser_id; + MTPstring vquery; + MTPstring voffset; +}; + class MTPDupdates_state : public mtpDataImpl { public: MTPDupdates_state() { @@ -13110,6 +13291,88 @@ public: MTPVector vgifs; }; +class MTPDinputBotContextResult : public mtpDataImpl { +public: + MTPDinputBotContextResult() { + } + MTPDinputBotContextResult(MTPint _flags, const MTPstring &_url, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_thumb_url, const MTPstring &_content_url, const MTPstring &_content_type, MTPint _w, MTPint _h, MTPint _duration) : vflags(_flags), vurl(_url), vtype(_type), vtitle(_title), vdescription(_description), vthumb_url(_thumb_url), vcontent_url(_content_url), vcontent_type(_content_type), vw(_w), vh(_h), vduration(_duration) { + } + + MTPint vflags; + MTPstring vurl; + MTPstring vtype; + MTPstring vtitle; + MTPstring vdescription; + MTPstring vthumb_url; + MTPstring vcontent_url; + MTPstring vcontent_type; + MTPint vw; + MTPint vh; + MTPint vduration; + + enum { + flag_hide_url = (1 << 20), + flag_type = (1 << 0), + flag_title = (1 << 1), + flag_description = (1 << 2), + flag_thumb_url = (1 << 3), + flag_content_url = (1 << 4), + flag_content_type = (1 << 4), + flag_w = (1 << 5), + flag_h = (1 << 5), + flag_duration = (1 << 6), + }; + + bool is_hide_url() const { return vflags.v & flag_hide_url; } + bool has_type() const { return vflags.v & flag_type; } + bool has_title() const { return vflags.v & flag_title; } + bool has_description() const { return vflags.v & flag_description; } + bool has_thumb_url() const { return vflags.v & flag_thumb_url; } + bool has_content_url() const { return vflags.v & flag_content_url; } + bool has_content_type() const { return vflags.v & flag_content_type; } + bool has_w() const { return vflags.v & flag_w; } + bool has_h() const { return vflags.v & flag_h; } + bool has_duration() const { return vflags.v & flag_duration; } +}; + +class MTPDbotContextResult : public mtpDataImpl { +public: + MTPDbotContextResult() { + } + MTPDbotContextResult(MTPint _flags, const MTPWebPage &_webpage) : vflags(_flags), vwebpage(_webpage) { + } + + MTPint vflags; + MTPWebPage vwebpage; + + enum { + flag_hide_url = (1 << 0), + }; + + bool is_hide_url() const { return vflags.v & flag_hide_url; } +}; + +class MTPDmessages_botResults : public mtpDataImpl { +public: + MTPDmessages_botResults() { + } + MTPDmessages_botResults(MTPint _flags, const MTPlong &_query_id, const MTPstring &_next_offset, const MTPVector &_results) : vflags(_flags), vquery_id(_query_id), vnext_offset(_next_offset), vresults(_results) { + } + + MTPint vflags; + MTPlong vquery_id; + MTPstring vnext_offset; + MTPVector vresults; + + enum { + flag_media = (1 << 0), + flag_next_offset = (1 << 1), + }; + + bool is_media() const { return vflags.v & flag_media; } + bool has_next_offset() const { return vflags.v & flag_next_offset; } +}; + // RPC methods class MTPreq_pq { // RPC method 'req_pq' @@ -18228,6 +18491,112 @@ public: } }; +class MTPmessages_getContextBotResults { // RPC method 'messages.getContextBotResults' +public: + MTPInputUser vbot; + MTPstring vquery; + MTPstring voffset; + + MTPmessages_getContextBotResults() { + } + MTPmessages_getContextBotResults(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_getContextBotResults) { + read(from, end, cons); + } + MTPmessages_getContextBotResults(const MTPInputUser &_bot, const MTPstring &_query, const MTPstring &_offset) : vbot(_bot), vquery(_query), voffset(_offset) { + } + + uint32 innerLength() const { + return vbot.innerLength() + vquery.innerLength() + voffset.innerLength(); + } + mtpTypeId type() const { + return mtpc_messages_getContextBotResults; + } + void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_getContextBotResults) { + vbot.read(from, end); + vquery.read(from, end); + voffset.read(from, end); + } + void write(mtpBuffer &to) const { + vbot.write(to); + vquery.write(to); + voffset.write(to); + } + + typedef MTPmessages_BotResults ResponseType; +}; +class MTPmessages_GetContextBotResults : public MTPBoxed { +public: + MTPmessages_GetContextBotResults() { + } + MTPmessages_GetContextBotResults(const MTPmessages_getContextBotResults &v) : MTPBoxed(v) { + } + MTPmessages_GetContextBotResults(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = 0) : MTPBoxed(from, end, cons) { + } + MTPmessages_GetContextBotResults(const MTPInputUser &_bot, const MTPstring &_query, const MTPstring &_offset) : MTPBoxed(MTPmessages_getContextBotResults(_bot, _query, _offset)) { + } +}; + +class MTPmessages_setContextBotResults { // RPC method 'messages.setContextBotResults' +public: + MTPint vflags; + MTPlong vquery_id; + MTPVector vresults; + MTPint vcache_time; + MTPstring vnext_offset; + + MTPmessages_setContextBotResults() { + } + MTPmessages_setContextBotResults(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_setContextBotResults) { + read(from, end, cons); + } + MTPmessages_setContextBotResults(MTPint _flags, const MTPlong &_query_id, const MTPVector &_results, MTPint _cache_time, const MTPstring &_next_offset) : vflags(_flags), vquery_id(_query_id), vresults(_results), vcache_time(_cache_time), vnext_offset(_next_offset) { + } + + enum { + flag_media = (1 << 0), + flag_private = (1 << 1), + flag_next_offset = (1 << 2), + }; + + bool is_media() const { return vflags.v & flag_media; } + bool is_private() const { return vflags.v & flag_private; } + bool has_next_offset() const { return vflags.v & flag_next_offset; } + + uint32 innerLength() const { + return vflags.innerLength() + vquery_id.innerLength() + vresults.innerLength() + vcache_time.innerLength() + (has_next_offset() ? vnext_offset.innerLength() : 0); + } + mtpTypeId type() const { + return mtpc_messages_setContextBotResults; + } + void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_setContextBotResults) { + vflags.read(from, end); + vquery_id.read(from, end); + vresults.read(from, end); + vcache_time.read(from, end); + if (has_next_offset()) { vnext_offset.read(from, end); } else { vnext_offset = MTPstring(); } + } + void write(mtpBuffer &to) const { + vflags.write(to); + vquery_id.write(to); + vresults.write(to); + vcache_time.write(to); + if (has_next_offset()) vnext_offset.write(to); + } + + typedef MTPBool ResponseType; +}; +class MTPmessages_SetContextBotResults : public MTPBoxed { +public: + MTPmessages_SetContextBotResults() { + } + MTPmessages_SetContextBotResults(const MTPmessages_setContextBotResults &v) : MTPBoxed(v) { + } + MTPmessages_SetContextBotResults(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = 0) : MTPBoxed(from, end, cons) { + } + MTPmessages_SetContextBotResults(MTPint _flags, const MTPlong &_query_id, const MTPVector &_results, MTPint _cache_time, const MTPstring &_next_offset) : MTPBoxed(MTPmessages_setContextBotResults(_flags, _query_id, _results, _cache_time, _next_offset)) { + } +}; + class MTPupdates_getState { // RPC method 'updates.getState' public: MTPupdates_getState() { @@ -21325,15 +21694,15 @@ inline uint32 MTPinputMedia::innerLength() const { } case mtpc_inputMediaUploadedDocument: { const MTPDinputMediaUploadedDocument &v(c_inputMediaUploadedDocument()); - return v.vfile.innerLength() + v.vmime_type.innerLength() + v.vattributes.innerLength(); + return v.vfile.innerLength() + v.vmime_type.innerLength() + v.vattributes.innerLength() + v.vcaption.innerLength(); } case mtpc_inputMediaUploadedThumbDocument: { const MTPDinputMediaUploadedThumbDocument &v(c_inputMediaUploadedThumbDocument()); - return v.vfile.innerLength() + v.vthumb.innerLength() + v.vmime_type.innerLength() + v.vattributes.innerLength(); + return v.vfile.innerLength() + v.vthumb.innerLength() + v.vmime_type.innerLength() + v.vattributes.innerLength() + v.vcaption.innerLength(); } case mtpc_inputMediaDocument: { const MTPDinputMediaDocument &v(c_inputMediaDocument()); - return v.vid.innerLength(); + return v.vid.innerLength() + v.vcaption.innerLength(); } case mtpc_inputMediaVenue: { const MTPDinputMediaVenue &v(c_inputMediaVenue()); @@ -21343,6 +21712,10 @@ inline uint32 MTPinputMedia::innerLength() const { const MTPDinputMediaGifExternal &v(c_inputMediaGifExternal()); return v.vurl.innerLength() + v.vq.innerLength(); } + case mtpc_inputMediaContextBotResult: { + const MTPDinputMediaContextBotResult &v(c_inputMediaContextBotResult()); + return v.vflags.innerLength() + v.vbot.innerLength() + v.vurl.innerLength() + v.vquery_id.innerLength(); + } } return 0; } @@ -21423,6 +21796,7 @@ inline void MTPinputMedia::read(const mtpPrime *&from, const mtpPrime *end, mtpT v.vfile.read(from, end); v.vmime_type.read(from, end); v.vattributes.read(from, end); + v.vcaption.read(from, end); } break; case mtpc_inputMediaUploadedThumbDocument: _type = cons; { if (!data) setData(new MTPDinputMediaUploadedThumbDocument()); @@ -21431,11 +21805,13 @@ inline void MTPinputMedia::read(const mtpPrime *&from, const mtpPrime *end, mtpT v.vthumb.read(from, end); v.vmime_type.read(from, end); v.vattributes.read(from, end); + v.vcaption.read(from, end); } break; case mtpc_inputMediaDocument: _type = cons; { if (!data) setData(new MTPDinputMediaDocument()); MTPDinputMediaDocument &v(_inputMediaDocument()); v.vid.read(from, end); + v.vcaption.read(from, end); } break; case mtpc_inputMediaVenue: _type = cons; { if (!data) setData(new MTPDinputMediaVenue()); @@ -21452,6 +21828,14 @@ inline void MTPinputMedia::read(const mtpPrime *&from, const mtpPrime *end, mtpT v.vurl.read(from, end); v.vq.read(from, end); } break; + case mtpc_inputMediaContextBotResult: _type = cons; { + if (!data) setData(new MTPDinputMediaContextBotResult()); + MTPDinputMediaContextBotResult &v(_inputMediaContextBotResult()); + v.vflags.read(from, end); + v.vbot.read(from, end); + v.vurl.read(from, end); + v.vquery_id.read(from, end); + } break; default: throw mtpErrorUnexpected(cons, "MTPinputMedia"); } } @@ -21516,6 +21900,7 @@ inline void MTPinputMedia::write(mtpBuffer &to) const { v.vfile.write(to); v.vmime_type.write(to); v.vattributes.write(to); + v.vcaption.write(to); } break; case mtpc_inputMediaUploadedThumbDocument: { const MTPDinputMediaUploadedThumbDocument &v(c_inputMediaUploadedThumbDocument()); @@ -21523,10 +21908,12 @@ inline void MTPinputMedia::write(mtpBuffer &to) const { v.vthumb.write(to); v.vmime_type.write(to); v.vattributes.write(to); + v.vcaption.write(to); } break; case mtpc_inputMediaDocument: { const MTPDinputMediaDocument &v(c_inputMediaDocument()); v.vid.write(to); + v.vcaption.write(to); } break; case mtpc_inputMediaVenue: { const MTPDinputMediaVenue &v(c_inputMediaVenue()); @@ -21541,6 +21928,13 @@ inline void MTPinputMedia::write(mtpBuffer &to) const { v.vurl.write(to); v.vq.write(to); } break; + case mtpc_inputMediaContextBotResult: { + const MTPDinputMediaContextBotResult &v(c_inputMediaContextBotResult()); + v.vflags.write(to); + v.vbot.write(to); + v.vurl.write(to); + v.vquery_id.write(to); + } break; } } inline MTPinputMedia::MTPinputMedia(mtpTypeId type) : mtpDataOwner(0), _type(type) { @@ -21560,6 +21954,7 @@ inline MTPinputMedia::MTPinputMedia(mtpTypeId type) : mtpDataOwner(0), _type(typ case mtpc_inputMediaDocument: setData(new MTPDinputMediaDocument()); break; case mtpc_inputMediaVenue: setData(new MTPDinputMediaVenue()); break; case mtpc_inputMediaGifExternal: setData(new MTPDinputMediaGifExternal()); break; + case mtpc_inputMediaContextBotResult: setData(new MTPDinputMediaContextBotResult()); break; default: throw mtpErrorBadTypeId(type, "MTPinputMedia"); } } @@ -21591,6 +21986,8 @@ inline MTPinputMedia::MTPinputMedia(MTPDinputMediaVenue *_data) : mtpDataOwner(_ } inline MTPinputMedia::MTPinputMedia(MTPDinputMediaGifExternal *_data) : mtpDataOwner(_data), _type(mtpc_inputMediaGifExternal) { } +inline MTPinputMedia::MTPinputMedia(MTPDinputMediaContextBotResult *_data) : mtpDataOwner(_data), _type(mtpc_inputMediaContextBotResult) { +} inline MTPinputMedia MTP_inputMediaEmpty() { return MTPinputMedia(mtpc_inputMediaEmpty); } @@ -21621,14 +22018,14 @@ inline MTPinputMedia MTP_inputMediaUploadedAudio(const MTPInputFile &_file, MTPi inline MTPinputMedia MTP_inputMediaAudio(const MTPInputAudio &_id) { return MTPinputMedia(new MTPDinputMediaAudio(_id)); } -inline MTPinputMedia MTP_inputMediaUploadedDocument(const MTPInputFile &_file, const MTPstring &_mime_type, const MTPVector &_attributes) { - return MTPinputMedia(new MTPDinputMediaUploadedDocument(_file, _mime_type, _attributes)); +inline MTPinputMedia MTP_inputMediaUploadedDocument(const MTPInputFile &_file, const MTPstring &_mime_type, const MTPVector &_attributes, const MTPstring &_caption) { + return MTPinputMedia(new MTPDinputMediaUploadedDocument(_file, _mime_type, _attributes, _caption)); } -inline MTPinputMedia MTP_inputMediaUploadedThumbDocument(const MTPInputFile &_file, const MTPInputFile &_thumb, const MTPstring &_mime_type, const MTPVector &_attributes) { - return MTPinputMedia(new MTPDinputMediaUploadedThumbDocument(_file, _thumb, _mime_type, _attributes)); +inline MTPinputMedia MTP_inputMediaUploadedThumbDocument(const MTPInputFile &_file, const MTPInputFile &_thumb, const MTPstring &_mime_type, const MTPVector &_attributes, const MTPstring &_caption) { + return MTPinputMedia(new MTPDinputMediaUploadedThumbDocument(_file, _thumb, _mime_type, _attributes, _caption)); } -inline MTPinputMedia MTP_inputMediaDocument(const MTPInputDocument &_id) { - return MTPinputMedia(new MTPDinputMediaDocument(_id)); +inline MTPinputMedia MTP_inputMediaDocument(const MTPInputDocument &_id, const MTPstring &_caption) { + return MTPinputMedia(new MTPDinputMediaDocument(_id, _caption)); } inline MTPinputMedia MTP_inputMediaVenue(const MTPInputGeoPoint &_geo_point, const MTPstring &_title, const MTPstring &_address, const MTPstring &_provider, const MTPstring &_venue_id) { return MTPinputMedia(new MTPDinputMediaVenue(_geo_point, _title, _address, _provider, _venue_id)); @@ -21636,6 +22033,9 @@ inline MTPinputMedia MTP_inputMediaVenue(const MTPInputGeoPoint &_geo_point, con inline MTPinputMedia MTP_inputMediaGifExternal(const MTPstring &_url, const MTPstring &_q) { return MTPinputMedia(new MTPDinputMediaGifExternal(_url, _q)); } +inline MTPinputMedia MTP_inputMediaContextBotResult(MTPint _flags, const MTPInputUser &_bot, const MTPstring &_url, const MTPlong &_query_id) { + return MTPinputMedia(new MTPDinputMediaContextBotResult(_flags, _bot, _url, _query_id)); +} inline uint32 MTPinputChatPhoto::innerLength() const { switch (_type) { @@ -22315,7 +22715,7 @@ inline uint32 MTPuser::innerLength() const { } case mtpc_user: { const MTPDuser &v(c_user()); - return v.vflags.innerLength() + v.vid.innerLength() + (v.has_access_hash() ? v.vaccess_hash.innerLength() : 0) + (v.has_first_name() ? v.vfirst_name.innerLength() : 0) + (v.has_last_name() ? v.vlast_name.innerLength() : 0) + (v.has_username() ? v.vusername.innerLength() : 0) + (v.has_phone() ? v.vphone.innerLength() : 0) + (v.has_photo() ? v.vphoto.innerLength() : 0) + (v.has_status() ? v.vstatus.innerLength() : 0) + (v.has_bot_info_version() ? v.vbot_info_version.innerLength() : 0) + (v.has_restriction_reason() ? v.vrestriction_reason.innerLength() : 0); + return v.vflags.innerLength() + v.vid.innerLength() + (v.has_access_hash() ? v.vaccess_hash.innerLength() : 0) + (v.has_first_name() ? v.vfirst_name.innerLength() : 0) + (v.has_last_name() ? v.vlast_name.innerLength() : 0) + (v.has_username() ? v.vusername.innerLength() : 0) + (v.has_phone() ? v.vphone.innerLength() : 0) + (v.has_photo() ? v.vphoto.innerLength() : 0) + (v.has_status() ? v.vstatus.innerLength() : 0) + (v.has_bot_info_version() ? v.vbot_info_version.innerLength() : 0) + (v.has_restriction_reason() ? v.vrestriction_reason.innerLength() : 0) + (v.has_bot_context_placeholder() ? v.vbot_context_placeholder.innerLength() : 0); } } return 0; @@ -22346,6 +22746,7 @@ inline void MTPuser::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId if (v.has_status()) { v.vstatus.read(from, end); } else { v.vstatus = MTPUserStatus(); } if (v.has_bot_info_version()) { v.vbot_info_version.read(from, end); } else { v.vbot_info_version = MTPint(); } if (v.has_restriction_reason()) { v.vrestriction_reason.read(from, end); } else { v.vrestriction_reason = MTPstring(); } + if (v.has_bot_context_placeholder()) { v.vbot_context_placeholder.read(from, end); } else { v.vbot_context_placeholder = MTPstring(); } } break; default: throw mtpErrorUnexpected(cons, "MTPuser"); } @@ -22369,6 +22770,7 @@ inline void MTPuser::write(mtpBuffer &to) const { if (v.has_status()) v.vstatus.write(to); if (v.has_bot_info_version()) v.vbot_info_version.write(to); if (v.has_restriction_reason()) v.vrestriction_reason.write(to); + if (v.has_bot_context_placeholder()) v.vbot_context_placeholder.write(to); } break; } } @@ -22386,8 +22788,8 @@ inline MTPuser::MTPuser(MTPDuser *_data) : mtpDataOwner(_data), _type(mtpc_user) inline MTPuser MTP_userEmpty(MTPint _id) { return MTPuser(new MTPDuserEmpty(_id)); } -inline MTPuser MTP_user(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_first_name, const MTPstring &_last_name, const MTPstring &_username, const MTPstring &_phone, const MTPUserProfilePhoto &_photo, const MTPUserStatus &_status, MTPint _bot_info_version, const MTPstring &_restriction_reason) { - return MTPuser(new MTPDuser(_flags, _id, _access_hash, _first_name, _last_name, _username, _phone, _photo, _status, _bot_info_version, _restriction_reason)); +inline MTPuser MTP_user(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_first_name, const MTPstring &_last_name, const MTPstring &_username, const MTPstring &_phone, const MTPUserProfilePhoto &_photo, const MTPUserStatus &_status, MTPint _bot_info_version, const MTPstring &_restriction_reason, const MTPstring &_bot_context_placeholder) { + return MTPuser(new MTPDuser(_flags, _id, _access_hash, _first_name, _last_name, _username, _phone, _photo, _status, _bot_info_version, _restriction_reason, _bot_context_placeholder)); } inline uint32 MTPuserProfilePhoto::innerLength() const { @@ -23131,7 +23533,7 @@ inline uint32 MTPmessageMedia::innerLength() const { } case mtpc_messageMediaDocument: { const MTPDmessageMediaDocument &v(c_messageMediaDocument()); - return v.vdocument.innerLength(); + return v.vdocument.innerLength() + v.vcaption.innerLength(); } case mtpc_messageMediaAudio: { const MTPDmessageMediaAudio &v(c_messageMediaAudio()); @@ -23186,6 +23588,7 @@ inline void MTPmessageMedia::read(const mtpPrime *&from, const mtpPrime *end, mt if (!data) setData(new MTPDmessageMediaDocument()); MTPDmessageMediaDocument &v(_messageMediaDocument()); v.vdocument.read(from, end); + v.vcaption.read(from, end); } break; case mtpc_messageMediaAudio: _type = cons; { if (!data) setData(new MTPDmessageMediaAudio()); @@ -23235,6 +23638,7 @@ inline void MTPmessageMedia::write(mtpBuffer &to) const { case mtpc_messageMediaDocument: { const MTPDmessageMediaDocument &v(c_messageMediaDocument()); v.vdocument.write(to); + v.vcaption.write(to); } break; case mtpc_messageMediaAudio: { const MTPDmessageMediaAudio &v(c_messageMediaAudio()); @@ -23303,8 +23707,8 @@ inline MTPmessageMedia MTP_messageMediaContact(const MTPstring &_phone_number, c inline MTPmessageMedia MTP_messageMediaUnsupported() { return MTPmessageMedia(mtpc_messageMediaUnsupported); } -inline MTPmessageMedia MTP_messageMediaDocument(const MTPDocument &_document) { - return MTPmessageMedia(new MTPDmessageMediaDocument(_document)); +inline MTPmessageMedia MTP_messageMediaDocument(const MTPDocument &_document, const MTPstring &_caption) { + return MTPmessageMedia(new MTPDmessageMediaDocument(_document, _caption)); } inline MTPmessageMedia MTP_messageMediaAudio(const MTPAudio &_audio) { return MTPmessageMedia(new MTPDmessageMediaAudio(_audio)); @@ -25306,6 +25710,10 @@ inline uint32 MTPupdate::innerLength() const { const MTPDupdateStickerSetsOrder &v(c_updateStickerSetsOrder()); return v.vorder.innerLength(); } + case mtpc_updateBotContextQuery: { + const MTPDupdateBotContextQuery &v(c_updateBotContextQuery()); + return v.vquery_id.innerLength() + v.vuser_id.innerLength() + v.vquery.innerLength() + v.voffset.innerLength(); + } } return 0; } @@ -25575,6 +25983,14 @@ inline void MTPupdate::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeI } break; case mtpc_updateStickerSets: _type = cons; break; case mtpc_updateSavedGifs: _type = cons; break; + case mtpc_updateBotContextQuery: _type = cons; { + if (!data) setData(new MTPDupdateBotContextQuery()); + MTPDupdateBotContextQuery &v(_updateBotContextQuery()); + v.vquery_id.read(from, end); + v.vuser_id.read(from, end); + v.vquery.read(from, end); + v.voffset.read(from, end); + } break; default: throw mtpErrorUnexpected(cons, "MTPupdate"); } } @@ -25798,6 +26214,13 @@ inline void MTPupdate::write(mtpBuffer &to) const { const MTPDupdateStickerSetsOrder &v(c_updateStickerSetsOrder()); v.vorder.write(to); } break; + case mtpc_updateBotContextQuery: { + const MTPDupdateBotContextQuery &v(c_updateBotContextQuery()); + v.vquery_id.write(to); + v.vuser_id.write(to); + v.vquery.write(to); + v.voffset.write(to); + } break; } } inline MTPupdate::MTPupdate(mtpTypeId type) : mtpDataOwner(0), _type(type) { @@ -25843,6 +26266,7 @@ inline MTPupdate::MTPupdate(mtpTypeId type) : mtpDataOwner(0), _type(type) { case mtpc_updateStickerSetsOrder: setData(new MTPDupdateStickerSetsOrder()); break; case mtpc_updateStickerSets: break; case mtpc_updateSavedGifs: break; + case mtpc_updateBotContextQuery: setData(new MTPDupdateBotContextQuery()); break; default: throw mtpErrorBadTypeId(type, "MTPupdate"); } } @@ -25924,6 +26348,8 @@ inline MTPupdate::MTPupdate(MTPDupdateNewStickerSet *_data) : mtpDataOwner(_data } inline MTPupdate::MTPupdate(MTPDupdateStickerSetsOrder *_data) : mtpDataOwner(_data), _type(mtpc_updateStickerSetsOrder) { } +inline MTPupdate::MTPupdate(MTPDupdateBotContextQuery *_data) : mtpDataOwner(_data), _type(mtpc_updateBotContextQuery) { +} inline MTPupdate MTP_updateNewMessage(const MTPMessage &_message, MTPint _pts, MTPint _pts_count) { return MTPupdate(new MTPDupdateNewMessage(_message, _pts, _pts_count)); } @@ -26047,6 +26473,9 @@ inline MTPupdate MTP_updateStickerSets() { inline MTPupdate MTP_updateSavedGifs() { return MTPupdate(mtpc_updateSavedGifs); } +inline MTPupdate MTP_updateBotContextQuery(const MTPlong &_query_id, MTPint _user_id, const MTPstring &_query, const MTPstring &_offset) { + return MTPupdate(new MTPDupdateBotContextQuery(_query_id, _user_id, _query, _offset)); +} inline MTPupdates_state::MTPupdates_state() : mtpDataOwner(new MTPDupdates_state()) { } @@ -30399,6 +30828,115 @@ inline MTPmessages_savedGifs MTP_messages_savedGifs(MTPint _hash, const MTPVecto return MTPmessages_savedGifs(new MTPDmessages_savedGifs(_hash, _gifs)); } +inline MTPinputBotContextResult::MTPinputBotContextResult() : mtpDataOwner(new MTPDinputBotContextResult()) { +} + +inline uint32 MTPinputBotContextResult::innerLength() const { + const MTPDinputBotContextResult &v(c_inputBotContextResult()); + return v.vflags.innerLength() + v.vurl.innerLength() + (v.has_type() ? v.vtype.innerLength() : 0) + (v.has_title() ? v.vtitle.innerLength() : 0) + (v.has_description() ? v.vdescription.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); +} +inline mtpTypeId MTPinputBotContextResult::type() const { + return mtpc_inputBotContextResult; +} +inline void MTPinputBotContextResult::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) { + if (cons != mtpc_inputBotContextResult) throw mtpErrorUnexpected(cons, "MTPinputBotContextResult"); + + if (!data) setData(new MTPDinputBotContextResult()); + MTPDinputBotContextResult &v(_inputBotContextResult()); + v.vflags.read(from, end); + v.vurl.read(from, end); + if (v.has_type()) { v.vtype.read(from, end); } else { v.vtype = MTPstring(); } + 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_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(); } +} +inline void MTPinputBotContextResult::write(mtpBuffer &to) const { + const MTPDinputBotContextResult &v(c_inputBotContextResult()); + v.vflags.write(to); + v.vurl.write(to); + if (v.has_type()) v.vtype.write(to); + if (v.has_title()) v.vtitle.write(to); + if (v.has_description()) v.vdescription.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); +} +inline MTPinputBotContextResult::MTPinputBotContextResult(MTPDinputBotContextResult *_data) : mtpDataOwner(_data) { +} +inline MTPinputBotContextResult MTP_inputBotContextResult(MTPint _flags, const MTPstring &_url, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_thumb_url, const MTPstring &_content_url, const MTPstring &_content_type, MTPint _w, MTPint _h, MTPint _duration) { + return MTPinputBotContextResult(new MTPDinputBotContextResult(_flags, _url, _type, _title, _description, _thumb_url, _content_url, _content_type, _w, _h, _duration)); +} + +inline MTPbotContextResult::MTPbotContextResult() : mtpDataOwner(new MTPDbotContextResult()) { +} + +inline uint32 MTPbotContextResult::innerLength() const { + const MTPDbotContextResult &v(c_botContextResult()); + return v.vflags.innerLength() + v.vwebpage.innerLength(); +} +inline mtpTypeId MTPbotContextResult::type() const { + return mtpc_botContextResult; +} +inline void MTPbotContextResult::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) { + if (cons != mtpc_botContextResult) throw mtpErrorUnexpected(cons, "MTPbotContextResult"); + + if (!data) setData(new MTPDbotContextResult()); + MTPDbotContextResult &v(_botContextResult()); + v.vflags.read(from, end); + v.vwebpage.read(from, end); +} +inline void MTPbotContextResult::write(mtpBuffer &to) const { + const MTPDbotContextResult &v(c_botContextResult()); + v.vflags.write(to); + v.vwebpage.write(to); +} +inline MTPbotContextResult::MTPbotContextResult(MTPDbotContextResult *_data) : mtpDataOwner(_data) { +} +inline MTPbotContextResult MTP_botContextResult(MTPint _flags, const MTPWebPage &_webpage) { + return MTPbotContextResult(new MTPDbotContextResult(_flags, _webpage)); +} + +inline MTPmessages_botResults::MTPmessages_botResults() : mtpDataOwner(new MTPDmessages_botResults()) { +} + +inline uint32 MTPmessages_botResults::innerLength() const { + const MTPDmessages_botResults &v(c_messages_botResults()); + return v.vflags.innerLength() + v.vquery_id.innerLength() + (v.has_next_offset() ? v.vnext_offset.innerLength() : 0) + v.vresults.innerLength(); +} +inline mtpTypeId MTPmessages_botResults::type() const { + return mtpc_messages_botResults; +} +inline void MTPmessages_botResults::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) { + if (cons != mtpc_messages_botResults) throw mtpErrorUnexpected(cons, "MTPmessages_botResults"); + + if (!data) setData(new MTPDmessages_botResults()); + MTPDmessages_botResults &v(_messages_botResults()); + v.vflags.read(from, end); + v.vquery_id.read(from, end); + if (v.has_next_offset()) { v.vnext_offset.read(from, end); } else { v.vnext_offset = MTPstring(); } + v.vresults.read(from, end); +} +inline void MTPmessages_botResults::write(mtpBuffer &to) const { + const MTPDmessages_botResults &v(c_messages_botResults()); + v.vflags.write(to); + v.vquery_id.write(to); + if (v.has_next_offset()) v.vnext_offset.write(to); + v.vresults.write(to); +} +inline MTPmessages_botResults::MTPmessages_botResults(MTPDmessages_botResults *_data) : mtpDataOwner(_data) { +} +inline MTPmessages_botResults MTP_messages_botResults(MTPint _flags, const MTPlong &_query_id, const MTPstring &_next_offset, const MTPVector &_results) { + return MTPmessages_botResults(new MTPDmessages_botResults(_flags, _query_id, _next_offset, _results)); +} + // Human-readable text serialization #if (defined _DEBUG || defined _WITH_DEBUG) diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index bbe853042..92fc21dc1 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -641,7 +641,7 @@ void Window::sendServiceHistoryRequest() { UserData *user = App::userLoaded(ServiceUserId); if (!user) { int32 userFlags = MTPDuser::flag_first_name | MTPDuser::flag_phone | MTPDuser::flag_status | MTPDuser::flag_verified; - user = App::feedUsers(MTP_vector(1, MTP_user(MTP_int(userFlags), MTP_int(ServiceUserId), MTPlong(), MTP_string("Telegram"), MTPstring(), MTPstring(), MTP_string("42777"), MTP_userProfilePhotoEmpty(), MTP_userStatusRecently(), MTPint(), MTPstring()))); + user = App::feedUsers(MTP_vector(1, MTP_user(MTP_int(userFlags), MTP_int(ServiceUserId), MTPlong(), MTP_string("Telegram"), MTPstring(), MTPstring(), MTP_string("42777"), MTP_userProfilePhotoEmpty(), MTP_userStatusRecently(), MTPint(), MTPstring(), MTPstring()))); } _serviceHistoryRequest = MTP::send(MTPmessages_GetHistory(user->input, MTP_int(0), MTP_int(0), MTP_int(1), MTP_int(0), MTP_int(0)), main->rpcDone(&MainWidget::serviceHistoryDone), main->rpcFail(&MainWidget::serviceHistoryFail)); }