Add Td::get_version_option_value_object().

This commit is contained in:
levlam 2022-07-11 12:47:23 +03:00
parent 6eb03bdc8b
commit 4300c64a30
3 changed files with 12 additions and 9 deletions

View File

@ -426,7 +426,7 @@ void OptionManager::get_option(const string &name, Promise<td_api::object_ptr<td
break; break;
case 'v': case 'v':
if (name == "version") { if (name == "version") {
return promise.set_value(td_api::make_object<td_api::optionValueString>(Td::TDLIB_VERSION)); return promise.set_value(Td::get_version_option_value_object());
} }
break; break;
} }
@ -760,8 +760,7 @@ td_api::object_ptr<td_api::OptionValue> OptionManager::get_option_value_object(S
} }
void OptionManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const { void OptionManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
updates.push_back(td_api::make_object<td_api::updateOption>( updates.push_back(td_api::make_object<td_api::updateOption>("version", Td::get_version_option_value_object()));
"version", td_api::make_object<td_api::optionValueString>(Td::TDLIB_VERSION)));
updates.push_back(td_api::make_object<td_api::updateOption>( updates.push_back(td_api::make_object<td_api::updateOption>(
"online", td_api::make_object<td_api::optionValueBoolean>(td_->is_online()))); "online", td_api::make_object<td_api::optionValueBoolean>(td_->is_online())));

View File

@ -3057,8 +3057,7 @@ void Td::run_request(uint64 id, tl_object_ptr<td_api::Function> function) {
return send_result(id, get_fake_authorization_state_object()); return send_result(id, get_fake_authorization_state_object());
case td_api::getCurrentState::ID: { case td_api::getCurrentState::ID: {
vector<td_api::object_ptr<td_api::Update>> updates; vector<td_api::object_ptr<td_api::Update>> updates;
updates.push_back(td_api::make_object<td_api::updateOption>( updates.push_back(td_api::make_object<td_api::updateOption>("version", get_version_option_value_object()));
"version", td_api::make_object<td_api::optionValueString>(TDLIB_VERSION)));
updates.push_back(td_api::make_object<td_api::updateAuthorizationState>(get_fake_authorization_state_object())); updates.push_back(td_api::make_object<td_api::updateAuthorizationState>(get_fake_authorization_state_object()));
// send response synchronously to prevent "Request aborted" // send response synchronously to prevent "Request aborted"
return send_result(id, td_api::make_object<td_api::updates>(std::move(updates))); return send_result(id, td_api::make_object<td_api::updates>(std::move(updates)));
@ -3255,6 +3254,10 @@ void Td::on_connection_state_changed(ConnectionState new_state) {
send_closure(actor_id(this), &Td::send_update, get_update_connection_state_object(connection_state_)); send_closure(actor_id(this), &Td::send_update, get_update_connection_state_object(connection_state_));
} }
td_api::object_ptr<td_api::OptionValue> Td::get_version_option_value_object() {
return td_api::make_object<td_api::optionValueString>(TDLIB_VERSION);
}
void Td::start_up() { void Td::start_up() {
always_wait_for_mailbox(); always_wait_for_mailbox();
@ -3275,8 +3278,7 @@ void Td::start_up() {
alarm_timeout_.set_callback_data(static_cast<void *>(this)); alarm_timeout_.set_callback_data(static_cast<void *>(this));
CHECK(state_ == State::WaitParameters); CHECK(state_ == State::WaitParameters);
send_update(td_api::make_object<td_api::updateOption>("version", send_update(td_api::make_object<td_api::updateOption>("version", get_version_option_value_object()));
td_api::make_object<td_api::optionValueString>(TDLIB_VERSION)));
send_update(td_api::make_object<td_api::updateAuthorizationState>( send_update(td_api::make_object<td_api::updateAuthorizationState>(
td_api::make_object<td_api::authorizationStateWaitTdlibParameters>())); td_api::make_object<td_api::authorizationStateWaitTdlibParameters>()));
} }

View File

@ -102,8 +102,6 @@ class Td final : public Actor {
Td &operator=(Td &&) = delete; Td &operator=(Td &&) = delete;
~Td() final; ~Td() final;
static constexpr const char *TDLIB_VERSION = "1.8.4";
struct Options { struct Options {
std::shared_ptr<NetQueryStats> net_query_stats; std::shared_ptr<NetQueryStats> net_query_stats;
}; };
@ -248,6 +246,8 @@ class Td final : public Actor {
static td_api::object_ptr<td_api::Object> static_request(td_api::object_ptr<td_api::Function> function); static td_api::object_ptr<td_api::Object> static_request(td_api::object_ptr<td_api::Function> function);
static td_api::object_ptr<td_api::OptionValue> get_version_option_value_object();
private: private:
static constexpr int64 ONLINE_ALARM_ID = 0; static constexpr int64 ONLINE_ALARM_ID = 0;
static constexpr int64 PING_SERVER_ALARM_ID = -1; static constexpr int64 PING_SERVER_ALARM_ID = -1;
@ -255,6 +255,8 @@ class Td final : public Actor {
static constexpr int64 TERMS_OF_SERVICE_ALARM_ID = -2; static constexpr int64 TERMS_OF_SERVICE_ALARM_ID = -2;
static constexpr int64 PROMO_DATA_ALARM_ID = -3; static constexpr int64 PROMO_DATA_ALARM_ID = -3;
static constexpr const char *TDLIB_VERSION = "1.8.4";
void on_connection_state_changed(ConnectionState new_state); void on_connection_state_changed(ConnectionState new_state);
void run_request(uint64 id, tl_object_ptr<td_api::Function> function); void run_request(uint64 id, tl_object_ptr<td_api::Function> function);