From 62723f7576a846bed043b2dff508133bc7872477 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 22 Dec 2015 11:01:02 +0300 Subject: [PATCH] disabled libexif usage, mediaview showing gif/mp4 through ClipReader --- Telegram/SourceFiles/apiwrap.cpp | 5 +- Telegram/SourceFiles/app.cpp | 44 +++--- Telegram/SourceFiles/facades.cpp | 29 ++++ Telegram/SourceFiles/facades.h | 10 ++ Telegram/SourceFiles/gui/animation.cpp | 176 +-------------------- Telegram/SourceFiles/gui/animation.h | 61 +------ Telegram/SourceFiles/history.cpp | 18 +-- Telegram/SourceFiles/history.h | 9 +- Telegram/SourceFiles/historywidget.cpp | 20 +-- Telegram/SourceFiles/historywidget.h | 6 +- Telegram/SourceFiles/mainwidget.cpp | 28 ++-- Telegram/SourceFiles/mainwidget.h | 2 +- Telegram/SourceFiles/mediaview.cpp | 146 ++++++++++------- Telegram/SourceFiles/mediaview.h | 10 +- Telegram/SourceFiles/mtproto/mtpScheme.cpp | 13 +- Telegram/SourceFiles/mtproto/mtpScheme.h | 73 ++++----- Telegram/SourceFiles/mtproto/scheme.tl | 6 +- Telegram/SourceFiles/overviewwidget.cpp | 8 +- Telegram/SourceFiles/window.cpp | 12 ++ Telegram/SourceFiles/window.h | 9 +- 20 files changed, 267 insertions(+), 418 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index d81582eff..d4a947b7f 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -916,12 +916,11 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs } } - MainWidget *m = App::main(); for (QMap::const_iterator i = msgsIds.cbegin(), e = msgsIds.cend(); i != e; ++i) { HistoryItem *item = App::histories().addNewMessage(v->at(i.value()), NewMessageExisting); if (item) { item->initDimensions(); - if (m) m->itemResized(item); + Notify::historyItemResized(item); } } @@ -934,7 +933,7 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs if (j != items.cend()) { for (HistoryItemsMap::const_iterator k = j.value().cbegin(), e = j.value().cend(); k != e; ++k) { k.key()->initDimensions(); - if (m) m->itemResized(k.key()); + Notify::historyItemResized(k.key()); } } } diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 05f1cffe7..27ff4c9e9 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -907,7 +907,7 @@ namespace App { if ((hasLinks && !existing->hasTextLinks()) || (!hasLinks && existing->textHasLinks())) { existing->setText(qs(m.vmessage), m.has_entities() ? entitiesFromMTP(m.ventities.c_vector().v) : EntitiesInText()); existing->initDimensions(); - if (App::main()) App::main()->itemResized(existing); + Notify::historyItemResized(existing); if (existing->hasTextLinks() && existing->indexInOverview()) { existing->history()->addToOverview(existing, OverviewLinks); } @@ -1058,7 +1058,7 @@ namespace App { } } if (resized) { - App::main()->itemResized(0); + Notify::historyItemsResized(); } if (main()) { for (QMap::const_iterator i = historiesToCheck.cbegin(), e = historiesToCheck.cend(); i != e; ++i) { @@ -2325,26 +2325,26 @@ namespace App { *format = reader.format(); QString fmt = QString::fromUtf8(*format).toLower() ; if (fmt == "jpg" || fmt == "jpeg") { - ExifData *exifData = exif_data_new_from_data((const uchar*)(data.constData()), data.size()); - if (exifData) { - ExifByteOrder byteOrder = exif_data_get_byte_order(exifData); - ExifEntry *exifEntry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION); - if (exifEntry) { - QTransform orientationFix; - int orientation = exif_get_short(exifEntry->data, byteOrder); - switch (orientation) { - case 2: orientationFix = QTransform(-1, 0, 0, 1, 0, 0); break; - case 3: orientationFix = QTransform(-1, 0, 0, -1, 0, 0); break; - case 4: orientationFix = QTransform(1, 0, 0, -1, 0, 0); break; - case 5: orientationFix = QTransform(0, -1, -1, 0, 0, 0); break; - case 6: orientationFix = QTransform(0, 1, -1, 0, 0, 0); break; - case 7: orientationFix = QTransform(0, 1, 1, 0, 0, 0); break; - case 8: orientationFix = QTransform(0, -1, 1, 0, 0, 0); break; - } - result = result.transformed(orientationFix); - } - exif_data_free(exifData); - } + //ExifData *exifData = exif_data_new_from_data((const uchar*)(data.constData()), data.size()); + //if (exifData) { + // ExifByteOrder byteOrder = exif_data_get_byte_order(exifData); + // ExifEntry *exifEntry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION); + // if (exifEntry) { + // QTransform orientationFix; + // int orientation = exif_get_short(exifEntry->data, byteOrder); + // switch (orientation) { + // case 2: orientationFix = QTransform(-1, 0, 0, 1, 0, 0); break; + // case 3: orientationFix = QTransform(-1, 0, 0, -1, 0, 0); break; + // case 4: orientationFix = QTransform(1, 0, 0, -1, 0, 0); break; + // case 5: orientationFix = QTransform(0, -1, -1, 0, 0, 0); break; + // case 6: orientationFix = QTransform(0, 1, -1, 0, 0, 0); break; + // case 7: orientationFix = QTransform(0, 1, 1, 0, 0, 0); break; + // case 8: orientationFix = QTransform(0, -1, 1, 0, 0, 0); break; + // } + // result = result.transformed(orientationFix); + // } + // exif_data_free(exifData); + //} } else if (opaque && result.hasAlphaChannel()) { QImage solid(result.width(), result.height(), QImage::Format_ARGB32_Premultiplied); solid.fill(st::white->c); diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index f25cf048d..651cc4043 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -95,6 +95,18 @@ namespace Ui { return false; } + void clipRedraw(ClipReader *reader) { + const GifItems &items(App::gifItems()); + GifItems::const_iterator it = items.constFind(reader); + if (it != items.cend()) { + if (reader->currentDisplayed()) { + return; + } + Ui::redrawHistoryItem(it.value()); + } + if (Window *w = App::wnd()) w->ui_clipRedraw(reader); + } + void redrawHistoryItem(const HistoryItem *item) { if (MainWidget *m = App::main()) m->ui_redrawHistoryItem(item); } @@ -129,6 +141,23 @@ namespace Notify { if (MainWidget *m = App::main()) m->notify_migrateUpdated(peer); } + void clipReinit(ClipReader *reader) { + const GifItems &items(App::gifItems()); + GifItems::const_iterator it = items.constFind(reader); + if (it != items.cend()) { + HistoryItem *item = it.value(); + + item->initDimensions(); // can delete reader and items entry it + Notify::historyItemResized(item, true); + Notify::historyItemLayoutChanged(item); + } + if (Window *w = App::wnd()) w->notify_clipReinit(reader); + } + + void historyItemResized(const HistoryItem *item, bool scrollToIt) { + if (MainWidget *m = App::main()) m->notify_historyItemResized(item, scrollToIt); + } + void historyItemLayoutChanged(const HistoryItem *item) { if (MainWidget *m = App::main()) m->notify_historyItemLayoutChanged(item); } diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 97ebf9cd7..c7fcb1e66 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -46,6 +46,8 @@ namespace Ui { // openssl doesn't allow me to use UI :( void hideLayer(bool fast = false); bool isLayerShown(); + void clipRedraw(ClipReader *reader); + void redrawHistoryItem(const HistoryItem *item); void showPeerHistory(const PeerId &peer, MsgId msgId, bool back = false); @@ -70,7 +72,15 @@ namespace Notify { void userIsBotChanged(UserData *user); void userIsContactChanged(UserData *user, bool fromThisApp = false); void botCommandsChanged(UserData *user); + void migrateUpdated(PeerData *peer); + + void clipReinit(ClipReader *reader); + + void historyItemResized(const HistoryItem *item, bool scrollToIt = false); + inline void historyItemsResized() { + historyItemResized(0); + } void historyItemLayoutChanged(const HistoryItem *item); }; diff --git a/Telegram/SourceFiles/gui/animation.cpp b/Telegram/SourceFiles/gui/animation.cpp index 8a58af534..20f5cf3a7 100644 --- a/Telegram/SourceFiles/gui/animation.cpp +++ b/Telegram/SourceFiles/gui/animation.cpp @@ -119,183 +119,11 @@ void Animation::stop() { } void AnimationManager::clipReinit(ClipReader *reader) { - const GifItems &items(App::gifItems()); - GifItems::const_iterator it = items.constFind(reader); - if (it != items.cend()) { - HistoryItem *item = it.value(); - - item->initDimensions(); // can delete reader and items entry it - if (App::main()) emit App::main()->itemResized(item, true); - - Notify::historyItemLayoutChanged(item); - } + Notify::clipReinit(reader); } void AnimationManager::clipRedraw(ClipReader *reader) { - const GifItems &items(App::gifItems()); - GifItems::const_iterator it = items.constFind(reader); - if (it != items.cend()) { - if (reader->currentDisplayed()) { - return; - } - Ui::redrawHistoryItem(it.value()); - } -} - -void AnimatedGif::step_frame(float64 ms, bool timer) { - int32 f = frame; - while (f < images.size() && ms > delays[f]) { - ++f; - if (f == images.size() && images.size() < framesCount) { - if (reader->read(&img)) { - int64 d = reader->nextImageDelay(), delay = delays[f - 1]; - if (!d) d = 1; - delay += d; - if (img.size() != QSize(w, h)) img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - images.push_back(img); - frames.push_back(QPixmap()); - delays.push_back(delay); - for (int32 i = 0; i < images.size(); ++i) { - if (!images[i].isNull() || !frames[i].isNull()) { - images[i] = QImage(); - frames[i] = QPixmap(); - break; - } - } - } else { - framesCount = images.size(); - } - } - if (f == images.size()) { - if (!duration) { - duration = delays.isEmpty() ? 1 : delays.back(); - } - - f = 0; - for (int32 i = 0, s = delays.size() - 1; i <= s; ++i) { - delays[i] += duration; - } - if (images[f].isNull()) { - QString fname = reader->fileName(); - delete reader; - reader = new QImageReader(fname); - } - } - if (images[f].isNull() && reader->read(&img)) { - if (img.size() != QSize(w, h)) img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - images[f] = img; - frames[f] = QPixmap(); - for (int32 i = 0; i < f; ++i) { - if (!images[i].isNull() || !frames[i].isNull()) { - images[i] = QImage(); - frames[i] = QPixmap(); - break; - } - } - } - } - if (frame != f) { - frame = f; - if (timer) { - if (msg) { - Ui::redrawHistoryItem(msg); - } else { - emit updated(); - } - } - } -} - -void AnimatedGif::start(HistoryItem *row, const FileLocation &f) { - stop(); - - file = new FileLocation(f); - if (!file->accessEnable()) { - stop(); - return; - } - access = true; - - reader = new QImageReader(file->name()); - if (!reader->canRead() || !reader->supportsAnimation()) { - stop(); - return; - } - - QSize s = reader->size(); - w = s.width(); - h = s.height(); - framesCount = reader->imageCount(); - if (!w || !h || !framesCount) { - stop(); - return; - } - - frames.reserve(framesCount); - images.reserve(framesCount); - delays.reserve(framesCount); - - int32 sizeLeft = MediaViewImageSizeLimit, delay = 0; - for (bool read = reader->read(&img); read; read = reader->read(&img)) { - sizeLeft -= w * h * 4; - if (img.size() != s) img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - images.push_back(img); - frames.push_back(QPixmap()); - int32 d = reader->nextImageDelay(); - if (!d) d = 1; - delay += d; - delays.push_back(delay); - if (sizeLeft < 0) break; - } - - msg = row; - - _a_frames.start(); - if (msg) { - msg->initDimensions(); - if (App::main()) App::main()->itemResized(msg, true); - } -} - -void AnimatedGif::stop(bool onItemRemoved) { - if (file) { - if (access) { - file->accessDisable(); - } - delete file; - file = 0; - } - access = false; - - if (isNull()) return; - - delete reader; - reader = 0; - HistoryItem *row = msg; - msg = 0; - frames.clear(); - images.clear(); - delays.clear(); - w = h = frame = framesCount = duration = 0; - - _a_frames.stop(); - if (row && !onItemRemoved) { - row->initDimensions(); - if (App::main()) App::main()->itemResized(row, true); - } -} - -const QPixmap &AnimatedGif::current(int32 width, int32 height, bool rounded) { - if (!width) width = w; - if (!height) height = h; - if ((frames[frame].isNull() || frames[frame].width() != width || frames[frame].height() != height) && !images[frame].isNull()) { - QImage img = images[frame]; - if (img.width() != width || img.height() != height) img = img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - if (rounded) imageRound(img); - frames[frame] = QPixmap::fromImage(img, Qt::ColorOnly); - frames[frame].setDevicePixelRatio(cRetinaFactor()); - } - return frames[frame]; + Ui::clipRedraw(reader); } QPixmap _prepareFrame(const ClipFrameRequest &request, const QImage &original, QImage &cache, bool smooth) { diff --git a/Telegram/SourceFiles/gui/animation.h b/Telegram/SourceFiles/gui/animation.h index dd4820964..355d57580 100644 --- a/Telegram/SourceFiles/gui/animation.h +++ b/Telegram/SourceFiles/gui/animation.h @@ -419,65 +419,7 @@ private: bool _iterating; }; - -class HistoryItem; class FileLocation; -class AnimatedGif : public QObject { - Q_OBJECT - -public: - - AnimatedGif() : QObject() - , msg(0) - , file(0) - , access(false) - , reader(0) - , w(0) - , h(0) - , frame(0) - , framesCount(0) - , duration(0) - , _a_frames(animation(this, &AnimatedGif::step_frame)) { - } - - void step_frame(float64 ms, bool timer); - - void start(HistoryItem *row, const FileLocation &file); - void stop(bool onItemRemoved = false); - - bool isNull() const { - return !reader; - } - - ~AnimatedGif() { - stop(true); - } - - const QPixmap ¤t(int32 width = 0, int32 height = 0, bool rounded = false); - -signals: - - void updated(); - -public: - - HistoryItem *msg; - QImage img; - FileLocation *file; - bool access; - QImageReader *reader; - int32 w, h, frame; - -private: - - QVector frames; - QVector images; - QVector delays; - int32 framesCount, duration; - - Animation _a_frames; - -}; enum ClipState { ClipReading, @@ -526,6 +468,9 @@ public: void start(int32 framew, int32 frameh, int32 outerw, int32 outerh, bool rounded); QPixmap current(int32 framew, int32 frameh, int32 outerw, int32 outerh, uint64 ms); + QImage frameOriginal() const { + return _currentOriginal; + } bool currentDisplayed() const { return _currentDisplayed.get(); } diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 533db8194..650ed5d96 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -75,8 +75,6 @@ namespace { _webpageDescriptionOptions.maxh = st::webPageDescriptionFont->height * 3; } - AnimatedGif animated; - inline HistoryReply *toHistoryReply(HistoryItem *item) { return item ? item->toHistoryReply() : 0; } @@ -2529,7 +2527,7 @@ MsgId History::msgIdForRead() const { return result; } -int32 History::geomResize(int32 newWidth, int32 *ytransform, HistoryItem *resizedItem) { +int32 History::geomResize(int32 newWidth, int32 *ytransform, const HistoryItem *resizedItem) { if (width != newWidth) resizedItem = 0; // recount all items if (width != newWidth || resizedItem) { int32 y = 0; @@ -2724,7 +2722,7 @@ void History::removeBlock(HistoryBlock *block) { delete block; } -int32 HistoryBlock::geomResize(int32 newWidth, int32 *ytransform, HistoryItem *resizedItem) { +int32 HistoryBlock::geomResize(int32 newWidth, int32 *ytransform, const HistoryItem *resizedItem) { int32 y = 0; for (Items::iterator i = items.begin(), e = items.end(); i != e; ++i) { HistoryItem *item = *i; @@ -4602,7 +4600,7 @@ void HistoryGif::stopInline(HistoryItem *parent) { _gif = 0; parent->initDimensions(); - if (App::main()) emit App::main()->itemResized(parent); + Notify::historyItemResized(parent); Notify::historyItemLayoutChanged(parent); } @@ -4933,7 +4931,7 @@ void HistoryContact::updateFrom(const MTPMessageMedia &media, HistoryItem *paren _userId = media.c_messageMediaContact().vuser_id.v; regItem(parent); parent->initDimensions(); - if (allowEmitResize && App::main()) App::main()->itemResized(parent); + if (allowEmitResize) Notify::historyItemResized(parent); } } } @@ -6073,7 +6071,7 @@ void HistoryMessage::setMedia(const MTPMessageMedia *media, bool allowEmitResize _textHeight = 0; } initDimensions(); - if (allowEmitResize && App::main()) App::main()->itemResized(this); + if (allowEmitResize) Notify::historyItemResized(this); } void HistoryMessage::setText(const QString &text, const EntitiesInText &entities) { @@ -6196,7 +6194,7 @@ void HistoryMessage::setViewsCount(int32 count) { _textHeight = 0; } initDimensions(); - if (App::main()) App::main()->itemResized(this); + Notify::historyItemResized(this); } } @@ -6212,7 +6210,7 @@ void HistoryMessage::setId(MsgId newId) { _textHeight = 0; } initDimensions(); - if (App::main()) App::main()->itemResized(this); + Notify::historyItemResized(this); } } @@ -6718,7 +6716,7 @@ bool HistoryReply::updateReplyTo(bool force) { } if (force) { initDimensions(); - if (App::main()) App::main()->itemResized(this); + Notify::historyItemResized(this); } return (replyToMsg || !replyToMsgId); } diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index e58f02cc6..c774b424c 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -241,7 +241,7 @@ public: MsgId maxMsgId() const; MsgId msgIdForRead() const; - int32 geomResize(int32 newWidth, int32 *ytransform = 0, HistoryItem *resizedItem = 0); // return new size + int32 geomResize(int32 newWidth, int32 *ytransform = 0, const HistoryItem *resizedItem = 0); // return new size void removeNotification(HistoryItem *item) { if (!notifies.isEmpty()) { @@ -752,7 +752,7 @@ public: } void removeItem(HistoryItem *item); - int32 geomResize(int32 newWidth, int32 *ytransform, HistoryItem *resizedItem); // return new size + int32 geomResize(int32 newWidth, int32 *ytransform, const HistoryItem *resizedItem); // return new size int32 y, height; History *history; }; @@ -838,10 +838,7 @@ public: virtual int32 resize(int32 width) = 0; // return new height virtual void draw(Painter &p, const QRect &r, uint32 selection, uint64 ms) const = 0; - History *history() { - return _history; - } - const History *history() const { + History *history() const { return _history; } PeerData *from() const { diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index cb672f977..5f2e1395f 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -1165,7 +1165,7 @@ void HistoryInner::keyPressEvent(QKeyEvent *e) { } } -int32 HistoryInner::recountHeight(HistoryItem *resizedItem) { +int32 HistoryInner::recountHeight(const HistoryItem *resizedItem) { int32 htop = historyTop(), mtop = migratedTop(); int32 st1 = (htop >= 0) ? (_history->lastScrollTop - htop) : -1, st2 = (_migrated && mtop >= 0) ? (_history->lastScrollTop - mtop) : -1; @@ -2994,6 +2994,10 @@ void HistoryWidget::notify_migrateUpdated(PeerData *peer) { } } +void HistoryWidget::notify_historyItemResized(const HistoryItem *row, bool scrollToIt) { + updateListSize(0, false, false, row, scrollToIt); +} + void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) { cSetLastStickersUpdate(getms(true)); _stickersUpdateRequest = 0; @@ -5680,10 +5684,6 @@ void HistoryWidget::itemReplaced(HistoryItem *oldItem, HistoryItem *newItem) { if (_replyReturn == oldItem) _replyReturn = newItem; } -void HistoryWidget::itemResized(HistoryItem *row, bool scrollToIt) { - updateListSize(0, false, false, row, scrollToIt); -} - void HistoryWidget::updateScrollColors() { if (!App::historyScrollBarColor()) return; _scroll.updateColors(App::historyScrollBarColor(), App::historyScrollBgColor(), App::historyScrollBarOverColor(), App::historyScrollBgOverColor()); @@ -5693,7 +5693,7 @@ MsgId HistoryWidget::replyToId() const { return _replyToId ? _replyToId : (_kbReplyTo ? _kbReplyTo->id : 0); } -void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown, HistoryItem *resizedItem, bool scrollToIt) { +void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown, const HistoryItem *resizedItem, bool scrollToIt) { if (!_history || (initial && _histInited) || (!initial && !_histInited)) return; if (_firstLoadRequest) { if (resizedItem) _list->recountHeight(resizedItem); @@ -6466,9 +6466,7 @@ void HistoryWidget::onDeleteSelectedSure() { for (SelectedItemSet::const_iterator i = sel.cbegin(), e = sel.cend(); i != e; ++i) { i.value()->destroy(); } - if (App::main() && App::main()->peer() == peer()) { - App::main()->itemResized(0); - } + Notify::historyItemsResized(); Ui::hideLayer(); for (QMap >::const_iterator i = ids.cbegin(), e = ids.cend(); i != e; ++i) { @@ -6490,9 +6488,7 @@ void HistoryWidget::onDeleteContextSure() { App::main()->checkPeerHistory(h->peer); } - if (App::main() && (App::main()->peer() == h->peer || (App::main()->peer() && h->peer->migrateTo() == App::main()->peer()))) { - App::main()->itemResized(0); - } + Notify::historyItemsResized(); Ui::hideLayer(); if (wasOnServer) { diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 35b5b361c..5e7b2752f 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -66,7 +66,7 @@ public: void touchScrollUpdated(const QPoint &screenPos); QPoint mapMouseToItem(QPoint p, HistoryItem *item); - int32 recountHeight(HistoryItem *resizedItem); + int32 recountHeight(const HistoryItem *resizedItem); void updateSize(); void redrawItem(const HistoryItem *item); @@ -492,7 +492,6 @@ public: void fillSelectedItems(SelectedItemSet &sel, bool forDelete = true); void itemRemoved(HistoryItem *item); void itemReplaced(HistoryItem *oldItem, HistoryItem *newItem); - void itemResized(HistoryItem *item, bool scrollToIt); void updateScrollColors(); @@ -563,6 +562,7 @@ public: void notify_botCommandsChanged(UserData *user); void notify_userIsBotChanged(UserData *user); void notify_migrateUpdated(PeerData *peer); + void notify_historyItemResized(const HistoryItem *item, bool scrollToIt); ~HistoryWidget(); @@ -696,7 +696,7 @@ private: QList _replyReturns; bool messagesFailed(const RPCError &error, mtpRequestId requestId); - void updateListSize(int32 addToY = 0, bool initial = false, bool loadedDown = false, HistoryItem *resizedItem = 0, bool scrollToIt = false); + void updateListSize(int32 addToY = 0, bool initial = false, bool loadedDown = false, const HistoryItem *resizedItem = 0, bool scrollToIt = false); void addMessagesToFront(PeerData *peer, const QVector &messages, const QVector *collapsed); void addMessagesToBack(PeerData *peer, const QVector &messages, const QVector *collapsed); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 7853dec45..de165b3dd 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -664,7 +664,7 @@ void MainWidget::webPagesUpdate() { if (j != items.cend()) { for (HistoryItemsMap::const_iterator k = j.value().cbegin(), e = j.value().cend(); k != e; ++k) { k.key()->initDimensions(); - itemResized(k.key()); + Notify::historyItemResized(k.key()); } } } @@ -790,6 +790,18 @@ void MainWidget::notify_historyItemLayoutChanged(const HistoryItem *item) { history.notify_historyItemLayoutChanged(item); } +void MainWidget::notify_historyItemResized(const HistoryItem *item, bool scrollToIt) { + if (!item || ((history.peer() == item->history()->peer || (history.peer() && history.peer() == item->history()->peer->migrateTo())) && !item->detached())) { + history.notify_historyItemResized(item, scrollToIt); + } else if (item) { + item->history()->width = 0; + if (history.peer() == item->history()->peer || (history.peer() && history.peer() == item->history()->peer->migrateTo())) { + history.resizeEvent(0); + } + } + if (item) Ui::redrawHistoryItem(item); +} + void MainWidget::noHider(HistoryHider *destroyed) { if (_hider == destroyed) { _hider = 0; @@ -1488,18 +1500,6 @@ void MainWidget::itemReplaced(HistoryItem *oldItem, HistoryItem *newItem) { } } -void MainWidget::itemResized(HistoryItem *row, bool scrollToIt) { - if (!row || ((history.peer() == row->history()->peer || (history.peer() && history.peer() == row->history()->peer->migrateTo())) && !row->detached())) { - history.itemResized(row, scrollToIt); - } else if (row) { - row->history()->width = 0; - if (history.peer() == row->history()->peer || (history.peer() && history.peer() == row->history()->peer->migrateTo())) { - history.resizeEvent(0); - } - } - if (row) Ui::redrawHistoryItem(row); -} - bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpRequestId req) { if (mtpIsFlood(error)) return false; @@ -4163,7 +4163,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) { if ((hasLinks && !item->hasTextLinks()) || (!hasLinks && item->textHasLinks())) { item->setText(text, d.has_entities() ? entitiesFromMTP(d.ventities.c_vector().v) : EntitiesInText()); item->initDimensions(); - itemResized(item); + Notify::historyItemResized(item); if (item->hasTextLinks() && item->indexInOverview()) { item->history()->addToOverview(item, OverviewLinks); } diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 215f7711b..ba07b887c 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -336,7 +336,6 @@ public: void changingMsgId(HistoryItem *row, MsgId newId); void itemRemoved(HistoryItem *item); void itemReplaced(HistoryItem *oldItem, HistoryItem *newItem); - void itemResized(HistoryItem *row, bool scrollToIt = false); void loadMediaBack(PeerData *peer, MediaOverviewType type, bool many = false); void peerUsernameChanged(PeerData *peer); @@ -416,6 +415,7 @@ public: void notify_userIsBotChanged(UserData *bot); void notify_userIsContactChanged(UserData *user, bool fromThisApp); void notify_migrateUpdated(PeerData *peer); + void notify_historyItemResized(const HistoryItem *row, bool scrollToIt); void notify_historyItemLayoutChanged(const HistoryItem *item); ~MainWidget(); diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 95db2d03a..59c62e63b 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -81,6 +81,7 @@ MediaView::MediaView() : TWidget(App::wnd()) , _zoomToScreen(0) , _pressed(false) , _dragging(0) +, _gif(0) , _full(-1) , _docNameWidth(0) , _docSizeWidth(0) @@ -150,8 +151,6 @@ MediaView::MediaView() : TWidget(App::wnd()) _touchTimer.setSingleShot(true); connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer())); - connect(&_currentGif, SIGNAL(updated()), this, SLOT(onGifUpdated())); - _btns.push_back(_btnSaveCancel = _dropdown.addButton(new IconedButton(this, st::mvButton, lang(lng_cancel)))); connect(_btnSaveCancel, SIGNAL(clicked()), this, SLOT(onSaveCancel())); _btns.push_back(_btnToMessage = _dropdown.addButton(new IconedButton(this, st::mvButton, lang(lng_context_to_msg)))); @@ -238,8 +237,23 @@ void MediaView::mediaOverviewUpdated(PeerData *peer, MediaOverviewType type) { } } +bool MediaView::fileShown() const { + return !_current.isNull() || gifShown(); +} + +bool MediaView::gifShown() const { + if (_gif && _gif->ready()) { + if (!_gif->started()) { + _gif->start(_gif->width(), _gif->height(), _gif->width(), _gif->height(), false); + const_cast(this)->_current = QPixmap(); + } + return _gif->state() != ClipError; + } + return false; +} + void MediaView::documentUpdated(DocumentData *doc) { - if (_doc && _doc == doc && _current.isNull() && _currentGif.isNull()) { + if (_doc && _doc == doc && !fileShown()) { if ((_doc->loader && _docCancel.isHidden()) || (!_doc->loader && !_docCancel.isHidden())) { updateControls(); } else if (_doc->loader) { @@ -249,10 +263,6 @@ void MediaView::documentUpdated(DocumentData *doc) { } } -void MediaView::onGifUpdated() { - update(_x, _y, _w, _h); -} - void MediaView::changingMsgId(HistoryItem *row, MsgId newId) { if (row->id == _msgid) { _msgid = newId; @@ -261,7 +271,7 @@ void MediaView::changingMsgId(HistoryItem *row, MsgId newId) { } void MediaView::updateDocSize() { - if (!_doc || !_current.isNull() || !_currentGif.isNull()) return; + if (!_doc || fileShown()) return; if (_doc->loader) { quint64 ready = _doc->loader->currentOffset(), total = _doc->size; @@ -294,7 +304,7 @@ void MediaView::updateDocSize() { } void MediaView::updateControls() { - if (_doc && _current.isNull() && _currentGif.isNull()) { + if (_doc && !fileShown()) { if (_doc->loader) { _docDownload.hide(); _docSaveAs.hide(); @@ -324,7 +334,7 @@ void MediaView::updateControls() { _docCancel.hide(); } - _saveVisible = ((_photo && _photo->full->loaded()) || (_doc && (!_doc->already(true).isEmpty() || (_current.isNull() && _currentGif.isNull() && (_photo || _doc))))); + _saveVisible = ((_photo && _photo->full->loaded()) || (_doc && (!_doc->already(true).isEmpty() || (!fileShown() && (_photo || _doc))))); _saveNav = myrtlrect(width() - st::mvIconSize.width() * 2, height() - st::mvIconSize.height(), st::mvIconSize.width(), st::mvIconSize.height()); _saveNavIcon = centersprite(_saveNav, st::mvSave); _moreNav = myrtlrect(width() - st::mvIconSize.width(), height() - st::mvIconSize.height(), st::mvIconSize.width(), st::mvIconSize.height()); @@ -387,7 +397,7 @@ void MediaView::updateDropdown() { _btnToMessage->setVisible(_msgid > 0); _btnShowInFolder->setVisible(_doc && !_doc->already(true).isEmpty()); _btnSaveAs->setVisible(true); - _btnCopy->setVisible((_doc && (!_current.isNull() || !_currentGif.isNull())) || (_photo && _photo->full->loaded())); + _btnCopy->setVisible((_doc && fileShown()) || (_photo && _photo->full->loaded())); _btnForward->setVisible(_canForward); _btnDelete->setVisible(_canDelete || (_photo && App::self() && App::self()->photoId == _photo->id) || (_photo && _photo->peer && _photo->peer->photoId == _photo->id && (_photo->peer->isChat() || (_photo->peer->isChannel() && _photo->peer->asChannel()->amCreator())))); _btnViewAll->setVisible((_overview != OverviewCount) && _history); @@ -478,7 +488,10 @@ void MediaView::step_state(uint64 ms, bool timer) { } MediaView::~MediaView() { + delete _gif; + setBadPointer(_gif); delete _menu; + setBadPointer(_menu); } void MediaView::showSaveMsgFile() { @@ -561,7 +574,7 @@ void MediaView::onSaveAs() { location.accessDisable(); } else { - if (_current.isNull() && _currentGif.isNull()) { + if (!fileShown()) { DocumentSaveLink::doSave(_doc, true); updateControls(); } else { @@ -600,6 +613,26 @@ void MediaView::onDocClick() { } } +void MediaView::ui_clipRedraw(ClipReader *reader) { + if (reader == _gif) { + update(_x, _y, _w, _h); + } +} + +void MediaView::notify_clipReinit(ClipReader *reader) { + if (reader == _gif) { + if (HistoryItem *item = App::histItemById(_msgmigrated ? 0 : _channel, _msgid)) { + if (_gif->state() == ClipError) { + _current = QPixmap(); + } + displayDocument(_doc, item); + } else { + delete _gif; + _gif = 0; + } + } +} + void MediaView::onDownload() { if (cAskDownloadPath()) { return onSaveAs(); @@ -624,7 +657,7 @@ void MediaView::onDownload() { } location.accessDisable(); } else { - if (_current.isNull() && _currentGif.isNull()) { + if (!fileShown()) { DocumentSaveLink::doSave(_doc); updateControls(); } else { @@ -713,8 +746,8 @@ void MediaView::onCopy() { if (_doc) { if (!_current.isNull()) { QApplication::clipboard()->setPixmap(_current); - } else if (!_currentGif.isNull()) { - QApplication::clipboard()->setPixmap(_currentGif.current(_currentGif.w, _currentGif.h, false)); + } else if (gifShown()) { + QApplication::clipboard()->setPixmap(QPixmap::fromImage(_gif->frameOriginal())); } } else { if (!_photo || !_photo->full->loaded()) return; @@ -850,8 +883,11 @@ void MediaView::showDocument(DocumentData *doc, HistoryItem *context) { } void MediaView::displayPhoto(PhotoData *photo, HistoryItem *item) { - _photo = photo; _doc = 0; + _photo = photo; + delete _gif; + _gif = 0; + _zoom = 0; _caption = Text(); @@ -865,7 +901,6 @@ void MediaView::displayPhoto(PhotoData *photo, HistoryItem *item) { MTP::clearLoaderPriorities(); _full = -1; _current = QPixmap(); - _currentGif.stop(); _down = OverNone; _w = convertScale(photo->full->width()); _h = convertScale(photo->full->height()); @@ -904,41 +939,39 @@ void MediaView::displayPhoto(PhotoData *photo, HistoryItem *item) { } void MediaView::displayDocument(DocumentData *doc, HistoryItem *item) { // empty messages shown as docs: doc can be NULL + if (!doc || !doc->isAnimation() || doc != _doc || (item && (item->id != _msgid || (item->history() != (_msgmigrated ? _migrated : _history))))) { + delete _gif; + _gif = 0; + } _doc = doc; _photo = 0; + _current = QPixmap(); + _caption = Text(); if (_doc) { const FileLocation &location(_doc->location(true)); if (_doc->sticker() && !_doc->sticker()->img->isNull() && _doc->sticker()->img->loaded()) { - _currentGif.stop(); _current = _doc->sticker()->img->pix(); } else if (location.accessEnable()) { - QImageReader reader(location.name()); - if (reader.canRead()) { - if (reader.supportsAnimation() && reader.imageCount() > 1) { - _currentGif.start(0, location); - _current = QPixmap(); - } else { - _currentGif.stop(); - QPixmap pix = QPixmap::fromImage(App::readImage(location.name(), 0, false), Qt::ColorOnly); - _current = pix; + if (_doc->isAnimation()) { + if (!_gif) { + if (_doc->dimensions.width() && _doc->dimensions.height()) { + _current = _doc->thumb->pixNoCache(_doc->dimensions.width(), _doc->dimensions.height(), true, true, false, _doc->dimensions.width(), _doc->dimensions.height()); + } + _gif = new ClipReader(location, _doc->data); } } else { - _currentGif.stop(); - _current = QPixmap(); + QImageReader reader(location.name()); + if (reader.canRead()) { + _current = QPixmap::fromImage(App::readImage(location.name(), 0, false), Qt::ColorOnly); + } } location.accessDisable(); - } else { - _currentGif.stop(); - _current = QPixmap(); } - } else { - _currentGif.stop(); - _current = QPixmap(); } - if (_current.isNull() && _currentGif.isNull()) { + if (!fileShown()) { if (!_doc || _doc->thumb->isNull()) { int32 colorIndex = documentColorIndex(_doc, _docExt); _docIconColor = documentColor(colorIndex); @@ -986,11 +1019,11 @@ void MediaView::displayDocument(DocumentData *doc, HistoryItem *item) { // empty _docIconRect = myrtlrect(_docRect.x() + st::mvDocPadding, _docRect.y() + st::mvDocPadding, st::mvDocIconSize, st::mvDocIconSize); } else if (!_current.isNull()) { _current.setDevicePixelRatio(cRetinaFactor()); - _w = _current.width() / cIntRetinaFactor(); - _h = _current.height() / cIntRetinaFactor(); + _w = convertScale(_current.width()); + _h = convertScale(_current.height()); } else { - _w = _currentGif.w / cIntRetinaFactor(); - _h = _currentGif.h / cIntRetinaFactor(); + _w = convertScale(_gif->width()); + _h = convertScale(_gif->height()); } if (isHidden()) { moveToScreen(); @@ -1045,9 +1078,8 @@ void MediaView::paintEvent(QPaintEvent *e) { QRect r(e->rect()); QRegion region(e->region()); QVector rs(region.rects()); - if (rs.size() > 1) { - int a = 0; - } + + uint64 ms = getms(); Painter p(this); @@ -1084,20 +1116,20 @@ void MediaView::paintEvent(QPaintEvent *e) { } } p.setOpacity(1); - if (_photo || !_current.isNull() || !_currentGif.isNull()) { + if (_photo || fileShown()) { QRect imgRect(_x, _y, _w, _h); - const QPixmap *toDraw = _currentGif.isNull() ? &_current : &_currentGif.current(_currentGif.w, _currentGif.h, false); if (imgRect.intersects(r)) { - if (toDraw->hasAlpha() && (!_doc || !_doc->sticker() || _doc->sticker()->img->isNull())) { + QPixmap toDraw = _current.isNull() ? _gif->current(_gif->width(), _gif->height(), _gif->width(), _gif->height(), ms) : _current; + if (!_gif && (!_doc || !_doc->sticker() || _doc->sticker()->img->isNull()) && toDraw.hasAlpha()) { p.fillRect(imgRect, _transparentBrush); } - if (_zoom) { + if (toDraw.width() != _w * cIntRetinaFactor()) { bool was = (p.renderHints() & QPainter::SmoothPixmapTransform); if (!was) p.setRenderHint(QPainter::SmoothPixmapTransform, true); - p.drawPixmap(QRect(_x, _y, _w, _h), *toDraw); + p.drawPixmap(QRect(_x, _y, _w, _h), toDraw); if (!was) p.setRenderHint(QPainter::SmoothPixmapTransform, false); } else { - p.drawPixmap(_x, _y, *toDraw); + p.drawPixmap(_x, _y, toDraw); } uint64 ms = 0; @@ -1353,7 +1385,7 @@ void MediaView::keyPressEvent(QKeyEvent *e) { } else if (e->key() == Qt::Key_Copy || (e->key() == Qt::Key_C && e->modifiers().testFlag(Qt::ControlModifier))) { onCopy(); } else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return || e->key() == Qt::Key_Space) { - if (_doc && !_doc->loader && _current.isNull() && _currentGif.isNull()) { + if (_doc && !_doc->loader && !fileShown()) { onDocClick(); } } else if (e->key() == Qt::Key_Left) { @@ -1397,7 +1429,7 @@ void MediaView::keyPressEvent(QKeyEvent *e) { newZoom = 0; } _x = -_width / 2; - _y = -(((_currentGif.isNull() ? _current.height() : _currentGif.h) / cIntRetinaFactor()) / 2); + _y = -((gifShown() ? _gif->height() : (_current.height() / cIntRetinaFactor())) / 2); float64 z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom; if (z >= 0) { _x = qRound(_x * (z + 1)); @@ -1417,8 +1449,8 @@ void MediaView::keyPressEvent(QKeyEvent *e) { } if (_zoom != newZoom) { float64 nx, ny, z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom; - _w = (_currentGif.isNull() ? _current.width() : _currentGif.w) / cIntRetinaFactor(); - _h = (_currentGif.isNull() ? _current.height() : _currentGif.h) / cIntRetinaFactor(); + _w = gifShown() ? _gif->width() : (_current.width() / cIntRetinaFactor()); + _h = gifShown() ? _gif->height() : (_current.height() / cIntRetinaFactor()); if (z >= 0) { nx = (_x - width() / 2.) / (z + 1); ny = (_y - height() / 2.) / (z + 1); @@ -1471,6 +1503,8 @@ void MediaView::moveToNext(int32 delta) { _channel = _history ? _history->channelId() : NoChannel; _canForward = _msgid > 0; _canDelete = item->canDelete(); + delete _gif; + _gif = 0; if (item->getMedia()) { switch (item->getMedia()->type()) { case MediaTypePhoto: displayPhoto(static_cast(item->getMedia())->photo(), item); preloadData(delta); break; @@ -1747,7 +1781,7 @@ void MediaView::updateOver(QPoint pos) { updateOverState(OverHeader); } else if (_saveVisible && _saveNav.contains(pos)) { updateOverState(OverSave); - } else if (_doc && _current.isNull() && _currentGif.isNull() && _docIconRect.contains(pos)) { + } else if (_doc && !fileShown() && _docIconRect.contains(pos)) { updateOverState(OverIcon); } else if (_moreNav.contains(pos)) { updateOverState(OverMore); @@ -1802,7 +1836,7 @@ void MediaView::mouseReleaseEvent(QMouseEvent *e) { } _dragging = 0; setCursor(style::cur_default); - } else if ((e->pos() - _lastAction).manhattanLength() >= st::mvDeltaFromLastAction && (!_doc || !_current.isNull() || !_currentGif.isNull() || !_docRect.contains(e->pos()))) { + } else if ((e->pos() - _lastAction).manhattanLength() >= st::mvDeltaFromLastAction && (!_doc || fileShown() || !_docRect.contains(e->pos()))) { close(); } _pressed = false; @@ -1914,6 +1948,8 @@ void MediaView::hide() { _controlsState = ControlsShown; a_cOpacity = anim::fvalue(1, 1); QWidget::hide(); + delete _gif; + _gif = 0; } void MediaView::onMenuDestroy(QObject *obj) { diff --git a/Telegram/SourceFiles/mediaview.h b/Telegram/SourceFiles/mediaview.h index 72c5cf3b4..d116397d5 100644 --- a/Telegram/SourceFiles/mediaview.h +++ b/Telegram/SourceFiles/mediaview.h @@ -73,6 +73,10 @@ public: void activateControls(); void onDocClick(); + void ui_clipRedraw(ClipReader *reader); + + void notify_clipReinit(ClipReader *reader); + ~MediaView(); public slots: @@ -98,7 +102,6 @@ public slots: void onTouchTimer(); void updateImage(); - void onGifUpdated(); private: @@ -138,9 +141,12 @@ private: bool _pressed; int32 _dragging; QPixmap _current; - AnimatedGif _currentGif; + ClipReader *_gif; int32 _full; // -1 - thumb, 0 - medium, 1 - full + bool fileShown() const; + bool gifShown() const; + style::sprite _docIcon; style::color _docIconColor; QString _docName, _docSize, _docExt; diff --git a/Telegram/SourceFiles/mtproto/mtpScheme.cpp b/Telegram/SourceFiles/mtproto/mtpScheme.cpp index a4b6e8960..0bdddfbd6 100644 --- a/Telegram/SourceFiles/mtproto/mtpScheme.cpp +++ b/Telegram/SourceFiles/mtproto/mtpScheme.cpp @@ -1140,7 +1140,7 @@ void _serialize_user(MTPStringLogger &to, int32 stage, int32 lev, Types &types, case 16: to.add(" photo: "); ++stages.back(); if (flag & MTPDuser::flag_photo) { types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 5 IN FIELD flags ]"); } break; case 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(" restiction_reason: "); ++stages.back(); if (flag & MTPDuser::flag_restiction_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 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; default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; } } @@ -1284,7 +1284,7 @@ void _serialize_channel(MTPStringLogger &to, int32 stage, int32 lev, Types &type case 14: to.add(" photo: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 15: to.add(" date: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 16: to.add(" version: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; - case 17: to.add(" restiction_reason: "); ++stages.back(); if (flag & MTPDchannel::flag_restiction_reason) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 9 IN FIELD flags ]"); } break; + case 17: to.add(" restriction_reason: "); ++stages.back(); if (flag & MTPDchannel::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 9 IN FIELD flags ]"); } break; default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; } } @@ -4246,11 +4246,10 @@ void _serialize_webPageExternal(MTPStringLogger &to, int32 stage, int32 lev, Typ case 5: to.add(" description: "); ++stages.back(); if (flag & MTPDwebPageExternal::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 & MTPDwebPageExternal::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 & MTPDwebPageExternal::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(" w: "); ++stages.back(); if (flag & MTPDwebPageExternal::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 9: to.add(" h: "); ++stages.back(); if (flag & MTPDwebPageExternal::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 10: to.add(" embed_url: "); ++stages.back(); if (flag & MTPDwebPageExternal::flag_embed_url) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 6 IN FIELD flags ]"); } break; - case 11: to.add(" embed_type: "); ++stages.back(); if (flag & MTPDwebPageExternal::flag_embed_type) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 6 IN FIELD flags ]"); } break; - case 12: to.add(" duration: "); ++stages.back(); if (flag & MTPDwebPageExternal::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 7 IN FIELD flags ]"); } break; + case 8: to.add(" content_type: "); ++stages.back(); if (flag & MTPDwebPageExternal::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 & MTPDwebPageExternal::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 & MTPDwebPageExternal::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 & MTPDwebPageExternal::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; } } diff --git a/Telegram/SourceFiles/mtproto/mtpScheme.h b/Telegram/SourceFiles/mtproto/mtpScheme.h index 910d981af..cf53b5277 100644 --- a/Telegram/SourceFiles/mtproto/mtpScheme.h +++ b/Telegram/SourceFiles/mtproto/mtpScheme.h @@ -130,7 +130,7 @@ enum { mtpc_fileLocationUnavailable = 0x7c596b46, mtpc_fileLocation = 0x53d69076, mtpc_userEmpty = 0x200250ba, - mtpc_user = 0x3289b590, + mtpc_user = 0x603539b4, mtpc_userProfilePhotoEmpty = 0x4f11bae1, mtpc_userProfilePhoto = 0xd559d8c8, mtpc_userStatusEmpty = 0x9d05049, @@ -142,7 +142,7 @@ enum { mtpc_chatEmpty = 0x9ba2d800, mtpc_chat = 0xd91cdd54, mtpc_chatForbidden = 0x7328bdb, - mtpc_channel = 0xe834ce68, + mtpc_channel = 0x4b1b7506, mtpc_channelForbidden = 0x2d85832c, mtpc_chatFull = 0x2e02a614, mtpc_channelFull = 0x9e341ddf, @@ -380,7 +380,7 @@ enum { mtpc_webPageEmpty = 0xeb1477e8, mtpc_webPagePending = 0xc586da1c, mtpc_webPage = 0xca820ed7, - mtpc_webPageExternal = 0xbb54b77, + mtpc_webPageExternal = 0xb08fbb93, mtpc_authorization = 0x7bf2e6f6, mtpc_account_authorizations = 0x1250abde, mtpc_account_noPassword = 0x96dabc18, @@ -3194,7 +3194,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 &_restiction_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); mtpTypeId _type; }; @@ -3379,7 +3379,7 @@ private: friend MTPchat MTP_chatEmpty(MTPint _id); friend MTPchat MTP_chat(MTPint _flags, MTPint _id, const MTPstring &_title, const MTPChatPhoto &_photo, MTPint _participants_count, MTPint _date, MTPint _version, const MTPInputChannel &_migrated_to); friend MTPchat MTP_chatForbidden(MTPint _id, const MTPstring &_title); - friend MTPchat MTP_channel(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_title, const MTPstring &_username, const MTPChatPhoto &_photo, MTPint _date, MTPint _version, const MTPstring &_restiction_reason); + friend MTPchat MTP_channel(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_title, const MTPstring &_username, const MTPChatPhoto &_photo, MTPint _date, MTPint _version, const MTPstring &_restriction_reason); friend MTPchat MTP_channelForbidden(MTPint _id, const MTPlong &_access_hash, const MTPstring &_title); mtpTypeId _type; @@ -7606,7 +7606,7 @@ private: friend MTPwebPage MTP_webPageEmpty(const MTPlong &_id); friend MTPwebPage MTP_webPagePending(const MTPlong &_id, MTPint _date); friend MTPwebPage MTP_webPage(MTPint _flags, const MTPlong &_id, const MTPstring &_url, const MTPstring &_display_url, const MTPstring &_type, const MTPstring &_site_name, const MTPstring &_title, const MTPstring &_description, const MTPPhoto &_photo, const MTPstring &_embed_url, const MTPstring &_embed_type, MTPint _embed_width, MTPint _embed_height, MTPint _duration, const MTPstring &_author, const MTPDocument &_document); - friend MTPwebPage MTP_webPageExternal(MTPint _flags, const MTPstring &_url, const MTPstring &_display_url, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_thumb_url, const MTPstring &_content_url, MTPint _w, MTPint _h, const MTPstring &_embed_url, const MTPstring &_embed_type, MTPint _duration); + friend MTPwebPage MTP_webPageExternal(MTPint _flags, const MTPstring &_url, const MTPstring &_display_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); mtpTypeId _type; }; @@ -9800,7 +9800,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 &_restiction_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), vrestiction_reason(_restiction_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) : 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) { } MTPint vflags; @@ -9813,7 +9813,7 @@ public: MTPUserProfilePhoto vphoto; MTPUserStatus vstatus; MTPint vbot_info_version; - MTPstring vrestiction_reason; + MTPstring vrestriction_reason; enum { flag_self = (1 << 10), @@ -9833,7 +9833,7 @@ public: flag_photo = (1 << 5), flag_status = (1 << 6), flag_bot_info_version = (1 << 14), - flag_restiction_reason = (1 << 18), + flag_restriction_reason = (1 << 18), }; bool is_self() const { return vflags.v & flag_self; } @@ -9853,7 +9853,7 @@ public: bool has_photo() const { return vflags.v & flag_photo; } bool has_status() const { return vflags.v & flag_status; } bool has_bot_info_version() const { return vflags.v & flag_bot_info_version; } - bool has_restiction_reason() const { return vflags.v & flag_restiction_reason; } + bool has_restriction_reason() const { return vflags.v & flag_restriction_reason; } }; class MTPDuserProfilePhoto : public mtpDataImpl { @@ -9948,7 +9948,7 @@ class MTPDchannel : public mtpDataImpl { public: MTPDchannel() { } - MTPDchannel(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_title, const MTPstring &_username, const MTPChatPhoto &_photo, MTPint _date, MTPint _version, const MTPstring &_restiction_reason) : vflags(_flags), vid(_id), vaccess_hash(_access_hash), vtitle(_title), vusername(_username), vphoto(_photo), vdate(_date), vversion(_version), vrestiction_reason(_restiction_reason) { + MTPDchannel(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_title, const MTPstring &_username, const MTPChatPhoto &_photo, MTPint _date, MTPint _version, const MTPstring &_restriction_reason) : vflags(_flags), vid(_id), vaccess_hash(_access_hash), vtitle(_title), vusername(_username), vphoto(_photo), vdate(_date), vversion(_version), vrestriction_reason(_restriction_reason) { } MTPint vflags; @@ -9959,7 +9959,7 @@ public: MTPChatPhoto vphoto; MTPint vdate; MTPint vversion; - MTPstring vrestiction_reason; + MTPstring vrestriction_reason; enum { flag_creator = (1 << 0), @@ -9972,7 +9972,7 @@ public: flag_megagroup = (1 << 8), flag_restricted = (1 << 9), flag_username = (1 << 6), - flag_restiction_reason = (1 << 9), + flag_restriction_reason = (1 << 9), }; bool is_creator() const { return vflags.v & flag_creator; } @@ -9985,7 +9985,7 @@ public: bool is_megagroup() const { return vflags.v & flag_megagroup; } bool is_restricted() const { return vflags.v & flag_restricted; } bool has_username() const { return vflags.v & flag_username; } - bool has_restiction_reason() const { return vflags.v & flag_restiction_reason; } + bool has_restriction_reason() const { return vflags.v & flag_restriction_reason; } }; class MTPDchannelForbidden : public mtpDataImpl { @@ -12299,7 +12299,7 @@ class MTPDwebPageExternal : public mtpDataImpl { public: MTPDwebPageExternal() { } - MTPDwebPageExternal(MTPint _flags, const MTPstring &_url, const MTPstring &_display_url, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_thumb_url, const MTPstring &_content_url, MTPint _w, MTPint _h, const MTPstring &_embed_url, const MTPstring &_embed_type, MTPint _duration) : vflags(_flags), vurl(_url), vdisplay_url(_display_url), vtype(_type), vtitle(_title), vdescription(_description), vthumb_url(_thumb_url), vcontent_url(_content_url), vw(_w), vh(_h), vembed_url(_embed_url), vembed_type(_embed_type), vduration(_duration) { + MTPDwebPageExternal(MTPint _flags, const MTPstring &_url, const MTPstring &_display_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), vdisplay_url(_display_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; @@ -12310,10 +12310,9 @@ public: MTPstring vdescription; MTPstring vthumb_url; MTPstring vcontent_url; + MTPstring vcontent_type; MTPint vw; MTPint vh; - MTPstring vembed_url; - MTPstring vembed_type; MTPint vduration; enum { @@ -12322,11 +12321,10 @@ public: 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_embed_url = (1 << 6), - flag_embed_type = (1 << 6), - flag_duration = (1 << 7), + flag_duration = (1 << 6), }; bool has_type() const { return vflags.v & flag_type; } @@ -12334,10 +12332,9 @@ public: 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_embed_url() const { return vflags.v & flag_embed_url; } - bool has_embed_type() const { return vflags.v & flag_embed_type; } bool has_duration() const { return vflags.v & flag_duration; } }; @@ -22175,7 +22172,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_restiction_reason() ? v.vrestiction_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); } } return 0; @@ -22205,7 +22202,7 @@ inline void MTPuser::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId if (v.has_photo()) { v.vphoto.read(from, end); } else { v.vphoto = MTPUserProfilePhoto(); } 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_restiction_reason()) { v.vrestiction_reason.read(from, end); } else { v.vrestiction_reason = MTPstring(); } + if (v.has_restriction_reason()) { v.vrestriction_reason.read(from, end); } else { v.vrestriction_reason = MTPstring(); } } break; default: throw mtpErrorUnexpected(cons, "MTPuser"); } @@ -22228,7 +22225,7 @@ inline void MTPuser::write(mtpBuffer &to) const { if (v.has_photo()) v.vphoto.write(to); if (v.has_status()) v.vstatus.write(to); if (v.has_bot_info_version()) v.vbot_info_version.write(to); - if (v.has_restiction_reason()) v.vrestiction_reason.write(to); + if (v.has_restriction_reason()) v.vrestriction_reason.write(to); } break; } } @@ -22246,8 +22243,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 &_restiction_reason) { - return MTPuser(new MTPDuser(_flags, _id, _access_hash, _first_name, _last_name, _username, _phone, _photo, _status, _bot_info_version, _restiction_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) { + return MTPuser(new MTPDuser(_flags, _id, _access_hash, _first_name, _last_name, _username, _phone, _photo, _status, _bot_info_version, _restriction_reason)); } inline uint32 MTPuserProfilePhoto::innerLength() const { @@ -22402,7 +22399,7 @@ inline uint32 MTPchat::innerLength() const { } case mtpc_channel: { const MTPDchannel &v(c_channel()); - return v.vflags.innerLength() + v.vid.innerLength() + v.vaccess_hash.innerLength() + v.vtitle.innerLength() + (v.has_username() ? v.vusername.innerLength() : 0) + v.vphoto.innerLength() + v.vdate.innerLength() + v.vversion.innerLength() + (v.has_restiction_reason() ? v.vrestiction_reason.innerLength() : 0); + return v.vflags.innerLength() + v.vid.innerLength() + v.vaccess_hash.innerLength() + v.vtitle.innerLength() + (v.has_username() ? v.vusername.innerLength() : 0) + v.vphoto.innerLength() + v.vdate.innerLength() + v.vversion.innerLength() + (v.has_restriction_reason() ? v.vrestriction_reason.innerLength() : 0); } case mtpc_channelForbidden: { const MTPDchannelForbidden &v(c_channelForbidden()); @@ -22452,7 +22449,7 @@ inline void MTPchat::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId v.vphoto.read(from, end); v.vdate.read(from, end); v.vversion.read(from, end); - if (v.has_restiction_reason()) { v.vrestiction_reason.read(from, end); } else { v.vrestiction_reason = MTPstring(); } + if (v.has_restriction_reason()) { v.vrestriction_reason.read(from, end); } else { v.vrestriction_reason = MTPstring(); } } break; case mtpc_channelForbidden: _type = cons; { if (!data) setData(new MTPDchannelForbidden()); @@ -22496,7 +22493,7 @@ inline void MTPchat::write(mtpBuffer &to) const { v.vphoto.write(to); v.vdate.write(to); v.vversion.write(to); - if (v.has_restiction_reason()) v.vrestiction_reason.write(to); + if (v.has_restriction_reason()) v.vrestriction_reason.write(to); } break; case mtpc_channelForbidden: { const MTPDchannelForbidden &v(c_channelForbidden()); @@ -22535,8 +22532,8 @@ inline MTPchat MTP_chat(MTPint _flags, MTPint _id, const MTPstring &_title, cons inline MTPchat MTP_chatForbidden(MTPint _id, const MTPstring &_title) { return MTPchat(new MTPDchatForbidden(_id, _title)); } -inline MTPchat MTP_channel(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_title, const MTPstring &_username, const MTPChatPhoto &_photo, MTPint _date, MTPint _version, const MTPstring &_restiction_reason) { - return MTPchat(new MTPDchannel(_flags, _id, _access_hash, _title, _username, _photo, _date, _version, _restiction_reason)); +inline MTPchat MTP_channel(MTPint _flags, MTPint _id, const MTPlong &_access_hash, const MTPstring &_title, const MTPstring &_username, const MTPChatPhoto &_photo, MTPint _date, MTPint _version, const MTPstring &_restriction_reason) { + return MTPchat(new MTPDchannel(_flags, _id, _access_hash, _title, _username, _photo, _date, _version, _restriction_reason)); } inline MTPchat MTP_channelForbidden(MTPint _id, const MTPlong &_access_hash, const MTPstring &_title) { return MTPchat(new MTPDchannelForbidden(_id, _access_hash, _title)); @@ -28304,7 +28301,7 @@ inline uint32 MTPwebPage::innerLength() const { } case mtpc_webPageExternal: { const MTPDwebPageExternal &v(c_webPageExternal()); - return v.vflags.innerLength() + v.vurl.innerLength() + v.vdisplay_url.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_w() ? v.vw.innerLength() : 0) + (v.has_h() ? v.vh.innerLength() : 0) + (v.has_embed_url() ? v.vembed_url.innerLength() : 0) + (v.has_embed_type() ? v.vembed_type.innerLength() : 0) + (v.has_duration() ? v.vduration.innerLength() : 0); + return v.vflags.innerLength() + v.vurl.innerLength() + v.vdisplay_url.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); } } return 0; @@ -28358,10 +28355,9 @@ inline void MTPwebPage::read(const mtpPrime *&from, const mtpPrime *end, mtpType 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_embed_url()) { v.vembed_url.read(from, end); } else { v.vembed_url = MTPstring(); } - if (v.has_embed_type()) { v.vembed_type.read(from, end); } else { v.vembed_type = MTPstring(); } if (v.has_duration()) { v.vduration.read(from, end); } else { v.vduration = MTPint(); } } break; default: throw mtpErrorUnexpected(cons, "MTPwebPage"); @@ -28407,10 +28403,9 @@ inline void MTPwebPage::write(mtpBuffer &to) const { 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_embed_url()) v.vembed_url.write(to); - if (v.has_embed_type()) v.vembed_type.write(to); if (v.has_duration()) v.vduration.write(to); } break; } @@ -28441,8 +28436,8 @@ inline MTPwebPage MTP_webPagePending(const MTPlong &_id, MTPint _date) { inline MTPwebPage MTP_webPage(MTPint _flags, const MTPlong &_id, const MTPstring &_url, const MTPstring &_display_url, const MTPstring &_type, const MTPstring &_site_name, const MTPstring &_title, const MTPstring &_description, const MTPPhoto &_photo, const MTPstring &_embed_url, const MTPstring &_embed_type, MTPint _embed_width, MTPint _embed_height, MTPint _duration, const MTPstring &_author, const MTPDocument &_document) { return MTPwebPage(new MTPDwebPage(_flags, _id, _url, _display_url, _type, _site_name, _title, _description, _photo, _embed_url, _embed_type, _embed_width, _embed_height, _duration, _author, _document)); } -inline MTPwebPage MTP_webPageExternal(MTPint _flags, const MTPstring &_url, const MTPstring &_display_url, const MTPstring &_type, const MTPstring &_title, const MTPstring &_description, const MTPstring &_thumb_url, const MTPstring &_content_url, MTPint _w, MTPint _h, const MTPstring &_embed_url, const MTPstring &_embed_type, MTPint _duration) { - return MTPwebPage(new MTPDwebPageExternal(_flags, _url, _display_url, _type, _title, _description, _thumb_url, _content_url, _w, _h, _embed_url, _embed_type, _duration)); +inline MTPwebPage MTP_webPageExternal(MTPint _flags, const MTPstring &_url, const MTPstring &_display_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 MTPwebPage(new MTPDwebPageExternal(_flags, _url, _display_url, _type, _title, _description, _thumb_url, _content_url, _content_type, _w, _h, _duration)); } inline MTPauthorization::MTPauthorization() : mtpDataOwner(new MTPDauthorization()) { diff --git a/Telegram/SourceFiles/mtproto/scheme.tl b/Telegram/SourceFiles/mtproto/scheme.tl index 811c9f1d5..441edfd1e 100644 --- a/Telegram/SourceFiles/mtproto/scheme.tl +++ b/Telegram/SourceFiles/mtproto/scheme.tl @@ -204,7 +204,7 @@ fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileL fileLocation#53d69076 dc_id:int volume_id:long local_id:int secret:long = FileLocation; userEmpty#200250ba id:int = User; -user#3289b590 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restiction_reason:flags.18?string = User; +user#603539b4 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?string = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; userProfilePhoto#d559d8c8 photo_id:long photo_small:FileLocation photo_big:FileLocation = UserProfilePhoto; @@ -219,7 +219,7 @@ userStatusLastMonth#77ebc742 = UserStatus; chatEmpty#9ba2d800 id:int = Chat; chat#d91cdd54 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true admins_enabled:flags.3?true admin:flags.4?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel = Chat; chatForbidden#7328bdb id:int title:string = Chat; -channel#e834ce68 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true editor:flags.3?true moderator:flags.4?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true id:int access_hash:long title:string username:flags.6?string photo:ChatPhoto date:int version:int restiction_reason:flags.9?string = Chat; +channel#4b1b7506 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true editor:flags.3?true moderator:flags.4?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true id:int access_hash:long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string = Chat; channelForbidden#2d85832c id:int access_hash:long title:string = Chat; chatFull#2e02a614 id:int participants:ChatParticipants chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector = ChatFull; @@ -539,7 +539,7 @@ contactLinkContact#d502c2d0 = ContactLink; webPageEmpty#eb1477e8 id:long = WebPage; webPagePending#c586da1c id:long date:int = WebPage; webPage#ca820ed7 flags:# id:long url:string display_url:string type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document = WebPage; -webPageExternal#bb54b77 flags:# url:string display_url:string type:flags.0?string title:flags.1?string description:flags.2?string thumb_url:flags.3?string content_url:flags.4?string w:flags.5?int h:flags.5?int embed_url:flags.6?string embed_type:flags.6?string duration:flags.7?int = WebPage; +webPageExternal#b08fbb93 flags:# url:string display_url:string type:flags.0?string title:flags.1?string description:flags.2?string thumb_url:flags.3?string content_url:flags.4?string content_type:flags.4?string w:flags.5?int h:flags.5?int duration:flags.6?int = WebPage; authorization#7bf2e6f6 hash:long flags:int device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index df1ee6bb4..269ca7b14 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -3198,9 +3198,7 @@ void OverviewWidget::onDeleteSelectedSure() { for (SelectedItemSet::const_iterator i = sel.cbegin(), e = sel.cend(); i != e; ++i) { i.value()->destroy(); } - if (App::main() && App::main()->peer() == peer()) { - App::main()->itemResized(0); - } + Notify::historyItemsResized(); Ui::hideLayer(); for (QMap >::const_iterator i = ids.cbegin(), e = ids.cend(); i != e; ++i) { @@ -3222,9 +3220,7 @@ void OverviewWidget::onDeleteContextSure() { App::main()->checkPeerHistory(h->peer); } - if (App::main() && (App::main()->peer() == h->peer || (App::main()->peer() && App::main()->peer() == h->peer->migrateTo()))) { - App::main()->itemResized(0); - } + Notify::historyItemsResized(); Ui::hideLayer(); if (wasOnServer) { diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index 3f7f61032..502df8e9b 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -797,6 +797,12 @@ void Window::showDocument(DocumentData *doc, HistoryItem *item) { _mediaView->setFocus(); } +void Window::ui_clipRedraw(ClipReader *reader) { + if (_mediaView && !_mediaView->isHidden()) { + _mediaView->ui_clipRedraw(reader); + } +} + void Window::ui_showLayer(LayeredWidget *box, ShowLayerOptions options) { if (box) { bool fast = (options.testFlag(ForceFastShowLayer)) || Ui::isLayerShown(); @@ -838,6 +844,12 @@ bool Window::ui_isLayerShown() { return !!layerBg; } +void Window::notify_clipReinit(ClipReader *reader) { + if (_mediaView && !_mediaView->isHidden()) { + _mediaView->notify_clipReinit(reader); + } +} + void Window::showConnecting(const QString &text, const QString &reconnect) { if (_connecting) { _connecting->set(text, reconnect); diff --git a/Telegram/SourceFiles/window.h b/Telegram/SourceFiles/window.h index e98da0f7c..0b273c5a2 100644 --- a/Telegram/SourceFiles/window.h +++ b/Telegram/SourceFiles/window.h @@ -184,9 +184,6 @@ public: void showPhoto(PhotoData *photo, PeerData *item); void showDocument(DocumentData *doc, HistoryItem *item); - void ui_showLayer(LayeredWidget *box, ShowLayerOptions options); - bool ui_isLayerShown(); - bool historyIsActive() const; void activate(); @@ -240,6 +237,12 @@ public: return contentOverlapped(QRect(w->mapToGlobal(r.boundingRect().topLeft()), r.boundingRect().size())); } + void ui_clipRedraw(ClipReader *reader); + void ui_showLayer(LayeredWidget *box, ShowLayerOptions options); + bool ui_isLayerShown(); + + void notify_clipReinit(ClipReader *reader); + public slots: void updateIsActive(int timeout = 0);