Update InitConnection request.
GitOrigin-RevId: b9785bf56bd4cb9c44c5a91f3cb07d2352bc6ca2
This commit is contained in:
parent
6f7d4b08bf
commit
5eea3d9c37
@ -133,8 +133,8 @@ tl_object_ptr<td_api::OptionValue> ConfigShared::get_option_value_object(Slice v
|
||||
return make_tl_object<td_api::optionValueString>(value.str());
|
||||
}
|
||||
|
||||
void ConfigShared::on_option_updated(Slice name) {
|
||||
callback_->on_option_updated(name.str());
|
||||
void ConfigShared::on_option_updated(Slice name) const {
|
||||
callback_->on_option_updated(name.str(), get_option(name));
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -25,7 +25,7 @@ class ConfigShared {
|
||||
Callback(const Callback &) = delete;
|
||||
Callback &operator=(const Callback &) = delete;
|
||||
virtual ~Callback() = default;
|
||||
virtual void on_option_updated(const string &name) = 0;
|
||||
virtual void on_option_updated(const string &name, const string &value) = 0;
|
||||
};
|
||||
|
||||
ConfigShared(BinlogPmcPtr config_pmc, unique_ptr<Callback> callback);
|
||||
@ -53,7 +53,7 @@ class ConfigShared {
|
||||
bool set_option(Slice name, Slice value);
|
||||
static tl_object_ptr<td_api::OptionValue> get_option_value_object(Slice value);
|
||||
|
||||
void on_option_updated(Slice name);
|
||||
void on_option_updated(Slice name) const;
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -4212,8 +4212,7 @@ void Td::on_config_option_updated(const string &name) {
|
||||
return;
|
||||
}
|
||||
if (name == "auth") {
|
||||
on_authorization_lost();
|
||||
return;
|
||||
return on_authorization_lost();
|
||||
} else if (name == "saved_animations_limit") {
|
||||
return animations_manager_->on_update_saved_animations_limit(G()->shared_config().get_option_integer(name));
|
||||
} else if (name == "recent_stickers_limit") {
|
||||
@ -4675,7 +4674,18 @@ Status Td::init(DbKey key) {
|
||||
VLOG(td_init) << "Create ConfigManager and ConfigShared";
|
||||
class ConfigSharedCallback : public ConfigShared::Callback {
|
||||
public:
|
||||
void on_option_updated(const string &name) override {
|
||||
void on_option_updated(const string &name, const string &value) override {
|
||||
if (name == "is_emulator" && !G()->close_flag()) {
|
||||
// it should be applied immediately, because it affects MtprotoHeader
|
||||
if (G()->have_mtproto_header()) {
|
||||
// can't use G()->shared_config(), because it may be not created yet
|
||||
G()->mtproto_header().set_is_emulator(value == "Btrue");
|
||||
}
|
||||
if (G()->have_net_query_dispatcher()) {
|
||||
G()->net_query_dispatcher().update_mtproto_header();
|
||||
}
|
||||
}
|
||||
|
||||
send_closure(G()->td(), &Td::on_config_option_updated, name);
|
||||
}
|
||||
};
|
||||
@ -5087,6 +5097,7 @@ Status Td::set_parameters(td_api::object_ptr<td_api::tdlibParameters> parameters
|
||||
options.application_version += ", TDLib ";
|
||||
options.application_version += TDLIB_VERSION;
|
||||
}
|
||||
options.is_emulator = false;
|
||||
options.proxy = Proxy();
|
||||
G()->set_mtproto_header(std::make_unique<MtprotoHeader>(options));
|
||||
|
||||
@ -6624,6 +6635,11 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
if (set_boolean_option("is_emulator")) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if (request.name_ == "online") {
|
||||
if (value_constructor_id != td_api::optionValueBoolean::ID &&
|
||||
|
@ -665,34 +665,40 @@ class CliClient final : public Actor {
|
||||
close_flag_ = false;
|
||||
ready_to_stop_ = false;
|
||||
|
||||
td_ = create_actor<ClientActor>("ClientActor1", make_td_callback());
|
||||
bool test_init = false;
|
||||
|
||||
if (test_init) {
|
||||
td_ = create_actor<ClientActor>("ClientActor1", make_td_callback());
|
||||
}
|
||||
td_ = create_actor<ClientActor>("ClientActor2", make_td_callback());
|
||||
ready_to_stop_ = false;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
send_closure_later(td_, &ClientActor::request, std::numeric_limits<uint64>::max(),
|
||||
td_api::make_object<td_api::setAlarm>(0.001 + 1000 * (i / 2)));
|
||||
if (test_init) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
send_closure_later(td_, &ClientActor::request, std::numeric_limits<uint64>::max(),
|
||||
td_api::make_object<td_api::setAlarm>(0.001 + 1000 * (i / 2)));
|
||||
}
|
||||
|
||||
send_request(td_api::make_object<td_api::getTextEntities>(
|
||||
"@telegram /test_command https://telegram.org telegram.me @gif @test"));
|
||||
|
||||
send_request(td_api::make_object<td_api::getOption>("use_pfs"));
|
||||
send_request(td_api::make_object<td_api::setOption>(
|
||||
"use_pfs", td_api::make_object<td_api::optionValueBoolean>(std::time(nullptr) / 86400 % 2 == 0)));
|
||||
send_request(td_api::make_object<td_api::setOption>("use_storage_optimizer",
|
||||
td_api::make_object<td_api::optionValueBoolean>(false)));
|
||||
|
||||
send_request(td_api::make_object<td_api::setNetworkType>(td_api::make_object<td_api::networkTypeWiFi>()));
|
||||
send_request(td_api::make_object<td_api::getNetworkStatistics>());
|
||||
send_request(td_api::make_object<td_api::getCountryCode>());
|
||||
|
||||
auto bad_parameters = td_api::make_object<td_api::tdlibParameters>();
|
||||
bad_parameters->database_directory_ = "/..";
|
||||
bad_parameters->api_id_ = api_id_;
|
||||
bad_parameters->api_hash_ = api_hash_;
|
||||
send_request(td_api::make_object<td_api::setTdlibParameters>(std::move(bad_parameters)));
|
||||
}
|
||||
|
||||
send_request(td_api::make_object<td_api::getTextEntities>(
|
||||
"@telegram /test_command https://telegram.org telegram.me @gif @test"));
|
||||
|
||||
send_request(td_api::make_object<td_api::getOption>("use_pfs"));
|
||||
send_request(td_api::make_object<td_api::setOption>(
|
||||
"use_pfs", td_api::make_object<td_api::optionValueBoolean>(std::time(nullptr) / 86400 % 2 == 0)));
|
||||
send_request(td_api::make_object<td_api::setOption>("use_storage_optimizer",
|
||||
td_api::make_object<td_api::optionValueBoolean>(false)));
|
||||
|
||||
send_request(td_api::make_object<td_api::setNetworkType>(td_api::make_object<td_api::networkTypeWiFi>()));
|
||||
send_request(td_api::make_object<td_api::getNetworkStatistics>());
|
||||
send_request(td_api::make_object<td_api::getCountryCode>());
|
||||
|
||||
auto bad_parameters = td_api::make_object<td_api::tdlibParameters>();
|
||||
bad_parameters->database_directory_ = "/..";
|
||||
bad_parameters->api_id_ = api_id_;
|
||||
bad_parameters->api_hash_ = api_hash_;
|
||||
send_request(td_api::make_object<td_api::setTdlibParameters>(std::move(bad_parameters)));
|
||||
|
||||
auto parameters = td_api::make_object<td_api::tdlibParameters>();
|
||||
parameters->use_test_dc_ = use_test_dc_;
|
||||
parameters->use_message_database_ = true;
|
||||
|
@ -28,9 +28,13 @@ class HeaderStorer {
|
||||
// system_lang_code:string lang_pack:string lang_code:string proxy:flags.0?InputClientProxy query:!X = X;
|
||||
store(static_cast<int32>(0x785188b8), storer);
|
||||
int32 flags = 0;
|
||||
if (!is_anonymous && options.proxy.type() == Proxy::Type::Mtproto) {
|
||||
bool have_proxy = !is_anonymous && options.proxy.type() == Proxy::Type::Mtproto;
|
||||
if (have_proxy) {
|
||||
flags |= 1 << 0;
|
||||
}
|
||||
if (options.is_emulator) {
|
||||
flags |= 1 << 10;
|
||||
}
|
||||
store(flags, storer);
|
||||
store(options.api_id, storer);
|
||||
if (is_anonymous) {
|
||||
@ -44,7 +48,7 @@ class HeaderStorer {
|
||||
store(options.system_language_code, storer);
|
||||
store(string(), storer);
|
||||
store(string(), storer);
|
||||
if ((flags & 1) != 0) {
|
||||
if (have_proxy) {
|
||||
// inputClientProxy#75588b3f address:string port:int = InputClientProxy;
|
||||
store(static_cast<int32>(0x75588b3f), storer);
|
||||
store(Slice(options.proxy.server()), storer);
|
||||
|
@ -20,6 +20,7 @@ class MtprotoHeader {
|
||||
string system_language_code;
|
||||
string device_model;
|
||||
string system_version;
|
||||
bool is_emulator = false;
|
||||
string application_version;
|
||||
Proxy proxy;
|
||||
};
|
||||
@ -33,6 +34,11 @@ class MtprotoHeader {
|
||||
default_header_ = gen_header(options_, false);
|
||||
}
|
||||
|
||||
void set_is_emulator(bool is_emulator) {
|
||||
options_.is_emulator = is_emulator;
|
||||
default_header_ = gen_header(options_, false);
|
||||
}
|
||||
|
||||
Slice get_default_header() const {
|
||||
return default_header_;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user