2016-09-27 14:20:49 +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.
|
2016-09-27 14:20:49 +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
|
2016-09-27 14:20:49 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
#include "history/history_item.h"
|
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
class Message;
|
|
|
|
} // namespace HistoryView
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
struct HistoryMessageEdited;
|
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
2020-06-08 09:06:50 +00:00
|
|
|
not_null<HistoryItem*> item);
|
2017-08-17 08:31:24 +00:00
|
|
|
MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer);
|
2019-08-09 19:19:23 +00:00
|
|
|
MTPDmessage_ClientFlags NewMessageClientFlags();
|
2019-08-30 13:17:46 +00:00
|
|
|
QString GetErrorTextForSending(
|
2017-12-06 10:13:38 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-07-18 16:09:50 +00:00
|
|
|
const HistoryItemsList &items,
|
|
|
|
bool ignoreSlowmodeCountdown = false);
|
2019-08-30 13:17:46 +00:00
|
|
|
QString GetErrorTextForSending(
|
2019-07-18 16:09:50 +00:00
|
|
|
not_null<PeerData*> peer,
|
|
|
|
const HistoryItemsList &items,
|
|
|
|
const TextWithTags &comment,
|
|
|
|
bool ignoreSlowmodeCountdown = false);
|
2017-08-17 08:31:24 +00:00
|
|
|
void FastShareMessage(not_null<HistoryItem*> item);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-01 21:14:19 +00:00
|
|
|
class HistoryMessage : public HistoryItem {
|
2016-09-27 14:20:49 +00:00
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2019-08-09 19:19:23 +00:00
|
|
|
const MTPDmessage &data,
|
|
|
|
MTPDmessage_ClientFlags clientFlags);
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2019-08-09 19:19:23 +00:00
|
|
|
const MTPDmessageService &data,
|
|
|
|
MTPDmessage_ClientFlags clientFlags);
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2017-12-13 18:10:48 +00:00
|
|
|
MTPDmessage::Flags flags,
|
2019-08-09 19:19:23 +00:00
|
|
|
MTPDmessage_ClientFlags clientFlags,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2017-12-13 18:10:48 +00:00
|
|
|
UserId from,
|
|
|
|
const QString &postAuthor,
|
2018-02-03 19:52:35 +00:00
|
|
|
not_null<HistoryMessage*> original); // local forwarded
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2017-12-13 18:10:48 +00:00
|
|
|
MTPDmessage::Flags flags,
|
2019-08-09 19:19:23 +00:00
|
|
|
MTPDmessage_ClientFlags clientFlags,
|
2017-12-13 18:10:48 +00:00
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2017-12-13 18:10:48 +00:00
|
|
|
UserId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
const TextWithEntities &textWithEntities); // local message
|
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2017-12-13 18:10:48 +00:00
|
|
|
MTPDmessage::Flags flags,
|
2019-08-09 19:19:23 +00:00
|
|
|
MTPDmessage_ClientFlags clientFlags,
|
2017-12-13 18:10:48 +00:00
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2017-12-13 18:10:48 +00:00
|
|
|
UserId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<DocumentData*> document,
|
2018-01-18 13:59:22 +00:00
|
|
|
const TextWithEntities &caption,
|
2017-12-13 18:10:48 +00:00
|
|
|
const MTPReplyMarkup &markup); // local document
|
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2017-12-13 18:10:48 +00:00
|
|
|
MTPDmessage::Flags flags,
|
2019-08-09 19:19:23 +00:00
|
|
|
MTPDmessage_ClientFlags clientFlags,
|
2017-12-13 18:10:48 +00:00
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2017-12-13 18:10:48 +00:00
|
|
|
UserId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<PhotoData*> photo,
|
2018-01-18 13:59:22 +00:00
|
|
|
const TextWithEntities &caption,
|
2017-12-13 18:10:48 +00:00
|
|
|
const MTPReplyMarkup &markup); // local photo
|
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2017-12-13 18:10:48 +00:00
|
|
|
MTPDmessage::Flags flags,
|
2019-08-09 19:19:23 +00:00
|
|
|
MTPDmessage_ClientFlags clientFlags,
|
2017-12-13 18:10:48 +00:00
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2017-12-13 18:10:48 +00:00
|
|
|
UserId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<GameData*> game,
|
|
|
|
const MTPReplyMarkup &markup); // local game
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2018-01-18 20:02:50 +00:00
|
|
|
void refreshMedia(const MTPMessageMedia *media);
|
|
|
|
void refreshSentMedia(const MTPMessageMedia *media);
|
2019-03-29 14:17:46 +00:00
|
|
|
void returnSavedMedia() override;
|
2018-01-18 20:02:50 +00:00
|
|
|
void setMedia(const MTPMessageMedia &media);
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] static std::unique_ptr<Data::Media> CreateMedia(
|
2018-01-18 20:02:50 +00:00
|
|
|
not_null<HistoryMessage*> item,
|
|
|
|
const MTPMessageMedia &media);
|
|
|
|
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] bool allowsForward() const override;
|
2019-08-09 17:58:58 +00:00
|
|
|
[[nodiscard]] bool allowsSendNow() const override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] bool allowsEdit(TimeId now) const override;
|
|
|
|
[[nodiscard]] bool uploading() const;
|
|
|
|
|
2019-07-19 15:05:48 +00:00
|
|
|
[[nodiscard]] const Ui::Text::String &messageBadge() const {
|
|
|
|
return _messageBadge;
|
2019-07-19 13:34:09 +00:00
|
|
|
}
|
2019-07-19 15:05:48 +00:00
|
|
|
[[nodiscard]] bool hasMessageBadge() const {
|
|
|
|
return !_messageBadge.isEmpty();
|
2019-05-24 12:13:16 +00:00
|
|
|
}
|
2019-08-30 15:00:32 +00:00
|
|
|
[[nodiscard]] bool hideEditedBadge() const {
|
|
|
|
return (_flags & MTPDmessage::Flag::f_edit_hide);
|
|
|
|
}
|
2018-01-18 20:02:50 +00:00
|
|
|
|
|
|
|
void applyGroupAdminChanges(
|
2019-07-19 13:34:09 +00:00
|
|
|
const base::flat_set<UserId> &changes) override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
|
|
|
void setViewsCount(int32 count) override;
|
|
|
|
void setRealId(MsgId newId) override;
|
|
|
|
|
|
|
|
void dependencyItemRemoved(HistoryItem *dependency) override;
|
|
|
|
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] QString notificationHeader() const override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
|
|
|
void applyEdition(const MTPDmessage &message) override;
|
|
|
|
void applyEdition(const MTPDmessageService &message) override;
|
2019-08-07 14:38:26 +00:00
|
|
|
void updateSentContent(
|
|
|
|
const TextWithEntities &textWithEntities,
|
|
|
|
const MTPMessageMedia *media) override;
|
2018-01-18 20:02:50 +00:00
|
|
|
void updateReplyMarkup(const MTPReplyMarkup *markup) override {
|
|
|
|
setReplyMarkup(markup);
|
|
|
|
}
|
2019-03-15 15:15:56 +00:00
|
|
|
void updateForwardedInfo(const MTPMessageFwdHeader *fwd) override;
|
2019-08-20 09:42:13 +00:00
|
|
|
void contributeToSlowmode(TimeId realDate = 0) override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
|
|
|
void addToUnreadMentions(UnreadMentionType type) override;
|
|
|
|
void eraseFromUnreadMentions() override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
|
|
|
void setText(const TextWithEntities &textWithEntities) override;
|
2019-08-02 18:19:14 +00:00
|
|
|
[[nodiscard]] Ui::Text::IsolatedEmoji isolatedEmoji() const override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] TextWithEntities originalText() const override;
|
|
|
|
[[nodiscard]] TextForMimeData clipboardText() const override;
|
|
|
|
[[nodiscard]] bool textHasLinks() const override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] int viewsCount() const override;
|
2018-01-18 20:02:50 +00:00
|
|
|
bool updateDependencyItem() override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] MsgId dependencyMsgId() const override {
|
2018-01-18 20:02:50 +00:00
|
|
|
return replyToId();
|
|
|
|
}
|
|
|
|
|
2019-05-24 12:13:16 +00:00
|
|
|
// dynamic_cast optimization.
|
|
|
|
[[nodiscard]] HistoryMessage *toHistoryMessage() override {
|
2018-01-18 20:02:50 +00:00
|
|
|
return this;
|
|
|
|
}
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] const HistoryMessage *toHistoryMessage() const override {
|
2018-01-18 20:02:50 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] std::unique_ptr<HistoryView::Element> createView(
|
2020-06-16 16:53:44 +00:00
|
|
|
not_null<HistoryView::ElementDelegate*> delegate,
|
|
|
|
HistoryView::Element *replacing = nullptr) override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
|
|
|
~HistoryMessage();
|
|
|
|
|
|
|
|
private:
|
2016-09-27 14:20:49 +00:00
|
|
|
void setEmptyText();
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] bool isTooOldForEdit(TimeId now) const;
|
|
|
|
[[nodiscard]] bool isLegacyMessage() const {
|
2019-05-20 14:57:25 +00:00
|
|
|
return _flags & MTPDmessage::Flag::f_legacy;
|
2018-12-26 06:18:53 +00:00
|
|
|
}
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-02 18:19:14 +00:00
|
|
|
void clearIsolatedEmoji();
|
|
|
|
void checkIsolatedEmoji();
|
2019-08-01 21:14:19 +00:00
|
|
|
|
2017-03-06 15:00:59 +00:00
|
|
|
// For an invoice button we replace the button text with a "Receipt" key.
|
|
|
|
// It should show the receipt for the payed invoice. Still let mobile apps do that.
|
|
|
|
void replaceBuyWithReceiptInMarkup();
|
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
void setReplyMarkup(const MTPReplyMarkup *markup);
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
struct CreateConfig;
|
2017-07-12 19:14:20 +00:00
|
|
|
void createComponentsHelper(MTPDmessage::Flags flags, MsgId replyTo, UserId viaBotId, const QString &postAuthor, const MTPReplyMarkup &markup);
|
2016-09-27 14:20:49 +00:00
|
|
|
void createComponents(const CreateConfig &config);
|
2019-03-15 15:15:56 +00:00
|
|
|
void setupForwardedComponent(const CreateConfig &config);
|
|
|
|
|
|
|
|
static void FillForwardedInfo(
|
|
|
|
CreateConfig &config,
|
|
|
|
const MTPDmessageFwdHeader &data);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-07-19 15:05:48 +00:00
|
|
|
void refreshMessageBadge();
|
2019-12-27 10:41:30 +00:00
|
|
|
[[nodiscard]] bool generateLocalEntitiesByReply() const;
|
|
|
|
[[nodiscard]] TextWithEntities withLocalEntities(
|
|
|
|
const TextWithEntities &textWithEntities) const;
|
|
|
|
void reapplyText();
|
2019-07-19 15:05:48 +00:00
|
|
|
|
|
|
|
Ui::Text::String _messageBadge;
|
2017-12-30 08:15:42 +00:00
|
|
|
|
|
|
|
QString _timeText;
|
|
|
|
int _timeWidth = 0;
|
|
|
|
|
|
|
|
mutable int32 _fromNameVersion = 0;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
friend class HistoryView::Element;
|
|
|
|
friend class HistoryView::Message;
|
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
};
|