2020-08-23 23:43:31 +02:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
|
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
2020-08-24 22:38:45 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
2020-08-24 13:39:03 +02:00
|
|
|
#include "td/actor/actor.h"
|
2020-08-23 23:43:31 +02:00
|
|
|
#include "td/actor/PromiseFuture.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2020-08-24 22:38:45 +02:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
#include <unordered_map>
|
2020-08-23 23:43:31 +02:00
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class Td;
|
|
|
|
|
2020-08-24 13:39:03 +02:00
|
|
|
class CountryInfoManager : public Actor {
|
2020-08-23 23:43:31 +02:00
|
|
|
public:
|
2020-08-24 13:39:03 +02:00
|
|
|
explicit CountryInfoManager(Td *td, ActorShared<> parent);
|
2020-08-23 23:43:31 +02:00
|
|
|
|
2020-08-24 22:38:45 +02:00
|
|
|
void get_countries(Promise<td_api::object_ptr<td_api::countries>> &&promise);
|
|
|
|
|
2020-08-23 23:43:31 +02:00
|
|
|
void get_current_country_code(Promise<string> &&promise);
|
|
|
|
|
2020-08-25 12:42:14 +02:00
|
|
|
void get_phone_number_info(string phone_number_prefix,
|
|
|
|
Promise<td_api::object_ptr<td_api::phoneNumberInfo>> &&promise);
|
|
|
|
|
2020-08-23 23:43:31 +02:00
|
|
|
private:
|
2020-08-24 13:39:03 +02:00
|
|
|
void tear_down() override;
|
|
|
|
|
2020-08-24 22:38:45 +02:00
|
|
|
struct CallingCodeInfo;
|
|
|
|
struct CountryInfo;
|
|
|
|
struct CountryList;
|
|
|
|
|
|
|
|
string get_main_language_code();
|
|
|
|
|
|
|
|
void do_get_countries(string language_code, bool is_recursive,
|
|
|
|
Promise<td_api::object_ptr<td_api::countries>> &&promise);
|
|
|
|
|
2020-08-25 12:42:14 +02:00
|
|
|
void do_get_phone_number_info(string phone_number_prefix, string language_code, bool is_recursive,
|
|
|
|
Promise<td_api::object_ptr<td_api::phoneNumberInfo>> &&promise);
|
|
|
|
|
2020-08-24 22:38:45 +02:00
|
|
|
void load_country_list(string language_code, int32 hash, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void on_get_country_list(const string &language_code,
|
|
|
|
Result<tl_object_ptr<telegram_api::help_CountriesList>> r_country_list);
|
|
|
|
|
|
|
|
const CountryList *get_country_list(const string &language_code);
|
|
|
|
|
|
|
|
std::unordered_map<string, vector<Promise<Unit>>> pending_load_country_queries_;
|
|
|
|
std::unordered_map<string, unique_ptr<CountryList>> countries_;
|
|
|
|
|
2020-08-23 23:43:31 +02:00
|
|
|
Td *td_;
|
2020-08-24 13:39:03 +02:00
|
|
|
ActorShared<> parent_;
|
2020-08-23 23:43:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|