2017-09-26 11:49:16 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-09-26 11:49:16 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "data/data_photo.h"
|
|
|
|
#include "data/data_document.h"
|
|
|
|
|
2020-06-05 09:03:45 +00:00
|
|
|
class ChannelData;
|
|
|
|
|
2020-06-08 09:06:50 +00:00
|
|
|
namespace Data {
|
2020-06-05 09:03:45 +00:00
|
|
|
class Session;
|
2020-06-08 09:06:50 +00:00
|
|
|
} // namespace Data
|
2020-06-05 09:03:45 +00:00
|
|
|
|
2018-10-31 10:11:01 +00:00
|
|
|
enum class WebPageType {
|
|
|
|
Photo,
|
|
|
|
Video,
|
|
|
|
Profile,
|
2019-01-16 12:25:29 +00:00
|
|
|
WallPaper,
|
2019-09-09 11:56:05 +00:00
|
|
|
Theme,
|
2018-10-31 10:11:01 +00:00
|
|
|
Article,
|
|
|
|
ArticleWithIV,
|
2017-09-26 11:49:16 +00:00
|
|
|
};
|
|
|
|
|
2018-10-31 10:11:01 +00:00
|
|
|
WebPageType ParseWebPageType(const MTPDwebPage &type);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2018-10-24 11:52:31 +00:00
|
|
|
struct WebPageCollage {
|
2020-08-31 08:14:53 +00:00
|
|
|
using Item = std::variant<PhotoData*, DocumentData*>;
|
2018-10-24 11:52:31 +00:00
|
|
|
|
|
|
|
WebPageCollage() = default;
|
2020-06-08 09:06:50 +00:00
|
|
|
explicit WebPageCollage(
|
|
|
|
not_null<Data::Session*> owner,
|
|
|
|
const MTPDwebPage &data);
|
2018-10-24 11:52:31 +00:00
|
|
|
|
|
|
|
std::vector<Item> items;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
struct WebPageData {
|
2020-06-08 09:06:50 +00:00
|
|
|
WebPageData(not_null<Data::Session*> owner, const WebPageId &id);
|
|
|
|
|
|
|
|
[[nodiscard]] Data::Session &owner() const;
|
|
|
|
[[nodiscard]] Main::Session &session() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2017-12-31 09:39:21 +00:00
|
|
|
bool applyChanges(
|
2018-10-31 10:11:01 +00:00
|
|
|
WebPageType newType,
|
2017-12-31 09:39:21 +00:00
|
|
|
const QString &newUrl,
|
|
|
|
const QString &newDisplayUrl,
|
|
|
|
const QString &newSiteName,
|
|
|
|
const QString &newTitle,
|
|
|
|
const TextWithEntities &newDescription,
|
|
|
|
PhotoData *newPhoto,
|
|
|
|
DocumentData *newDocument,
|
2018-10-24 11:52:31 +00:00
|
|
|
WebPageCollage &&newCollage,
|
2017-12-31 09:39:21 +00:00
|
|
|
int newDuration,
|
|
|
|
const QString &newAuthor,
|
|
|
|
int newPendingTill);
|
|
|
|
|
2020-06-05 09:03:45 +00:00
|
|
|
static void ApplyChanges(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
ChannelData *channel,
|
|
|
|
const MTPmessages_Messages &result);
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
WebPageId id = 0;
|
2018-10-31 10:11:01 +00:00
|
|
|
WebPageType type = WebPageType::Article;
|
2017-09-26 11:49:16 +00:00
|
|
|
QString url;
|
|
|
|
QString displayUrl;
|
|
|
|
QString siteName;
|
|
|
|
QString title;
|
|
|
|
TextWithEntities description;
|
2017-12-31 09:39:21 +00:00
|
|
|
int duration = 0;
|
2017-09-26 11:49:16 +00:00
|
|
|
QString author;
|
|
|
|
PhotoData *photo = nullptr;
|
|
|
|
DocumentData *document = nullptr;
|
2018-10-24 11:52:31 +00:00
|
|
|
WebPageCollage collage;
|
2017-12-31 09:39:21 +00:00
|
|
|
int pendingTill = 0;
|
|
|
|
int version = 0;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2018-10-25 09:24:45 +00:00
|
|
|
private:
|
|
|
|
void replaceDocumentGoodThumbnail();
|
|
|
|
|
2020-06-08 09:06:50 +00:00
|
|
|
const not_null<Data::Session*> _owner;
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
};
|