Make get_*_duration const.

GitOrigin-RevId: 85b5eb4cb221c2144318989d4d93b45784adcdf4
This commit is contained in:
levlam 2018-09-27 21:14:32 +03:00
parent 073541718d
commit c1f4e9d292
14 changed files with 36 additions and 35 deletions

View File

@ -107,10 +107,10 @@ void AnimationsManager::tear_down() {
parent_.reset();
}
int32 AnimationsManager::get_animation_duration(FileId file_id) {
auto &animation = animations_[file_id];
CHECK(animation != nullptr);
return animation->duration;
int32 AnimationsManager::get_animation_duration(FileId file_id) const {
auto it = animations_.find(file_id);
CHECK(it != animations_.end());
return it->second->duration;
}
tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId file_id, const char *source) {

View File

@ -34,7 +34,7 @@ class AnimationsManager : public Actor {
public:
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);

View File

@ -24,10 +24,10 @@ namespace td {
AudiosManager::AudiosManager(Td *td) : td_(td) {
}
int32 AudiosManager::get_audio_duration(FileId file_id) {
auto &audio = audios_[file_id];
CHECK(audio != nullptr);
return audio->duration;
int32 AudiosManager::get_audio_duration(FileId file_id) const {
auto it = audios_.find(file_id);
CHECK(it != audios_.end());
return it->second->duration;
}
tl_object_ptr<td_api::audio> AudiosManager::get_audio_object(FileId file_id) {

View File

@ -28,7 +28,7 @@ class AudiosManager {
public:
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);

View File

@ -99,7 +99,7 @@ class InlineQueriesManager : public Actor {
Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> get_inline_message(
tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
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,
tl_object_ptr<telegram_api::BotInlineMessage> &&inline_message,

View File

@ -4373,7 +4373,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
if (has_media_album_id) {
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) {
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)) {
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) {
mentions_mask |= search_messages_filter_index_mask(SearchMessagesFilter::Mention);
if (m->contains_unread_mention) {
@ -5167,14 +5167,14 @@ int32 MessagesManager::get_message_index_mask(DialogId dialog_id, const Message
return mentions_mask;
}
int32 MessagesManager::get_message_content_index_mask(const MessageContent *content, bool is_secret,
bool is_outgoing) const {
int32 MessagesManager::get_message_content_index_mask(const MessageContent *content, const Td *td, bool is_secret,
bool is_outgoing) {
switch (content->get_type()) {
case MessageContentType::Animation:
return search_messages_filter_index_mask(SearchMessagesFilter::Animation);
case MessageContentType::Audio: {
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)
: search_messages_filter_index_mask(SearchMessagesFilter::Document);
}
@ -5193,14 +5193,14 @@ int32 MessagesManager::get_message_content_index_mask(const MessageContent *cont
return 0;
case MessageContentType::Video: {
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) |
search_messages_filter_index_mask(SearchMessagesFilter::PhotoAndVideo)
: search_messages_filter_index_mask(SearchMessagesFilter::Document);
}
case MessageContentType::VideoNote: {
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) |
search_messages_filter_index_mask(SearchMessagesFilter::VoiceAndVideoNote)
: search_messages_filter_index_mask(SearchMessagesFilter::Document);

View File

@ -2238,7 +2238,8 @@ class MessagesManager : public Actor {
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,
bool *need_update_dialog_pos, const char *source);

View File

@ -24,10 +24,10 @@ namespace td {
VideoNotesManager::VideoNotesManager(Td *td) : td_(td) {
}
int32 VideoNotesManager::get_video_note_duration(FileId file_id) {
auto &video_note = video_notes_[file_id];
CHECK(video_note != nullptr);
return video_note->duration;
int32 VideoNotesManager::get_video_note_duration(FileId file_id) const {
auto it = video_notes_.find(file_id);
CHECK(it != video_notes_.end());
return it->second->duration;
}
tl_object_ptr<td_api::videoNote> VideoNotesManager::get_video_note_object(FileId file_id) {

View File

@ -28,7 +28,7 @@ class VideoNotesManager {
public:
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);

View File

@ -25,10 +25,10 @@ namespace td {
VideosManager::VideosManager(Td *td) : td_(td) {
}
int32 VideosManager::get_video_duration(FileId file_id) {
auto &video = videos_[file_id];
CHECK(video != nullptr);
return video->duration;
int32 VideosManager::get_video_duration(FileId file_id) const {
auto it = videos_.find(file_id);
CHECK(it != videos_.end());
return it->second->duration;
}
tl_object_ptr<td_api::video> VideosManager::get_video_object(FileId file_id) {

View File

@ -28,7 +28,7 @@ class VideosManager {
public:
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);

View File

@ -25,10 +25,10 @@ namespace td {
VoiceNotesManager::VoiceNotesManager(Td *td) : td_(td) {
}
int32 VoiceNotesManager::get_voice_note_duration(FileId file_id) {
auto &voice_note = voice_notes_[file_id];
CHECK(voice_note != nullptr);
return voice_note->duration;
int32 VoiceNotesManager::get_voice_note_duration(FileId file_id) const {
auto it = voice_notes_.find(file_id);
CHECK(it != voice_notes_.end());
return it->second->duration;
}
tl_object_ptr<td_api::voiceNote> VoiceNotesManager::get_voice_note_object(FileId file_id) {

View File

@ -26,7 +26,7 @@ class VoiceNotesManager {
public:
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);

View File

@ -1238,7 +1238,7 @@ void FileManager::flush_to_pmc(FileNodePtr node, bool new_remote, bool new_local
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) {
data.local_ = LocalFileLocation();
data.remote_ = RemoteFileLocation();