Reduce more cpp source code interdependecies.

GitOrigin-RevId: e80ac4246299a5a3bf515977c24d281055fcadb6
This commit is contained in:
levlam 2018-10-02 00:24:45 +03:00
parent 5ad403a932
commit 4d8a832b7d
6 changed files with 40 additions and 52 deletions

View File

@ -2290,19 +2290,6 @@ bool ContactsManager::ChannelFull::is_expired() const {
return expires_at < Time::now();
}
class ContactsManager::OnChatUpdate {
ContactsManager *manager_;
public:
explicit OnChatUpdate(ContactsManager *manager) : manager_(manager) {
}
template <class T>
void operator()(T &func) const {
manager_->on_chat_update(func);
}
};
class ContactsManager::UploadProfilePhotoCallback : public FileManager::UploadCallback {
public:
void on_upload_ok(FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file) override {
@ -6462,7 +6449,7 @@ bool ContactsManager::on_update_user_full_bot_info(UserFull *user_full, UserId u
void ContactsManager::on_get_chat(tl_object_ptr<telegram_api::Chat> &&chat) {
LOG(DEBUG) << "Receive " << to_string(chat);
downcast_call(*chat, OnChatUpdate(this));
downcast_call(*chat, [this](auto &c) { this->on_chat_update(c); });
}
void ContactsManager::on_get_chats(vector<tl_object_ptr<telegram_api::Chat>> &&chats) {

View File

@ -1108,8 +1108,6 @@ class ContactsManager : public Actor {
MultiTimeout user_online_timeout_{"UserOnlineTimeout"};
MultiTimeout channel_unban_timeout_{"ChannelUnbanTimeout"};
class OnChatUpdate;
};
} // namespace td

View File

@ -76,39 +76,6 @@ void dummyUpdate::store(TlStorerToString &s, const char *field_name) const {
s.store_class_end();
}
class updateSentMessage : public telegram_api::Update {
public:
int64 random_id_;
MessageId message_id_;
int32 date_;
updateSentMessage(int64 random_id, MessageId message_id, int32 date)
: random_id_(random_id), message_id_(message_id), date_(date) {
}
static constexpr int32 ID = 1234567890;
int32 get_id() const override {
return ID;
}
void store(TlStorerUnsafe &s) const override {
UNREACHABLE();
}
void store(TlStorerCalcLength &s) const override {
UNREACHABLE();
}
void store(TlStorerToString &s, const char *field_name) const override {
s.store_class_begin(field_name, "updateSentMessage");
s.store_field("random_id_", random_id_);
s.store_field("message_id_", message_id_.get());
s.store_field("date_", date_);
s.store_class_end();
}
};
class GetDialogQuery : public Td::ResultHandler {
DialogId dialog_id_;
@ -4077,8 +4044,6 @@ MessagesManager::Dialog::~Dialog() {
}
MessagesManager::MessagesManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
// td_->create_handler<GetDialogListQuery>()->send(2147000000, ServerMessageId(), DialogId(), 5);
upload_media_callback_ = std::make_shared<UploadMediaCallback>();
upload_thumbnail_callback_ = std::make_shared<UploadThumbnailCallback>();
upload_dialog_photo_callback_ = std::make_shared<UploadDialogPhotoCallback>();

View File

@ -82,6 +82,38 @@ class dummyUpdate : public telegram_api::Update {
void store(TlStorerToString &s, const char *field_name) const override;
};
class updateSentMessage : public telegram_api::Update {
public:
int64 random_id_;
MessageId message_id_;
int32 date_;
updateSentMessage(int64 random_id, MessageId message_id, int32 date)
: random_id_(random_id), message_id_(message_id), date_(date) {
}
static constexpr int32 ID = 1234567890;
int32 get_id() const override {
return ID;
}
void store(TlStorerUnsafe &s) const override {
UNREACHABLE();
}
void store(TlStorerCalcLength &s) const override {
UNREACHABLE();
}
void store(TlStorerToString &s, const char *field_name) const override {
s.store_class_begin(field_name, "updateSentMessage");
s.store_field("random_id", random_id_);
s.store_field("message_id", message_id_.get());
s.store_field("date", date_);
s.store_class_end();
}
};
class MessagesManager : public Actor {
public:
// static constexpr int32 MESSAGE_FLAG_IS_UNREAD = 1 << 0;

View File

@ -4120,7 +4120,7 @@ Status Td::init(DbKey key) {
VLOG(td_init) << "Ping datacenter";
if (!auth_manager_->is_authorized()) {
create_handler<GetNearestDcQuery>(Promise<string>())->send();
send_get_nearest_dc_query(Promise<string>());
} else {
updates_manager_->get_difference("init");
schedule_get_terms_of_service(0);
@ -4132,6 +4132,10 @@ Status Td::init(DbKey key) {
return Status::OK();
}
void Td::send_get_nearest_dc_query(Promise<string> promise) {
create_handler<GetNearestDcQuery>(std::move(promise))->send();
}
void Td::send_update(tl_object_ptr<td_api::Update> &&object) {
auto object_id = object->get_id();
if (close_flag_ >= 5 && object_id != td_api::updateAuthorizationState::ID) {

View File

@ -946,6 +946,8 @@ class Td final : public NetQueryCallback {
static Status fix_parameters(TdParameters &parameters) TD_WARN_UNUSED_RESULT;
Status set_parameters(td_api::object_ptr<td_api::tdlibParameters> parameters) TD_WARN_UNUSED_RESULT;
void send_get_nearest_dc_query(Promise<string> promise);
static td_api::object_ptr<td_api::error> make_error(int32 code, CSlice error) {
return td_api::make_object<td_api::error>(code, error.str());
}