Fix Global.h and TdDb.h includes.

GitOrigin-RevId: 89fa1ee3e8071ad3f27687f79d1a52de113f9705
This commit is contained in:
levlam 2019-01-06 22:59:17 +03:00
parent ea06aa19d6
commit 5438119bb4
42 changed files with 69 additions and 39 deletions

View File

@ -15,6 +15,7 @@
#include "td/telegram/misc.h"
#include "td/telegram/SecretChatActor.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/td_api.h"

View File

@ -7,7 +7,6 @@
#include "td/telegram/AudiosManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/Td.h"
#include "td/telegram/secret_api.h"

View File

@ -20,6 +20,7 @@
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/PasswordManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/UniqueId.h"
#include "td/telegram/UpdatesManager.h"

View File

@ -6,8 +6,6 @@
//
#include "td/telegram/CallManager.h"
#include "td/telegram/Global.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"

View File

@ -18,6 +18,7 @@
#include "td/telegram/net/PublicRsaKeyShared.h"
#include "td/telegram/net/Session.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/TdDb.h"
#if !TD_EMSCRIPTEN //FIXME
#include "td/net/HttpQuery.h"

View File

@ -10,13 +10,6 @@
#include "td/telegram/telegram_api.h"
#include "td/telegram/telegram_api.hpp"
#include "td/actor/PromiseFuture.h"
#include "td/actor/SleepActor.h"
#include "td/db/binlog/BinlogEvent.h"
#include "td/db/binlog/BinlogHelper.h"
#include "td/db/SqliteKeyValueAsync.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ConfigShared.h"
#include "td/telegram/files/FileManager.h"
@ -32,10 +25,18 @@
#include "td/telegram/SecretChatActor.h"
#include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/TopDialogManager.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/Version.h"
#include "td/actor/PromiseFuture.h"
#include "td/actor/SleepActor.h"
#include "td/db/binlog/BinlogEvent.h"
#include "td/db/binlog/BinlogHelper.h"
#include "td/db/SqliteKeyValueAsync.h"
#include "td/utils/buffer.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"

View File

@ -9,6 +9,7 @@
#include "td/telegram/Global.h"
#include "td/telegram/misc.h"
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/UserId.h"
#include "td/telegram/td_api.hpp"

View File

@ -10,7 +10,6 @@
#include "td/telegram/AudiosManager.h"
#include "td/telegram/files/FileEncryptionKey.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/Photo.h"
#include "td/telegram/StickersManager.h"

View File

@ -9,7 +9,6 @@
#include "td/telegram/DhConfig.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/NetQueryCreator.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/TdParameters.h"
#include "td/actor/actor.h"
@ -49,6 +48,7 @@ class StateManager;
class StickersManager;
class StorageManager;
class Td;
class TdDb;
class TempAuthKeyWatchdog;
class TopDialogManager;
class UpdatesManager;

View File

@ -6,9 +6,11 @@
//
#include "td/telegram/HashtagHints.h"
#include "td/telegram/Global.h"
#include "td/telegram/TdDb.h"
#include "td/db/Pmc.h"
#include "td/db/SqliteKeyValueAsync.h"
#include "td/telegram/Global.h"
#include "td/utils/logging.h"
#include "td/utils/tl_helpers.h"

View File

@ -31,6 +31,7 @@
#include "td/telegram/ReplyMarkup.h"
#include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/VideosManager.h"
#include "td/telegram/VoiceNotesManager.h"

View File

@ -39,6 +39,7 @@
#include "td/telegram/SecretChatsManager.h"
#include "td/telegram/SequenceDispatcher.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/TopDialogManager.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/WebPageId.h"

View File

@ -6,6 +6,7 @@
//
#pragma once
#include "td/telegram/Global.h"
#include "td/telegram/NotificationSettings.h"
#include "td/utils/tl_helpers.h"

View File

@ -6,6 +6,7 @@
//
#include "td/telegram/NotificationType.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h"

View File

@ -11,6 +11,7 @@
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/SecureStorage.h"
#include "td/telegram/TdDb.h"
#include "td/mtproto/crypto.h"

View File

@ -11,7 +11,6 @@
#include "td/telegram/files/FileEncryptionKey.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/net/DcId.h"
#include "td/utils/common.h"

View File

@ -16,6 +16,7 @@
#include "td/telegram/telegram_api.hpp"
#include "td/db/binlog/BinlogHelper.h"
#include "td/db/binlog/BinlogInterface.h"
#include "td/actor/MultiPromise.h"

View File

@ -9,6 +9,7 @@
#include "td/telegram/ConfigShared.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DhCache.h"
#include "td/telegram/Global.h"
#include "td/telegram/logevent/SecretChatEvent.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/MessagesManager.h"
@ -16,6 +17,7 @@
#include "td/telegram/SequenceDispatcher.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/telegram_api.hpp"
@ -23,6 +25,7 @@
#include "td/actor/PromiseFuture.h"
#include "td/db/binlog/BinlogEvent.h"
#include "td/db/binlog/BinlogInterface.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"

View File

@ -24,6 +24,7 @@
#include "td/telegram/net/DcId.h"
#include "td/telegram/StickersManager.hpp"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/actor/MultiPromise.h"
#include "td/actor/PromiseFuture.h"

View File

@ -13,6 +13,7 @@
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/TdDb.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"

View File

@ -3259,7 +3259,7 @@ td_api::object_ptr<td_api::AuthorizationState> Td::get_fake_authorization_state_
case State::WaitParameters:
return td_api::make_object<td_api::authorizationStateWaitTdlibParameters>();
case State::Decrypt:
return td_api::make_object<td_api::authorizationStateWaitEncryptionKey>(encryption_info_.is_encrypted);
return td_api::make_object<td_api::authorizationStateWaitEncryptionKey>(is_database_encrypted_);
case State::Run:
UNREACHABLE();
return nullptr;
@ -4468,7 +4468,7 @@ Status Td::set_parameters(td_api::object_ptr<td_api::tdlibParameters> parameters
TRY_STATUS(fix_parameters(parameters_));
VLOG(td_init) << "Check binlog encryption...";
TRY_RESULT(encryption_info, TdDb::check_encryption(parameters_));
encryption_info_ = std::move(encryption_info);
is_database_encrypted_ = encryption_info.is_encrypted;
VLOG(td_init) << "Create Global";
set_context(std::make_shared<Global>());
@ -4506,7 +4506,7 @@ Status Td::set_parameters(td_api::object_ptr<td_api::tdlibParameters> parameters
VLOG(td_init) << "Send authorizationStateWaitEncryptionKey";
send_closure(actor_id(this), &Td::send_update,
td_api::make_object<td_api::updateAuthorizationState>(
td_api::make_object<td_api::authorizationStateWaitEncryptionKey>(encryption_info_.is_encrypted)));
td_api::make_object<td_api::authorizationStateWaitEncryptionKey>(is_database_encrypted_)));
VLOG(td_init) << "Finish set parameters";
return Status::OK();
}

View File

@ -10,7 +10,6 @@
#include "td/telegram/net/NetQuery.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/TdCallback.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/TdParameters.h"
#include "td/telegram/TermsOfService.h"
@ -20,6 +19,8 @@
#include "td/actor/PromiseFuture.h"
#include "td/actor/Timeout.h"
#include "td/db/DbKey.h"
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include "td/utils/Container.h"
@ -245,7 +246,7 @@ class Td final : public NetQueryCallback {
int close_flag_ = 0;
enum class State : int32 { WaitParameters, Decrypt, Run, Close } state_ = State::WaitParameters;
EncryptionInfo encryption_info_;
bool is_database_encrypted_ = false;
vector<std::pair<uint64, std::shared_ptr<ResultHandler>>> result_handlers_;
enum : int8 { RequestActorIdType = 1, ActorIdType = 2 };

View File

@ -37,13 +37,13 @@ std::string get_sqlite_path(const TdParameters &parameters) {
return parameters.database_directory + db_name + ".sqlite";
}
Result<EncryptionInfo> check_encryption(string path) {
Result<TdDb::EncryptionInfo> check_encryption(string path) {
Binlog binlog;
auto status = binlog.init(path, Binlog::Callback());
if (status.is_error() && status.code() != Binlog::Error::WrongPassword) {
return Status::Error(400, status.message());
}
EncryptionInfo info;
TdDb::EncryptionInfo info;
info.is_encrypted = binlog.get_info().wrong_password;
binlog.close(false /*need_sync*/).ensure();
return info;
@ -420,7 +420,7 @@ Result<unique_ptr<TdDb>> TdDb::open(int32 scheduler_id, const TdParameters &para
TRY_STATUS(db->init(scheduler_id, parameters, std::move(key), events));
return std::move(db);
}
Result<EncryptionInfo> TdDb::check_encryption(const TdParameters &parameters) {
Result<TdDb::EncryptionInfo> TdDb::check_encryption(const TdParameters &parameters) {
return ::td::check_encryption(get_binlog_path(parameters));
}
void TdDb::change_key(DbKey key, Promise<> promise) {

View File

@ -37,10 +37,6 @@ class DialogDbSyncSafeInterface;
class DialogDbAsyncInterface;
class FileDbInterface;
struct EncryptionInfo {
bool is_encrypted{false};
};
class TdDb {
public:
TdDb();
@ -59,9 +55,13 @@ class TdDb {
vector<BinlogEvent> web_page_events;
vector<BinlogEvent> to_messages_manager;
};
static Result<unique_ptr<TdDb>> open(int32 scheduler_id, const TdParameters &parameters, DbKey key, Events &events);
struct EncryptionInfo {
bool is_encrypted{false};
};
static Result<EncryptionInfo> check_encryption(const TdParameters &parameters);
static Status destroy(const TdParameters &parameters);
std::shared_ptr<FileDbInterface> get_file_db_shared();
@ -74,9 +74,12 @@ class TdDb {
SqliteKeyValue *get_sqlite_sync_pmc();
SqliteKeyValueAsyncInterface *get_sqlite_pmc();
CSlice binlog_path() const;
CSlice sqlite_path() const;
void flush_all();
void close_all(Promise<> on_finished);
void close_and_destroy_all(Promise<> on_finished);

View File

@ -18,6 +18,7 @@
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/utils/misc.h"
#include "td/utils/port/Clocks.h"

View File

@ -33,6 +33,7 @@
#include "td/telegram/StateManager.h"
#include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/WebPagesManager.h"
#include "td/utils/buffer.h"

View File

@ -12,7 +12,6 @@
#include "td/telegram/AuthManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/Td.h"
#include "td/utils/logging.h"

View File

@ -11,7 +11,6 @@
#include "td/telegram/telegram_api.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/Td.h"
#include "td/utils/buffer.h"

View File

@ -28,6 +28,7 @@
#include "td/telegram/StickersManager.h"
#include "td/telegram/StickersManager.hpp"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/Version.h"
#include "td/telegram/VideoNotesManager.h"
#include "td/telegram/VideoNotesManager.hpp"

View File

@ -8,6 +8,7 @@
#include "td/telegram/files/FileLocation.h"
#include "td/telegram/Global.h"
#include "td/telegram/TdDb.h"
#include "td/utils/common.h"
#include "td/utils/filesystem.h"

View File

@ -13,6 +13,7 @@
#include "td/telegram/Global.h"
#include "td/telegram/misc.h"
#include "td/telegram/SecureStorage.h"
#include "td/telegram/TdDb.h"
#include "td/utils/base64.h"
#include "td/utils/format.h"

View File

@ -9,7 +9,6 @@
#include "td/telegram/td_api.h"
#include "td/telegram/files/FileLoaderUtils.h"
#include "td/telegram/Global.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"

View File

@ -10,6 +10,7 @@
#include "td/telegram/files/FileDb.h"
#include "td/telegram/files/FileLoaderUtils.h"
#include "td/telegram/Global.h"
#include "td/telegram/TdDb.h"
#include "td/db/SqliteKeyValue.h"

View File

@ -7,6 +7,7 @@
#include "td/telegram/net/AuthDataShared.h"
#include "td/telegram/Global.h"
#include "td/telegram/TdDb.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"

View File

@ -17,6 +17,7 @@
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/net/NetType.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/TdDb.h"
#include "td/mtproto/IStreamTransport.h"
#include "td/mtproto/PingConnection.h"

View File

@ -13,6 +13,7 @@
#include "td/telegram/net/AuthDataShared.h"
#include "td/telegram/net/NetQuery.h"
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/UniqueId.h"
#include "td/telegram/telegram_api.h"

View File

@ -6,7 +6,6 @@
//
#pragma once
#include "td/telegram/Global.h"
#include "td/telegram/net/AuthDataShared.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/NetQuery.h"

View File

@ -16,6 +16,7 @@
#include "td/telegram/ConfigShared.h"
#include "td/telegram/Global.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/db/Pmc.h"

View File

@ -12,6 +12,7 @@
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/Version.h"
#include "td/utils/logging.h"

View File

@ -8,6 +8,7 @@
#include "td/telegram/Global.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/telegram_api.h"

View File

@ -15,6 +15,7 @@
#include "td/utils/common.h"
namespace td {
class BinlogInterface {
public:
BinlogInterface() = default;
@ -51,4 +52,5 @@ class BinlogInterface {
virtual void close_and_destroy_impl(Promise<> promise) = 0;
virtual void add_raw_event_impl(uint64 id, BufferSlice &&raw_event, Promise<> promise, BinlogDebugInfo info) = 0;
};
} // namespace td

View File

@ -4,14 +4,6 @@
// 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)
//
#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"
#include "td/db/binlog/detail/BinlogEventsProcessor.h"
#include "td/mtproto/crypto.h"
#include "td/mtproto/utils.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/SecretChatActor.h"
@ -20,6 +12,17 @@
#include "td/telegram/secret_api.h"
#include "td/telegram/telegram_api.h"
#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"
#include "td/db/binlog/BinlogInterface.h"
#include "td/db/binlog/detail/BinlogEventsProcessor.h"
#include "td/db/BinlogKeyValue.h"
#include "td/db/DbKey.h"
#include "td/mtproto/crypto.h"
#include "td/mtproto/utils.h"
#include "td/tl/tl_object_parse.h"
#include "td/tl/tl_object_store.h"