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