2016-10-11 13:57:01 +02:00
|
|
|
/*
|
2018-07-30 04:07:02 +02:00
|
|
|
* This is the source code of tgnet library v. 1.1
|
2016-10-11 13:57:01 +02:00
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
2018-07-30 04:07:02 +02:00
|
|
|
* Copyright Nikolai Kudashov, 2015-2018.
|
2016-10-11 13:57:01 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ApiScheme.h"
|
|
|
|
#include "ByteArray.h"
|
|
|
|
#include "NativeByteBuffer.h"
|
|
|
|
#include "FileLog.h"
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
Bool *Bool::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
Bool *result = nullptr;
|
|
|
|
switch (constructor) {
|
|
|
|
case 0x997275b5:
|
|
|
|
result = new TL_boolTrue();
|
|
|
|
break;
|
|
|
|
case 0xbc799737:
|
|
|
|
result = new TL_boolFalse();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in Bool", constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_boolTrue::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_boolFalse::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TL_dcOption *TL_dcOption::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (TL_dcOption::constructor != constructor) {
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_dcOption", constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
TL_dcOption *result = new TL_dcOption();
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_dcOption::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
flags = stream->readInt32(&error);
|
2017-07-08 18:32:04 +02:00
|
|
|
ipv6 = (flags & 1) != 0;
|
|
|
|
media_only = (flags & 2) != 0;
|
|
|
|
tcpo_only = (flags & 4) != 0;
|
|
|
|
cdn = (flags & 8) != 0;
|
|
|
|
isStatic = (flags & 16) != 0;
|
2022-06-21 04:51:00 +02:00
|
|
|
thisPortOnly = (flags & 32) != 0;
|
2023-03-24 12:38:14 +01:00
|
|
|
force_try_ipv6 = (flags & 16384) != 0;
|
2016-10-11 13:57:01 +02:00
|
|
|
id = stream->readInt32(&error);
|
|
|
|
ip_address = stream->readString(&error);
|
|
|
|
port = stream->readInt32(&error);
|
2018-07-30 04:07:02 +02:00
|
|
|
if ((flags & 1024) != 0) {
|
|
|
|
secret = std::unique_ptr<ByteArray>(stream->readByteArray(&error));
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_dcOption::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2017-07-08 18:32:04 +02:00
|
|
|
flags = ipv6 ? (flags | 1) : (flags &~ 1);
|
|
|
|
flags = media_only ? (flags | 2) : (flags &~ 2);
|
|
|
|
flags = tcpo_only ? (flags | 4) : (flags &~ 4);
|
|
|
|
flags = cdn ? (flags | 8) : (flags &~ 8);
|
|
|
|
flags = isStatic ? (flags | 16) : (flags &~ 16);
|
2022-06-21 04:51:00 +02:00
|
|
|
flags = thisPortOnly ? (flags | 32) : (flags &~ 32);
|
2023-03-24 12:38:14 +01:00
|
|
|
flags = force_try_ipv6 ? (flags | 16384) : (flags &~ 16384);
|
2016-10-11 13:57:01 +02:00
|
|
|
stream->writeInt32(flags);
|
|
|
|
stream->writeInt32(id);
|
|
|
|
stream->writeString(ip_address);
|
|
|
|
stream->writeInt32(port);
|
2018-07-30 04:07:02 +02:00
|
|
|
if ((flags & 1024) != 0) {
|
|
|
|
stream->writeByteArray(secret.get());
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TL_cdnPublicKey *TL_cdnPublicKey::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2017-07-08 18:32:04 +02:00
|
|
|
if (TL_cdnPublicKey::constructor != constructor) {
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_cdnPublicKey", constructor);
|
2017-07-08 18:32:04 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
TL_cdnPublicKey *result = new TL_cdnPublicKey();
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2017-07-08 18:32:04 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_cdnPublicKey::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2017-07-08 18:32:04 +02:00
|
|
|
dc_id = stream->readInt32(&error);
|
|
|
|
public_key = stream->readString(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_cdnPublicKey::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(dc_id);
|
|
|
|
stream->writeString(public_key);
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TL_cdnConfig *TL_cdnConfig::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2017-07-08 18:32:04 +02:00
|
|
|
if (TL_cdnConfig::constructor != constructor) {
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_cdnConfig", constructor);
|
2017-07-08 18:32:04 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
TL_cdnConfig *result = new TL_cdnConfig();
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2017-07-08 18:32:04 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_cdnConfig::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2017-07-08 18:32:04 +02:00
|
|
|
int magic = stream->readInt32(&error);
|
|
|
|
if (magic != 0x1cb5c415) {
|
|
|
|
error = true;
|
2022-12-30 13:32:20 +01:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_cdnConfig, got %x", magic);
|
2017-07-08 18:32:04 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int count = stream->readInt32(&error);
|
2018-07-30 04:07:02 +02:00
|
|
|
for (int32_t a = 0; a < count; a++) {
|
|
|
|
TL_cdnPublicKey *object = TL_cdnPublicKey::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error);
|
2017-07-08 18:32:04 +02:00
|
|
|
if (object == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
public_keys.push_back(std::unique_ptr<TL_cdnPublicKey>(object));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_cdnConfig::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(0x1cb5c415);
|
2018-07-30 04:07:02 +02:00
|
|
|
int32_t count = (int32_t) public_keys.size();
|
2017-07-08 18:32:04 +02:00
|
|
|
stream->writeInt32(count);
|
2018-07-30 04:07:02 +02:00
|
|
|
for (int32_t a = 0; a < count; a++) {
|
2017-07-08 18:32:04 +02:00
|
|
|
public_keys[a]->serializeToStream(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TL_help_getCdnConfig::isNeedLayer() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TLObject *TL_help_getCdnConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
return TL_cdnConfig::TLdeserialize(stream, constructor, instanceNum, error);
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_help_getCdnConfig::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TL_config *TL_config::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (TL_config::constructor != constructor) {
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_config", constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
TL_config *result = new TL_config();
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_config::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
flags = stream->readInt32(&error);
|
|
|
|
date = stream->readInt32(&error);
|
|
|
|
expires = stream->readInt32(&error);
|
|
|
|
test_mode = stream->readBool(&error);
|
|
|
|
this_dc = stream->readInt32(&error);
|
|
|
|
uint32_t magic = stream->readUint32(&error);
|
|
|
|
if (magic != 0x1cb5c415) {
|
|
|
|
error = true;
|
2022-12-30 13:32:20 +01:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_config, got %x", magic);
|
2016-10-11 13:57:01 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int32_t count = stream->readInt32(&error);
|
|
|
|
for (int32_t a = 0; a < count; a++) {
|
2018-07-30 04:07:02 +02:00
|
|
|
TL_dcOption *object = TL_dcOption::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (object == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dc_options.push_back(std::unique_ptr<TL_dcOption>(object));
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
dc_txt_domain_name = stream->readString(&error);
|
2016-10-11 13:57:01 +02:00
|
|
|
chat_size_max = stream->readInt32(&error);
|
|
|
|
megagroup_size_max = stream->readInt32(&error);
|
|
|
|
forwarded_count_max = stream->readInt32(&error);
|
|
|
|
online_update_period_ms = stream->readInt32(&error);
|
|
|
|
offline_blur_timeout_ms = stream->readInt32(&error);
|
|
|
|
offline_idle_timeout_ms = stream->readInt32(&error);
|
|
|
|
online_cloud_timeout_ms = stream->readInt32(&error);
|
|
|
|
notify_cloud_delay_ms = stream->readInt32(&error);
|
|
|
|
notify_default_delay_ms = stream->readInt32(&error);
|
|
|
|
push_chat_period_ms = stream->readInt32(&error);
|
|
|
|
push_chat_limit = stream->readInt32(&error);
|
2023-03-08 08:27:18 +01:00
|
|
|
// saved_gifs_limit = stream->readInt32(&error);
|
2016-10-11 13:57:01 +02:00
|
|
|
edit_time_limit = stream->readInt32(&error);
|
2018-07-30 04:07:02 +02:00
|
|
|
revoke_time_limit = stream->readInt32(&error);
|
|
|
|
revoke_pm_time_limit = stream->readInt32(&error);
|
2016-10-11 13:57:01 +02:00
|
|
|
rating_e_decay = stream->readInt32(&error);
|
|
|
|
stickers_recent_limit = stream->readInt32(&error);
|
2023-03-08 08:27:18 +01:00
|
|
|
// stickers_faved_limit = stream->readInt32(&error);
|
2017-12-08 18:35:59 +01:00
|
|
|
channels_read_media_period = stream->readInt32(&error);
|
2016-10-11 13:57:01 +02:00
|
|
|
if ((flags & 1) != 0) {
|
|
|
|
tmp_sessions = stream->readInt32(&error);
|
|
|
|
}
|
2023-03-08 08:27:18 +01:00
|
|
|
// pinned_dialogs_count_max = stream->readInt32(&error);
|
|
|
|
// pinned_infolder_count_max = stream->readInt32(&error);
|
2017-03-31 01:58:05 +02:00
|
|
|
call_receive_timeout_ms = stream->readInt32(&error);
|
|
|
|
call_ring_timeout_ms = stream->readInt32(&error);
|
|
|
|
call_connect_timeout_ms = stream->readInt32(&error);
|
|
|
|
call_packet_timeout_ms = stream->readInt32(&error);
|
|
|
|
me_url_prefix = stream->readString(&error);
|
2018-07-30 04:07:02 +02:00
|
|
|
if ((flags & 128) != 0) {
|
|
|
|
autoupdate_url_prefix = stream->readString(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 512) != 0) {
|
|
|
|
gif_search_username = stream->readString(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 1024) != 0) {
|
|
|
|
venue_search_username = stream->readString(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 2048) != 0) {
|
|
|
|
img_search_username = stream->readString(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 4096) != 0) {
|
|
|
|
static_maps_provider = stream->readString(&error);
|
|
|
|
}
|
|
|
|
caption_length_max = stream->readInt32(&error);
|
|
|
|
message_length_max = stream->readInt32(&error);
|
|
|
|
webfile_dc_id = stream->readInt32(&error);
|
2017-07-08 18:32:04 +02:00
|
|
|
if ((flags & 4) != 0) {
|
|
|
|
suggested_lang_code = stream->readString(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 4) != 0) {
|
|
|
|
lang_pack_version = stream->readInt32(&error);
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
if ((flags & 4) != 0) {
|
|
|
|
base_lang_pack_version = stream->readInt32(&error);
|
|
|
|
}
|
2022-09-18 19:02:37 +02:00
|
|
|
if ((flags & 32768) != 0) {
|
|
|
|
reactions_default = std::unique_ptr<Reaction>(Reaction::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
2022-09-16 20:48:21 +02:00
|
|
|
}
|
2023-03-08 08:27:18 +01:00
|
|
|
if ((flags & 65536) != 0) {
|
|
|
|
autologin_token = stream->readString(&error);
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_config::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(flags);
|
|
|
|
stream->writeInt32(date);
|
|
|
|
stream->writeInt32(expires);
|
|
|
|
stream->writeBool(test_mode);
|
|
|
|
stream->writeInt32(this_dc);
|
|
|
|
stream->writeInt32(0x1cb5c415);
|
|
|
|
uint32_t count = (uint32_t) dc_options.size();
|
|
|
|
stream->writeInt32(count);
|
|
|
|
for (uint32_t a = 0; a < count; a++) {
|
|
|
|
dc_options[a]->serializeToStream(stream);
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
stream->writeString(dc_txt_domain_name);
|
2016-10-11 13:57:01 +02:00
|
|
|
stream->writeInt32(chat_size_max);
|
|
|
|
stream->writeInt32(megagroup_size_max);
|
|
|
|
stream->writeInt32(forwarded_count_max);
|
|
|
|
stream->writeInt32(online_update_period_ms);
|
|
|
|
stream->writeInt32(offline_blur_timeout_ms);
|
|
|
|
stream->writeInt32(offline_idle_timeout_ms);
|
|
|
|
stream->writeInt32(online_cloud_timeout_ms);
|
|
|
|
stream->writeInt32(notify_cloud_delay_ms);
|
|
|
|
stream->writeInt32(notify_default_delay_ms);
|
|
|
|
stream->writeInt32(push_chat_period_ms);
|
|
|
|
stream->writeInt32(push_chat_limit);
|
2023-03-08 08:27:18 +01:00
|
|
|
// stream->writeInt32(saved_gifs_limit);
|
2016-10-11 13:57:01 +02:00
|
|
|
stream->writeInt32(edit_time_limit);
|
2018-07-30 04:07:02 +02:00
|
|
|
stream->writeInt32(revoke_time_limit);
|
|
|
|
stream->writeInt32(revoke_pm_time_limit);
|
2016-10-11 13:57:01 +02:00
|
|
|
stream->writeInt32(rating_e_decay);
|
|
|
|
stream->writeInt32(stickers_recent_limit);
|
2023-03-08 08:27:18 +01:00
|
|
|
// stream->writeInt32(stickers_faved_limit);
|
2017-12-08 18:35:59 +01:00
|
|
|
stream->writeInt32(channels_read_media_period);
|
2016-10-11 13:57:01 +02:00
|
|
|
if ((flags & 1) != 0) {
|
|
|
|
stream->writeInt32(tmp_sessions);
|
|
|
|
}
|
2023-03-08 08:27:18 +01:00
|
|
|
// stream->writeInt32(pinned_dialogs_count_max);
|
|
|
|
// stream->writeInt32(pinned_infolder_count_max);
|
2017-03-31 01:58:05 +02:00
|
|
|
stream->writeInt32(call_receive_timeout_ms);
|
|
|
|
stream->writeInt32(call_ring_timeout_ms);
|
|
|
|
stream->writeInt32(call_connect_timeout_ms);
|
|
|
|
stream->writeInt32(call_packet_timeout_ms);
|
|
|
|
stream->writeString(me_url_prefix);
|
2018-07-30 04:07:02 +02:00
|
|
|
if ((flags & 128) != 0) {
|
|
|
|
stream->writeString(autoupdate_url_prefix);
|
|
|
|
}
|
|
|
|
if ((flags & 512) != 0) {
|
|
|
|
stream->writeString(gif_search_username);
|
|
|
|
}
|
|
|
|
if ((flags & 1024) != 0) {
|
|
|
|
stream->writeString(venue_search_username);
|
|
|
|
}
|
|
|
|
if ((flags & 2048) != 0) {
|
|
|
|
stream->writeString(img_search_username);
|
|
|
|
}
|
|
|
|
if ((flags & 4096) != 0) {
|
|
|
|
stream->writeString(static_maps_provider);
|
|
|
|
}
|
|
|
|
stream->writeInt32(caption_length_max);
|
|
|
|
stream->writeInt32(message_length_max);
|
|
|
|
stream->writeInt32(webfile_dc_id);
|
2017-07-08 18:32:04 +02:00
|
|
|
if ((flags & 4) != 0) {
|
|
|
|
stream->writeString(suggested_lang_code);
|
|
|
|
}
|
|
|
|
if ((flags & 4) != 0) {
|
|
|
|
stream->writeInt32(lang_pack_version);
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
if ((flags & 4) != 0) {
|
|
|
|
stream->writeInt32(base_lang_pack_version);
|
|
|
|
}
|
2022-09-16 20:48:21 +02:00
|
|
|
if ((flags & 32768) != 0 && reactions_default != nullptr) {
|
|
|
|
reactions_default->serializeToStream(stream);
|
|
|
|
}
|
2023-03-08 08:27:18 +01:00
|
|
|
if ((flags & 65536) != 0) {
|
|
|
|
stream->writeString(autologin_token);
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TLObject *TL_help_getConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
return TL_config::TLdeserialize(stream, constructor, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_help_getConfig::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TL_help_getConfig::isNeedLayer() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TL_account_registerDevice::isNeedLayer() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TLObject *TL_account_registerDevice::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
return Bool::TLdeserialize(stream, constructor, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_account_registerDevice::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(token_type);
|
|
|
|
stream->writeString(token);
|
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
TL_restrictionReason *TL_restrictionReason::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
if (TL_restrictionReason::constructor != constructor) {
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_restrictionReason", constructor);
|
2019-09-10 12:56:11 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
TL_restrictionReason *result = new TL_restrictionReason();
|
|
|
|
result->readParams(stream, instanceNum, error);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-11-05 13:34:47 +01:00
|
|
|
TL_username *TL_username::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
if (TL_username::constructor != constructor) {
|
|
|
|
error = true;
|
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_username", constructor);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
TL_username *result = new TL_username();
|
|
|
|
result->readParams(stream, instanceNum, error);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
void TL_restrictionReason::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
platform = stream->readString(&error);
|
|
|
|
reason = stream->readString(&error);
|
|
|
|
text = stream->readString(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_restrictionReason::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeString(platform);
|
|
|
|
stream->writeString(reason);
|
|
|
|
stream->writeString(text);
|
|
|
|
}
|
|
|
|
|
2022-11-05 13:34:47 +01:00
|
|
|
void TL_username::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
flags = stream->readInt32(&error);
|
|
|
|
editable = (flags & 1) != 0;
|
|
|
|
active = (flags & 2) != 0;
|
|
|
|
username = stream->readString(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_username::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
flags = editable ? (flags | 1) : (flags &~ 1);
|
|
|
|
flags = active ? (flags | 2) : (flags &~ 2);
|
|
|
|
stream->writeInt32(flags);
|
|
|
|
stream->writeString(username);
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
User *User::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
User *result = nullptr;
|
|
|
|
switch (constructor) {
|
2022-09-16 20:48:21 +02:00
|
|
|
case TL_userEmpty::constructor:
|
2016-10-11 13:57:01 +02:00
|
|
|
result = new TL_userEmpty();
|
|
|
|
break;
|
2022-09-16 20:48:21 +02:00
|
|
|
case TL_user::constructor:
|
2016-10-11 13:57:01 +02:00
|
|
|
result = new TL_user();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in User", constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_userEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2021-09-20 07:54:41 +02:00
|
|
|
id = stream->readInt64(&error);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userEmpty::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(id);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
flags = stream->readInt32(&error);
|
2022-11-05 13:34:47 +01:00
|
|
|
flags2 = stream->readInt32(&error);
|
2021-09-20 07:54:41 +02:00
|
|
|
id = stream->readInt64(&error);
|
2016-10-11 13:57:01 +02:00
|
|
|
if ((flags & 1) != 0) {
|
|
|
|
access_hash = stream->readInt64(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 2) != 0) {
|
|
|
|
first_name = stream->readString(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 4) != 0) {
|
|
|
|
last_name = stream->readString(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 8) != 0) {
|
|
|
|
username = stream->readString(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 16) != 0) {
|
|
|
|
phone = stream->readString(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 32) != 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
if ((flags & 64) != 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
if ((flags & 16384) != 0) {
|
|
|
|
bot_info_version = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
if ((flags & 262144) != 0) {
|
2019-09-10 12:56:11 +02:00
|
|
|
uint32_t magic = stream->readUint32(&error);
|
|
|
|
if (magic != 0x1cb5c415) {
|
|
|
|
error = true;
|
2022-12-30 13:32:20 +01:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user, got %x", magic);
|
2019-09-10 12:56:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int32_t count = stream->readInt32(&error);
|
|
|
|
for (int32_t a = 0; a < count; a++) {
|
|
|
|
TL_restrictionReason *object = TL_restrictionReason::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error);
|
|
|
|
if (object == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
restriction_reason.push_back(std::unique_ptr<TL_restrictionReason>(object));
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
if ((flags & 524288) != 0) {
|
|
|
|
bot_inline_placeholder = stream->readString(&error);
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
if ((flags & 4194304) != 0) {
|
|
|
|
lang_code = stream->readString(&error);
|
|
|
|
}
|
2022-12-30 13:32:20 +01:00
|
|
|
if ((flags & 1073741824) != 0) {
|
2023-10-28 22:52:06 +02:00
|
|
|
emojiStatusMagic = stream->readUint32(&error);
|
|
|
|
if (emojiStatusMagic == 0x2de11aae) {
|
2022-12-30 13:32:20 +01:00
|
|
|
// emojiStatusEmpty
|
2023-10-28 22:52:06 +02:00
|
|
|
} else if (emojiStatusMagic == 0x929b619d) {
|
2022-12-30 13:32:20 +01:00
|
|
|
// emojiStatus
|
2023-10-28 22:52:06 +02:00
|
|
|
emojiStatusDocumentId = stream->readInt64(&error);
|
|
|
|
} else if (emojiStatusMagic == 0xfa30a8c7) {
|
2022-12-30 13:32:20 +01:00
|
|
|
// emojiStatusUntil
|
2023-10-28 22:52:06 +02:00
|
|
|
emojiStatusDocumentId = stream->readInt64(&error);
|
|
|
|
emojiStatusUntil = stream->readInt32(&error);
|
2022-12-30 13:32:20 +01:00
|
|
|
} else {
|
|
|
|
error = true;
|
2023-10-28 22:52:06 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("wrong EmojiStatus magic, got %x", emojiStatusMagic);
|
2022-12-30 13:32:20 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2022-11-05 13:34:47 +01:00
|
|
|
if ((flags2 & 1) != 0) {
|
|
|
|
uint32_t magic = stream->readUint32(&error);
|
|
|
|
if (magic != 0x1cb5c415) {
|
|
|
|
error = true;
|
2022-12-30 13:32:20 +01:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user (2), got %x", magic);
|
2022-11-05 13:34:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int32_t count = stream->readInt32(&error);
|
|
|
|
for (int32_t a = 0; a < count; a++) {
|
|
|
|
TL_username *object = TL_username::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error);
|
|
|
|
if (object == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
usernames.push_back(std::unique_ptr<TL_username>(object));
|
|
|
|
}
|
|
|
|
}
|
2023-07-20 22:15:36 +02:00
|
|
|
if ((flags2 & 32) != 0) {
|
|
|
|
stories_max_id = stream->readInt32(&error);
|
|
|
|
}
|
2023-12-04 19:17:50 +01:00
|
|
|
if ((flags2 & 256) != 0) {
|
|
|
|
int magic = stream->readInt32(&error);
|
|
|
|
color_color = stream->readInt32(&error);
|
|
|
|
color_background_emoji_id = stream->readInt64(&error);
|
2023-10-28 22:52:06 +02:00
|
|
|
}
|
2023-12-04 19:17:50 +01:00
|
|
|
if ((flags2 & 512) != 0) {
|
|
|
|
int magic = stream->readInt32(&error);
|
|
|
|
profile_color_color = stream->readInt32(&error);
|
|
|
|
profile_color_background_emoji_id = stream->readInt64(&error);
|
2023-10-28 22:52:06 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_user::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(flags);
|
2023-07-20 22:15:36 +02:00
|
|
|
stream->writeInt32(flags2);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(id);
|
2016-10-11 13:57:01 +02:00
|
|
|
if ((flags & 1) != 0) {
|
|
|
|
stream->writeInt64(access_hash);
|
|
|
|
}
|
|
|
|
if ((flags & 2) != 0) {
|
|
|
|
stream->writeString(first_name);
|
|
|
|
}
|
|
|
|
if ((flags & 4) != 0) {
|
|
|
|
stream->writeString(last_name);
|
|
|
|
}
|
|
|
|
if ((flags & 8) != 0) {
|
|
|
|
stream->writeString(username);
|
|
|
|
}
|
|
|
|
if ((flags & 16) != 0) {
|
|
|
|
stream->writeString(phone);
|
|
|
|
}
|
|
|
|
if ((flags & 32) != 0) {
|
|
|
|
photo->serializeToStream(stream);
|
|
|
|
}
|
|
|
|
if ((flags & 64) != 0) {
|
|
|
|
status->serializeToStream(stream);
|
|
|
|
}
|
|
|
|
if ((flags & 16384) != 0) {
|
|
|
|
stream->writeInt32(bot_info_version);
|
|
|
|
}
|
|
|
|
if ((flags & 262144) != 0) {
|
2019-09-10 12:56:11 +02:00
|
|
|
stream->writeInt32(0x1cb5c415);
|
|
|
|
uint32_t count = (uint32_t) restriction_reason.size();
|
|
|
|
stream->writeInt32(count);
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
restriction_reason[a]->serializeToStream(stream);
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
if ((flags & 524288) != 0) {
|
|
|
|
stream->writeString(bot_inline_placeholder);
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
if ((flags & 4194304) != 0) {
|
|
|
|
stream->writeString(lang_code);
|
|
|
|
}
|
2023-10-28 22:52:06 +02:00
|
|
|
if ((flags & 1073741824) != 0) {
|
|
|
|
stream->writeInt32(emojiStatusMagic);
|
|
|
|
if (emojiStatusMagic == 0x929b619d) {
|
|
|
|
// emojiStatus
|
|
|
|
stream->writeInt64(emojiStatusDocumentId);
|
|
|
|
} else if (emojiStatusMagic == 0xfa30a8c7) {
|
|
|
|
// emojiStatusUntil
|
|
|
|
stream->writeInt64(emojiStatusDocumentId);
|
|
|
|
stream->writeInt32(emojiStatusUntil);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((flags2 & 1) != 0) {
|
|
|
|
stream->writeInt32(0x1cb5c415);
|
|
|
|
int32_t count = (int32_t) usernames.size();
|
|
|
|
stream->writeInt32(count);
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
usernames[a]->serializeToStream(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((flags2 & 32) != 0) {
|
|
|
|
stream->writeInt32(stories_max_id);
|
|
|
|
}
|
2023-12-04 19:17:50 +01:00
|
|
|
if ((flags2 & 256) != 0) {
|
|
|
|
stream->writeInt32(0xba278146);
|
|
|
|
stream->writeInt32(color_color);
|
|
|
|
stream->writeInt32(color_background_emoji_id);
|
2023-10-28 22:52:06 +02:00
|
|
|
}
|
2023-12-04 19:17:50 +01:00
|
|
|
if ((flags2 & 512) != 0) {
|
|
|
|
stream->writeInt32(0xba278146);
|
|
|
|
stream->writeInt32(profile_color_color);
|
|
|
|
stream->writeInt32(profile_color_background_emoji_id);
|
2023-10-28 22:52:06 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
InputPeer *InputPeer::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
InputPeer *result = nullptr;
|
|
|
|
switch (constructor) {
|
|
|
|
case 0x7da07ec9:
|
|
|
|
result = new TL_inputPeerSelf();
|
|
|
|
break;
|
2021-09-20 07:54:41 +02:00
|
|
|
case 0xdde8a54c:
|
2019-08-22 01:53:26 +02:00
|
|
|
result = new TL_inputPeerUser();
|
|
|
|
break;
|
2021-09-20 07:54:41 +02:00
|
|
|
case 0x35a95cb9:
|
2019-08-22 01:53:26 +02:00
|
|
|
result = new TL_inputPeerChat();
|
|
|
|
break;
|
2021-09-20 07:54:41 +02:00
|
|
|
case 0xa87b0a1c:
|
2019-08-22 01:53:26 +02:00
|
|
|
result = new TL_inputPeerUserFromMessage();
|
|
|
|
break;
|
2021-09-20 07:54:41 +02:00
|
|
|
case 0xbd2a0840:
|
2019-08-22 01:53:26 +02:00
|
|
|
result = new TL_inputPeerChannelFromMessage();
|
|
|
|
break;
|
2021-09-20 07:54:41 +02:00
|
|
|
case 0x27bcbbfc:
|
2019-08-22 01:53:26 +02:00
|
|
|
result = new TL_inputPeerChannel();
|
|
|
|
break;
|
|
|
|
case 0x7f3b18ea:
|
|
|
|
result = new TL_inputPeerEmpty();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in InputPeer", constructor);
|
2019-08-22 01:53:26 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
result->readParams(stream, instanceNum, error);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerSelf::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2021-09-20 07:54:41 +02:00
|
|
|
user_id = stream->readInt64(&error);
|
2019-08-22 01:53:26 +02:00
|
|
|
access_hash = stream->readInt64(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerUser::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(user_id);
|
2019-08-22 01:53:26 +02:00
|
|
|
stream->writeInt64(access_hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerChat::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2021-09-20 07:54:41 +02:00
|
|
|
chat_id = stream->readInt64(&error);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerChat::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(chat_id);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
|
|
|
msg_id = stream->readInt32(&error);
|
2021-09-20 07:54:41 +02:00
|
|
|
user_id = stream->readInt64(&error);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerUserFromMessage::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
peer->serializeToStream(stream);
|
|
|
|
stream->writeInt32(msg_id);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(user_id);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerChannelFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
|
|
|
msg_id = stream->readInt32(&error);
|
2021-09-20 07:54:41 +02:00
|
|
|
channel_id = stream->readInt64(&error);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerChannelFromMessage::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
peer->serializeToStream(stream);
|
|
|
|
stream->writeInt32(msg_id);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(channel_id);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerChannel::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2021-09-20 07:54:41 +02:00
|
|
|
channel_id = stream->readInt64(&error);
|
2019-08-22 01:53:26 +02:00
|
|
|
access_hash = stream->readInt64(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerChannel::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(channel_id);
|
2019-08-22 01:53:26 +02:00
|
|
|
stream->writeInt64(access_hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputPeerEmpty::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
|
|
|
InputUser *InputUser::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
InputUser *result = nullptr;
|
|
|
|
switch (constructor) {
|
|
|
|
case 0xf7c1b13f:
|
|
|
|
result = new TL_inputUserSelf();
|
|
|
|
break;
|
2021-09-20 07:54:41 +02:00
|
|
|
case 0xf21158c6:
|
2019-08-22 01:53:26 +02:00
|
|
|
result = new TL_inputUser();
|
|
|
|
break;
|
|
|
|
case 0xb98886cf:
|
|
|
|
result = new TL_inputUserEmpty();
|
|
|
|
break;
|
2021-09-20 07:54:41 +02:00
|
|
|
case 0x1da448e2:
|
2019-08-22 01:53:26 +02:00
|
|
|
result = new TL_inputUserFromMessage();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in InputUser", constructor);
|
2019-08-22 01:53:26 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
result->readParams(stream, instanceNum, error);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputUserSelf::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2021-09-20 07:54:41 +02:00
|
|
|
user_id = stream->readInt64(&error);
|
2019-08-22 01:53:26 +02:00
|
|
|
access_hash = stream->readInt64(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputUser::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(user_id);
|
2019-08-22 01:53:26 +02:00
|
|
|
stream->writeInt64(access_hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputUserEmpty::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
|
|
|
msg_id = stream->readInt32(&error);
|
2021-09-20 07:54:41 +02:00
|
|
|
user_id = stream->readInt64(&error);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputUserFromMessage::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
peer->serializeToStream(stream);
|
|
|
|
stream->writeInt32(msg_id);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(user_id);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageEntity *MessageEntity::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
MessageEntity *result = nullptr;
|
|
|
|
switch (constructor) {
|
|
|
|
case 0x76a6d327:
|
|
|
|
result = new TL_messageEntityTextUrl();
|
|
|
|
break;
|
|
|
|
case 0x6cef8ac7:
|
|
|
|
result = new TL_messageEntityBotCommand();
|
|
|
|
break;
|
|
|
|
case 0x64e475c2:
|
|
|
|
result = new TL_messageEntityEmail();
|
|
|
|
break;
|
|
|
|
case 0x73924be0:
|
|
|
|
result = new TL_messageEntityPre();
|
|
|
|
break;
|
|
|
|
case 0xbb92ba95:
|
|
|
|
result = new TL_messageEntityUnknown();
|
|
|
|
break;
|
|
|
|
case 0x6ed02538:
|
|
|
|
result = new TL_messageEntityUrl();
|
|
|
|
break;
|
|
|
|
case 0x826f8b60:
|
|
|
|
result = new TL_messageEntityItalic();
|
|
|
|
break;
|
|
|
|
case 0xfa04579d:
|
|
|
|
result = new TL_messageEntityMention();
|
|
|
|
break;
|
2021-09-20 07:54:41 +02:00
|
|
|
case 0xdc7b1140:
|
2019-08-22 01:53:26 +02:00
|
|
|
result = new TL_messageEntityMentionName();
|
|
|
|
break;
|
|
|
|
case 0x208e68c9:
|
|
|
|
result = new TL_inputMessageEntityMentionName();
|
|
|
|
break;
|
|
|
|
case 0x4c4e743f:
|
|
|
|
result = new TL_messageEntityCashtag();
|
|
|
|
break;
|
|
|
|
case 0xbd610bc9:
|
|
|
|
result = new TL_messageEntityBold();
|
|
|
|
break;
|
|
|
|
case 0x6f635b0d:
|
|
|
|
result = new TL_messageEntityHashtag();
|
|
|
|
break;
|
|
|
|
case 0x28a20571:
|
|
|
|
result = new TL_messageEntityCode();
|
|
|
|
break;
|
|
|
|
case 0xbf0693d4:
|
|
|
|
result = new TL_messageEntityStrike();
|
|
|
|
break;
|
|
|
|
case 0x20df5d0:
|
|
|
|
result = new TL_messageEntityBlockquote();
|
|
|
|
break;
|
|
|
|
case 0x9c4e7e8b:
|
|
|
|
result = new TL_messageEntityUnderline();
|
|
|
|
break;
|
|
|
|
case 0x9b69e34b:
|
|
|
|
result = new TL_messageEntityPhone();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in MessageEntity", constructor);
|
2019-08-22 01:53:26 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
result->readParams(stream, instanceNum, error);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityTextUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
url = stream->readString(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityTextUrl::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
stream->writeString(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityBotCommand::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityBotCommand::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityEmail::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityEmail::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityPre::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
language = stream->readString(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityPre::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
stream->writeString(language);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityUnknown::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityUnknown::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityUrl::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityItalic::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityItalic::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityMention::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityMention::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
2021-09-20 07:54:41 +02:00
|
|
|
user_id = stream->readInt64(&error);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityMentionName::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(user_id);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputMessageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
user_id = std::unique_ptr<InputUser>(InputUser::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_inputMessageEntityMentionName::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
user_id->serializeToStream(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityCashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityCashtag::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityBold::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityBold::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityHashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityHashtag::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityCode::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityCode::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityStrike::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityStrike::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityBlockquote::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityBlockquote::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityUnderline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityUnderline::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityPhone::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
offset = stream->readInt32(&error);
|
|
|
|
length = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_messageEntityPhone::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(offset);
|
|
|
|
stream->writeInt32(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
TL_dataJSON *TL_dataJSON::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
if (TL_dataJSON::constructor != constructor) {
|
2016-10-11 13:57:01 +02:00
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_dataJSON", constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
TL_dataJSON *result = new TL_dataJSON();
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
void TL_dataJSON::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
data = stream->readString(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_dataJSON::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeString(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
TL_help_termsOfService *TL_help_termsOfService::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
if (TL_help_termsOfService::constructor != constructor) {
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_help_termsOfService", constructor);
|
2019-08-22 01:53:26 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
TL_help_termsOfService *result = new TL_help_termsOfService();
|
|
|
|
result->readParams(stream, instanceNum, error);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_help_termsOfService::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
flags = stream->readInt32(&error);
|
|
|
|
popup = (flags & 1) != 0;
|
|
|
|
id = std::unique_ptr<TL_dataJSON>(TL_dataJSON::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
|
|
|
text = stream->readString(&error);
|
|
|
|
int magic = stream->readInt32(&error);
|
|
|
|
if (magic != 0x1cb5c415) {
|
|
|
|
error = true;
|
2022-12-30 13:32:20 +01:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_help_termsOfService, got %x", magic);
|
2019-08-22 01:53:26 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int count = stream->readInt32(&error);
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
MessageEntity *object = MessageEntity::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error);
|
|
|
|
if (object == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
entities.push_back(std::unique_ptr<MessageEntity>(object));
|
|
|
|
}
|
|
|
|
if ((flags & 2) != 0) {
|
|
|
|
min_age_confirm = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_help_termsOfService::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
flags = popup ? (flags | 1) : (flags & ~1);
|
|
|
|
stream->writeInt32(flags);
|
|
|
|
id->serializeToStream(stream);
|
|
|
|
stream->writeString(text);
|
|
|
|
stream->writeInt32(0x1cb5c415);
|
|
|
|
int32_t count = (int32_t) entities.size();
|
|
|
|
stream->writeInt32(count);
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
entities[a]->serializeToStream(stream);
|
|
|
|
}
|
|
|
|
if ((flags & 2) != 0) {
|
|
|
|
stream->writeInt32(min_age_confirm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auth_Authorization *auth_Authorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
auth_Authorization *result = nullptr;
|
|
|
|
switch (constructor) {
|
|
|
|
case 0x44747e9a:
|
|
|
|
result = new TL_auth_authorizationSignUpRequired();
|
|
|
|
break;
|
2023-02-03 20:11:36 +01:00
|
|
|
case 0x2ea2c0d4:
|
2019-08-22 01:53:26 +02:00
|
|
|
result = new TL_auth_authorization();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in auth_Authorization", constructor);
|
2019-08-22 01:53:26 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
result->readParams(stream, instanceNum, error);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_auth_authorizationSignUpRequired::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
flags = stream->readInt32(&error);
|
|
|
|
if ((flags & 1) != 0) {
|
|
|
|
terms_of_service = std::unique_ptr<TL_help_termsOfService>(TL_help_termsOfService::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_auth_authorizationSignUpRequired::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(flags);
|
|
|
|
if ((flags & 1) != 0) {
|
|
|
|
terms_of_service->serializeToStream(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_auth_authorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
flags = stream->readInt32(&error);
|
2023-02-03 20:11:36 +01:00
|
|
|
if ((flags & 2) != 0) {
|
|
|
|
otherwise_relogin_days = stream->readInt32(&error);
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
if ((flags & 1) != 0) {
|
|
|
|
tmp_sessions = stream->readInt32(&error);
|
|
|
|
}
|
2023-02-03 20:11:36 +01:00
|
|
|
if ((flags & 4) != 0) {
|
|
|
|
future_auth_token = std::unique_ptr<ByteArray>(stream->readByteArray(&error));
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
user = std::unique_ptr<User>(User::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
void TL_auth_authorization::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(flags);
|
|
|
|
if ((flags & 1) != 0) {
|
|
|
|
stream->writeInt32(tmp_sessions);
|
|
|
|
}
|
|
|
|
user->serializeToStream(stream);
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TL_auth_exportedAuthorization *TL_auth_exportedAuthorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (TL_auth_exportedAuthorization::constructor != constructor) {
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_auth_exportedAuthorization", constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
TL_auth_exportedAuthorization *result = new TL_auth_exportedAuthorization();
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_auth_exportedAuthorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2021-09-20 07:54:41 +02:00
|
|
|
id = stream->readInt64(&error);
|
2016-10-11 13:57:01 +02:00
|
|
|
bytes = std::unique_ptr<ByteArray>(stream->readByteArray(&error));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TL_auth_exportAuthorization::isNeedLayer() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TLObject *TL_auth_exportAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
return TL_auth_exportedAuthorization::TLdeserialize(stream, constructor, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_auth_exportAuthorization::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(dc_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TL_auth_importAuthorization::isNeedLayer() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TLObject *TL_auth_importAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2019-08-22 01:53:26 +02:00
|
|
|
return auth_Authorization::TLdeserialize(stream, constructor, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_auth_importAuthorization::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2021-09-20 07:54:41 +02:00
|
|
|
stream->writeInt64(id);
|
2016-10-11 13:57:01 +02:00
|
|
|
stream->writeByteArray(bytes.get());
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
UserStatus *UserStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
UserStatus *result = nullptr;
|
|
|
|
switch (constructor) {
|
|
|
|
case 0x8c703f:
|
|
|
|
result = new TL_userStatusOffline();
|
|
|
|
break;
|
|
|
|
case 0x9d05049:
|
|
|
|
result = new TL_userStatusEmpty();
|
|
|
|
break;
|
|
|
|
case 0xedb93949:
|
|
|
|
result = new TL_userStatusOnline();
|
|
|
|
break;
|
2024-01-18 09:41:46 +01:00
|
|
|
case 0x7b197dc8:
|
2016-10-11 13:57:01 +02:00
|
|
|
result = new TL_userStatusRecently();
|
|
|
|
break;
|
2024-01-18 09:41:46 +01:00
|
|
|
case 0x541a1d1a:
|
|
|
|
result = new TL_userStatusLastWeek();
|
|
|
|
break;
|
|
|
|
case 0x65899777:
|
|
|
|
result = new TL_userStatusLastMonth();
|
|
|
|
break;
|
|
|
|
case 0xe26f42f1:
|
|
|
|
result = new TL_userStatusRecently_layer171();
|
|
|
|
break;
|
|
|
|
case 0x7bf09fc:
|
|
|
|
result = new TL_userStatusLastWeek_layer171();
|
|
|
|
break;
|
|
|
|
case 0x77ebc742:
|
|
|
|
result = new TL_userStatusLastMonth_layer171();
|
|
|
|
break;
|
2016-10-11 13:57:01 +02:00
|
|
|
default:
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in UserStatus", constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_userStatusOffline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
expires = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusOffline::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(expires);
|
|
|
|
}
|
|
|
|
|
2024-01-18 09:41:46 +01:00
|
|
|
void TL_userStatusLastWeek_layer171::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
void TL_userStatusLastWeek::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2024-01-18 09:41:46 +01:00
|
|
|
flags = by_me ? flags | 1 : flags &~ 1;
|
|
|
|
stream->writeInt32(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusLastWeek::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
flags = stream->readInt32(&error);
|
|
|
|
by_me = (flags & 1) != 0;
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusEmpty::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusLastMonth::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2024-01-18 09:41:46 +01:00
|
|
|
flags = by_me ? flags | 1 : flags &~ 1;
|
|
|
|
stream->writeInt32(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusLastMonth::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
flags = stream->readInt32(&error);
|
|
|
|
by_me = (flags & 1) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusLastMonth_layer171::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_userStatusOnline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
expires = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusOnline::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt32(expires);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusRecently::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2024-01-18 09:41:46 +01:00
|
|
|
flags = by_me ? flags | 1 : flags &~ 1;
|
|
|
|
stream->writeInt32(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusRecently::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
flags = stream->readInt32(&error);
|
|
|
|
by_me = (flags & 1) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusRecently_layer171::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userStatusHidden::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
FileLocation *FileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
FileLocation *result = nullptr;
|
|
|
|
switch (constructor) {
|
2019-05-14 14:08:05 +02:00
|
|
|
case 0xbc7fc6cd:
|
|
|
|
result = new TL_fileLocationToBeDeprecated();
|
2016-10-11 13:57:01 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in FileLocation", constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
void TL_fileLocationToBeDeprecated::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
volume_id = stream->readInt64(&error);
|
|
|
|
local_id = stream->readInt32(&error);
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
void TL_fileLocationToBeDeprecated::serializeToStream(NativeByteBuffer *stream) {
|
2016-10-11 13:57:01 +02:00
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt64(volume_id);
|
|
|
|
stream->writeInt32(local_id);
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
UserProfilePhoto *UserProfilePhoto::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
2016-10-11 13:57:01 +02:00
|
|
|
UserProfilePhoto *result = nullptr;
|
|
|
|
switch (constructor) {
|
|
|
|
case 0x4f11bae1:
|
|
|
|
result = new TL_userProfilePhotoEmpty();
|
|
|
|
break;
|
2021-06-25 02:43:10 +02:00
|
|
|
case 0x82d1f706:
|
2016-10-11 13:57:01 +02:00
|
|
|
result = new TL_userProfilePhoto();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
2022-09-16 20:48:21 +02:00
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in UserProfilePhoto", constructor);
|
2016-10-11 13:57:01 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
result->readParams(stream, instanceNum, error);
|
2016-10-11 13:57:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userProfilePhotoEmpty::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void TL_userProfilePhoto::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
2020-07-26 10:03:38 +02:00
|
|
|
flags = stream->readInt32(&error);
|
|
|
|
has_video = (flags & 1) != 0;
|
2016-10-11 13:57:01 +02:00
|
|
|
photo_id = stream->readInt64(&error);
|
2021-04-14 03:44:46 +02:00
|
|
|
if ((flags & 2) != 0) {
|
|
|
|
stripped_thumb = std::unique_ptr<ByteArray>(stream->readByteArray(&error));
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
dc_id = stream->readInt32(&error);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_userProfilePhoto::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
2020-07-26 10:03:38 +02:00
|
|
|
flags = has_video ? (flags | 1) : (flags &~ 1);
|
|
|
|
stream->writeInt32(flags);
|
2016-10-11 13:57:01 +02:00
|
|
|
stream->writeInt64(photo_id);
|
2021-04-14 03:44:46 +02:00
|
|
|
if ((flags & 2) != 0) {
|
|
|
|
stream->writeByteArray(stripped_thumb.get());
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
stream->writeInt32(dc_id);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TL_updatesTooLong::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
2022-09-16 20:48:21 +02:00
|
|
|
|
|
|
|
Reaction *Reaction::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
|
|
|
|
Reaction *result = nullptr;
|
|
|
|
switch (constructor) {
|
|
|
|
case 0x79f5d419:
|
|
|
|
result = new TL_reactionEmpty();
|
|
|
|
break;
|
|
|
|
case 0x8935fc73:
|
|
|
|
result = new TL_reactionCustomEmoji();
|
|
|
|
break;
|
|
|
|
case 0x1b2286b8:
|
|
|
|
result = new TL_reactionEmoji();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
|
|
|
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in Reaction", constructor);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
result->readParams(stream, instanceNum, error);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_reactionEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_reactionEmpty::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_reactionCustomEmoji::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
document_id = stream->readInt64(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_reactionCustomEmoji::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeInt64(document_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_reactionEmoji::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
|
|
|
|
emoticon = stream->readString(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TL_reactionEmoji::serializeToStream(NativeByteBuffer *stream) {
|
|
|
|
stream->writeInt32(constructor);
|
|
|
|
stream->writeString(emoticon);
|
|
|
|
}
|
|
|
|
|
|
|
|
|