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());
|
return make_tl_object<td_api::optionValueString>(value.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigShared::on_option_updated(Slice name) {
|
void ConfigShared::on_option_updated(Slice name) const {
|
||||||
callback_->on_option_updated(name.str());
|
callback_->on_option_updated(name.str(), get_option(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -25,7 +25,7 @@ class ConfigShared {
|
|||||||
Callback(const Callback &) = delete;
|
Callback(const Callback &) = delete;
|
||||||
Callback &operator=(const Callback &) = delete;
|
Callback &operator=(const Callback &) = delete;
|
||||||
virtual ~Callback() = default;
|
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);
|
ConfigShared(BinlogPmcPtr config_pmc, unique_ptr<Callback> callback);
|
||||||
@ -53,7 +53,7 @@ class ConfigShared {
|
|||||||
bool set_option(Slice name, Slice value);
|
bool set_option(Slice name, Slice value);
|
||||||
static tl_object_ptr<td_api::OptionValue> get_option_value_object(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
|
} // namespace td
|
||||||
|
@ -4212,8 +4212,7 @@ void Td::on_config_option_updated(const string &name) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (name == "auth") {
|
if (name == "auth") {
|
||||||
on_authorization_lost();
|
return on_authorization_lost();
|
||||||
return;
|
|
||||||
} else if (name == "saved_animations_limit") {
|
} else if (name == "saved_animations_limit") {
|
||||||
return animations_manager_->on_update_saved_animations_limit(G()->shared_config().get_option_integer(name));
|
return animations_manager_->on_update_saved_animations_limit(G()->shared_config().get_option_integer(name));
|
||||||
} else if (name == "recent_stickers_limit") {
|
} else if (name == "recent_stickers_limit") {
|
||||||
@ -4675,7 +4674,18 @@ Status Td::init(DbKey key) {
|
|||||||
VLOG(td_init) << "Create ConfigManager and ConfigShared";
|
VLOG(td_init) << "Create ConfigManager and ConfigShared";
|
||||||
class ConfigSharedCallback : public ConfigShared::Callback {
|
class ConfigSharedCallback : public ConfigShared::Callback {
|
||||||
public:
|
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);
|
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 ";
|
||||||
options.application_version += TDLIB_VERSION;
|
options.application_version += TDLIB_VERSION;
|
||||||
}
|
}
|
||||||
|
options.is_emulator = false;
|
||||||
options.proxy = Proxy();
|
options.proxy = Proxy();
|
||||||
G()->set_mtproto_header(std::make_unique<MtprotoHeader>(options));
|
G()->set_mtproto_header(std::make_unique<MtprotoHeader>(options));
|
||||||
|
|
||||||
@ -6624,6 +6635,11 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
if (set_boolean_option("is_emulator")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if (request.name_ == "online") {
|
if (request.name_ == "online") {
|
||||||
if (value_constructor_id != td_api::optionValueBoolean::ID &&
|
if (value_constructor_id != td_api::optionValueBoolean::ID &&
|
||||||
|
@ -665,10 +665,15 @@ class CliClient final : public Actor {
|
|||||||
close_flag_ = false;
|
close_flag_ = false;
|
||||||
ready_to_stop_ = false;
|
ready_to_stop_ = false;
|
||||||
|
|
||||||
|
bool test_init = false;
|
||||||
|
|
||||||
|
if (test_init) {
|
||||||
td_ = create_actor<ClientActor>("ClientActor1", make_td_callback());
|
td_ = create_actor<ClientActor>("ClientActor1", make_td_callback());
|
||||||
|
}
|
||||||
td_ = create_actor<ClientActor>("ClientActor2", make_td_callback());
|
td_ = create_actor<ClientActor>("ClientActor2", make_td_callback());
|
||||||
ready_to_stop_ = false;
|
ready_to_stop_ = false;
|
||||||
|
|
||||||
|
if (test_init) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
send_closure_later(td_, &ClientActor::request, std::numeric_limits<uint64>::max(),
|
send_closure_later(td_, &ClientActor::request, std::numeric_limits<uint64>::max(),
|
||||||
td_api::make_object<td_api::setAlarm>(0.001 + 1000 * (i / 2)));
|
td_api::make_object<td_api::setAlarm>(0.001 + 1000 * (i / 2)));
|
||||||
@ -692,6 +697,7 @@ class CliClient final : public Actor {
|
|||||||
bad_parameters->api_id_ = api_id_;
|
bad_parameters->api_id_ = api_id_;
|
||||||
bad_parameters->api_hash_ = api_hash_;
|
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::setTdlibParameters>(std::move(bad_parameters)));
|
||||||
|
}
|
||||||
|
|
||||||
auto parameters = td_api::make_object<td_api::tdlibParameters>();
|
auto parameters = td_api::make_object<td_api::tdlibParameters>();
|
||||||
parameters->use_test_dc_ = use_test_dc_;
|
parameters->use_test_dc_ = use_test_dc_;
|
||||||
|
@ -28,9 +28,13 @@ class HeaderStorer {
|
|||||||
// system_lang_code:string lang_pack:string lang_code:string proxy:flags.0?InputClientProxy query:!X = X;
|
// system_lang_code:string lang_pack:string lang_code:string proxy:flags.0?InputClientProxy query:!X = X;
|
||||||
store(static_cast<int32>(0x785188b8), storer);
|
store(static_cast<int32>(0x785188b8), storer);
|
||||||
int32 flags = 0;
|
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;
|
flags |= 1 << 0;
|
||||||
}
|
}
|
||||||
|
if (options.is_emulator) {
|
||||||
|
flags |= 1 << 10;
|
||||||
|
}
|
||||||
store(flags, storer);
|
store(flags, storer);
|
||||||
store(options.api_id, storer);
|
store(options.api_id, storer);
|
||||||
if (is_anonymous) {
|
if (is_anonymous) {
|
||||||
@ -44,7 +48,7 @@ class HeaderStorer {
|
|||||||
store(options.system_language_code, storer);
|
store(options.system_language_code, storer);
|
||||||
store(string(), storer);
|
store(string(), storer);
|
||||||
store(string(), storer);
|
store(string(), storer);
|
||||||
if ((flags & 1) != 0) {
|
if (have_proxy) {
|
||||||
// inputClientProxy#75588b3f address:string port:int = InputClientProxy;
|
// inputClientProxy#75588b3f address:string port:int = InputClientProxy;
|
||||||
store(static_cast<int32>(0x75588b3f), storer);
|
store(static_cast<int32>(0x75588b3f), storer);
|
||||||
store(Slice(options.proxy.server()), storer);
|
store(Slice(options.proxy.server()), storer);
|
||||||
|
@ -20,6 +20,7 @@ class MtprotoHeader {
|
|||||||
string system_language_code;
|
string system_language_code;
|
||||||
string device_model;
|
string device_model;
|
||||||
string system_version;
|
string system_version;
|
||||||
|
bool is_emulator = false;
|
||||||
string application_version;
|
string application_version;
|
||||||
Proxy proxy;
|
Proxy proxy;
|
||||||
};
|
};
|
||||||
@ -33,6 +34,11 @@ class MtprotoHeader {
|
|||||||
default_header_ = gen_header(options_, false);
|
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 {
|
Slice get_default_header() const {
|
||||||
return default_header_;
|
return default_header_;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user