Improve constant names.
This commit is contained in:
parent
4b0bda767c
commit
1d3e72aa9d
@ -4459,7 +4459,7 @@ void ContactsManager::ChannelFull::parse(ParserT &parser) {
|
|||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void ContactsManager::SecretChat::store(StorerT &storer) const {
|
void ContactsManager::SecretChat::store(StorerT &storer) const {
|
||||||
using td::store;
|
using td::store;
|
||||||
bool has_layer = layer > static_cast<int32>(SecretChatLayer::DEFAULT_LAYER);
|
bool has_layer = layer > static_cast<int32>(SecretChatLayer::Default);
|
||||||
bool has_initial_folder_id = initial_folder_id != FolderId();
|
bool has_initial_folder_id = initial_folder_id != FolderId();
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(is_outbound);
|
STORE_FLAG(is_outbound);
|
||||||
@ -4505,7 +4505,7 @@ void ContactsManager::SecretChat::parse(ParserT &parser) {
|
|||||||
if (has_layer) {
|
if (has_layer) {
|
||||||
parse(layer, parser);
|
parse(layer, parser);
|
||||||
} else {
|
} else {
|
||||||
layer = static_cast<int32>(SecretChatLayer::DEFAULT_LAYER);
|
layer = static_cast<int32>(SecretChatLayer::Default);
|
||||||
}
|
}
|
||||||
if (has_initial_folder_id) {
|
if (has_initial_folder_id) {
|
||||||
parse(initial_folder_id, parser);
|
parse(initial_folder_id, parser);
|
||||||
|
@ -132,51 +132,51 @@ void DeviceTokenManager::register_device(tl_object_ptr<td_api::DeviceToken> devi
|
|||||||
case td_api::deviceTokenApplePush::ID: {
|
case td_api::deviceTokenApplePush::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenApplePush *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenApplePush *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->device_token_);
|
token = std::move(device_token->device_token_);
|
||||||
token_type = TokenType::APNS;
|
token_type = TokenType::Apns;
|
||||||
is_app_sandbox = device_token->is_app_sandbox_;
|
is_app_sandbox = device_token->is_app_sandbox_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::deviceTokenFirebaseCloudMessaging::ID: {
|
case td_api::deviceTokenFirebaseCloudMessaging::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenFirebaseCloudMessaging *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenFirebaseCloudMessaging *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->token_);
|
token = std::move(device_token->token_);
|
||||||
token_type = TokenType::FCM;
|
token_type = TokenType::Fcm;
|
||||||
encrypt = device_token->encrypt_;
|
encrypt = device_token->encrypt_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::deviceTokenMicrosoftPush::ID: {
|
case td_api::deviceTokenMicrosoftPush::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenMicrosoftPush *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenMicrosoftPush *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->channel_uri_);
|
token = std::move(device_token->channel_uri_);
|
||||||
token_type = TokenType::MPNS;
|
token_type = TokenType::Mpns;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::deviceTokenSimplePush::ID: {
|
case td_api::deviceTokenSimplePush::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenSimplePush *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenSimplePush *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->endpoint_);
|
token = std::move(device_token->endpoint_);
|
||||||
token_type = TokenType::SIMPLE_PUSH;
|
token_type = TokenType::SimplePush;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::deviceTokenUbuntuPush::ID: {
|
case td_api::deviceTokenUbuntuPush::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenUbuntuPush *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenUbuntuPush *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->token_);
|
token = std::move(device_token->token_);
|
||||||
token_type = TokenType::UBUNTU_PHONE;
|
token_type = TokenType::UbuntuPhone;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::deviceTokenBlackBerryPush::ID: {
|
case td_api::deviceTokenBlackBerryPush::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenBlackBerryPush *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenBlackBerryPush *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->token_);
|
token = std::move(device_token->token_);
|
||||||
token_type = TokenType::BLACKBERRY;
|
token_type = TokenType::BlackBerry;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::deviceTokenWindowsPush::ID: {
|
case td_api::deviceTokenWindowsPush::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenWindowsPush *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenWindowsPush *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->access_token_);
|
token = std::move(device_token->access_token_);
|
||||||
token_type = TokenType::WNS;
|
token_type = TokenType::Wns;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::deviceTokenApplePushVoIP::ID: {
|
case td_api::deviceTokenApplePushVoIP::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenApplePushVoIP *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenApplePushVoIP *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->device_token_);
|
token = std::move(device_token->device_token_);
|
||||||
token_type = TokenType::APNS_VOIP;
|
token_type = TokenType::ApnsVoip;
|
||||||
is_app_sandbox = device_token->is_app_sandbox_;
|
is_app_sandbox = device_token->is_app_sandbox_;
|
||||||
encrypt = device_token->encrypt_;
|
encrypt = device_token->encrypt_;
|
||||||
break;
|
break;
|
||||||
@ -205,19 +205,19 @@ void DeviceTokenManager::register_device(tl_object_ptr<td_api::DeviceToken> devi
|
|||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
token_type = TokenType::WEB_PUSH;
|
token_type = TokenType::WebPush;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::deviceTokenMicrosoftPushVoIP::ID: {
|
case td_api::deviceTokenMicrosoftPushVoIP::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenMicrosoftPushVoIP *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenMicrosoftPushVoIP *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->channel_uri_);
|
token = std::move(device_token->channel_uri_);
|
||||||
token_type = TokenType::MPNS_VOIP;
|
token_type = TokenType::MpnsVoip;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::deviceTokenTizenPush::ID: {
|
case td_api::deviceTokenTizenPush::ID: {
|
||||||
auto device_token = static_cast<td_api::deviceTokenTizenPush *>(device_token_ptr.get());
|
auto device_token = static_cast<td_api::deviceTokenTizenPush *>(device_token_ptr.get());
|
||||||
token = std::move(device_token->reg_id_);
|
token = std::move(device_token->reg_id_);
|
||||||
token_type = TokenType::TIZEN;
|
token_type = TokenType::Tizen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -273,7 +273,7 @@ void DeviceTokenManager::register_device(tl_object_ptr<td_api::DeviceToken> devi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceTokenManager::reregister_device() {
|
void DeviceTokenManager::reregister_device() {
|
||||||
for (int32 token_type = 1; token_type < TokenType::SIZE; token_type++) {
|
for (int32 token_type = 1; token_type < TokenType::Size; token_type++) {
|
||||||
auto &token = tokens_[token_type];
|
auto &token = tokens_[token_type];
|
||||||
if (token.state == TokenInfo::State::Sync && !token.token.empty()) {
|
if (token.state == TokenInfo::State::Sync && !token.token.empty()) {
|
||||||
token.state = TokenInfo::State::Reregister;
|
token.state = TokenInfo::State::Reregister;
|
||||||
@ -284,7 +284,7 @@ void DeviceTokenManager::reregister_device() {
|
|||||||
|
|
||||||
vector<std::pair<int64, Slice>> DeviceTokenManager::get_encryption_keys() const {
|
vector<std::pair<int64, Slice>> DeviceTokenManager::get_encryption_keys() const {
|
||||||
vector<std::pair<int64, Slice>> result;
|
vector<std::pair<int64, Slice>> result;
|
||||||
for (int32 token_type = 1; token_type < TokenType::SIZE; token_type++) {
|
for (int32 token_type = 1; token_type < TokenType::Size; token_type++) {
|
||||||
auto &info = tokens_[token_type];
|
auto &info = tokens_[token_type];
|
||||||
if (!info.token.empty() && info.state != TokenInfo::State::Unregister) {
|
if (!info.token.empty() && info.state != TokenInfo::State::Unregister) {
|
||||||
if (info.encrypt) {
|
if (info.encrypt) {
|
||||||
@ -302,7 +302,7 @@ string DeviceTokenManager::get_database_key(int32 token_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceTokenManager::start_up() {
|
void DeviceTokenManager::start_up() {
|
||||||
for (int32 token_type = 1; token_type < TokenType::SIZE; token_type++) {
|
for (int32 token_type = 1; token_type < TokenType::Size; token_type++) {
|
||||||
auto serialized = G()->td_db()->get_binlog_pmc()->get(get_database_key(token_type));
|
auto serialized = G()->td_db()->get_binlog_pmc()->get(get_database_key(token_type));
|
||||||
if (serialized.empty()) {
|
if (serialized.empty()) {
|
||||||
continue;
|
continue;
|
||||||
@ -360,7 +360,7 @@ void DeviceTokenManager::loop() {
|
|||||||
if (sync_cnt_ != 0 || G()->close_flag()) {
|
if (sync_cnt_ != 0 || G()->close_flag()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int32 token_type = 1; token_type < TokenType::SIZE; token_type++) {
|
for (int32 token_type = 1; token_type < TokenType::Size; token_type++) {
|
||||||
auto &info = tokens_[token_type];
|
auto &info = tokens_[token_type];
|
||||||
if (info.state == TokenInfo::State::Sync) {
|
if (info.state == TokenInfo::State::Sync) {
|
||||||
continue;
|
continue;
|
||||||
@ -387,7 +387,7 @@ void DeviceTokenManager::loop() {
|
|||||||
|
|
||||||
void DeviceTokenManager::on_result(NetQueryPtr net_query) {
|
void DeviceTokenManager::on_result(NetQueryPtr net_query) {
|
||||||
auto token_type = static_cast<TokenType>(get_link_token());
|
auto token_type = static_cast<TokenType>(get_link_token());
|
||||||
CHECK(token_type >= 1 && token_type < TokenType::SIZE);
|
CHECK(token_type >= 1 && token_type < TokenType::Size);
|
||||||
auto &info = tokens_[token_type];
|
auto &info = tokens_[token_type];
|
||||||
if (info.net_query_id != net_query->id()) {
|
if (info.net_query_id != net_query->id()) {
|
||||||
net_query->clear();
|
net_query->clear();
|
||||||
|
@ -36,19 +36,19 @@ class DeviceTokenManager final : public NetQueryCallback {
|
|||||||
private:
|
private:
|
||||||
ActorShared<> parent_;
|
ActorShared<> parent_;
|
||||||
enum TokenType : int32 {
|
enum TokenType : int32 {
|
||||||
APNS = 1,
|
Apns = 1,
|
||||||
FCM = 2,
|
Fcm = 2,
|
||||||
MPNS = 3,
|
Mpns = 3,
|
||||||
SIMPLE_PUSH = 4,
|
SimplePush = 4,
|
||||||
UBUNTU_PHONE = 5,
|
UbuntuPhone = 5,
|
||||||
BLACKBERRY = 6,
|
BlackBerry = 6,
|
||||||
UNUSED = 7,
|
Unused = 7,
|
||||||
WNS = 8,
|
Wns = 8,
|
||||||
APNS_VOIP = 9,
|
ApnsVoip = 9,
|
||||||
WEB_PUSH = 10,
|
WebPush = 10,
|
||||||
MPNS_VOIP = 11,
|
MpnsVoip = 11,
|
||||||
TIZEN = 12,
|
Tizen = 12,
|
||||||
SIZE
|
Size
|
||||||
};
|
};
|
||||||
struct TokenInfo {
|
struct TokenInfo {
|
||||||
enum class State : int32 { Sync, Unregister, Register, Reregister };
|
enum class State : int32 { Sync, Unregister, Register, Reregister };
|
||||||
@ -73,7 +73,7 @@ class DeviceTokenManager final : public NetQueryCallback {
|
|||||||
|
|
||||||
friend StringBuilder &operator<<(StringBuilder &string_builder, const TokenInfo &token_info);
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const TokenInfo &token_info);
|
||||||
|
|
||||||
std::array<TokenInfo, TokenType::SIZE> tokens_;
|
std::array<TokenInfo, TokenType::Size> tokens_;
|
||||||
int32 sync_cnt_{0};
|
int32 sync_cnt_{0};
|
||||||
|
|
||||||
void start_up() final;
|
void start_up() final;
|
||||||
|
@ -2992,17 +2992,17 @@ vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entiti
|
|||||||
result.push_back(make_tl_object<secret_api::messageEntityItalic>(entity.offset, entity.length));
|
result.push_back(make_tl_object<secret_api::messageEntityItalic>(entity.offset, entity.length));
|
||||||
break;
|
break;
|
||||||
case MessageEntity::Type::Underline:
|
case MessageEntity::Type::Underline:
|
||||||
if (layer >= static_cast<int32>(SecretChatLayer::NEW_ENTITIES_LAYER)) {
|
if (layer >= static_cast<int32>(SecretChatLayer::NewEntities)) {
|
||||||
result.push_back(make_tl_object<secret_api::messageEntityUnderline>(entity.offset, entity.length));
|
result.push_back(make_tl_object<secret_api::messageEntityUnderline>(entity.offset, entity.length));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MessageEntity::Type::Strikethrough:
|
case MessageEntity::Type::Strikethrough:
|
||||||
if (layer >= static_cast<int32>(SecretChatLayer::NEW_ENTITIES_LAYER)) {
|
if (layer >= static_cast<int32>(SecretChatLayer::NewEntities)) {
|
||||||
result.push_back(make_tl_object<secret_api::messageEntityStrike>(entity.offset, entity.length));
|
result.push_back(make_tl_object<secret_api::messageEntityStrike>(entity.offset, entity.length));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MessageEntity::Type::BlockQuote:
|
case MessageEntity::Type::BlockQuote:
|
||||||
if (layer >= static_cast<int32>(SecretChatLayer::NEW_ENTITIES_LAYER)) {
|
if (layer >= static_cast<int32>(SecretChatLayer::NewEntities)) {
|
||||||
result.push_back(make_tl_object<secret_api::messageEntityBlockquote>(entity.offset, entity.length));
|
result.push_back(make_tl_object<secret_api::messageEntityBlockquote>(entity.offset, entity.length));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -440,7 +440,7 @@ void SecretChatActor::binlog_replay_finish() {
|
|||||||
LOG(INFO) << "Binlog replay is finished with PfsState " << pfs_state_;
|
LOG(INFO) << "Binlog replay is finished with PfsState " << pfs_state_;
|
||||||
binlog_replay_finish_flag_ = true;
|
binlog_replay_finish_flag_ = true;
|
||||||
if (auth_state_.state == State::Ready) {
|
if (auth_state_.state == State::Ready) {
|
||||||
auto my_layer = static_cast<int32>(SecretChatLayer::MY_LAYER);
|
auto my_layer = static_cast<int32>(SecretChatLayer::Current);
|
||||||
if (config_state_.my_layer < my_layer) {
|
if (config_state_.my_layer < my_layer) {
|
||||||
send_action(secret_api::make_object<secret_api::decryptedMessageActionNotifyLayer>(my_layer), SendFlag::None,
|
send_action(secret_api::make_object<secret_api::decryptedMessageActionNotifyLayer>(my_layer), SendFlag::None,
|
||||||
Promise<>());
|
Promise<>());
|
||||||
@ -846,7 +846,7 @@ Status SecretChatActor::do_inbound_message_encrypted(unique_ptr<log_event::Inbou
|
|||||||
parser.fetch_end();
|
parser.fetch_end();
|
||||||
if (!parser.get_error()) {
|
if (!parser.get_error()) {
|
||||||
auto layer = message_with_layer->layer_;
|
auto layer = message_with_layer->layer_;
|
||||||
if (layer < static_cast<int32>(SecretChatLayer::DEFAULT_LAYER) &&
|
if (layer < static_cast<int32>(SecretChatLayer::Default) &&
|
||||||
false /* old Android app could send such messages */) {
|
false /* old Android app could send such messages */) {
|
||||||
LOG(ERROR) << "Layer " << layer << " is not supported, drop message " << to_string(message_with_layer);
|
LOG(ERROR) << "Layer " << layer << " is not supported, drop message " << to_string(message_with_layer);
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
@ -856,7 +856,7 @@ Status SecretChatActor::do_inbound_message_encrypted(unique_ptr<log_event::Inbou
|
|||||||
context_->secret_chat_db()->set_value(config_state_);
|
context_->secret_chat_db()->set_value(config_state_);
|
||||||
send_update_secret_chat();
|
send_update_secret_chat();
|
||||||
}
|
}
|
||||||
if (layer >= static_cast<int32>(SecretChatLayer::MTPROTO_2_LAYER) && mtproto_version < 2) {
|
if (layer >= static_cast<int32>(SecretChatLayer::Mtproto2) && mtproto_version < 2) {
|
||||||
return Status::Error(PSLICE() << "MTProto 1.0 encryption is forbidden for this layer");
|
return Status::Error(PSLICE() << "MTProto 1.0 encryption is forbidden for this layer");
|
||||||
}
|
}
|
||||||
if (message_with_layer->in_seq_no_ < 0) {
|
if (message_with_layer->in_seq_no_ < 0) {
|
||||||
@ -874,7 +874,7 @@ Status SecretChatActor::do_inbound_message_encrypted(unique_ptr<log_event::Inbou
|
|||||||
// support for older layer
|
// support for older layer
|
||||||
LOG(WARNING) << "Failed to fetch update: " << status;
|
LOG(WARNING) << "Failed to fetch update: " << status;
|
||||||
send_action(secret_api::make_object<secret_api::decryptedMessageActionNotifyLayer>(
|
send_action(secret_api::make_object<secret_api::decryptedMessageActionNotifyLayer>(
|
||||||
static_cast<int32>(SecretChatLayer::MY_LAYER)),
|
static_cast<int32>(SecretChatLayer::Current)),
|
||||||
SendFlag::None, Promise<>());
|
SendFlag::None, Promise<>());
|
||||||
|
|
||||||
if (config_state_.his_layer == 8) {
|
if (config_state_.his_layer == 8) {
|
||||||
@ -1848,7 +1848,7 @@ Status SecretChatActor::on_update_chat(telegram_api::encryptedChat &update) {
|
|||||||
context_->secret_chat_db()->set_value(auth_state_);
|
context_->secret_chat_db()->set_value(auth_state_);
|
||||||
send_update_secret_chat();
|
send_update_secret_chat();
|
||||||
send_action(secret_api::make_object<secret_api::decryptedMessageActionNotifyLayer>(
|
send_action(secret_api::make_object<secret_api::decryptedMessageActionNotifyLayer>(
|
||||||
static_cast<int32>(SecretChatLayer::MY_LAYER)),
|
static_cast<int32>(SecretChatLayer::Current)),
|
||||||
SendFlag::None, Promise<>());
|
SendFlag::None, Promise<>());
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
@ -639,12 +639,12 @@ class SecretChatActor final : public NetQueryCallback {
|
|||||||
Status save_common_info(T &update);
|
Status save_common_info(T &update);
|
||||||
|
|
||||||
int32 current_layer() const {
|
int32 current_layer() const {
|
||||||
int32 layer = static_cast<int32>(SecretChatLayer::MY_LAYER);
|
int32 layer = static_cast<int32>(SecretChatLayer::Current);
|
||||||
if (config_state_.his_layer < layer) {
|
if (config_state_.his_layer < layer) {
|
||||||
layer = config_state_.his_layer;
|
layer = config_state_.his_layer;
|
||||||
}
|
}
|
||||||
if (layer < static_cast<int32>(SecretChatLayer::DEFAULT_LAYER)) {
|
if (layer < static_cast<int32>(SecretChatLayer::Default)) {
|
||||||
layer = static_cast<int32>(SecretChatLayer::DEFAULT_LAYER);
|
layer = static_cast<int32>(SecretChatLayer::Default);
|
||||||
}
|
}
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
enum class SecretChatLayer : int32 {
|
enum class SecretChatLayer : int32 {
|
||||||
DEFAULT_LAYER = 73,
|
Default = 73,
|
||||||
MTPROTO_2_LAYER = 73,
|
Mtproto2 = 73,
|
||||||
NEW_ENTITIES_LAYER = 101,
|
NewEntities = 101,
|
||||||
DELETE_MESSAGES_ON_CLOSE_LAYER = 123,
|
DeleteMessagesOnClose = 123,
|
||||||
MY_LAYER = DELETE_MESSAGES_ON_CLOSE_LAYER
|
Current = DeleteMessagesOnClose
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
Loading…
Reference in New Issue
Block a user