tdlight/td/telegram/AccountManager.h

96 lines
3.0 KiB
C
Raw Normal View History

2023-09-08 15:19:30 +02:00
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// 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
#include "td/telegram/td_api.h"
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/Promise.h"
2023-09-08 15:19:30 +02:00
namespace td {
class Td;
class AccountManager final : public Actor {
public:
AccountManager(Td *td, ActorShared<> parent);
2023-09-11 21:03:01 +02:00
AccountManager(const AccountManager &) = delete;
AccountManager &operator=(const AccountManager &) = delete;
AccountManager(AccountManager &&) = delete;
AccountManager &operator=(AccountManager &&) = delete;
~AccountManager() final;
2023-09-08 15:19:30 +02:00
void set_default_message_ttl(int32 message_ttl, Promise<Unit> &&promise);
void get_default_message_ttl(Promise<int32> &&promise);
void set_account_ttl(int32 account_ttl, Promise<Unit> &&promise);
void get_account_ttl(Promise<int32> &&promise);
void confirm_qr_code_authentication(const string &link, Promise<td_api::object_ptr<td_api::session>> &&promise);
void get_active_sessions(Promise<td_api::object_ptr<td_api::sessions>> &&promise);
void terminate_session(int64 session_id, Promise<Unit> &&promise);
void terminate_all_other_sessions(Promise<Unit> &&promise);
2023-09-12 13:28:02 +02:00
void confirm_session(int64 session_id, Promise<Unit> &&promise);
void toggle_session_can_accept_calls(int64 session_id, bool can_accept_calls, Promise<Unit> &&promise);
void toggle_session_can_accept_secret_chats(int64 session_id, bool can_accept_secret_chats, Promise<Unit> &&promise);
void set_inactive_session_ttl_days(int32 authorization_ttl_days, Promise<Unit> &&promise);
void get_connected_websites(Promise<td_api::object_ptr<td_api::connectedWebsites>> &&promise);
void disconnect_website(int64 website_id, Promise<Unit> &&promise);
void disconnect_all_websites(Promise<Unit> &&promise);
2023-09-11 17:59:19 +02:00
void get_user_link(Promise<td_api::object_ptr<td_api::userLink>> &&promise);
void import_contact_token(const string &token, Promise<td_api::object_ptr<td_api::user>> &&promise);
void invalidate_authentication_codes(vector<string> &&authentication_codes);
2023-09-11 21:03:01 +02:00
void on_new_unconfirmed_authorization(int64 hash, int32 date, string &&device, string &&location);
2023-09-12 13:28:02 +02:00
bool on_confirm_authorization(int64 hash);
2023-09-11 21:03:01 +02:00
2023-09-08 15:19:30 +02:00
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
private:
2023-09-11 21:03:01 +02:00
class UnconfirmedAuthorization;
class UnconfirmedAuthorizations;
void start_up() final;
2023-09-08 15:19:30 +02:00
void tear_down() final;
2023-09-11 17:59:19 +02:00
void get_user_link_impl(Promise<td_api::object_ptr<td_api::userLink>> &&promise);
static string get_unconfirmed_authorizations_key();
void save_unconfirmed_authorizations() const;
2023-09-11 21:03:01 +02:00
td_api::object_ptr<td_api::updateUnconfirmedSession> get_update_unconfirmed_session() const;
void send_update_unconfirmed_session() const;
2023-09-08 15:19:30 +02:00
Td *td_;
ActorShared<> parent_;
2023-09-11 21:03:01 +02:00
unique_ptr<UnconfirmedAuthorizations> unconfirmed_authorizations_;
2023-09-08 15:19:30 +02:00
};
} // namespace td