| 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_FATAL("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_FATAL("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_FATAL("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_FATAL("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_FATAL("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_FATAL("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_FATAL("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 | if ((flags & 32768) != 0) { |
| 245 | reactions_default = std::unique_ptr<Reaction>(Reaction::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 246 | } |
| 247 | } |
| 248 |
| 249 | void TL_config::serializeToStream(NativeByteBuffer *stream) { |
| 250 | stream->writeInt32(constructor); |
| 251 | stream->writeInt32(flags); |
| 252 | stream->writeInt32(date); |
| 253 | stream->writeInt32(expires); |
| 254 | stream->writeBool(test_mode); |
| 255 | stream->writeInt32(this_dc); |
| 256 | stream->writeInt32(0x1cb5c415); |
| 257 | uint32_t count = (uint32_t) dc_options.size(); |
| 258 | stream->writeInt32(count); |
| 259 | for (uint32_t a = 0; a < count; a++) { |
| 260 | dc_options[a]->serializeToStream(stream); |
| 261 | } |
| 262 | stream->writeString(dc_txt_domain_name); |
| 263 | stream->writeInt32(chat_size_max); |
| 264 | stream->writeInt32(megagroup_size_max); |
| 265 | stream->writeInt32(forwarded_count_max); |
| 266 | stream->writeInt32(online_update_period_ms); |
| 267 | stream->writeInt32(offline_blur_timeout_ms); |
| 268 | stream->writeInt32(offline_idle_timeout_ms); |
| 269 | stream->writeInt32(online_cloud_timeout_ms); |
| 270 | stream->writeInt32(notify_cloud_delay_ms); |
| 271 | stream->writeInt32(notify_default_delay_ms); |
| 272 | stream->writeInt32(push_chat_period_ms); |
| 273 | stream->writeInt32(push_chat_limit); |
| 274 | stream->writeInt32(saved_gifs_limit); |
| 275 | stream->writeInt32(edit_time_limit); |
| 276 | stream->writeInt32(revoke_time_limit); |
| 277 | stream->writeInt32(revoke_pm_time_limit); |
| 278 | stream->writeInt32(rating_e_decay); |
| 279 | stream->writeInt32(stickers_recent_limit); |
| 280 | stream->writeInt32(stickers_faved_limit); |
| 281 | stream->writeInt32(channels_read_media_period); |
| 282 | if ((flags & 1) != 0) { |
| 283 | stream->writeInt32(tmp_sessions); |
| 284 | } |
| 285 | stream->writeInt32(pinned_dialogs_count_max); |
| 286 | stream->writeInt32(pinned_infolder_count_max); |
| 287 | stream->writeInt32(call_receive_timeout_ms); |
| 288 | stream->writeInt32(call_ring_timeout_ms); |
| 289 | stream->writeInt32(call_connect_timeout_ms); |
| 290 | stream->writeInt32(call_packet_timeout_ms); |
| 291 | stream->writeString(me_url_prefix); |
| 292 | if ((flags & 128) != 0) { |
| 293 | stream->writeString(autoupdate_url_prefix); |
| 294 | } |
| 295 | if ((flags & 512) != 0) { |
| 296 | stream->writeString(gif_search_username); |
| 297 | } |
| 298 | if ((flags & 1024) != 0) { |
| 299 | stream->writeString(venue_search_username); |
| 300 | } |
| 301 | if ((flags & 2048) != 0) { |
| 302 | stream->writeString(img_search_username); |
| 303 | } |
| 304 | if ((flags & 4096) != 0) { |
| 305 | stream->writeString(static_maps_provider); |
| 306 | } |
| 307 | stream->writeInt32(caption_length_max); |
| 308 | stream->writeInt32(message_length_max); |
| 309 | stream->writeInt32(webfile_dc_id); |
| 310 | if ((flags & 4) != 0) { |
| 311 | stream->writeString(suggested_lang_code); |
| 312 | } |
| 313 | if ((flags & 4) != 0) { |
| 314 | stream->writeInt32(lang_pack_version); |
| 315 | } |
| 316 | if ((flags & 4) != 0) { |
| 317 | stream->writeInt32(base_lang_pack_version); |
| 318 | } |
| 319 | if ((flags & 32768) != 0 && reactions_default != nullptr) { |
| 320 | reactions_default->serializeToStream(stream); |
| 321 | } |
| 322 | } |
| 323 |
| 324 | TLObject *TL_help_getConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 325 | return TL_config::TLdeserialize(stream, constructor, instanceNum, error); |
| 326 | } |
| 327 |
| 328 | void TL_help_getConfig::serializeToStream(NativeByteBuffer *stream) { |
| 329 | stream->writeInt32(constructor); |
| 330 | } |
| 331 |
| 332 | bool TL_help_getConfig::isNeedLayer() { |
| 333 | return true; |
| 334 | } |
| 335 |
| 336 | bool TL_account_registerDevice::isNeedLayer() { |
| 337 | return true; |
| 338 | } |
| 339 |
| 340 | TLObject *TL_account_registerDevice::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 341 | return Bool::TLdeserialize(stream, constructor, instanceNum, error); |
| 342 | } |
| 343 |
| 344 | void TL_account_registerDevice::serializeToStream(NativeByteBuffer *stream) { |
| 345 | stream->writeInt32(constructor); |
| 346 | stream->writeInt32(token_type); |
| 347 | stream->writeString(token); |
| 348 | } |
| 349 |
| 350 | TL_restrictionReason *TL_restrictionReason::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 351 | if (TL_restrictionReason::constructor != constructor) { |
| 352 | error = true; |
| 353 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_restrictionReason", constructor); |
| 354 | return nullptr; |
| 355 | } |
| 356 | TL_restrictionReason *result = new TL_restrictionReason(); |
| 357 | result->readParams(stream, instanceNum, error); |
| 358 | return result; |
| 359 | } |
| 360 |
| 361 | void TL_restrictionReason::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 362 | platform = stream->readString(&error); |
| 363 | reason = stream->readString(&error); |
| 364 | text = stream->readString(&error); |
| 365 | } |
| 366 |
| 367 | void TL_restrictionReason::serializeToStream(NativeByteBuffer *stream) { |
| 368 | stream->writeInt32(constructor); |
| 369 | stream->writeString(platform); |
| 370 | stream->writeString(reason); |
| 371 | stream->writeString(text); |
| 372 | } |
| 373 |
| 374 | User *User::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 375 | User *result = nullptr; |
| 376 | switch (constructor) { |
| 377 | case TL_userEmpty::constructor: |
| 378 | result = new TL_userEmpty(); |
| 379 | break; |
| 380 | case TL_user::constructor: |
| 381 | result = new TL_user(); |
| 382 | break; |
| 383 | default: |
| 384 | error = true; |
| 385 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in User", constructor); |
| 386 | return nullptr; |
| 387 | } |
| 388 | result->readParams(stream, instanceNum, error); |
| 389 | return result; |
| 390 | } |
| 391 |
| 392 | void TL_userEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 393 | id = stream->readInt64(&error); |
| 394 | } |
| 395 |
| 396 | void TL_userEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 397 | stream->writeInt32(constructor); |
| 398 | stream->writeInt64(id); |
| 399 | } |
| 400 |
| 401 | void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 402 | flags = stream->readInt32(&error); |
| 403 | id = stream->readInt64(&error); |
| 404 | if ((flags & 1) != 0) { |
| 405 | access_hash = stream->readInt64(&error); |
| 406 | } |
| 407 | if ((flags & 2) != 0) { |
| 408 | first_name = stream->readString(&error); |
| 409 | } |
| 410 | if ((flags & 4) != 0) { |
| 411 | last_name = stream->readString(&error); |
| 412 | } |
| 413 | if ((flags & 8) != 0) { |
| 414 | username = stream->readString(&error); |
| 415 | } |
| 416 | if ((flags & 16) != 0) { |
| 417 | phone = stream->readString(&error); |
| 418 | } |
| 419 | if ((flags & 32) != 0) { |
| 420 | photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 421 | } |
| 422 | if ((flags & 64) != 0) { |
| 423 | status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 424 | } |
| 425 | if ((flags & 16384) != 0) { |
| 426 | bot_info_version = stream->readInt32(&error); |
| 427 | } |
| 428 | if ((flags & 262144) != 0) { |
| 429 | uint32_t magic = stream->readUint32(&error); |
| 430 | if (magic != 0x1cb5c415) { |
| 431 | error = true; |
| 432 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic, got %x", magic); |
| 433 | return; |
| 434 | } |
| 435 | int32_t count = stream->readInt32(&error); |
| 436 | for (int32_t a = 0; a < count; a++) { |
| 437 | TL_restrictionReason *object = TL_restrictionReason::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 438 | if (object == nullptr) { |
| 439 | return; |
| 440 | } |
| 441 | restriction_reason.push_back(std::unique_ptr<TL_restrictionReason>(object)); |
| 442 | } |
| 443 | } |
| 444 | if ((flags & 524288) != 0) { |
| 445 | bot_inline_placeholder = stream->readString(&error); |
| 446 | } |
| 447 | if ((flags & 4194304) != 0) { |
| 448 | lang_code = stream->readString(&error); |
| 449 | } |
| 450 | } |
| 451 |
| 452 | void TL_user::serializeToStream(NativeByteBuffer *stream) { |
| 453 | stream->writeInt32(constructor); |
| 454 | stream->writeInt32(flags); |
| 455 | stream->writeInt64(id); |
| 456 | if ((flags & 1) != 0) { |
| 457 | stream->writeInt64(access_hash); |
| 458 | } |
| 459 | if ((flags & 2) != 0) { |
| 460 | stream->writeString(first_name); |
| 461 | } |
| 462 | if ((flags & 4) != 0) { |
| 463 | stream->writeString(last_name); |
| 464 | } |
| 465 | if ((flags & 8) != 0) { |
| 466 | stream->writeString(username); |
| 467 | } |
| 468 | if ((flags & 16) != 0) { |
| 469 | stream->writeString(phone); |
| 470 | } |
| 471 | if ((flags & 32) != 0) { |
| 472 | photo->serializeToStream(stream); |
| 473 | } |
| 474 | if ((flags & 64) != 0) { |
| 475 | status->serializeToStream(stream); |
| 476 | } |
| 477 | if ((flags & 16384) != 0) { |
| 478 | stream->writeInt32(bot_info_version); |
| 479 | } |
| 480 | if ((flags & 262144) != 0) { |
| 481 | stream->writeInt32(0x1cb5c415); |
| 482 | uint32_t count = (uint32_t) restriction_reason.size(); |
| 483 | stream->writeInt32(count); |
| 484 | for (int a = 0; a < count; a++) { |
| 485 | restriction_reason[a]->serializeToStream(stream); |
| 486 | } |
| 487 | } |
| 488 | if ((flags & 524288) != 0) { |
| 489 | stream->writeString(bot_inline_placeholder); |
| 490 | } |
| 491 | if ((flags & 4194304) != 0) { |
| 492 | stream->writeString(lang_code); |
| 493 | } |
| 494 | } |
| 495 |
| 496 | InputPeer *InputPeer::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 497 | InputPeer *result = nullptr; |
| 498 | switch (constructor) { |
| 499 | case 0x7da07ec9: |
| 500 | result = new TL_inputPeerSelf(); |
| 501 | break; |
| 502 | case 0xdde8a54c: |
| 503 | result = new TL_inputPeerUser(); |
| 504 | break; |
| 505 | case 0x35a95cb9: |
| 506 | result = new TL_inputPeerChat(); |
| 507 | break; |
| 508 | case 0xa87b0a1c: |
| 509 | result = new TL_inputPeerUserFromMessage(); |
| 510 | break; |
| 511 | case 0xbd2a0840: |
| 512 | result = new TL_inputPeerChannelFromMessage(); |
| 513 | break; |
| 514 | case 0x27bcbbfc: |
| 515 | result = new TL_inputPeerChannel(); |
| 516 | break; |
| 517 | case 0x7f3b18ea: |
| 518 | result = new TL_inputPeerEmpty(); |
| 519 | break; |
| 520 | default: |
| 521 | error = true; |
| 522 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in InputPeer", constructor); |
| 523 | return nullptr; |
| 524 | } |
| 525 | result->readParams(stream, instanceNum, error); |
| 526 | return result; |
| 527 | } |
| 528 |
| 529 | void TL_inputPeerSelf::serializeToStream(NativeByteBuffer *stream) { |
| 530 | stream->writeInt32(constructor); |
| 531 | } |
| 532 |
| 533 | void TL_inputPeerUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 534 | user_id = stream->readInt64(&error); |
| 535 | access_hash = stream->readInt64(&error); |
| 536 | } |
| 537 |
| 538 | void TL_inputPeerUser::serializeToStream(NativeByteBuffer *stream) { |
| 539 | stream->writeInt32(constructor); |
| 540 | stream->writeInt64(user_id); |
| 541 | stream->writeInt64(access_hash); |
| 542 | } |
| 543 |
| 544 | void TL_inputPeerChat::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 545 | chat_id = stream->readInt64(&error); |
| 546 | } |
| 547 |
| 548 | void TL_inputPeerChat::serializeToStream(NativeByteBuffer *stream) { |
| 549 | stream->writeInt32(constructor); |
| 550 | stream->writeInt64(chat_id); |
| 551 | } |
| 552 |
| 553 | void TL_inputPeerUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 554 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 555 | msg_id = stream->readInt32(&error); |
| 556 | user_id = stream->readInt64(&error); |
| 557 | } |
| 558 |
| 559 | void TL_inputPeerUserFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 560 | stream->writeInt32(constructor); |
| 561 | peer->serializeToStream(stream); |
| 562 | stream->writeInt32(msg_id); |
| 563 | stream->writeInt64(user_id); |
| 564 | } |
| 565 |
| 566 | void TL_inputPeerChannelFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 567 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 568 | msg_id = stream->readInt32(&error); |
| 569 | channel_id = stream->readInt64(&error); |
| 570 | } |
| 571 |
| 572 | void TL_inputPeerChannelFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 573 | stream->writeInt32(constructor); |
| 574 | peer->serializeToStream(stream); |
| 575 | stream->writeInt32(msg_id); |
| 576 | stream->writeInt64(channel_id); |
| 577 | } |
| 578 |
| 579 | void TL_inputPeerChannel::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 580 | channel_id = stream->readInt64(&error); |
| 581 | access_hash = stream->readInt64(&error); |
| 582 | } |
| 583 |
| 584 | void TL_inputPeerChannel::serializeToStream(NativeByteBuffer *stream) { |
| 585 | stream->writeInt32(constructor); |
| 586 | stream->writeInt64(channel_id); |
| 587 | stream->writeInt64(access_hash); |
| 588 | } |
| 589 |
| 590 | void TL_inputPeerEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 591 | stream->writeInt32(constructor); |
| 592 | } |
| 593 |
| 594 | InputUser *InputUser::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 595 | InputUser *result = nullptr; |
| 596 | switch (constructor) { |
| 597 | case 0xf7c1b13f: |
| 598 | result = new TL_inputUserSelf(); |
| 599 | break; |
| 600 | case 0xf21158c6: |
| 601 | result = new TL_inputUser(); |
| 602 | break; |
| 603 | case 0xb98886cf: |
| 604 | result = new TL_inputUserEmpty(); |
| 605 | break; |
| 606 | case 0x1da448e2: |
| 607 | result = new TL_inputUserFromMessage(); |
| 608 | break; |
| 609 | default: |
| 610 | error = true; |
| 611 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in InputUser", constructor); |
| 612 | return nullptr; |
| 613 | } |
| 614 | result->readParams(stream, instanceNum, error); |
| 615 | return result; |
| 616 | } |
| 617 |
| 618 | void TL_inputUserSelf::serializeToStream(NativeByteBuffer *stream) { |
| 619 | stream->writeInt32(constructor); |
| 620 | } |
| 621 |
| 622 | void TL_inputUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 623 | user_id = stream->readInt64(&error); |
| 624 | access_hash = stream->readInt64(&error); |
| 625 | } |
| 626 |
| 627 | void TL_inputUser::serializeToStream(NativeByteBuffer *stream) { |
| 628 | stream->writeInt32(constructor); |
| 629 | stream->writeInt64(user_id); |
| 630 | stream->writeInt64(access_hash); |
| 631 | } |
| 632 |
| 633 | void TL_inputUserEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 634 | stream->writeInt32(constructor); |
| 635 | } |
| 636 |
| 637 | void TL_inputUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 638 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 639 | msg_id = stream->readInt32(&error); |
| 640 | user_id = stream->readInt64(&error); |
| 641 | } |
| 642 |
| 643 | void TL_inputUserFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 644 | stream->writeInt32(constructor); |
| 645 | peer->serializeToStream(stream); |
| 646 | stream->writeInt32(msg_id); |
| 647 | stream->writeInt64(user_id); |
| 648 | } |
| 649 |
| 650 | MessageEntity *MessageEntity::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 651 | MessageEntity *result = nullptr; |
| 652 | switch (constructor) { |
| 653 | case 0x76a6d327: |
| 654 | result = new TL_messageEntityTextUrl(); |
| 655 | break; |
| 656 | case 0x6cef8ac7: |
| 657 | result = new TL_messageEntityBotCommand(); |
| 658 | break; |
| 659 | case 0x64e475c2: |
| 660 | result = new TL_messageEntityEmail(); |
| 661 | break; |
| 662 | case 0x73924be0: |
| 663 | result = new TL_messageEntityPre(); |
| 664 | break; |
| 665 | case 0xbb92ba95: |
| 666 | result = new TL_messageEntityUnknown(); |
| 667 | break; |
| 668 | case 0x6ed02538: |
| 669 | result = new TL_messageEntityUrl(); |
| 670 | break; |
| 671 | case 0x826f8b60: |
| 672 | result = new TL_messageEntityItalic(); |
| 673 | break; |
| 674 | case 0xfa04579d: |
| 675 | result = new TL_messageEntityMention(); |
| 676 | break; |
| 677 | case 0xdc7b1140: |
| 678 | result = new TL_messageEntityMentionName(); |
| 679 | break; |
| 680 | case 0x208e68c9: |
| 681 | result = new TL_inputMessageEntityMentionName(); |
| 682 | break; |
| 683 | case 0x4c4e743f: |
| 684 | result = new TL_messageEntityCashtag(); |
| 685 | break; |
| 686 | case 0xbd610bc9: |
| 687 | result = new TL_messageEntityBold(); |
| 688 | break; |
| 689 | case 0x6f635b0d: |
| 690 | result = new TL_messageEntityHashtag(); |
| 691 | break; |
| 692 | case 0x28a20571: |
| 693 | result = new TL_messageEntityCode(); |
| 694 | break; |
| 695 | case 0xbf0693d4: |
| 696 | result = new TL_messageEntityStrike(); |
| 697 | break; |
| 698 | case 0x20df5d0: |
| 699 | result = new TL_messageEntityBlockquote(); |
| 700 | break; |
| 701 | case 0x9c4e7e8b: |
| 702 | result = new TL_messageEntityUnderline(); |
| 703 | break; |
| 704 | case 0x9b69e34b: |
| 705 | result = new TL_messageEntityPhone(); |
| 706 | break; |
| 707 | default: |
| 708 | error = true; |
| 709 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in MessageEntity", constructor); |
| 710 | return nullptr; |
| 711 | } |
| 712 | result->readParams(stream, instanceNum, error); |
| 713 | return result; |
| 714 | } |
| 715 |
| 716 | void TL_messageEntityTextUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 717 | offset = stream->readInt32(&error); |
| 718 | length = stream->readInt32(&error); |
| 719 | url = stream->readString(&error); |
| 720 | } |
| 721 |
| 722 | void TL_messageEntityTextUrl::serializeToStream(NativeByteBuffer *stream) { |
| 723 | stream->writeInt32(constructor); |
| 724 | stream->writeInt32(offset); |
| 725 | stream->writeInt32(length); |
| 726 | stream->writeString(url); |
| 727 | } |
| 728 |
| 729 | void TL_messageEntityBotCommand::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 730 | offset = stream->readInt32(&error); |
| 731 | length = stream->readInt32(&error); |
| 732 | } |
| 733 |
| 734 | void TL_messageEntityBotCommand::serializeToStream(NativeByteBuffer *stream) { |
| 735 | stream->writeInt32(constructor); |
| 736 | stream->writeInt32(offset); |
| 737 | stream->writeInt32(length); |
| 738 | } |
| 739 |
| 740 | void TL_messageEntityEmail::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 741 | offset = stream->readInt32(&error); |
| 742 | length = stream->readInt32(&error); |
| 743 | } |
| 744 |
| 745 | void TL_messageEntityEmail::serializeToStream(NativeByteBuffer *stream) { |
| 746 | stream->writeInt32(constructor); |
| 747 | stream->writeInt32(offset); |
| 748 | stream->writeInt32(length); |
| 749 | } |
| 750 |
| 751 | void TL_messageEntityPre::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 752 | offset = stream->readInt32(&error); |
| 753 | length = stream->readInt32(&error); |
| 754 | language = stream->readString(&error); |
| 755 | } |
| 756 |
| 757 | void TL_messageEntityPre::serializeToStream(NativeByteBuffer *stream) { |
| 758 | stream->writeInt32(constructor); |
| 759 | stream->writeInt32(offset); |
| 760 | stream->writeInt32(length); |
| 761 | stream->writeString(language); |
| 762 | } |
| 763 |
| 764 | void TL_messageEntityUnknown::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 765 | offset = stream->readInt32(&error); |
| 766 | length = stream->readInt32(&error); |
| 767 | } |
| 768 |
| 769 | void TL_messageEntityUnknown::serializeToStream(NativeByteBuffer *stream) { |
| 770 | stream->writeInt32(constructor); |
| 771 | stream->writeInt32(offset); |
| 772 | stream->writeInt32(length); |
| 773 | } |
| 774 |
| 775 | void TL_messageEntityUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 776 | offset = stream->readInt32(&error); |
| 777 | length = stream->readInt32(&error); |
| 778 | } |
| 779 |
| 780 | void TL_messageEntityUrl::serializeToStream(NativeByteBuffer *stream) { |
| 781 | stream->writeInt32(constructor); |
| 782 | stream->writeInt32(offset); |
| 783 | stream->writeInt32(length); |
| 784 | } |
| 785 |
| 786 | void TL_messageEntityItalic::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 787 | offset = stream->readInt32(&error); |
| 788 | length = stream->readInt32(&error); |
| 789 | } |
| 790 |
| 791 | void TL_messageEntityItalic::serializeToStream(NativeByteBuffer *stream) { |
| 792 | stream->writeInt32(constructor); |
| 793 | stream->writeInt32(offset); |
| 794 | stream->writeInt32(length); |
| 795 | } |
| 796 |
| 797 | void TL_messageEntityMention::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 798 | offset = stream->readInt32(&error); |
| 799 | length = stream->readInt32(&error); |
| 800 | } |
| 801 |
| 802 | void TL_messageEntityMention::serializeToStream(NativeByteBuffer *stream) { |
| 803 | stream->writeInt32(constructor); |
| 804 | stream->writeInt32(offset); |
| 805 | stream->writeInt32(length); |
| 806 | } |
| 807 |
| 808 | void TL_messageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 809 | offset = stream->readInt32(&error); |
| 810 | length = stream->readInt32(&error); |
| 811 | user_id = stream->readInt64(&error); |
| 812 | } |
| 813 |
| 814 | void TL_messageEntityMentionName::serializeToStream(NativeByteBuffer *stream) { |
| 815 | stream->writeInt32(constructor); |
| 816 | stream->writeInt32(offset); |
| 817 | stream->writeInt32(length); |
| 818 | stream->writeInt64(user_id); |
| 819 | } |
| 820 |
| 821 | void TL_inputMessageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 822 | offset = stream->readInt32(&error); |
| 823 | length = stream->readInt32(&error); |
| 824 | user_id = std::unique_ptr<InputUser>(InputUser::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 825 | } |
| 826 |
| 827 | void TL_inputMessageEntityMentionName::serializeToStream(NativeByteBuffer *stream) { |
| 828 | stream->writeInt32(constructor); |
| 829 | stream->writeInt32(offset); |
| 830 | stream->writeInt32(length); |
| 831 | user_id->serializeToStream(stream); |
| 832 | } |
| 833 |
| 834 | void TL_messageEntityCashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 835 | offset = stream->readInt32(&error); |
| 836 | length = stream->readInt32(&error); |
| 837 | } |
| 838 |
| 839 | void TL_messageEntityCashtag::serializeToStream(NativeByteBuffer *stream) { |
| 840 | stream->writeInt32(constructor); |
| 841 | stream->writeInt32(offset); |
| 842 | stream->writeInt32(length); |
| 843 | } |
| 844 |
| 845 | void TL_messageEntityBold::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 846 | offset = stream->readInt32(&error); |
| 847 | length = stream->readInt32(&error); |
| 848 | } |
| 849 |
| 850 | void TL_messageEntityBold::serializeToStream(NativeByteBuffer *stream) { |
| 851 | stream->writeInt32(constructor); |
| 852 | stream->writeInt32(offset); |
| 853 | stream->writeInt32(length); |
| 854 | } |
| 855 |
| 856 | void TL_messageEntityHashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 857 | offset = stream->readInt32(&error); |
| 858 | length = stream->readInt32(&error); |
| 859 | } |
| 860 |
| 861 | void TL_messageEntityHashtag::serializeToStream(NativeByteBuffer *stream) { |
| 862 | stream->writeInt32(constructor); |
| 863 | stream->writeInt32(offset); |
| 864 | stream->writeInt32(length); |
| 865 | } |
| 866 |
| 867 | void TL_messageEntityCode::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 868 | offset = stream->readInt32(&error); |
| 869 | length = stream->readInt32(&error); |
| 870 | } |
| 871 |
| 872 | void TL_messageEntityCode::serializeToStream(NativeByteBuffer *stream) { |
| 873 | stream->writeInt32(constructor); |
| 874 | stream->writeInt32(offset); |
| 875 | stream->writeInt32(length); |
| 876 | } |
| 877 |
| 878 | void TL_messageEntityStrike::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 879 | offset = stream->readInt32(&error); |
| 880 | length = stream->readInt32(&error); |
| 881 | } |
| 882 |
| 883 | void TL_messageEntityStrike::serializeToStream(NativeByteBuffer *stream) { |
| 884 | stream->writeInt32(constructor); |
| 885 | stream->writeInt32(offset); |
| 886 | stream->writeInt32(length); |
| 887 | } |
| 888 |
| 889 | void TL_messageEntityBlockquote::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 890 | offset = stream->readInt32(&error); |
| 891 | length = stream->readInt32(&error); |
| 892 | } |
| 893 |
| 894 | void TL_messageEntityBlockquote::serializeToStream(NativeByteBuffer *stream) { |
| 895 | stream->writeInt32(constructor); |
| 896 | stream->writeInt32(offset); |
| 897 | stream->writeInt32(length); |
| 898 | } |
| 899 |
| 900 | void TL_messageEntityUnderline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 901 | offset = stream->readInt32(&error); |
| 902 | length = stream->readInt32(&error); |
| 903 | } |
| 904 |
| 905 | void TL_messageEntityUnderline::serializeToStream(NativeByteBuffer *stream) { |
| 906 | stream->writeInt32(constructor); |
| 907 | stream->writeInt32(offset); |
| 908 | stream->writeInt32(length); |
| 909 | } |
| 910 |
| 911 | void TL_messageEntityPhone::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 912 | offset = stream->readInt32(&error); |
| 913 | length = stream->readInt32(&error); |
| 914 | } |
| 915 |
| 916 | void TL_messageEntityPhone::serializeToStream(NativeByteBuffer *stream) { |
| 917 | stream->writeInt32(constructor); |
| 918 | stream->writeInt32(offset); |
| 919 | stream->writeInt32(length); |
| 920 | } |
| 921 |
| 922 | TL_dataJSON *TL_dataJSON::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 923 | if (TL_dataJSON::constructor != constructor) { |
| 924 | error = true; |
| 925 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_dataJSON", constructor); |
| 926 | return nullptr; |
| 927 | } |
| 928 | TL_dataJSON *result = new TL_dataJSON(); |
| 929 | result->readParams(stream, instanceNum, error); |
| 930 | return result; |
| 931 | } |
| 932 |
| 933 | void TL_dataJSON::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 934 | data = stream->readString(&error); |
| 935 | } |
| 936 |
| 937 | void TL_dataJSON::serializeToStream(NativeByteBuffer *stream) { |
| 938 | stream->writeInt32(constructor); |
| 939 | stream->writeString(data); |
| 940 | } |
| 941 |
| 942 | TL_help_termsOfService *TL_help_termsOfService::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 943 | if (TL_help_termsOfService::constructor != constructor) { |
| 944 | error = true; |
| 945 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_help_termsOfService", constructor); |
| 946 | return nullptr; |
| 947 | } |
| 948 | TL_help_termsOfService *result = new TL_help_termsOfService(); |
| 949 | result->readParams(stream, instanceNum, error); |
| 950 | return result; |
| 951 | } |
| 952 |
| 953 | void TL_help_termsOfService::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 954 | flags = stream->readInt32(&error); |
| 955 | popup = (flags & 1) != 0; |
| 956 | id = std::unique_ptr<TL_dataJSON>(TL_dataJSON::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 957 | text = stream->readString(&error); |
| 958 | int magic = stream->readInt32(&error); |
| 959 | if (magic != 0x1cb5c415) { |
| 960 | error = true; |
| 961 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic, got %x", magic); |
| 962 | return; |
| 963 | } |
| 964 | int count = stream->readInt32(&error); |
| 965 | for (int a = 0; a < count; a++) { |
| 966 | MessageEntity *object = MessageEntity::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 967 | if (object == nullptr) { |
| 968 | return; |
| 969 | } |
| 970 | entities.push_back(std::unique_ptr<MessageEntity>(object)); |
| 971 | } |
| 972 | if ((flags & 2) != 0) { |
| 973 | min_age_confirm = stream->readInt32(&error); |
| 974 | } |
| 975 | } |
| 976 |
| 977 | void TL_help_termsOfService::serializeToStream(NativeByteBuffer *stream) { |
| 978 | stream->writeInt32(constructor); |
| 979 | flags = popup ? (flags | 1) : (flags & ~1); |
| 980 | stream->writeInt32(flags); |
| 981 | id->serializeToStream(stream); |
| 982 | stream->writeString(text); |
| 983 | stream->writeInt32(0x1cb5c415); |
| 984 | int32_t count = (int32_t) entities.size(); |
| 985 | stream->writeInt32(count); |
| 986 | for (int a = 0; a < count; a++) { |
| 987 | entities[a]->serializeToStream(stream); |
| 988 | } |
| 989 | if ((flags & 2) != 0) { |
| 990 | stream->writeInt32(min_age_confirm); |
| 991 | } |
| 992 | } |
| 993 |
| 994 | auth_Authorization *auth_Authorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 995 | auth_Authorization *result = nullptr; |
| 996 | switch (constructor) { |
| 997 | case 0x44747e9a: |
| 998 | result = new TL_auth_authorizationSignUpRequired(); |
| 999 | break; |
| 1000 | case 0x33fb7bb8: |
| 1001 | result = new TL_auth_authorization(); |
| 1002 | break; |
| 1003 | default: |
| 1004 | error = true; |
| 1005 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in auth_Authorization", constructor); |
| 1006 | return nullptr; |
| 1007 | } |
| 1008 | result->readParams(stream, instanceNum, error); |
| 1009 | return result; |
| 1010 | } |
| 1011 |
| 1012 | void TL_auth_authorizationSignUpRequired::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1013 | flags = stream->readInt32(&error); |
| 1014 | if ((flags & 1) != 0) { |
| 1015 | terms_of_service = std::unique_ptr<TL_help_termsOfService>(TL_help_termsOfService::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1016 | } |
| 1017 | } |
| 1018 |
| 1019 | void TL_auth_authorizationSignUpRequired::serializeToStream(NativeByteBuffer *stream) { |
| 1020 | stream->writeInt32(constructor); |
| 1021 | stream->writeInt32(flags); |
| 1022 | if ((flags & 1) != 0) { |
| 1023 | terms_of_service->serializeToStream(stream); |
| 1024 | } |
| 1025 | } |
| 1026 |
| 1027 | void TL_auth_authorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1028 | flags = stream->readInt32(&error); |
| 1029 | if ((flags & 1) != 0) { |
| 1030 | tmp_sessions = stream->readInt32(&error); |
| 1031 | } |
| 1032 | user = std::unique_ptr<User>(User::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1033 | } |
| 1034 |
| 1035 | void TL_auth_authorization::serializeToStream(NativeByteBuffer *stream) { |
| 1036 | stream->writeInt32(constructor); |
| 1037 | stream->writeInt32(flags); |
| 1038 | if ((flags & 1) != 0) { |
| 1039 | stream->writeInt32(tmp_sessions); |
| 1040 | } |
| 1041 | user->serializeToStream(stream); |
| 1042 | } |
| 1043 |
| 1044 | TL_auth_exportedAuthorization *TL_auth_exportedAuthorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1045 | if (TL_auth_exportedAuthorization::constructor != constructor) { |
| 1046 | error = true; |
| 1047 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_auth_exportedAuthorization", constructor); |
| 1048 | return nullptr; |
| 1049 | } |
| 1050 | TL_auth_exportedAuthorization *result = new TL_auth_exportedAuthorization(); |
| 1051 | result->readParams(stream, instanceNum, error); |
| 1052 | return result; |
| 1053 | } |
| 1054 |
| 1055 | void TL_auth_exportedAuthorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1056 | id = stream->readInt64(&error); |
| 1057 | bytes = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1058 | } |
| 1059 |
| 1060 | bool TL_auth_exportAuthorization::isNeedLayer() { |
| 1061 | return true; |
| 1062 | } |
| 1063 |
| 1064 | TLObject *TL_auth_exportAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1065 | return TL_auth_exportedAuthorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 1066 | } |
| 1067 |
| 1068 | void TL_auth_exportAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 1069 | stream->writeInt32(constructor); |
| 1070 | stream->writeInt32(dc_id); |
| 1071 | } |
| 1072 |
| 1073 | bool TL_auth_importAuthorization::isNeedLayer() { |
| 1074 | return true; |
| 1075 | } |
| 1076 |
| 1077 | TLObject *TL_auth_importAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1078 | return auth_Authorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 1079 | } |
| 1080 |
| 1081 | void TL_auth_importAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 1082 | stream->writeInt32(constructor); |
| 1083 | stream->writeInt64(id); |
| 1084 | stream->writeByteArray(bytes.get()); |
| 1085 | } |
| 1086 |
| 1087 | UserStatus *UserStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1088 | UserStatus *result = nullptr; |
| 1089 | switch (constructor) { |
| 1090 | case 0x8c703f: |
| 1091 | result = new TL_userStatusOffline(); |
| 1092 | break; |
| 1093 | case 0x7bf09fc: |
| 1094 | result = new TL_userStatusLastWeek(); |
| 1095 | break; |
| 1096 | case 0x9d05049: |
| 1097 | result = new TL_userStatusEmpty(); |
| 1098 | break; |
| 1099 | case 0x77ebc742: |
| 1100 | result = new TL_userStatusLastMonth(); |
| 1101 | break; |
| 1102 | case 0xedb93949: |
| 1103 | result = new TL_userStatusOnline(); |
| 1104 | break; |
| 1105 | case 0xe26f42f1: |
| 1106 | result = new TL_userStatusRecently(); |
| 1107 | break; |
| 1108 | default: |
| 1109 | error = true; |
| 1110 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in UserStatus", constructor); |
| 1111 | return nullptr; |
| 1112 | } |
| 1113 | result->readParams(stream, instanceNum, error); |
| 1114 | return result; |
| 1115 | } |
| 1116 |
| 1117 | void TL_userStatusOffline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1118 | expires = stream->readInt32(&error); |
| 1119 | } |
| 1120 |
| 1121 | void TL_userStatusOffline::serializeToStream(NativeByteBuffer *stream) { |
| 1122 | stream->writeInt32(constructor); |
| 1123 | stream->writeInt32(expires); |
| 1124 | } |
| 1125 |
| 1126 | void TL_userStatusLastWeek::serializeToStream(NativeByteBuffer *stream) { |
| 1127 | stream->writeInt32(constructor); |
| 1128 | } |
| 1129 |
| 1130 | void TL_userStatusEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1131 | stream->writeInt32(constructor); |
| 1132 | } |
| 1133 |
| 1134 | void TL_userStatusLastMonth::serializeToStream(NativeByteBuffer *stream) { |
| 1135 | stream->writeInt32(constructor); |
| 1136 | } |
| 1137 |
| 1138 | void TL_userStatusOnline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1139 | expires = stream->readInt32(&error); |
| 1140 | } |
| 1141 |
| 1142 | void TL_userStatusOnline::serializeToStream(NativeByteBuffer *stream) { |
| 1143 | stream->writeInt32(constructor); |
| 1144 | stream->writeInt32(expires); |
| 1145 | } |
| 1146 |
| 1147 | void TL_userStatusRecently::serializeToStream(NativeByteBuffer *stream) { |
| 1148 | stream->writeInt32(constructor); |
| 1149 | } |
| 1150 |
| 1151 | FileLocation *FileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1152 | FileLocation *result = nullptr; |
| 1153 | switch (constructor) { |
| 1154 | case 0xbc7fc6cd: |
| 1155 | result = new TL_fileLocationToBeDeprecated(); |
| 1156 | break; |
| 1157 | default: |
| 1158 | error = true; |
| 1159 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in FileLocation", constructor); |
| 1160 | return nullptr; |
| 1161 | } |
| 1162 | result->readParams(stream, instanceNum, error); |
| 1163 | return result; |
| 1164 | } |
| 1165 |
| 1166 | void TL_fileLocationToBeDeprecated::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1167 | volume_id = stream->readInt64(&error); |
| 1168 | local_id = stream->readInt32(&error); |
| 1169 | } |
| 1170 |
| 1171 | void TL_fileLocationToBeDeprecated::serializeToStream(NativeByteBuffer *stream) { |
| 1172 | stream->writeInt32(constructor); |
| 1173 | stream->writeInt64(volume_id); |
| 1174 | stream->writeInt32(local_id); |
| 1175 | } |
| 1176 |
| 1177 | UserProfilePhoto *UserProfilePhoto::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1178 | UserProfilePhoto *result = nullptr; |
| 1179 | switch (constructor) { |
| 1180 | case 0x4f11bae1: |
| 1181 | result = new TL_userProfilePhotoEmpty(); |
| 1182 | break; |
| 1183 | case 0x82d1f706: |
| 1184 | result = new TL_userProfilePhoto(); |
| 1185 | break; |
| 1186 | default: |
| 1187 | error = true; |
| 1188 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in UserProfilePhoto", constructor); |
| 1189 | return nullptr; |
| 1190 | } |
| 1191 | result->readParams(stream, instanceNum, error); |
| 1192 | return result; |
| 1193 | } |
| 1194 |
| 1195 | void TL_userProfilePhotoEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1196 | stream->writeInt32(constructor); |
| 1197 | } |
| 1198 |
| 1199 | void TL_userProfilePhoto::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1200 | flags = stream->readInt32(&error); |
| 1201 | has_video = (flags & 1) != 0; |
| 1202 | photo_id = stream->readInt64(&error); |
| 1203 | if ((flags & 2) != 0) { |
| 1204 | stripped_thumb = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1205 | } |
| 1206 | dc_id = stream->readInt32(&error); |
| 1207 | } |
| 1208 |
| 1209 | void TL_userProfilePhoto::serializeToStream(NativeByteBuffer *stream) { |
| 1210 | stream->writeInt32(constructor); |
| 1211 | flags = has_video ? (flags | 1) : (flags &~ 1); |
| 1212 | stream->writeInt32(flags); |
| 1213 | stream->writeInt64(photo_id); |
| 1214 | if ((flags & 2) != 0) { |
| 1215 | stream->writeByteArray(stripped_thumb.get()); |
| 1216 | } |
| 1217 | stream->writeInt32(dc_id); |
| 1218 | } |
| 1219 |
| 1220 | void TL_updatesTooLong::serializeToStream(NativeByteBuffer *stream) { |
| 1221 | stream->writeInt32(constructor); |
| 1222 | } |
| 1223 |
| 1224 | Reaction *Reaction::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1225 | Reaction *result = nullptr; |
| 1226 | switch (constructor) { |
| 1227 | case 0x79f5d419: |
| 1228 | result = new TL_reactionEmpty(); |
| 1229 | break; |
| 1230 | case 0x8935fc73: |
| 1231 | result = new TL_reactionCustomEmoji(); |
| 1232 | break; |
| 1233 | case 0x1b2286b8: |
| 1234 | result = new TL_reactionEmoji(); |
| 1235 | break; |
| 1236 | default: |
| 1237 | error = true; |
| 1238 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in Reaction", constructor); |
| 1239 | return nullptr; |
| 1240 | } |
| 1241 | result->readParams(stream, instanceNum, error); |
| 1242 | return result; |
| 1243 | } |
| 1244 |
| 1245 | void TL_reactionEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1246 |
| 1247 | } |
| 1248 |
| 1249 | void TL_reactionEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1250 | stream->writeInt32(constructor); |
| 1251 | } |
| 1252 |
| 1253 | void TL_reactionCustomEmoji::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1254 | document_id = stream->readInt64(&error); |
| 1255 | } |
| 1256 |
| 1257 | void TL_reactionCustomEmoji::serializeToStream(NativeByteBuffer *stream) { |
| 1258 | stream->writeInt32(constructor); |
| 1259 | stream->writeInt64(document_id); |
| 1260 | } |
| 1261 |
| 1262 | void TL_reactionEmoji::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1263 | emoticon = stream->readString(&error); |
| 1264 | } |
| 1265 |
| 1266 | void TL_reactionEmoji::serializeToStream(NativeByteBuffer *stream) { |
| 1267 | stream->writeInt32(constructor); |
| 1268 | stream->writeString(emoticon); |
| 1269 | } |
| 1270 |
| 1271 |
| 1272 |