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(
|
2017-12-18 15:44:50 +00:00
|
|
|
const FullMsgId &msgId);
|
2017-08-17 08:31:24 +00:00
|
|
|
MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer);
|
2017-12-06 10:13:38 +00:00
|
|
|
QString GetErrorTextForForward(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
const HistoryItemsList &items);
|
2017-08-17 08:31:24 +00:00
|
|
|
void FastShareMessage(not_null<HistoryItem*> item);
|
2018-01-14 16:02:25 +00:00
|
|
|
QString FormatViewsCount(int views);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
class HistoryMessage
|
2018-01-18 20:02:50 +00:00
|
|
|
: public HistoryItem {
|
2016-09-27 14:20:49 +00:00
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
const MTPDmessage &data);
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
const MTPDmessageService &data);
|
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,
|
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,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
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);
|
|
|
|
void setMedia(const MTPMessageMedia &media);
|
|
|
|
static std::unique_ptr<Data::Media> CreateMedia(
|
|
|
|
not_null<HistoryMessage*> item,
|
|
|
|
const MTPMessageMedia &media);
|
|
|
|
|
|
|
|
bool allowsForward() const override;
|
2018-02-03 19:52:35 +00:00
|
|
|
bool allowsEdit(TimeId now) const override;
|
2018-01-18 20:02:50 +00:00
|
|
|
bool uploading() const;
|
|
|
|
|
|
|
|
void applyGroupAdminChanges(
|
|
|
|
const base::flat_map<UserId, bool> &changes) override;
|
|
|
|
|
|
|
|
void setViewsCount(int32 count) override;
|
|
|
|
void setRealId(MsgId newId) override;
|
|
|
|
|
|
|
|
void dependencyItemRemoved(HistoryItem *dependency) override;
|
|
|
|
|
|
|
|
QString notificationHeader() const override;
|
|
|
|
|
|
|
|
void applyEdition(const MTPDmessage &message) override;
|
|
|
|
void applyEdition(const MTPDmessageService &message) override;
|
|
|
|
void updateSentMedia(const MTPMessageMedia *media) override;
|
|
|
|
void updateReplyMarkup(const MTPReplyMarkup *markup) override {
|
|
|
|
setReplyMarkup(markup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void addToUnreadMentions(UnreadMentionType type) override;
|
|
|
|
void eraseFromUnreadMentions() override;
|
|
|
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
|
|
|
|
|
|
|
void setText(const TextWithEntities &textWithEntities) override;
|
|
|
|
TextWithEntities originalText() const override;
|
2018-01-26 15:40:11 +00:00
|
|
|
TextWithEntities clipboardText() const override;
|
2018-01-18 20:02:50 +00:00
|
|
|
bool textHasLinks() const override;
|
|
|
|
|
|
|
|
int viewsCount() const override;
|
|
|
|
not_null<PeerData*> displayFrom() const;
|
|
|
|
bool updateDependencyItem() override;
|
|
|
|
MsgId dependencyMsgId() const override {
|
|
|
|
return replyToId();
|
|
|
|
}
|
|
|
|
|
|
|
|
HistoryMessage *toHistoryMessage() override { // dynamic_cast optimize
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
const HistoryMessage *toHistoryMessage() const override { // dynamic_cast optimize
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<HistoryView::Element> createView(
|
|
|
|
not_null<HistoryView::ElementDelegate*> delegate) override;
|
|
|
|
|
|
|
|
~HistoryMessage();
|
|
|
|
|
|
|
|
private:
|
2016-09-27 14:20:49 +00:00
|
|
|
void setEmptyText();
|
2018-01-13 12:45:11 +00:00
|
|
|
bool hasAdminBadge() const {
|
|
|
|
return _flags & MTPDmessage_ClientFlag::f_has_admin_badge;
|
|
|
|
}
|
2018-12-19 11:20:04 +00:00
|
|
|
bool isTooOldForEdit(TimeId now) const;
|
2018-12-26 06:18:53 +00:00
|
|
|
bool isUnsupportedMessage() const {
|
|
|
|
return _flags & MTPDmessage_ClientFlag::f_is_unsupported;
|
|
|
|
}
|
2016-09-27 14:20:49 +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 applyEditionToEmpty();
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2017-12-01 18:38:44 +00:00
|
|
|
void updateAdminBadgeState();
|
2017-12-30 08:15:42 +00:00
|
|
|
ClickHandlerPtr fastReplyLink() const;
|
|
|
|
|
|
|
|
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
|
|
|
};
|