| 1 | /* |
| 2 | * This is the source code of tgnet library v. 1.1 |
| 3 | * It is licensed under GNU GPL v. 2 or later. |
| 4 | * You should have received a copy of the license in this archive (see LICENSE). |
| 5 | * |
| 6 | * Copyright Nikolai Kudashov, 2015-2018. |
| 7 | */ |
| 8 | |
| 9 | #include "ApiScheme.h" |
| 10 | #include "ByteArray.h" |
| 11 | #include "NativeByteBuffer.h" |
| 12 | #include "FileLog.h" |
| 13 | |
| 14 | Bool *Bool::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 15 | Bool *result = nullptr; |
| 16 | switch (constructor) { |
| 17 | case 0x997275b5: |
| 18 | result = new TL_boolTrue(); |
| 19 | break; |
| 20 | case 0xbc799737: |
| 21 | result = new TL_boolFalse(); |
| 22 | break; |
| 23 | default: |
| 24 | error = true; |
| 25 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in Bool", constructor); |
| 26 | return nullptr; |
| 27 | } |
| 28 | result->readParams(stream, instanceNum, error); |
| 29 | return result; |
| 30 | } |
| 31 | |
| 32 | void TL_boolTrue::serializeToStream(NativeByteBuffer *stream) { |
| 33 | stream->writeInt32(constructor); |
| 34 | } |
| 35 | |
| 36 | void TL_boolFalse::serializeToStream(NativeByteBuffer *stream) { |
| 37 | stream->writeInt32(constructor); |
| 38 | } |
| 39 | |
| 40 | TL_dcOption *TL_dcOption::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 41 | if (TL_dcOption::constructor != constructor) { |
| 42 | error = true; |
| 43 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_dcOption", constructor); |
| 44 | return nullptr; |
| 45 | } |
| 46 | TL_dcOption *result = new TL_dcOption(); |
| 47 | result->readParams(stream, instanceNum, error); |
| 48 | return result; |
| 49 | } |
| 50 | |
| 51 | void TL_dcOption::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 52 | flags = stream->readInt32(&error); |
| 53 | ipv6 = (flags & 1) != 0; |
| 54 | media_only = (flags & 2) != 0; |
| 55 | tcpo_only = (flags & 4) != 0; |
| 56 | cdn = (flags & 8) != 0; |
| 57 | isStatic = (flags & 16) != 0; |
| 58 | thisPortOnly = (flags & 32) != 0; |
| 59 | id = stream->readInt32(&error); |
| 60 | ip_address = stream->readString(&error); |
| 61 | port = stream->readInt32(&error); |
| 62 | if ((flags & 1024) != 0) { |
| 63 | secret = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | void TL_dcOption::serializeToStream(NativeByteBuffer *stream) { |
| 68 | stream->writeInt32(constructor); |
| 69 | flags = ipv6 ? (flags | 1) : (flags &~ 1); |
| 70 | flags = media_only ? (flags | 2) : (flags &~ 2); |
| 71 | flags = tcpo_only ? (flags | 4) : (flags &~ 4); |
| 72 | flags = cdn ? (flags | 8) : (flags &~ 8); |
| 73 | flags = isStatic ? (flags | 16) : (flags &~ 16); |
| 74 | flags = thisPortOnly ? (flags | 32) : (flags &~ 32); |
| 75 | stream->writeInt32(flags); |
| 76 | stream->writeInt32(id); |
| 77 | stream->writeString(ip_address); |
| 78 | stream->writeInt32(port); |
| 79 | if ((flags & 1024) != 0) { |
| 80 | stream->writeByteArray(secret.get()); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | TL_cdnPublicKey *TL_cdnPublicKey::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 85 | if (TL_cdnPublicKey::constructor != constructor) { |
| 86 | error = true; |
| 87 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_cdnPublicKey", constructor); |
| 88 | return nullptr; |
| 89 | } |
| 90 | TL_cdnPublicKey *result = new TL_cdnPublicKey(); |
| 91 | result->readParams(stream, instanceNum, error); |
| 92 | return result; |
| 93 | } |
| 94 | |
| 95 | void TL_cdnPublicKey::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 96 | dc_id = stream->readInt32(&error); |
| 97 | public_key = stream->readString(&error); |
| 98 | } |
| 99 | |
| 100 | void TL_cdnPublicKey::serializeToStream(NativeByteBuffer *stream) { |
| 101 | stream->writeInt32(constructor); |
| 102 | stream->writeInt32(dc_id); |
| 103 | stream->writeString(public_key); |
| 104 | } |
| 105 | |
| 106 | TL_cdnConfig *TL_cdnConfig::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 107 | if (TL_cdnConfig::constructor != constructor) { |
| 108 | error = true; |
| 109 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_cdnConfig", constructor); |
| 110 | return nullptr; |
| 111 | } |
| 112 | TL_cdnConfig *result = new TL_cdnConfig(); |
| 113 | result->readParams(stream, instanceNum, error); |
| 114 | return result; |
| 115 | } |
| 116 | |
| 117 | void TL_cdnConfig::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 118 | int magic = stream->readInt32(&error); |
| 119 | if (magic != 0x1cb5c415) { |
| 120 | error = true; |
| 121 | if (LOGS_ENABLED) DEBUG_E("wrong Vector magic, got %x", magic); |
| 122 | return; |
| 123 | } |
| 124 | int count = stream->readInt32(&error); |
| 125 | for (int32_t a = 0; a < count; a++) { |
| 126 | TL_cdnPublicKey *object = TL_cdnPublicKey::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 127 | if (object == nullptr) { |
| 128 | return; |
| 129 | } |
| 130 | public_keys.push_back(std::unique_ptr<TL_cdnPublicKey>(object)); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | void TL_cdnConfig::serializeToStream(NativeByteBuffer *stream) { |
| 135 | stream->writeInt32(constructor); |
| 136 | stream->writeInt32(0x1cb5c415); |
| 137 | int32_t count = (int32_t) public_keys.size(); |
| 138 | stream->writeInt32(count); |
| 139 | for (int32_t a = 0; a < count; a++) { |
| 140 | public_keys[a]->serializeToStream(stream); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | bool TL_help_getCdnConfig::isNeedLayer() { |
| 145 | return true; |
| 146 | } |
| 147 | |
| 148 | TLObject *TL_help_getCdnConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 149 | return TL_cdnConfig::TLdeserialize(stream, constructor, instanceNum, error); |
| 150 | } |
| 151 | |
| 152 | void TL_help_getCdnConfig::serializeToStream(NativeByteBuffer *stream) { |
| 153 | stream->writeInt32(constructor); |
| 154 | } |
| 155 | |
| 156 | TL_config *TL_config::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 157 | if (TL_config::constructor != constructor) { |
| 158 | error = true; |
| 159 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_config", constructor); |
| 160 | return nullptr; |
| 161 | } |
| 162 | TL_config *result = new TL_config(); |
| 163 | result->readParams(stream, instanceNum, error); |
| 164 | return result; |
| 165 | } |
| 166 | |
| 167 | void TL_config::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 168 | flags = stream->readInt32(&error); |
| 169 | date = stream->readInt32(&error); |
| 170 | expires = stream->readInt32(&error); |
| 171 | test_mode = stream->readBool(&error); |
| 172 | this_dc = stream->readInt32(&error); |
| 173 | uint32_t magic = stream->readUint32(&error); |
| 174 | if (magic != 0x1cb5c415) { |
| 175 | error = true; |
| 176 | if (LOGS_ENABLED) DEBUG_E("wrong Vector magic, got %x", magic); |
| 177 | return; |
| 178 | } |
| 179 | int32_t count = stream->readInt32(&error); |
| 180 | for (int32_t a = 0; a < count; a++) { |
| 181 | TL_dcOption *object = TL_dcOption::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 182 | if (object == nullptr) { |
| 183 | return; |
| 184 | } |
| 185 | dc_options.push_back(std::unique_ptr<TL_dcOption>(object)); |
| 186 | } |
| 187 | dc_txt_domain_name = stream->readString(&error); |
| 188 | chat_size_max = stream->readInt32(&error); |
| 189 | megagroup_size_max = stream->readInt32(&error); |
| 190 | forwarded_count_max = stream->readInt32(&error); |
| 191 | online_update_period_ms = stream->readInt32(&error); |
| 192 | offline_blur_timeout_ms = stream->readInt32(&error); |
| 193 | offline_idle_timeout_ms = stream->readInt32(&error); |
| 194 | online_cloud_timeout_ms = stream->readInt32(&error); |
| 195 | notify_cloud_delay_ms = stream->readInt32(&error); |
| 196 | notify_default_delay_ms = stream->readInt32(&error); |
| 197 | push_chat_period_ms = stream->readInt32(&error); |
| 198 | push_chat_limit = stream->readInt32(&error); |
| 199 | saved_gifs_limit = stream->readInt32(&error); |
| 200 | edit_time_limit = stream->readInt32(&error); |
| 201 | revoke_time_limit = stream->readInt32(&error); |
| 202 | revoke_pm_time_limit = stream->readInt32(&error); |
| 203 | rating_e_decay = stream->readInt32(&error); |
| 204 | stickers_recent_limit = stream->readInt32(&error); |
| 205 | stickers_faved_limit = stream->readInt32(&error); |
| 206 | channels_read_media_period = stream->readInt32(&error); |
| 207 | if ((flags & 1) != 0) { |
| 208 | tmp_sessions = stream->readInt32(&error); |
| 209 | } |
| 210 | pinned_dialogs_count_max = stream->readInt32(&error); |
| 211 | pinned_infolder_count_max = stream->readInt32(&error); |
| 212 | call_receive_timeout_ms = stream->readInt32(&error); |
| 213 | call_ring_timeout_ms = stream->readInt32(&error); |
| 214 | call_connect_timeout_ms = stream->readInt32(&error); |
| 215 | call_packet_timeout_ms = stream->readInt32(&error); |
| 216 | me_url_prefix = stream->readString(&error); |
| 217 | if ((flags & 128) != 0) { |
| 218 | autoupdate_url_prefix = stream->readString(&error); |
| 219 | } |
| 220 | if ((flags & 512) != 0) { |
| 221 | gif_search_username = stream->readString(&error); |
| 222 | } |
| 223 | if ((flags & 1024) != 0) { |
| 224 | venue_search_username = stream->readString(&error); |
| 225 | } |
| 226 | if ((flags & 2048) != 0) { |
| 227 | img_search_username = stream->readString(&error); |
| 228 | } |
| 229 | if ((flags & 4096) != 0) { |
| 230 | static_maps_provider = stream->readString(&error); |
| 231 | } |
| 232 | caption_length_max = stream->readInt32(&error); |
| 233 | message_length_max = stream->readInt32(&error); |
| 234 | webfile_dc_id = stream->readInt32(&error); |
| 235 | if ((flags & 4) != 0) { |
| 236 | suggested_lang_code = stream->readString(&error); |
| 237 | } |
| 238 | if ((flags & 4) != 0) { |
| 239 | lang_pack_version = stream->readInt32(&error); |
| 240 | } |
| 241 | if ((flags & 4) != 0) { |
| 242 | base_lang_pack_version = stream->readInt32(&error); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | void TL_config::serializeToStream(NativeByteBuffer *stream) { |
| 247 | stream->writeInt32(constructor); |
| 248 | stream->writeInt32(flags); |
| 249 | stream->writeInt32(date); |
| 250 | stream->writeInt32(expires); |
| 251 | stream->writeBool(test_mode); |
| 252 | stream->writeInt32(this_dc); |
| 253 | stream->writeInt32(0x1cb5c415); |
| 254 | uint32_t count = (uint32_t) dc_options.size(); |
| 255 | stream->writeInt32(count); |
| 256 | for (uint32_t a = 0; a < count; a++) { |
| 257 | dc_options[a]->serializeToStream(stream); |
| 258 | } |
| 259 | stream->writeString(dc_txt_domain_name); |
| 260 | stream->writeInt32(chat_size_max); |
| 261 | stream->writeInt32(megagroup_size_max); |
| 262 | stream->writeInt32(forwarded_count_max); |
| 263 | stream->writeInt32(online_update_period_ms); |
| 264 | stream->writeInt32(offline_blur_timeout_ms); |
| 265 | stream->writeInt32(offline_idle_timeout_ms); |
| 266 | stream->writeInt32(online_cloud_timeout_ms); |
| 267 | stream->writeInt32(notify_cloud_delay_ms); |
| 268 | stream->writeInt32(notify_default_delay_ms); |
| 269 | stream->writeInt32(push_chat_period_ms); |
| 270 | stream->writeInt32(push_chat_limit); |
| 271 | stream->writeInt32(saved_gifs_limit); |
| 272 | stream->writeInt32(edit_time_limit); |
| 273 | stream->writeInt32(revoke_time_limit); |
| 274 | stream->writeInt32(revoke_pm_time_limit); |
| 275 | stream->writeInt32(rating_e_decay); |
| 276 | stream->writeInt32(stickers_recent_limit); |
| 277 | stream->writeInt32(stickers_faved_limit); |
| 278 | stream->writeInt32(channels_read_media_period); |
| 279 | if ((flags & 1) != 0) { |
| 280 | stream->writeInt32(tmp_sessions); |
| 281 | } |
| 282 | stream->writeInt32(pinned_dialogs_count_max); |
| 283 | stream->writeInt32(pinned_infolder_count_max); |
| 284 | stream->writeInt32(call_receive_timeout_ms); |
| 285 | stream->writeInt32(call_ring_timeout_ms); |
| 286 | stream->writeInt32(call_connect_timeout_ms); |
| 287 | stream->writeInt32(call_packet_timeout_ms); |
| 288 | stream->writeString(me_url_prefix); |
| 289 | if ((flags & 128) != 0) { |
| 290 | stream->writeString(autoupdate_url_prefix); |
| 291 | } |
| 292 | if ((flags & 512) != 0) { |
| 293 | stream->writeString(gif_search_username); |
| 294 | } |
| 295 | if ((flags & 1024) != 0) { |
| 296 | stream->writeString(venue_search_username); |
| 297 | } |
| 298 | if ((flags & 2048) != 0) { |
| 299 | stream->writeString(img_search_username); |
| 300 | } |
| 301 | if ((flags & 4096) != 0) { |
| 302 | stream->writeString(static_maps_provider); |
| 303 | } |
| 304 | stream->writeInt32(caption_length_max); |
| 305 | stream->writeInt32(message_length_max); |
| 306 | stream->writeInt32(webfile_dc_id); |
| 307 | if ((flags & 4) != 0) { |
| 308 | stream->writeString(suggested_lang_code); |
| 309 | } |
| 310 | if ((flags & 4) != 0) { |
| 311 | stream->writeInt32(lang_pack_version); |
| 312 | } |
| 313 | if ((flags & 4) != 0) { |
| 314 | stream->writeInt32(base_lang_pack_version); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | TLObject *TL_help_getConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 319 | return TL_config::TLdeserialize(stream, constructor, instanceNum, error); |
| 320 | } |
| 321 | |
| 322 | void TL_help_getConfig::serializeToStream(NativeByteBuffer *stream) { |
| 323 | stream->writeInt32(constructor); |
| 324 | } |
| 325 | |
| 326 | bool TL_help_getConfig::isNeedLayer() { |
| 327 | return true; |
| 328 | } |
| 329 | |
| 330 | bool TL_account_registerDevice::isNeedLayer() { |
| 331 | return true; |
| 332 | } |
| 333 | |
| 334 | TLObject *TL_account_registerDevice::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 335 | return Bool::TLdeserialize(stream, constructor, instanceNum, error); |
| 336 | } |
| 337 | |
| 338 | void TL_account_registerDevice::serializeToStream(NativeByteBuffer *stream) { |
| 339 | stream->writeInt32(constructor); |
| 340 | stream->writeInt32(token_type); |
| 341 | stream->writeString(token); |
| 342 | } |
| 343 | |
| 344 | TL_restrictionReason *TL_restrictionReason::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 345 | if (TL_restrictionReason::constructor != constructor) { |
| 346 | error = true; |
| 347 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_restrictionReason", constructor); |
| 348 | return nullptr; |
| 349 | } |
| 350 | TL_restrictionReason *result = new TL_restrictionReason(); |
| 351 | result->readParams(stream, instanceNum, error); |
| 352 | return result; |
| 353 | } |
| 354 | |
| 355 | void TL_restrictionReason::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 356 | platform = stream->readString(&error); |
| 357 | reason = stream->readString(&error); |
| 358 | text = stream->readString(&error); |
| 359 | } |
| 360 | |
| 361 | void TL_restrictionReason::serializeToStream(NativeByteBuffer *stream) { |
| 362 | stream->writeInt32(constructor); |
| 363 | stream->writeString(platform); |
| 364 | stream->writeString(reason); |
| 365 | stream->writeString(text); |
| 366 | } |
| 367 | |
| 368 | User *User::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 369 | User *result = nullptr; |
| 370 | switch (constructor) { |
| 371 | case 0xd3bc4b7a: |
| 372 | result = new TL_userEmpty(); |
| 373 | break; |
| 374 | case 0x3ff6ecb0: |
| 375 | result = new TL_user(); |
| 376 | break; |
| 377 | default: |
| 378 | error = true; |
| 379 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in User", constructor); |
| 380 | return nullptr; |
| 381 | } |
| 382 | result->readParams(stream, instanceNum, error); |
| 383 | return result; |
| 384 | } |
| 385 | |
| 386 | void TL_userEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 387 | id = stream->readInt64(&error); |
| 388 | } |
| 389 | |
| 390 | void TL_userEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 391 | stream->writeInt32(constructor); |
| 392 | stream->writeInt64(id); |
| 393 | } |
| 394 | |
| 395 | void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 396 | flags = stream->readInt32(&error); |
| 397 | id = stream->readInt64(&error); |
| 398 | if ((flags & 1) != 0) { |
| 399 | access_hash = stream->readInt64(&error); |
| 400 | } |
| 401 | if ((flags & 2) != 0) { |
| 402 | first_name = stream->readString(&error); |
| 403 | } |
| 404 | if ((flags & 4) != 0) { |
| 405 | last_name = stream->readString(&error); |
| 406 | } |
| 407 | if ((flags & 8) != 0) { |
| 408 | username = stream->readString(&error); |
| 409 | } |
| 410 | if ((flags & 16) != 0) { |
| 411 | phone = stream->readString(&error); |
| 412 | } |
| 413 | if ((flags & 32) != 0) { |
| 414 | photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 415 | } |
| 416 | if ((flags & 64) != 0) { |
| 417 | status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 418 | } |
| 419 | if ((flags & 16384) != 0) { |
| 420 | bot_info_version = stream->readInt32(&error); |
| 421 | } |
| 422 | if ((flags & 262144) != 0) { |
| 423 | uint32_t magic = stream->readUint32(&error); |
| 424 | if (magic != 0x1cb5c415) { |
| 425 | error = true; |
| 426 | if (LOGS_ENABLED) DEBUG_E("wrong Vector magic, got %x", magic); |
| 427 | return; |
| 428 | } |
| 429 | int32_t count = stream->readInt32(&error); |
| 430 | for (int32_t a = 0; a < count; a++) { |
| 431 | TL_restrictionReason *object = TL_restrictionReason::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 432 | if (object == nullptr) { |
| 433 | return; |
| 434 | } |
| 435 | restriction_reason.push_back(std::unique_ptr<TL_restrictionReason>(object)); |
| 436 | } |
| 437 | } |
| 438 | if ((flags & 524288) != 0) { |
| 439 | bot_inline_placeholder = stream->readString(&error); |
| 440 | } |
| 441 | if ((flags & 4194304) != 0) { |
| 442 | lang_code = stream->readString(&error); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | void TL_user::serializeToStream(NativeByteBuffer *stream) { |
| 447 | stream->writeInt32(constructor); |
| 448 | stream->writeInt32(flags); |
| 449 | stream->writeInt64(id); |
| 450 | if ((flags & 1) != 0) { |
| 451 | stream->writeInt64(access_hash); |
| 452 | } |
| 453 | if ((flags & 2) != 0) { |
| 454 | stream->writeString(first_name); |
| 455 | } |
| 456 | if ((flags & 4) != 0) { |
| 457 | stream->writeString(last_name); |
| 458 | } |
| 459 | if ((flags & 8) != 0) { |
| 460 | stream->writeString(username); |
| 461 | } |
| 462 | if ((flags & 16) != 0) { |
| 463 | stream->writeString(phone); |
| 464 | } |
| 465 | if ((flags & 32) != 0) { |
| 466 | photo->serializeToStream(stream); |
| 467 | } |
| 468 | if ((flags & 64) != 0) { |
| 469 | status->serializeToStream(stream); |
| 470 | } |
| 471 | if ((flags & 16384) != 0) { |
| 472 | stream->writeInt32(bot_info_version); |
| 473 | } |
| 474 | if ((flags & 262144) != 0) { |
| 475 | stream->writeInt32(0x1cb5c415); |
| 476 | uint32_t count = (uint32_t) restriction_reason.size(); |
| 477 | stream->writeInt32(count); |
| 478 | for (int a = 0; a < count; a++) { |
| 479 | restriction_reason[a]->serializeToStream(stream); |
| 480 | } |
| 481 | } |
| 482 | if ((flags & 524288) != 0) { |
| 483 | stream->writeString(bot_inline_placeholder); |
| 484 | } |
| 485 | if ((flags & 4194304) != 0) { |
| 486 | stream->writeString(lang_code); |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | InputPeer *InputPeer::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 491 | InputPeer *result = nullptr; |
| 492 | switch (constructor) { |
| 493 | case 0x7da07ec9: |
| 494 | result = new TL_inputPeerSelf(); |
| 495 | break; |
| 496 | case 0xdde8a54c: |
| 497 | result = new TL_inputPeerUser(); |
| 498 | break; |
| 499 | case 0x35a95cb9: |
| 500 | result = new TL_inputPeerChat(); |
| 501 | break; |
| 502 | case 0xa87b0a1c: |
| 503 | result = new TL_inputPeerUserFromMessage(); |
| 504 | break; |
| 505 | case 0xbd2a0840: |
| 506 | result = new TL_inputPeerChannelFromMessage(); |
| 507 | break; |
| 508 | case 0x27bcbbfc: |
| 509 | result = new TL_inputPeerChannel(); |
| 510 | break; |
| 511 | case 0x7f3b18ea: |
| 512 | result = new TL_inputPeerEmpty(); |
| 513 | break; |
| 514 | default: |
| 515 | error = true; |
| 516 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in InputPeer", constructor); |
| 517 | return nullptr; |
| 518 | } |
| 519 | result->readParams(stream, instanceNum, error); |
| 520 | return result; |
| 521 | } |
| 522 | |
| 523 | void TL_inputPeerSelf::serializeToStream(NativeByteBuffer *stream) { |
| 524 | stream->writeInt32(constructor); |
| 525 | } |
| 526 | |
| 527 | void TL_inputPeerUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 528 | user_id = stream->readInt64(&error); |
| 529 | access_hash = stream->readInt64(&error); |
| 530 | } |
| 531 | |
| 532 | void TL_inputPeerUser::serializeToStream(NativeByteBuffer *stream) { |
| 533 | stream->writeInt32(constructor); |
| 534 | stream->writeInt64(user_id); |
| 535 | stream->writeInt64(access_hash); |
| 536 | } |
| 537 | |
| 538 | void TL_inputPeerChat::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 539 | chat_id = stream->readInt64(&error); |
| 540 | } |
| 541 | |
| 542 | void TL_inputPeerChat::serializeToStream(NativeByteBuffer *stream) { |
| 543 | stream->writeInt32(constructor); |
| 544 | stream->writeInt64(chat_id); |
| 545 | } |
| 546 | |
| 547 | void TL_inputPeerUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 548 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 549 | msg_id = stream->readInt32(&error); |
| 550 | user_id = stream->readInt64(&error); |
| 551 | } |
| 552 | |
| 553 | void TL_inputPeerUserFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 554 | stream->writeInt32(constructor); |
| 555 | peer->serializeToStream(stream); |
| 556 | stream->writeInt32(msg_id); |
| 557 | stream->writeInt64(user_id); |
| 558 | } |
| 559 | |
| 560 | void TL_inputPeerChannelFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 561 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 562 | msg_id = stream->readInt32(&error); |
| 563 | channel_id = stream->readInt64(&error); |
| 564 | } |
| 565 | |
| 566 | void TL_inputPeerChannelFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 567 | stream->writeInt32(constructor); |
| 568 | peer->serializeToStream(stream); |
| 569 | stream->writeInt32(msg_id); |
| 570 | stream->writeInt64(channel_id); |
| 571 | } |
| 572 | |
| 573 | void TL_inputPeerChannel::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 574 | channel_id = stream->readInt64(&error); |
| 575 | access_hash = stream->readInt64(&error); |
| 576 | } |
| 577 | |
| 578 | void TL_inputPeerChannel::serializeToStream(NativeByteBuffer *stream) { |
| 579 | stream->writeInt32(constructor); |
| 580 | stream->writeInt64(channel_id); |
| 581 | stream->writeInt64(access_hash); |
| 582 | } |
| 583 | |
| 584 | void TL_inputPeerEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 585 | stream->writeInt32(constructor); |
| 586 | } |
| 587 | |
| 588 | InputUser *InputUser::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 589 | InputUser *result = nullptr; |
| 590 | switch (constructor) { |
| 591 | case 0xf7c1b13f: |
| 592 | result = new TL_inputUserSelf(); |
| 593 | break; |
| 594 | case 0xf21158c6: |
| 595 | result = new TL_inputUser(); |
| 596 | break; |
| 597 | case 0xb98886cf: |
| 598 | result = new TL_inputUserEmpty(); |
| 599 | break; |
| 600 | case 0x1da448e2: |
| 601 | result = new TL_inputUserFromMessage(); |
| 602 | break; |
| 603 | default: |
| 604 | error = true; |
| 605 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in InputUser", constructor); |
| 606 | return nullptr; |
| 607 | } |
| 608 | result->readParams(stream, instanceNum, error); |
| 609 | return result; |
| 610 | } |
| 611 | |
| 612 | void TL_inputUserSelf::serializeToStream(NativeByteBuffer *stream) { |
| 613 | stream->writeInt32(constructor); |
| 614 | } |
| 615 | |
| 616 | void TL_inputUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 617 | user_id = stream->readInt64(&error); |
| 618 | access_hash = stream->readInt64(&error); |
| 619 | } |
| 620 | |
| 621 | void TL_inputUser::serializeToStream(NativeByteBuffer *stream) { |
| 622 | stream->writeInt32(constructor); |
| 623 | stream->writeInt64(user_id); |
| 624 | stream->writeInt64(access_hash); |
| 625 | } |
| 626 | |
| 627 | void TL_inputUserEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 628 | stream->writeInt32(constructor); |
| 629 | } |
| 630 | |
| 631 | void TL_inputUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 632 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 633 | msg_id = stream->readInt32(&error); |
| 634 | user_id = stream->readInt64(&error); |
| 635 | } |
| 636 | |
| 637 | void TL_inputUserFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 638 | stream->writeInt32(constructor); |
| 639 | peer->serializeToStream(stream); |
| 640 | stream->writeInt32(msg_id); |
| 641 | stream->writeInt64(user_id); |
| 642 | } |
| 643 | |
| 644 | MessageEntity *MessageEntity::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 645 | MessageEntity *result = nullptr; |
| 646 | switch (constructor) { |
| 647 | case 0x76a6d327: |
| 648 | result = new TL_messageEntityTextUrl(); |
| 649 | break; |
| 650 | case 0x6cef8ac7: |
| 651 | result = new TL_messageEntityBotCommand(); |
| 652 | break; |
| 653 | case 0x64e475c2: |
| 654 | result = new TL_messageEntityEmail(); |
| 655 | break; |
| 656 | case 0x73924be0: |
| 657 | result = new TL_messageEntityPre(); |
| 658 | break; |
| 659 | case 0xbb92ba95: |
| 660 | result = new TL_messageEntityUnknown(); |
| 661 | break; |
| 662 | case 0x6ed02538: |
| 663 | result = new TL_messageEntityUrl(); |
| 664 | break; |
| 665 | case 0x826f8b60: |
| 666 | result = new TL_messageEntityItalic(); |
| 667 | break; |
| 668 | case 0xfa04579d: |
| 669 | result = new TL_messageEntityMention(); |
| 670 | break; |
| 671 | case 0xdc7b1140: |
| 672 | result = new TL_messageEntityMentionName(); |
| 673 | break; |
| 674 | case 0x208e68c9: |
| 675 | result = new TL_inputMessageEntityMentionName(); |
| 676 | break; |
| 677 | case 0x4c4e743f: |
| 678 | result = new TL_messageEntityCashtag(); |
| 679 | break; |
| 680 | case 0xbd610bc9: |
| 681 | result = new TL_messageEntityBold(); |
| 682 | break; |
| 683 | case 0x6f635b0d: |
| 684 | result = new TL_messageEntityHashtag(); |
| 685 | break; |
| 686 | case 0x28a20571: |
| 687 | result = new TL_messageEntityCode(); |
| 688 | break; |
| 689 | case 0xbf0693d4: |
| 690 | result = new TL_messageEntityStrike(); |
| 691 | break; |
| 692 | case 0x20df5d0: |
| 693 | result = new TL_messageEntityBlockquote(); |
| 694 | break; |
| 695 | case 0x9c4e7e8b: |
| 696 | result = new TL_messageEntityUnderline(); |
| 697 | break; |
| 698 | case 0x9b69e34b: |
| 699 | result = new TL_messageEntityPhone(); |
| 700 | break; |
| 701 | default: |
| 702 | error = true; |
| 703 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in MessageEntity", constructor); |
| 704 | return nullptr; |
| 705 | } |
| 706 | result->readParams(stream, instanceNum, error); |
| 707 | return result; |
| 708 | } |
| 709 | |
| 710 | void TL_messageEntityTextUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 711 | offset = stream->readInt32(&error); |
| 712 | length = stream->readInt32(&error); |
| 713 | url = stream->readString(&error); |
| 714 | } |
| 715 | |
| 716 | void TL_messageEntityTextUrl::serializeToStream(NativeByteBuffer *stream) { |
| 717 | stream->writeInt32(constructor); |
| 718 | stream->writeInt32(offset); |
| 719 | stream->writeInt32(length); |
| 720 | stream->writeString(url); |
| 721 | } |
| 722 | |
| 723 | void TL_messageEntityBotCommand::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 724 | offset = stream->readInt32(&error); |
| 725 | length = stream->readInt32(&error); |
| 726 | } |
| 727 | |
| 728 | void TL_messageEntityBotCommand::serializeToStream(NativeByteBuffer *stream) { |
| 729 | stream->writeInt32(constructor); |
| 730 | stream->writeInt32(offset); |
| 731 | stream->writeInt32(length); |
| 732 | } |
| 733 | |
| 734 | void TL_messageEntityEmail::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 735 | offset = stream->readInt32(&error); |
| 736 | length = stream->readInt32(&error); |
| 737 | } |
| 738 | |
| 739 | void TL_messageEntityEmail::serializeToStream(NativeByteBuffer *stream) { |
| 740 | stream->writeInt32(constructor); |
| 741 | stream->writeInt32(offset); |
| 742 | stream->writeInt32(length); |
| 743 | } |
| 744 | |
| 745 | void TL_messageEntityPre::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 746 | offset = stream->readInt32(&error); |
| 747 | length = stream->readInt32(&error); |
| 748 | language = stream->readString(&error); |
| 749 | } |
| 750 | |
| 751 | void TL_messageEntityPre::serializeToStream(NativeByteBuffer *stream) { |
| 752 | stream->writeInt32(constructor); |
| 753 | stream->writeInt32(offset); |
| 754 | stream->writeInt32(length); |
| 755 | stream->writeString(language); |
| 756 | } |
| 757 | |
| 758 | void TL_messageEntityUnknown::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 759 | offset = stream->readInt32(&error); |
| 760 | length = stream->readInt32(&error); |
| 761 | } |
| 762 | |
| 763 | void TL_messageEntityUnknown::serializeToStream(NativeByteBuffer *stream) { |
| 764 | stream->writeInt32(constructor); |
| 765 | stream->writeInt32(offset); |
| 766 | stream->writeInt32(length); |
| 767 | } |
| 768 | |
| 769 | void TL_messageEntityUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 770 | offset = stream->readInt32(&error); |
| 771 | length = stream->readInt32(&error); |
| 772 | } |
| 773 | |
| 774 | void TL_messageEntityUrl::serializeToStream(NativeByteBuffer *stream) { |
| 775 | stream->writeInt32(constructor); |
| 776 | stream->writeInt32(offset); |
| 777 | stream->writeInt32(length); |
| 778 | } |
| 779 | |
| 780 | void TL_messageEntityItalic::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 781 | offset = stream->readInt32(&error); |
| 782 | length = stream->readInt32(&error); |
| 783 | } |
| 784 | |
| 785 | void TL_messageEntityItalic::serializeToStream(NativeByteBuffer *stream) { |
| 786 | stream->writeInt32(constructor); |
| 787 | stream->writeInt32(offset); |
| 788 | stream->writeInt32(length); |
| 789 | } |
| 790 | |
| 791 | void TL_messageEntityMention::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 792 | offset = stream->readInt32(&error); |
| 793 | length = stream->readInt32(&error); |
| 794 | } |
| 795 | |
| 796 | void TL_messageEntityMention::serializeToStream(NativeByteBuffer *stream) { |
| 797 | stream->writeInt32(constructor); |
| 798 | stream->writeInt32(offset); |
| 799 | stream->writeInt32(length); |
| 800 | } |
| 801 | |
| 802 | void TL_messageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 803 | offset = stream->readInt32(&error); |
| 804 | length = stream->readInt32(&error); |
| 805 | user_id = stream->readInt64(&error); |
| 806 | } |
| 807 | |
| 808 | void TL_messageEntityMentionName::serializeToStream(NativeByteBuffer *stream) { |
| 809 | stream->writeInt32(constructor); |
| 810 | stream->writeInt32(offset); |
| 811 | stream->writeInt32(length); |
| 812 | stream->writeInt64(user_id); |
| 813 | } |
| 814 | |
| 815 | void TL_inputMessageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 816 | offset = stream->readInt32(&error); |
| 817 | length = stream->readInt32(&error); |
| 818 | user_id = std::unique_ptr<InputUser>(InputUser::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 819 | } |
| 820 | |
| 821 | void TL_inputMessageEntityMentionName::serializeToStream(NativeByteBuffer *stream) { |
| 822 | stream->writeInt32(constructor); |
| 823 | stream->writeInt32(offset); |
| 824 | stream->writeInt32(length); |
| 825 | user_id->serializeToStream(stream); |
| 826 | } |
| 827 | |
| 828 | void TL_messageEntityCashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 829 | offset = stream->readInt32(&error); |
| 830 | length = stream->readInt32(&error); |
| 831 | } |
| 832 | |
| 833 | void TL_messageEntityCashtag::serializeToStream(NativeByteBuffer *stream) { |
| 834 | stream->writeInt32(constructor); |
| 835 | stream->writeInt32(offset); |
| 836 | stream->writeInt32(length); |
| 837 | } |
| 838 | |
| 839 | void TL_messageEntityBold::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 840 | offset = stream->readInt32(&error); |
| 841 | length = stream->readInt32(&error); |
| 842 | } |
| 843 | |
| 844 | void TL_messageEntityBold::serializeToStream(NativeByteBuffer *stream) { |
| 845 | stream->writeInt32(constructor); |
| 846 | stream->writeInt32(offset); |
| 847 | stream->writeInt32(length); |
| 848 | } |
| 849 | |
| 850 | void TL_messageEntityHashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 851 | offset = stream->readInt32(&error); |
| 852 | length = stream->readInt32(&error); |
| 853 | } |
| 854 | |
| 855 | void TL_messageEntityHashtag::serializeToStream(NativeByteBuffer *stream) { |
| 856 | stream->writeInt32(constructor); |
| 857 | stream->writeInt32(offset); |
| 858 | stream->writeInt32(length); |
| 859 | } |
| 860 | |
| 861 | void TL_messageEntityCode::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 862 | offset = stream->readInt32(&error); |
| 863 | length = stream->readInt32(&error); |
| 864 | } |
| 865 | |
| 866 | void TL_messageEntityCode::serializeToStream(NativeByteBuffer *stream) { |
| 867 | stream->writeInt32(constructor); |
| 868 | stream->writeInt32(offset); |
| 869 | stream->writeInt32(length); |
| 870 | } |
| 871 | |
| 872 | void TL_messageEntityStrike::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 873 | offset = stream->readInt32(&error); |
| 874 | length = stream->readInt32(&error); |
| 875 | } |
| 876 | |
| 877 | void TL_messageEntityStrike::serializeToStream(NativeByteBuffer *stream) { |
| 878 | stream->writeInt32(constructor); |
| 879 | stream->writeInt32(offset); |
| 880 | stream->writeInt32(length); |
| 881 | } |
| 882 | |
| 883 | void TL_messageEntityBlockquote::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 884 | offset = stream->readInt32(&error); |
| 885 | length = stream->readInt32(&error); |
| 886 | } |
| 887 | |
| 888 | void TL_messageEntityBlockquote::serializeToStream(NativeByteBuffer *stream) { |
| 889 | stream->writeInt32(constructor); |
| 890 | stream->writeInt32(offset); |
| 891 | stream->writeInt32(length); |
| 892 | } |
| 893 | |
| 894 | void TL_messageEntityUnderline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 895 | offset = stream->readInt32(&error); |
| 896 | length = stream->readInt32(&error); |
| 897 | } |
| 898 | |
| 899 | void TL_messageEntityUnderline::serializeToStream(NativeByteBuffer *stream) { |
| 900 | stream->writeInt32(constructor); |
| 901 | stream->writeInt32(offset); |
| 902 | stream->writeInt32(length); |
| 903 | } |
| 904 | |
| 905 | void TL_messageEntityPhone::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 906 | offset = stream->readInt32(&error); |
| 907 | length = stream->readInt32(&error); |
| 908 | } |
| 909 | |
| 910 | void TL_messageEntityPhone::serializeToStream(NativeByteBuffer *stream) { |
| 911 | stream->writeInt32(constructor); |
| 912 | stream->writeInt32(offset); |
| 913 | stream->writeInt32(length); |
| 914 | } |
| 915 | |
| 916 | TL_dataJSON *TL_dataJSON::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 917 | if (TL_dataJSON::constructor != constructor) { |
| 918 | error = true; |
| 919 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_dataJSON", constructor); |
| 920 | return nullptr; |
| 921 | } |
| 922 | TL_dataJSON *result = new TL_dataJSON(); |
| 923 | result->readParams(stream, instanceNum, error); |
| 924 | return result; |
| 925 | } |
| 926 | |
| 927 | void TL_dataJSON::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 928 | data = stream->readString(&error); |
| 929 | } |
| 930 | |
| 931 | void TL_dataJSON::serializeToStream(NativeByteBuffer *stream) { |
| 932 | stream->writeInt32(constructor); |
| 933 | stream->writeString(data); |
| 934 | } |
| 935 | |
| 936 | TL_help_termsOfService *TL_help_termsOfService::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 937 | if (TL_help_termsOfService::constructor != constructor) { |
| 938 | error = true; |
| 939 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_help_termsOfService", constructor); |
| 940 | return nullptr; |
| 941 | } |
| 942 | TL_help_termsOfService *result = new TL_help_termsOfService(); |
| 943 | result->readParams(stream, instanceNum, error); |
| 944 | return result; |
| 945 | } |
| 946 | |
| 947 | void TL_help_termsOfService::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 948 | flags = stream->readInt32(&error); |
| 949 | popup = (flags & 1) != 0; |
| 950 | id = std::unique_ptr<TL_dataJSON>(TL_dataJSON::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 951 | text = stream->readString(&error); |
| 952 | int magic = stream->readInt32(&error); |
| 953 | if (magic != 0x1cb5c415) { |
| 954 | error = true; |
| 955 | if (LOGS_ENABLED) DEBUG_E("wrong Vector magic, got %x", magic); |
| 956 | return; |
| 957 | } |
| 958 | int count = stream->readInt32(&error); |
| 959 | for (int a = 0; a < count; a++) { |
| 960 | MessageEntity *object = MessageEntity::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 961 | if (object == nullptr) { |
| 962 | return; |
| 963 | } |
| 964 | entities.push_back(std::unique_ptr<MessageEntity>(object)); |
| 965 | } |
| 966 | if ((flags & 2) != 0) { |
| 967 | min_age_confirm = stream->readInt32(&error); |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | void TL_help_termsOfService::serializeToStream(NativeByteBuffer *stream) { |
| 972 | stream->writeInt32(constructor); |
| 973 | flags = popup ? (flags | 1) : (flags & ~1); |
| 974 | stream->writeInt32(flags); |
| 975 | id->serializeToStream(stream); |
| 976 | stream->writeString(text); |
| 977 | stream->writeInt32(0x1cb5c415); |
| 978 | int32_t count = (int32_t) entities.size(); |
| 979 | stream->writeInt32(count); |
| 980 | for (int a = 0; a < count; a++) { |
| 981 | entities[a]->serializeToStream(stream); |
| 982 | } |
| 983 | if ((flags & 2) != 0) { |
| 984 | stream->writeInt32(min_age_confirm); |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | auth_Authorization *auth_Authorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 989 | auth_Authorization *result = nullptr; |
| 990 | switch (constructor) { |
| 991 | case 0x44747e9a: |
| 992 | result = new TL_auth_authorizationSignUpRequired(); |
| 993 | break; |
| 994 | case 0x33fb7bb8: |
| 995 | result = new TL_auth_authorization(); |
| 996 | break; |
| 997 | default: |
| 998 | error = true; |
| 999 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in auth_Authorization", constructor); |
| 1000 | return nullptr; |
| 1001 | } |
| 1002 | result->readParams(stream, instanceNum, error); |
| 1003 | return result; |
| 1004 | } |
| 1005 | |
| 1006 | void TL_auth_authorizationSignUpRequired::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1007 | flags = stream->readInt32(&error); |
| 1008 | if ((flags & 1) != 0) { |
| 1009 | terms_of_service = std::unique_ptr<TL_help_termsOfService>(TL_help_termsOfService::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | void TL_auth_authorizationSignUpRequired::serializeToStream(NativeByteBuffer *stream) { |
| 1014 | stream->writeInt32(constructor); |
| 1015 | stream->writeInt32(flags); |
| 1016 | if ((flags & 1) != 0) { |
| 1017 | terms_of_service->serializeToStream(stream); |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | void TL_auth_authorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1022 | flags = stream->readInt32(&error); |
| 1023 | if ((flags & 1) != 0) { |
| 1024 | tmp_sessions = stream->readInt32(&error); |
| 1025 | } |
| 1026 | user = std::unique_ptr<User>(User::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1027 | } |
| 1028 | |
| 1029 | void TL_auth_authorization::serializeToStream(NativeByteBuffer *stream) { |
| 1030 | stream->writeInt32(constructor); |
| 1031 | stream->writeInt32(flags); |
| 1032 | if ((flags & 1) != 0) { |
| 1033 | stream->writeInt32(tmp_sessions); |
| 1034 | } |
| 1035 | user->serializeToStream(stream); |
| 1036 | } |
| 1037 | |
| 1038 | TL_auth_exportedAuthorization *TL_auth_exportedAuthorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1039 | if (TL_auth_exportedAuthorization::constructor != constructor) { |
| 1040 | error = true; |
| 1041 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_auth_exportedAuthorization", constructor); |
| 1042 | return nullptr; |
| 1043 | } |
| 1044 | TL_auth_exportedAuthorization *result = new TL_auth_exportedAuthorization(); |
| 1045 | result->readParams(stream, instanceNum, error); |
| 1046 | return result; |
| 1047 | } |
| 1048 | |
| 1049 | void TL_auth_exportedAuthorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1050 | id = stream->readInt64(&error); |
| 1051 | bytes = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1052 | } |
| 1053 | |
| 1054 | bool TL_auth_exportAuthorization::isNeedLayer() { |
| 1055 | return true; |
| 1056 | } |
| 1057 | |
| 1058 | TLObject *TL_auth_exportAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1059 | return TL_auth_exportedAuthorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 1060 | } |
| 1061 | |
| 1062 | void TL_auth_exportAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 1063 | stream->writeInt32(constructor); |
| 1064 | stream->writeInt32(dc_id); |
| 1065 | } |
| 1066 | |
| 1067 | bool TL_auth_importAuthorization::isNeedLayer() { |
| 1068 | return true; |
| 1069 | } |
| 1070 | |
| 1071 | TLObject *TL_auth_importAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1072 | return auth_Authorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 1073 | } |
| 1074 | |
| 1075 | void TL_auth_importAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 1076 | stream->writeInt32(constructor); |
| 1077 | stream->writeInt64(id); |
| 1078 | stream->writeByteArray(bytes.get()); |
| 1079 | } |
| 1080 | |
| 1081 | UserStatus *UserStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1082 | UserStatus *result = nullptr; |
| 1083 | switch (constructor) { |
| 1084 | case 0x8c703f: |
| 1085 | result = new TL_userStatusOffline(); |
| 1086 | break; |
| 1087 | case 0x7bf09fc: |
| 1088 | result = new TL_userStatusLastWeek(); |
| 1089 | break; |
| 1090 | case 0x9d05049: |
| 1091 | result = new TL_userStatusEmpty(); |
| 1092 | break; |
| 1093 | case 0x77ebc742: |
| 1094 | result = new TL_userStatusLastMonth(); |
| 1095 | break; |
| 1096 | case 0xedb93949: |
| 1097 | result = new TL_userStatusOnline(); |
| 1098 | break; |
| 1099 | case 0xe26f42f1: |
| 1100 | result = new TL_userStatusRecently(); |
| 1101 | break; |
| 1102 | default: |
| 1103 | error = true; |
| 1104 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in UserStatus", constructor); |
| 1105 | return nullptr; |
| 1106 | } |
| 1107 | result->readParams(stream, instanceNum, error); |
| 1108 | return result; |
| 1109 | } |
| 1110 | |
| 1111 | void TL_userStatusOffline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1112 | expires = stream->readInt32(&error); |
| 1113 | } |
| 1114 | |
| 1115 | void TL_userStatusOffline::serializeToStream(NativeByteBuffer *stream) { |
| 1116 | stream->writeInt32(constructor); |
| 1117 | stream->writeInt32(expires); |
| 1118 | } |
| 1119 | |
| 1120 | void TL_userStatusLastWeek::serializeToStream(NativeByteBuffer *stream) { |
| 1121 | stream->writeInt32(constructor); |
| 1122 | } |
| 1123 | |
| 1124 | void TL_userStatusEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1125 | stream->writeInt32(constructor); |
| 1126 | } |
| 1127 | |
| 1128 | void TL_userStatusLastMonth::serializeToStream(NativeByteBuffer *stream) { |
| 1129 | stream->writeInt32(constructor); |
| 1130 | } |
| 1131 | |
| 1132 | void TL_userStatusOnline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1133 | expires = stream->readInt32(&error); |
| 1134 | } |
| 1135 | |
| 1136 | void TL_userStatusOnline::serializeToStream(NativeByteBuffer *stream) { |
| 1137 | stream->writeInt32(constructor); |
| 1138 | stream->writeInt32(expires); |
| 1139 | } |
| 1140 | |
| 1141 | void TL_userStatusRecently::serializeToStream(NativeByteBuffer *stream) { |
| 1142 | stream->writeInt32(constructor); |
| 1143 | } |
| 1144 | |
| 1145 | FileLocation *FileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1146 | FileLocation *result = nullptr; |
| 1147 | switch (constructor) { |
| 1148 | case 0xbc7fc6cd: |
| 1149 | result = new TL_fileLocationToBeDeprecated(); |
| 1150 | break; |
| 1151 | default: |
| 1152 | error = true; |
| 1153 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in FileLocation", constructor); |
| 1154 | return nullptr; |
| 1155 | } |
| 1156 | result->readParams(stream, instanceNum, error); |
| 1157 | return result; |
| 1158 | } |
| 1159 | |
| 1160 | void TL_fileLocationToBeDeprecated::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1161 | volume_id = stream->readInt64(&error); |
| 1162 | local_id = stream->readInt32(&error); |
| 1163 | } |
| 1164 | |
| 1165 | void TL_fileLocationToBeDeprecated::serializeToStream(NativeByteBuffer *stream) { |
| 1166 | stream->writeInt32(constructor); |
| 1167 | stream->writeInt64(volume_id); |
| 1168 | stream->writeInt32(local_id); |
| 1169 | } |
| 1170 | |
| 1171 | UserProfilePhoto *UserProfilePhoto::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1172 | UserProfilePhoto *result = nullptr; |
| 1173 | switch (constructor) { |
| 1174 | case 0x4f11bae1: |
| 1175 | result = new TL_userProfilePhotoEmpty(); |
| 1176 | break; |
| 1177 | case 0x82d1f706: |
| 1178 | result = new TL_userProfilePhoto(); |
| 1179 | break; |
| 1180 | default: |
| 1181 | error = true; |
| 1182 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in UserProfilePhoto", constructor); |
| 1183 | return nullptr; |
| 1184 | } |
| 1185 | result->readParams(stream, instanceNum, error); |
| 1186 | return result; |
| 1187 | } |
| 1188 | |
| 1189 | void TL_userProfilePhotoEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1190 | stream->writeInt32(constructor); |
| 1191 | } |
| 1192 | |
| 1193 | void TL_userProfilePhoto::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1194 | flags = stream->readInt32(&error); |
| 1195 | has_video = (flags & 1) != 0; |
| 1196 | photo_id = stream->readInt64(&error); |
| 1197 | if ((flags & 2) != 0) { |
| 1198 | stripped_thumb = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1199 | } |
| 1200 | dc_id = stream->readInt32(&error); |
| 1201 | } |
| 1202 | |
| 1203 | void TL_userProfilePhoto::serializeToStream(NativeByteBuffer *stream) { |
| 1204 | stream->writeInt32(constructor); |
| 1205 | flags = has_video ? (flags | 1) : (flags &~ 1); |
| 1206 | stream->writeInt32(flags); |
| 1207 | stream->writeInt64(photo_id); |
| 1208 | if ((flags & 2) != 0) { |
| 1209 | stream->writeByteArray(stripped_thumb.get()); |
| 1210 | } |
| 1211 | stream->writeInt32(dc_id); |
| 1212 | } |
| 1213 | |
| 1214 | void TL_updatesTooLong::serializeToStream(NativeByteBuffer *stream) { |
| 1215 | stream->writeInt32(constructor); |
| 1216 | } |
| 1217 | |