Make get_*_duration const.
GitOrigin-RevId: 85b5eb4cb221c2144318989d4d93b45784adcdf4
This commit is contained in:
parent
073541718d
commit
c1f4e9d292
@ -107,10 +107,10 @@ void AnimationsManager::tear_down() {
|
|||||||
parent_.reset();
|
parent_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 AnimationsManager::get_animation_duration(FileId file_id) {
|
int32 AnimationsManager::get_animation_duration(FileId file_id) const {
|
||||||
auto &animation = animations_[file_id];
|
auto it = animations_.find(file_id);
|
||||||
CHECK(animation != nullptr);
|
CHECK(it != animations_.end());
|
||||||
return animation->duration;
|
return it->second->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId file_id, const char *source) {
|
tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId file_id, const char *source) {
|
||||||
|
@ -34,7 +34,7 @@ class AnimationsManager : public Actor {
|
|||||||
public:
|
public:
|
||||||
AnimationsManager(Td *td, ActorShared<> parent);
|
AnimationsManager(Td *td, ActorShared<> parent);
|
||||||
|
|
||||||
int32 get_animation_duration(FileId file_id);
|
int32 get_animation_duration(FileId file_id) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::animation> get_animation_object(FileId file_id, const char *source);
|
tl_object_ptr<td_api::animation> get_animation_object(FileId file_id, const char *source);
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ namespace td {
|
|||||||
AudiosManager::AudiosManager(Td *td) : td_(td) {
|
AudiosManager::AudiosManager(Td *td) : td_(td) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 AudiosManager::get_audio_duration(FileId file_id) {
|
int32 AudiosManager::get_audio_duration(FileId file_id) const {
|
||||||
auto &audio = audios_[file_id];
|
auto it = audios_.find(file_id);
|
||||||
CHECK(audio != nullptr);
|
CHECK(it != audios_.end());
|
||||||
return audio->duration;
|
return it->second->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::audio> AudiosManager::get_audio_object(FileId file_id) {
|
tl_object_ptr<td_api::audio> AudiosManager::get_audio_object(FileId file_id) {
|
||||||
|
@ -28,7 +28,7 @@ class AudiosManager {
|
|||||||
public:
|
public:
|
||||||
explicit AudiosManager(Td *td);
|
explicit AudiosManager(Td *td);
|
||||||
|
|
||||||
int32 get_audio_duration(FileId file_id);
|
int32 get_audio_duration(FileId file_id) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::audio> get_audio_object(FileId file_id);
|
tl_object_ptr<td_api::audio> get_audio_object(FileId file_id);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class InlineQueriesManager : public Actor {
|
|||||||
Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> get_inline_message(
|
Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> get_inline_message(
|
||||||
tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
|
tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
|
||||||
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr,
|
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr,
|
||||||
int32 allowed_media_content_id) const TD_WARN_UNUSED_RESULT; // TODO make static
|
int32 allowed_media_content_id) const TD_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
InlineMessageContent create_inline_message_content(FileId file_id,
|
InlineMessageContent create_inline_message_content(FileId file_id,
|
||||||
tl_object_ptr<telegram_api::BotInlineMessage> &&inline_message,
|
tl_object_ptr<telegram_api::BotInlineMessage> &&inline_message,
|
||||||
|
@ -4373,7 +4373,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
|
|||||||
if (has_media_album_id) {
|
if (has_media_album_id) {
|
||||||
store(media_album_id, storer);
|
store(media_album_id, storer);
|
||||||
}
|
}
|
||||||
store(static_cast<const MessageContent *>(content.get()), storer); // TODO unique_ptr with const propagation
|
store(content.get(), storer);
|
||||||
if (has_reply_markup) {
|
if (has_reply_markup) {
|
||||||
store(*reply_markup, storer);
|
store(*reply_markup, storer);
|
||||||
}
|
}
|
||||||
@ -5157,7 +5157,7 @@ int32 MessagesManager::get_message_index_mask(DialogId dialog_id, const Message
|
|||||||
if (m->is_content_secret || (m->ttl > 0 && !is_secret)) {
|
if (m->is_content_secret || (m->ttl > 0 && !is_secret)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32 mentions_mask = get_message_content_index_mask(m->content.get(), is_secret, m->is_outgoing);
|
int32 mentions_mask = get_message_content_index_mask(m->content.get(), td_, is_secret, m->is_outgoing);
|
||||||
if (m->contains_mention) {
|
if (m->contains_mention) {
|
||||||
mentions_mask |= search_messages_filter_index_mask(SearchMessagesFilter::Mention);
|
mentions_mask |= search_messages_filter_index_mask(SearchMessagesFilter::Mention);
|
||||||
if (m->contains_unread_mention) {
|
if (m->contains_unread_mention) {
|
||||||
@ -5167,14 +5167,14 @@ int32 MessagesManager::get_message_index_mask(DialogId dialog_id, const Message
|
|||||||
return mentions_mask;
|
return mentions_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 MessagesManager::get_message_content_index_mask(const MessageContent *content, bool is_secret,
|
int32 MessagesManager::get_message_content_index_mask(const MessageContent *content, const Td *td, bool is_secret,
|
||||||
bool is_outgoing) const {
|
bool is_outgoing) {
|
||||||
switch (content->get_type()) {
|
switch (content->get_type()) {
|
||||||
case MessageContentType::Animation:
|
case MessageContentType::Animation:
|
||||||
return search_messages_filter_index_mask(SearchMessagesFilter::Animation);
|
return search_messages_filter_index_mask(SearchMessagesFilter::Animation);
|
||||||
case MessageContentType::Audio: {
|
case MessageContentType::Audio: {
|
||||||
auto message_audio = static_cast<const MessageAudio *>(content);
|
auto message_audio = static_cast<const MessageAudio *>(content);
|
||||||
auto duration = td_->audios_manager_->get_audio_duration(message_audio->file_id);
|
auto duration = td->audios_manager_->get_audio_duration(message_audio->file_id);
|
||||||
return is_secret || duration > 0 ? search_messages_filter_index_mask(SearchMessagesFilter::Audio)
|
return is_secret || duration > 0 ? search_messages_filter_index_mask(SearchMessagesFilter::Audio)
|
||||||
: search_messages_filter_index_mask(SearchMessagesFilter::Document);
|
: search_messages_filter_index_mask(SearchMessagesFilter::Document);
|
||||||
}
|
}
|
||||||
@ -5193,14 +5193,14 @@ int32 MessagesManager::get_message_content_index_mask(const MessageContent *cont
|
|||||||
return 0;
|
return 0;
|
||||||
case MessageContentType::Video: {
|
case MessageContentType::Video: {
|
||||||
auto message_video = static_cast<const MessageVideo *>(content);
|
auto message_video = static_cast<const MessageVideo *>(content);
|
||||||
auto duration = td_->videos_manager_->get_video_duration(message_video->file_id);
|
auto duration = td->videos_manager_->get_video_duration(message_video->file_id);
|
||||||
return is_secret || duration > 0 ? search_messages_filter_index_mask(SearchMessagesFilter::Video) |
|
return is_secret || duration > 0 ? search_messages_filter_index_mask(SearchMessagesFilter::Video) |
|
||||||
search_messages_filter_index_mask(SearchMessagesFilter::PhotoAndVideo)
|
search_messages_filter_index_mask(SearchMessagesFilter::PhotoAndVideo)
|
||||||
: search_messages_filter_index_mask(SearchMessagesFilter::Document);
|
: search_messages_filter_index_mask(SearchMessagesFilter::Document);
|
||||||
}
|
}
|
||||||
case MessageContentType::VideoNote: {
|
case MessageContentType::VideoNote: {
|
||||||
auto message_video_note = static_cast<const MessageVideoNote *>(content);
|
auto message_video_note = static_cast<const MessageVideoNote *>(content);
|
||||||
auto duration = td_->video_notes_manager_->get_video_note_duration(message_video_note->file_id);
|
auto duration = td->video_notes_manager_->get_video_note_duration(message_video_note->file_id);
|
||||||
return is_secret || duration > 0 ? search_messages_filter_index_mask(SearchMessagesFilter::VideoNote) |
|
return is_secret || duration > 0 ? search_messages_filter_index_mask(SearchMessagesFilter::VideoNote) |
|
||||||
search_messages_filter_index_mask(SearchMessagesFilter::VoiceAndVideoNote)
|
search_messages_filter_index_mask(SearchMessagesFilter::VoiceAndVideoNote)
|
||||||
: search_messages_filter_index_mask(SearchMessagesFilter::Document);
|
: search_messages_filter_index_mask(SearchMessagesFilter::Document);
|
||||||
|
@ -2238,7 +2238,8 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
int32 get_message_index_mask(DialogId dialog_id, const Message *m) const;
|
int32 get_message_index_mask(DialogId dialog_id, const Message *m) const;
|
||||||
|
|
||||||
int32 get_message_content_index_mask(const MessageContent *content, bool is_secret, bool is_outgoing) const;
|
static int32 get_message_content_index_mask(const MessageContent *content, const Td *td, bool is_secret,
|
||||||
|
bool is_outgoing);
|
||||||
|
|
||||||
Message *add_message_to_dialog(DialogId dialog_id, unique_ptr<Message> message, bool from_update, bool *need_update,
|
Message *add_message_to_dialog(DialogId dialog_id, unique_ptr<Message> message, bool from_update, bool *need_update,
|
||||||
bool *need_update_dialog_pos, const char *source);
|
bool *need_update_dialog_pos, const char *source);
|
||||||
|
@ -24,10 +24,10 @@ namespace td {
|
|||||||
VideoNotesManager::VideoNotesManager(Td *td) : td_(td) {
|
VideoNotesManager::VideoNotesManager(Td *td) : td_(td) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 VideoNotesManager::get_video_note_duration(FileId file_id) {
|
int32 VideoNotesManager::get_video_note_duration(FileId file_id) const {
|
||||||
auto &video_note = video_notes_[file_id];
|
auto it = video_notes_.find(file_id);
|
||||||
CHECK(video_note != nullptr);
|
CHECK(it != video_notes_.end());
|
||||||
return video_note->duration;
|
return it->second->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::videoNote> VideoNotesManager::get_video_note_object(FileId file_id) {
|
tl_object_ptr<td_api::videoNote> VideoNotesManager::get_video_note_object(FileId file_id) {
|
||||||
|
@ -28,7 +28,7 @@ class VideoNotesManager {
|
|||||||
public:
|
public:
|
||||||
explicit VideoNotesManager(Td *td);
|
explicit VideoNotesManager(Td *td);
|
||||||
|
|
||||||
int32 get_video_note_duration(FileId file_id);
|
int32 get_video_note_duration(FileId file_id) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::videoNote> get_video_note_object(FileId file_id);
|
tl_object_ptr<td_api::videoNote> get_video_note_object(FileId file_id);
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ namespace td {
|
|||||||
VideosManager::VideosManager(Td *td) : td_(td) {
|
VideosManager::VideosManager(Td *td) : td_(td) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 VideosManager::get_video_duration(FileId file_id) {
|
int32 VideosManager::get_video_duration(FileId file_id) const {
|
||||||
auto &video = videos_[file_id];
|
auto it = videos_.find(file_id);
|
||||||
CHECK(video != nullptr);
|
CHECK(it != videos_.end());
|
||||||
return video->duration;
|
return it->second->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::video> VideosManager::get_video_object(FileId file_id) {
|
tl_object_ptr<td_api::video> VideosManager::get_video_object(FileId file_id) {
|
||||||
|
@ -28,7 +28,7 @@ class VideosManager {
|
|||||||
public:
|
public:
|
||||||
explicit VideosManager(Td *td);
|
explicit VideosManager(Td *td);
|
||||||
|
|
||||||
int32 get_video_duration(FileId file_id);
|
int32 get_video_duration(FileId file_id) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::video> get_video_object(FileId file_id);
|
tl_object_ptr<td_api::video> get_video_object(FileId file_id);
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ namespace td {
|
|||||||
VoiceNotesManager::VoiceNotesManager(Td *td) : td_(td) {
|
VoiceNotesManager::VoiceNotesManager(Td *td) : td_(td) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 VoiceNotesManager::get_voice_note_duration(FileId file_id) {
|
int32 VoiceNotesManager::get_voice_note_duration(FileId file_id) const {
|
||||||
auto &voice_note = voice_notes_[file_id];
|
auto it = voice_notes_.find(file_id);
|
||||||
CHECK(voice_note != nullptr);
|
CHECK(it != voice_notes_.end());
|
||||||
return voice_note->duration;
|
return it->second->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::voiceNote> VoiceNotesManager::get_voice_note_object(FileId file_id) {
|
tl_object_ptr<td_api::voiceNote> VoiceNotesManager::get_voice_note_object(FileId file_id) {
|
||||||
|
@ -26,7 +26,7 @@ class VoiceNotesManager {
|
|||||||
public:
|
public:
|
||||||
explicit VoiceNotesManager(Td *td);
|
explicit VoiceNotesManager(Td *td);
|
||||||
|
|
||||||
int32 get_voice_note_duration(FileId file_id);
|
int32 get_voice_note_duration(FileId file_id) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::voiceNote> get_voice_note_object(FileId file_id);
|
tl_object_ptr<td_api::voiceNote> get_voice_note_object(FileId file_id);
|
||||||
|
|
||||||
|
@ -1238,7 +1238,7 @@ void FileManager::flush_to_pmc(FileNodePtr node, bool new_remote, bool new_local
|
|||||||
data.generate_ = make_unique<FullGenerateFileLocation>(*node->generate_);
|
data.generate_ = make_unique<FullGenerateFileLocation>(*node->generate_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: not needed when GenerateLocation has constant convertion
|
// TODO: not needed when GenerateLocation has constant conversion
|
||||||
if (data.remote_.type() != RemoteFileLocation::Type::Full && data.local_.type() != LocalFileLocation::Type::Full) {
|
if (data.remote_.type() != RemoteFileLocation::Type::Full && data.local_.type() != LocalFileLocation::Type::Full) {
|
||||||
data.local_ = LocalFileLocation();
|
data.local_ = LocalFileLocation();
|
||||||
data.remote_ = RemoteFileLocation();
|
data.remote_ = RemoteFileLocation();
|
||||||
|
Loading…
Reference in New Issue
Block a user