tdesktop/Telegram/SourceFiles/data/data_web_page.h

104 lines
1.9 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "data/data_photo.h"
#include "data/data_document.h"
class ChannelData;
2020-06-08 09:06:50 +00:00
namespace Data {
class Session;
2020-06-08 09:06:50 +00:00
} // namespace Data
enum class WebPageType {
2021-10-10 16:11:08 +00:00
Message,
Group,
2021-10-12 12:50:18 +00:00
GroupWithRequest,
2021-10-10 16:11:08 +00:00
Channel,
2021-10-12 12:50:18 +00:00
ChannelWithRequest,
2021-10-10 16:11:08 +00:00
Photo,
Video,
2021-10-10 16:11:08 +00:00
User,
Bot,
Profile,
2021-10-10 16:11:08 +00:00
2019-01-16 12:25:29 +00:00
WallPaper,
Theme,
2021-10-10 16:11:08 +00:00
Article,
ArticleWithIV,
2021-10-10 16:11:08 +00:00
VoiceChat,
Livestream,
};
WebPageType ParseWebPageType(const MTPDwebPage &type);
struct WebPageCollage {
using Item = std::variant<PhotoData*, DocumentData*>;
WebPageCollage() = default;
2020-06-08 09:06:50 +00:00
explicit WebPageCollage(
not_null<Data::Session*> owner,
const MTPDwebPage &data);
std::vector<Item> items;
};
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-12-31 09:39:21 +00:00
bool applyChanges(
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,
WebPageCollage &&newCollage,
2017-12-31 09:39:21 +00:00
int newDuration,
const QString &newAuthor,
int newPendingTill);
static void ApplyChanges(
not_null<Main::Session*> session,
ChannelData *channel,
const MTPmessages_Messages &result);
WebPageId id = 0;
WebPageType type = WebPageType::Article;
QString url;
QString displayUrl;
QString siteName;
QString title;
TextWithEntities description;
2017-12-31 09:39:21 +00:00
int duration = 0;
QString author;
PhotoData *photo = nullptr;
DocumentData *document = nullptr;
WebPageCollage collage;
2017-12-31 09:39:21 +00:00
int pendingTill = 0;
int version = 0;
private:
void replaceDocumentGoodThumbnail();
2020-06-08 09:06:50 +00:00
const not_null<Data::Session*> _owner;
};