| 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 | force_try_ipv6 = (flags & 16384) != 0; |
| 60 | id = stream->readInt32(&error); |
| 61 | ip_address = stream->readString(&error); |
| 62 | port = stream->readInt32(&error); |
| 63 | if ((flags & 1024) != 0) { |
| 64 | secret = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 65 | } |
| 66 | } |
| 67 |
| 68 | void TL_dcOption::serializeToStream(NativeByteBuffer *stream) { |
| 69 | stream->writeInt32(constructor); |
| 70 | flags = ipv6 ? (flags | 1) : (flags &~ 1); |
| 71 | flags = media_only ? (flags | 2) : (flags &~ 2); |
| 72 | flags = tcpo_only ? (flags | 4) : (flags &~ 4); |
| 73 | flags = cdn ? (flags | 8) : (flags &~ 8); |
| 74 | flags = isStatic ? (flags | 16) : (flags &~ 16); |
| 75 | flags = thisPortOnly ? (flags | 32) : (flags &~ 32); |
| 76 | flags = force_try_ipv6 ? (flags | 16384) : (flags &~ 16384); |
| 77 | stream->writeInt32(flags); |
| 78 | stream->writeInt32(id); |
| 79 | stream->writeString(ip_address); |
| 80 | stream->writeInt32(port); |
| 81 | if ((flags & 1024) != 0) { |
| 82 | stream->writeByteArray(secret.get()); |
| 83 | } |
| 84 | } |
| 85 |
| 86 | TL_cdnPublicKey *TL_cdnPublicKey::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 87 | if (TL_cdnPublicKey::constructor != constructor) { |
| 88 | error = true; |
| 89 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_cdnPublicKey", constructor); |
| 90 | return nullptr; |
| 91 | } |
| 92 | TL_cdnPublicKey *result = new TL_cdnPublicKey(); |
| 93 | result->readParams(stream, instanceNum, error); |
| 94 | return result; |
| 95 | } |
| 96 |
| 97 | void TL_cdnPublicKey::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 98 | dc_id = stream->readInt32(&error); |
| 99 | public_key = stream->readString(&error); |
| 100 | } |
| 101 |
| 102 | void TL_cdnPublicKey::serializeToStream(NativeByteBuffer *stream) { |
| 103 | stream->writeInt32(constructor); |
| 104 | stream->writeInt32(dc_id); |
| 105 | stream->writeString(public_key); |
| 106 | } |
| 107 |
| 108 | TL_cdnConfig *TL_cdnConfig::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 109 | if (TL_cdnConfig::constructor != constructor) { |
| 110 | error = true; |
| 111 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_cdnConfig", constructor); |
| 112 | return nullptr; |
| 113 | } |
| 114 | TL_cdnConfig *result = new TL_cdnConfig(); |
| 115 | result->readParams(stream, instanceNum, error); |
| 116 | return result; |
| 117 | } |
| 118 |
| 119 | void TL_cdnConfig::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 120 | int magic = stream->readInt32(&error); |
| 121 | if (magic != 0x1cb5c415) { |
| 122 | error = true; |
| 123 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_cdnConfig, got %x", magic); |
| 124 | return; |
| 125 | } |
| 126 | int count = stream->readInt32(&error); |
| 127 | for (int32_t a = 0; a < count; a++) { |
| 128 | TL_cdnPublicKey *object = TL_cdnPublicKey::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 129 | if (object == nullptr) { |
| 130 | return; |
| 131 | } |
| 132 | public_keys.push_back(std::unique_ptr<TL_cdnPublicKey>(object)); |
| 133 | } |
| 134 | } |
| 135 |
| 136 | void TL_cdnConfig::serializeToStream(NativeByteBuffer *stream) { |
| 137 | stream->writeInt32(constructor); |
| 138 | stream->writeInt32(0x1cb5c415); |
| 139 | int32_t count = (int32_t) public_keys.size(); |
| 140 | stream->writeInt32(count); |
| 141 | for (int32_t a = 0; a < count; a++) { |
| 142 | public_keys[a]->serializeToStream(stream); |
| 143 | } |
| 144 | } |
| 145 |
| 146 | bool TL_help_getCdnConfig::isNeedLayer() { |
| 147 | return true; |
| 148 | } |
| 149 |
| 150 | TLObject *TL_help_getCdnConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 151 | return TL_cdnConfig::TLdeserialize(stream, constructor, instanceNum, error); |
| 152 | } |
| 153 |
| 154 | void TL_help_getCdnConfig::serializeToStream(NativeByteBuffer *stream) { |
| 155 | stream->writeInt32(constructor); |
| 156 | } |
| 157 |
| 158 | TL_config *TL_config::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 159 | if (TL_config::constructor != constructor) { |
| 160 | error = true; |
| 161 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_config", constructor); |
| 162 | return nullptr; |
| 163 | } |
| 164 | TL_config *result = new TL_config(); |
| 165 | result->readParams(stream, instanceNum, error); |
| 166 | return result; |
| 167 | } |
| 168 |
| 169 | void TL_config::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 170 | flags = stream->readInt32(&error); |
| 171 | date = stream->readInt32(&error); |
| 172 | expires = stream->readInt32(&error); |
| 173 | test_mode = stream->readBool(&error); |
| 174 | this_dc = stream->readInt32(&error); |
| 175 | uint32_t magic = stream->readUint32(&error); |
| 176 | if (magic != 0x1cb5c415) { |
| 177 | error = true; |
| 178 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_config, got %x", magic); |
| 179 | return; |
| 180 | } |
| 181 | int32_t count = stream->readInt32(&error); |
| 182 | for (int32_t a = 0; a < count; a++) { |
| 183 | TL_dcOption *object = TL_dcOption::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 184 | if (object == nullptr) { |
| 185 | return; |
| 186 | } |
| 187 | dc_options.push_back(std::unique_ptr<TL_dcOption>(object)); |
| 188 | } |
| 189 | dc_txt_domain_name = stream->readString(&error); |
| 190 | chat_size_max = stream->readInt32(&error); |
| 191 | megagroup_size_max = stream->readInt32(&error); |
| 192 | forwarded_count_max = stream->readInt32(&error); |
| 193 | online_update_period_ms = stream->readInt32(&error); |
| 194 | offline_blur_timeout_ms = stream->readInt32(&error); |
| 195 | offline_idle_timeout_ms = stream->readInt32(&error); |
| 196 | online_cloud_timeout_ms = stream->readInt32(&error); |
| 197 | notify_cloud_delay_ms = stream->readInt32(&error); |
| 198 | notify_default_delay_ms = stream->readInt32(&error); |
| 199 | push_chat_period_ms = stream->readInt32(&error); |
| 200 | push_chat_limit = stream->readInt32(&error); |
| 201 | // saved_gifs_limit = stream->readInt32(&error); |
| 202 | edit_time_limit = stream->readInt32(&error); |
| 203 | revoke_time_limit = stream->readInt32(&error); |
| 204 | revoke_pm_time_limit = stream->readInt32(&error); |
| 205 | rating_e_decay = stream->readInt32(&error); |
| 206 | stickers_recent_limit = stream->readInt32(&error); |
| 207 | // stickers_faved_limit = stream->readInt32(&error); |
| 208 | channels_read_media_period = stream->readInt32(&error); |
| 209 | if ((flags & 1) != 0) { |
| 210 | tmp_sessions = stream->readInt32(&error); |
| 211 | } |
| 212 | // pinned_dialogs_count_max = stream->readInt32(&error); |
| 213 | // pinned_infolder_count_max = stream->readInt32(&error); |
| 214 | call_receive_timeout_ms = stream->readInt32(&error); |
| 215 | call_ring_timeout_ms = stream->readInt32(&error); |
| 216 | call_connect_timeout_ms = stream->readInt32(&error); |
| 217 | call_packet_timeout_ms = stream->readInt32(&error); |
| 218 | me_url_prefix = stream->readString(&error); |
| 219 | if ((flags & 128) != 0) { |
| 220 | autoupdate_url_prefix = stream->readString(&error); |
| 221 | } |
| 222 | if ((flags & 512) != 0) { |
| 223 | gif_search_username = stream->readString(&error); |
| 224 | } |
| 225 | if ((flags & 1024) != 0) { |
| 226 | venue_search_username = stream->readString(&error); |
| 227 | } |
| 228 | if ((flags & 2048) != 0) { |
| 229 | img_search_username = stream->readString(&error); |
| 230 | } |
| 231 | if ((flags & 4096) != 0) { |
| 232 | static_maps_provider = stream->readString(&error); |
| 233 | } |
| 234 | caption_length_max = stream->readInt32(&error); |
| 235 | message_length_max = stream->readInt32(&error); |
| 236 | webfile_dc_id = stream->readInt32(&error); |
| 237 | if ((flags & 4) != 0) { |
| 238 | suggested_lang_code = stream->readString(&error); |
| 239 | } |
| 240 | if ((flags & 4) != 0) { |
| 241 | lang_pack_version = stream->readInt32(&error); |
| 242 | } |
| 243 | if ((flags & 4) != 0) { |
| 244 | base_lang_pack_version = stream->readInt32(&error); |
| 245 | } |
| 246 | if ((flags & 32768) != 0) { |
| 247 | reactions_default = std::unique_ptr<Reaction>(Reaction::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 248 | } |
| 249 | if ((flags & 65536) != 0) { |
| 250 | autologin_token = stream->readString(&error); |
| 251 | } |
| 252 | } |
| 253 |
| 254 | void TL_config::serializeToStream(NativeByteBuffer *stream) { |
| 255 | stream->writeInt32(constructor); |
| 256 | stream->writeInt32(flags); |
| 257 | stream->writeInt32(date); |
| 258 | stream->writeInt32(expires); |
| 259 | stream->writeBool(test_mode); |
| 260 | stream->writeInt32(this_dc); |
| 261 | stream->writeInt32(0x1cb5c415); |
| 262 | uint32_t count = (uint32_t) dc_options.size(); |
| 263 | stream->writeInt32(count); |
| 264 | for (uint32_t a = 0; a < count; a++) { |
| 265 | dc_options[a]->serializeToStream(stream); |
| 266 | } |
| 267 | stream->writeString(dc_txt_domain_name); |
| 268 | stream->writeInt32(chat_size_max); |
| 269 | stream->writeInt32(megagroup_size_max); |
| 270 | stream->writeInt32(forwarded_count_max); |
| 271 | stream->writeInt32(online_update_period_ms); |
| 272 | stream->writeInt32(offline_blur_timeout_ms); |
| 273 | stream->writeInt32(offline_idle_timeout_ms); |
| 274 | stream->writeInt32(online_cloud_timeout_ms); |
| 275 | stream->writeInt32(notify_cloud_delay_ms); |
| 276 | stream->writeInt32(notify_default_delay_ms); |
| 277 | stream->writeInt32(push_chat_period_ms); |
| 278 | stream->writeInt32(push_chat_limit); |
| 279 | // stream->writeInt32(saved_gifs_limit); |
| 280 | stream->writeInt32(edit_time_limit); |
| 281 | stream->writeInt32(revoke_time_limit); |
| 282 | stream->writeInt32(revoke_pm_time_limit); |
| 283 | stream->writeInt32(rating_e_decay); |
| 284 | stream->writeInt32(stickers_recent_limit); |
| 285 | // stream->writeInt32(stickers_faved_limit); |
| 286 | stream->writeInt32(channels_read_media_period); |
| 287 | if ((flags & 1) != 0) { |
| 288 | stream->writeInt32(tmp_sessions); |
| 289 | } |
| 290 | // stream->writeInt32(pinned_dialogs_count_max); |
| 291 | // stream->writeInt32(pinned_infolder_count_max); |
| 292 | stream->writeInt32(call_receive_timeout_ms); |
| 293 | stream->writeInt32(call_ring_timeout_ms); |
| 294 | stream->writeInt32(call_connect_timeout_ms); |
| 295 | stream->writeInt32(call_packet_timeout_ms); |
| 296 | stream->writeString(me_url_prefix); |
| 297 | if ((flags & 128) != 0) { |
| 298 | stream->writeString(autoupdate_url_prefix); |
| 299 | } |
| 300 | if ((flags & 512) != 0) { |
| 301 | stream->writeString(gif_search_username); |
| 302 | } |
| 303 | if ((flags & 1024) != 0) { |
| 304 | stream->writeString(venue_search_username); |
| 305 | } |
| 306 | if ((flags & 2048) != 0) { |
| 307 | stream->writeString(img_search_username); |
| 308 | } |
| 309 | if ((flags & 4096) != 0) { |
| 310 | stream->writeString(static_maps_provider); |
| 311 | } |
| 312 | stream->writeInt32(caption_length_max); |
| 313 | stream->writeInt32(message_length_max); |
| 314 | stream->writeInt32(webfile_dc_id); |
| 315 | if ((flags & 4) != 0) { |
| 316 | stream->writeString(suggested_lang_code); |
| 317 | } |
| 318 | if ((flags & 4) != 0) { |
| 319 | stream->writeInt32(lang_pack_version); |
| 320 | } |
| 321 | if ((flags & 4) != 0) { |
| 322 | stream->writeInt32(base_lang_pack_version); |
| 323 | } |
| 324 | if ((flags & 32768) != 0 && reactions_default != nullptr) { |
| 325 | reactions_default->serializeToStream(stream); |
| 326 | } |
| 327 | if ((flags & 65536) != 0) { |
| 328 | stream->writeString(autologin_token); |
| 329 | } |
| 330 | } |
| 331 |
| 332 | TLObject *TL_help_getConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 333 | return TL_config::TLdeserialize(stream, constructor, instanceNum, error); |
| 334 | } |
| 335 |
| 336 | void TL_help_getConfig::serializeToStream(NativeByteBuffer *stream) { |
| 337 | stream->writeInt32(constructor); |
| 338 | } |
| 339 |
| 340 | bool TL_help_getConfig::isNeedLayer() { |
| 341 | return true; |
| 342 | } |
| 343 |
| 344 | bool TL_account_registerDevice::isNeedLayer() { |
| 345 | return true; |
| 346 | } |
| 347 |
| 348 | TLObject *TL_account_registerDevice::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 349 | return Bool::TLdeserialize(stream, constructor, instanceNum, error); |
| 350 | } |
| 351 |
| 352 | void TL_account_registerDevice::serializeToStream(NativeByteBuffer *stream) { |
| 353 | stream->writeInt32(constructor); |
| 354 | stream->writeInt32(token_type); |
| 355 | stream->writeString(token); |
| 356 | } |
| 357 |
| 358 | TL_restrictionReason *TL_restrictionReason::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 359 | if (TL_restrictionReason::constructor != constructor) { |
| 360 | error = true; |
| 361 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_restrictionReason", constructor); |
| 362 | return nullptr; |
| 363 | } |
| 364 | TL_restrictionReason *result = new TL_restrictionReason(); |
| 365 | result->readParams(stream, instanceNum, error); |
| 366 | return result; |
| 367 | } |
| 368 |
| 369 | TL_recentStory *TL_recentStory::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 370 | if (TL_recentStory::constructor != constructor) { |
| 371 | error = true; |
| 372 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_recentStory", constructor); |
| 373 | return nullptr; |
| 374 | } |
| 375 | TL_recentStory *result = new TL_recentStory(); |
| 376 | result->readParams(stream, instanceNum, error); |
| 377 | return result; |
| 378 | } |
| 379 |
| 380 | TL_username *TL_username::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 381 | if (TL_username::constructor != constructor) { |
| 382 | error = true; |
| 383 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_username", constructor); |
| 384 | return nullptr; |
| 385 | } |
| 386 | TL_username *result = new TL_username(); |
| 387 | result->readParams(stream, instanceNum, error); |
| 388 | return result; |
| 389 | } |
| 390 |
| 391 | TL_peerColor *TL_peerColor::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 392 | if (TL_peerColor::constructor != constructor) { |
| 393 | error = true; |
| 394 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_peerColor", constructor); |
| 395 | return nullptr; |
| 396 | } |
| 397 | TL_peerColor *result = new TL_peerColor(); |
| 398 | result->readParams(stream, instanceNum, error); |
| 399 | return result; |
| 400 | } |
| 401 |
| 402 | void TL_restrictionReason::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 403 | platform = stream->readString(&error); |
| 404 | reason = stream->readString(&error); |
| 405 | text = stream->readString(&error); |
| 406 | } |
| 407 |
| 408 | void TL_restrictionReason::serializeToStream(NativeByteBuffer *stream) { |
| 409 | stream->writeInt32(constructor); |
| 410 | stream->writeString(platform); |
| 411 | stream->writeString(reason); |
| 412 | stream->writeString(text); |
| 413 | } |
| 414 |
| 415 | void TL_recentStory::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 416 | flags = stream->readInt32(&error); |
| 417 | is_live = (flags & 1) != 0; |
| 418 | if ((flags & 2) != 0) { |
| 419 | max_id = stream->readInt32(&error); |
| 420 | } |
| 421 | } |
| 422 |
| 423 | void TL_recentStory::serializeToStream(NativeByteBuffer *stream) { |
| 424 | stream->writeInt32(constructor); |
| 425 | flags = is_live ? flags | 1 : flags &~ 1; |
| 426 | stream->writeInt32(flags); |
| 427 | if ((flags & 2) != 0) { |
| 428 | stream->writeInt32(max_id); |
| 429 | } |
| 430 | } |
| 431 |
| 432 | void TL_username::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 433 | flags = stream->readInt32(&error); |
| 434 | editable = (flags & 1) != 0; |
| 435 | active = (flags & 2) != 0; |
| 436 | username = stream->readString(&error); |
| 437 | } |
| 438 |
| 439 | void TL_username::serializeToStream(NativeByteBuffer *stream) { |
| 440 | stream->writeInt32(constructor); |
| 441 | flags = editable ? (flags | 1) : (flags &~ 1); |
| 442 | flags = active ? (flags | 2) : (flags &~ 2); |
| 443 | stream->writeInt32(flags); |
| 444 | stream->writeString(username); |
| 445 | } |
| 446 |
| 447 | void TL_peerColor::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 448 | flags = stream->readInt32(&error); |
| 449 | if ((flags & 1) != 0) { |
| 450 | color = stream->readInt32(&error); |
| 451 | } |
| 452 | if ((flags & 2) != 0) { |
| 453 | background_emoji_id = stream->readInt64(&error); |
| 454 | } |
| 455 | } |
| 456 |
| 457 | void TL_peerColor::serializeToStream(NativeByteBuffer *stream) { |
| 458 | stream->writeInt32(constructor); |
| 459 | stream->writeInt32(flags); |
| 460 | if ((flags & 1) != 0) { |
| 461 | stream->writeInt32(color); |
| 462 | } |
| 463 | if ((flags & 2) != 0) { |
| 464 | stream->writeInt64(background_emoji_id); |
| 465 | } |
| 466 | } |
| 467 |
| 468 | EmojiStatus *EmojiStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 469 | EmojiStatus *result = nullptr; |
| 470 | switch (constructor) { |
| 471 | case TL_emojiStatusEmpty::constructor: |
| 472 | result = new TL_emojiStatusEmpty(); |
| 473 | break; |
| 474 | case TL_emojiStatus::constructor: |
| 475 | result = new TL_emojiStatus(); |
| 476 | break; |
| 477 | case TL_emojiStatusCollectible::constructor: |
| 478 | result = new TL_emojiStatusCollectible(); |
| 479 | break; |
| 480 | case TL_emojiStatus_layer197::constructor: |
| 481 | result = new TL_emojiStatus_layer197(); |
| 482 | break; |
| 483 | case TL_emojiStatusUntil_layer197::constructor: |
| 484 | result = new TL_emojiStatusUntil_layer197(); |
| 485 | break; |
| 486 | default: |
| 487 | error = true; |
| 488 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in User", constructor); |
| 489 | return nullptr; |
| 490 | } |
| 491 | result->readParams(stream, instanceNum, error); |
| 492 | return result; |
| 493 | } |
| 494 |
| 495 | void TL_emojiStatusEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 496 |
| 497 | } |
| 498 |
| 499 | void TL_emojiStatusEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 500 | stream->writeInt32(constructor); |
| 501 | } |
| 502 |
| 503 | void TL_emojiStatus::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 504 | flags = stream->readInt32(&error); |
| 505 | document_id = stream->readInt64(&error); |
| 506 | if ((flags & 1) != 0) { |
| 507 | until = stream->readInt32(&error); |
| 508 | } |
| 509 | } |
| 510 |
| 511 | void TL_emojiStatus::serializeToStream(NativeByteBuffer *stream) { |
| 512 | stream->writeInt32(constructor); |
| 513 | stream->writeInt32(flags); |
| 514 | stream->writeInt64(document_id); |
| 515 | if ((flags & 1) != 0) { |
| 516 | stream->writeInt32(until); |
| 517 | } |
| 518 | } |
| 519 |
| 520 | void TL_emojiStatus_layer197::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 521 | document_id = stream->readInt64(&error); |
| 522 | } |
| 523 |
| 524 | void TL_emojiStatus_layer197::serializeToStream(NativeByteBuffer *stream) { |
| 525 | stream->writeInt32(constructor); |
| 526 | stream->writeInt64(document_id); |
| 527 | } |
| 528 |
| 529 | void TL_emojiStatusUntil_layer197::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 530 | document_id = stream->readInt64(&error); |
| 531 | until = stream->readInt32(&error); |
| 532 | } |
| 533 |
| 534 | void TL_emojiStatusUntil_layer197::serializeToStream(NativeByteBuffer *stream) { |
| 535 | stream->writeInt32(constructor); |
| 536 | stream->writeInt64(document_id); |
| 537 | stream->writeInt32(until); |
| 538 | } |
| 539 |
| 540 | void TL_emojiStatusCollectible::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 541 | flags = stream->readInt32(&error); |
| 542 | collectible_id = stream->readInt64(&error); |
| 543 | document_id = stream->readInt64(&error); |
| 544 | title = stream->readString(&error); |
| 545 | slug = stream->readString(&error); |
| 546 | pattern_document_id = stream->readInt64(&error); |
| 547 | center_color = stream->readInt32(&error); |
| 548 | edge_color = stream->readInt32(&error); |
| 549 | pattern_color = stream->readInt32(&error); |
| 550 | text_color = stream->readInt32(&error); |
| 551 | if ((flags & 1) != 0) { |
| 552 | until = stream->readInt32(&error); |
| 553 | } |
| 554 | } |
| 555 |
| 556 | void TL_emojiStatusCollectible::serializeToStream(NativeByteBuffer *stream) { |
| 557 | stream->writeInt32(constructor); |
| 558 | stream->writeInt32(flags); |
| 559 | stream->writeInt64(collectible_id); |
| 560 | stream->writeInt64(document_id); |
| 561 | stream->writeString(title); |
| 562 | stream->writeString(slug); |
| 563 | stream->writeInt64(pattern_document_id); |
| 564 | stream->writeInt32(center_color); |
| 565 | stream->writeInt32(edge_color); |
| 566 | stream->writeInt32(pattern_color); |
| 567 | stream->writeInt32(text_color); |
| 568 | if ((flags & 1) != 0) { |
| 569 | stream->writeInt32(until); |
| 570 | } |
| 571 | } |
| 572 |
| 573 | User *User::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 574 | User *result = nullptr; |
| 575 | switch (constructor) { |
| 576 | case TL_userEmpty::constructor: |
| 577 | result = new TL_userEmpty(); |
| 578 | break; |
| 579 | case TL_user::constructor: |
| 580 | result = new TL_user(); |
| 581 | break; |
| 582 | case TL_user_layer216::constructor: |
| 583 | result = new TL_user_layer216(); |
| 584 | break; |
| 585 | default: |
| 586 | error = true; |
| 587 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in User", constructor); |
| 588 | return nullptr; |
| 589 | } |
| 590 | result->readParams(stream, instanceNum, error); |
| 591 | return result; |
| 592 | } |
| 593 |
| 594 | void TL_userEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 595 | id = stream->readInt64(&error); |
| 596 | } |
| 597 |
| 598 | void TL_userEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 599 | stream->writeInt32(constructor); |
| 600 | stream->writeInt64(id); |
| 601 | } |
| 602 |
| 603 | void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 604 | flags = stream->readInt32(&error); |
| 605 | flags2 = stream->readInt32(&error); |
| 606 | id = stream->readInt64(&error); |
| 607 | if ((flags & 1) != 0) { |
| 608 | access_hash = stream->readInt64(&error); |
| 609 | } |
| 610 | if ((flags & 2) != 0) { |
| 611 | first_name = stream->readString(&error); |
| 612 | } |
| 613 | if ((flags & 4) != 0) { |
| 614 | last_name = stream->readString(&error); |
| 615 | } |
| 616 | if ((flags & 8) != 0) { |
| 617 | username = stream->readString(&error); |
| 618 | } |
| 619 | if ((flags & 16) != 0) { |
| 620 | phone = stream->readString(&error); |
| 621 | } |
| 622 | if ((flags & 32) != 0) { |
| 623 | photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 624 | } |
| 625 | if ((flags & 64) != 0) { |
| 626 | status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 627 | } |
| 628 | if ((flags & 16384) != 0) { |
| 629 | bot_info_version = stream->readInt32(&error); |
| 630 | } |
| 631 | if ((flags & 262144) != 0) { |
| 632 | uint32_t magic = stream->readUint32(&error); |
| 633 | if (magic != 0x1cb5c415) { |
| 634 | error = true; |
| 635 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user, got %x", magic); |
| 636 | return; |
| 637 | } |
| 638 | int32_t count = stream->readInt32(&error); |
| 639 | for (int32_t a = 0; a < count; a++) { |
| 640 | TL_restrictionReason *object = TL_restrictionReason::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 641 | if (object == nullptr) { |
| 642 | return; |
| 643 | } |
| 644 | restriction_reason.push_back(std::unique_ptr<TL_restrictionReason>(object)); |
| 645 | } |
| 646 | } |
| 647 | if ((flags & 524288) != 0) { |
| 648 | bot_inline_placeholder = stream->readString(&error); |
| 649 | } |
| 650 | if ((flags & 4194304) != 0) { |
| 651 | lang_code = stream->readString(&error); |
| 652 | } |
| 653 | if ((flags & 1073741824) != 0) { |
| 654 | emoji_status = std::unique_ptr<EmojiStatus>(EmojiStatus::TLdeserialize(stream, stream->readInt32(&error), instanceNum, error)); |
| 655 | } |
| 656 | if ((flags2 & 1) != 0) { |
| 657 | uint32_t magic = stream->readUint32(&error); |
| 658 | if (magic != 0x1cb5c415) { |
| 659 | error = true; |
| 660 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user (2), got %x", magic); |
| 661 | return; |
| 662 | } |
| 663 | int32_t count = stream->readInt32(&error); |
| 664 | for (int32_t a = 0; a < count; a++) { |
| 665 | TL_username *object = TL_username::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 666 | if (object == nullptr) { |
| 667 | return; |
| 668 | } |
| 669 | usernames.push_back(std::unique_ptr<TL_username>(object)); |
| 670 | } |
| 671 | } |
| 672 | if ((flags2 & 32) != 0) { |
| 673 | stories_max_id = std::unique_ptr<TL_recentStory>(TL_recentStory::TLdeserialize(stream, stream->readInt32(&error), instanceNum, error)); |
| 674 | } |
| 675 | if ((flags2 & 256) != 0) { |
| 676 | color = std::unique_ptr<TL_peerColor>(TL_peerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 677 | } |
| 678 | if ((flags2 & 512) != 0) { |
| 679 | profile_color = std::unique_ptr<TL_peerColor>(TL_peerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 680 | } |
| 681 | if ((flags2 & 4096) != 0) { |
| 682 | bot_active_users = stream->readInt32(&error); |
| 683 | } |
| 684 | if ((flags2 & 16384) != 0) { |
| 685 | bot_verification_icon = stream->readInt64(&error); |
| 686 | } |
| 687 | if ((flags2 & 32768) != 0) { |
| 688 | send_paid_messages_stars = stream->readInt64(&error); |
| 689 | } |
| 690 | } |
| 691 |
| 692 | void TL_user::serializeToStream(NativeByteBuffer *stream) { |
| 693 | stream->writeInt32(constructor); |
| 694 | stream->writeInt32(flags); |
| 695 | stream->writeInt32(flags2); |
| 696 | stream->writeInt64(id); |
| 697 | if ((flags & 1) != 0) { |
| 698 | stream->writeInt64(access_hash); |
| 699 | } |
| 700 | if ((flags & 2) != 0) { |
| 701 | stream->writeString(first_name); |
| 702 | } |
| 703 | if ((flags & 4) != 0) { |
| 704 | stream->writeString(last_name); |
| 705 | } |
| 706 | if ((flags & 8) != 0) { |
| 707 | stream->writeString(username); |
| 708 | } |
| 709 | if ((flags & 16) != 0) { |
| 710 | stream->writeString(phone); |
| 711 | } |
| 712 | if ((flags & 32) != 0) { |
| 713 | photo->serializeToStream(stream); |
| 714 | } |
| 715 | if ((flags & 64) != 0) { |
| 716 | status->serializeToStream(stream); |
| 717 | } |
| 718 | if ((flags & 16384) != 0) { |
| 719 | stream->writeInt32(bot_info_version); |
| 720 | } |
| 721 | if ((flags & 262144) != 0) { |
| 722 | stream->writeInt32(0x1cb5c415); |
| 723 | uint32_t count = (uint32_t) restriction_reason.size(); |
| 724 | stream->writeInt32(count); |
| 725 | for (int a = 0; a < count; a++) { |
| 726 | restriction_reason[a]->serializeToStream(stream); |
| 727 | } |
| 728 | } |
| 729 | if ((flags & 524288) != 0) { |
| 730 | stream->writeString(bot_inline_placeholder); |
| 731 | } |
| 732 | if ((flags & 4194304) != 0) { |
| 733 | stream->writeString(lang_code); |
| 734 | } |
| 735 | if ((flags & 1073741824) != 0) { |
| 736 | emoji_status->serializeToStream(stream); |
| 737 | } |
| 738 | if ((flags2 & 1) != 0) { |
| 739 | stream->writeInt32(0x1cb5c415); |
| 740 | int32_t count = (int32_t) usernames.size(); |
| 741 | stream->writeInt32(count); |
| 742 | for (int a = 0; a < count; a++) { |
| 743 | usernames[a]->serializeToStream(stream); |
| 744 | } |
| 745 | } |
| 746 | if ((flags2 & 32) != 0) { |
| 747 | stories_max_id->serializeToStream(stream); |
| 748 | } |
| 749 | if ((flags2 & 256) != 0) { |
| 750 | color->serializeToStream(stream); |
| 751 | } |
| 752 | if ((flags2 & 512) != 0) { |
| 753 | profile_color->serializeToStream(stream); |
| 754 | } |
| 755 | if ((flags2 & 4096) != 0) { |
| 756 | stream->writeInt32(bot_active_users); |
| 757 | } |
| 758 | if ((flags2 & 16384) != 0) { |
| 759 | stream->writeInt64(bot_verification_icon); |
| 760 | } |
| 761 | if ((flags2 & 32768) != 0) { |
| 762 | stream->writeInt64(send_paid_messages_stars); |
| 763 | } |
| 764 | } |
| 765 |
| 766 | void TL_user_layer216::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 767 | flags = stream->readInt32(&error); |
| 768 | flags2 = stream->readInt32(&error); |
| 769 | id = stream->readInt64(&error); |
| 770 | if ((flags & 1) != 0) { |
| 771 | access_hash = stream->readInt64(&error); |
| 772 | } |
| 773 | if ((flags & 2) != 0) { |
| 774 | first_name = stream->readString(&error); |
| 775 | } |
| 776 | if ((flags & 4) != 0) { |
| 777 | last_name = stream->readString(&error); |
| 778 | } |
| 779 | if ((flags & 8) != 0) { |
| 780 | username = stream->readString(&error); |
| 781 | } |
| 782 | if ((flags & 16) != 0) { |
| 783 | phone = stream->readString(&error); |
| 784 | } |
| 785 | if ((flags & 32) != 0) { |
| 786 | photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 787 | } |
| 788 | if ((flags & 64) != 0) { |
| 789 | status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 790 | } |
| 791 | if ((flags & 16384) != 0) { |
| 792 | bot_info_version = stream->readInt32(&error); |
| 793 | } |
| 794 | if ((flags & 262144) != 0) { |
| 795 | uint32_t magic = stream->readUint32(&error); |
| 796 | if (magic != 0x1cb5c415) { |
| 797 | error = true; |
| 798 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user, got %x", magic); |
| 799 | return; |
| 800 | } |
| 801 | int32_t count = stream->readInt32(&error); |
| 802 | for (int32_t a = 0; a < count; a++) { |
| 803 | TL_restrictionReason *object = TL_restrictionReason::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 804 | if (object == nullptr) { |
| 805 | return; |
| 806 | } |
| 807 | restriction_reason.push_back(std::unique_ptr<TL_restrictionReason>(object)); |
| 808 | } |
| 809 | } |
| 810 | if ((flags & 524288) != 0) { |
| 811 | bot_inline_placeholder = stream->readString(&error); |
| 812 | } |
| 813 | if ((flags & 4194304) != 0) { |
| 814 | lang_code = stream->readString(&error); |
| 815 | } |
| 816 | if ((flags & 1073741824) != 0) { |
| 817 | emoji_status = std::unique_ptr<EmojiStatus>(EmojiStatus::TLdeserialize(stream, stream->readInt32(&error), instanceNum, error)); |
| 818 | } |
| 819 | if ((flags2 & 1) != 0) { |
| 820 | uint32_t magic = stream->readUint32(&error); |
| 821 | if (magic != 0x1cb5c415) { |
| 822 | error = true; |
| 823 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user (2), got %x", magic); |
| 824 | return; |
| 825 | } |
| 826 | int32_t count = stream->readInt32(&error); |
| 827 | for (int32_t a = 0; a < count; a++) { |
| 828 | TL_username *object = TL_username::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 829 | if (object == nullptr) { |
| 830 | return; |
| 831 | } |
| 832 | usernames.push_back(std::unique_ptr<TL_username>(object)); |
| 833 | } |
| 834 | } |
| 835 | if ((flags2 & 32) != 0) { |
| 836 | stories_max_id = std::make_unique<TL_recentStory>(); |
| 837 | stories_max_id->flags |= 2; |
| 838 | stories_max_id->max_id = stream->readInt32(&error); |
| 839 | } |
| 840 | if ((flags2 & 256) != 0) { |
| 841 | color = std::unique_ptr<TL_peerColor>(TL_peerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 842 | } |
| 843 | if ((flags2 & 512) != 0) { |
| 844 | profile_color = std::unique_ptr<TL_peerColor>(TL_peerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 845 | } |
| 846 | if ((flags2 & 4096) != 0) { |
| 847 | bot_active_users = stream->readInt32(&error); |
| 848 | } |
| 849 | if ((flags2 & 16384) != 0) { |
| 850 | bot_verification_icon = stream->readInt64(&error); |
| 851 | } |
| 852 | if ((flags2 & 32768) != 0) { |
| 853 | send_paid_messages_stars = stream->readInt64(&error); |
| 854 | } |
| 855 | } |
| 856 |
| 857 | void TL_user_layer216::serializeToStream(NativeByteBuffer *stream) { |
| 858 | stream->writeInt32(constructor); |
| 859 | stream->writeInt32(flags); |
| 860 | stream->writeInt32(flags2); |
| 861 | stream->writeInt64(id); |
| 862 | if ((flags & 1) != 0) { |
| 863 | stream->writeInt64(access_hash); |
| 864 | } |
| 865 | if ((flags & 2) != 0) { |
| 866 | stream->writeString(first_name); |
| 867 | } |
| 868 | if ((flags & 4) != 0) { |
| 869 | stream->writeString(last_name); |
| 870 | } |
| 871 | if ((flags & 8) != 0) { |
| 872 | stream->writeString(username); |
| 873 | } |
| 874 | if ((flags & 16) != 0) { |
| 875 | stream->writeString(phone); |
| 876 | } |
| 877 | if ((flags & 32) != 0) { |
| 878 | photo->serializeToStream(stream); |
| 879 | } |
| 880 | if ((flags & 64) != 0) { |
| 881 | status->serializeToStream(stream); |
| 882 | } |
| 883 | if ((flags & 16384) != 0) { |
| 884 | stream->writeInt32(bot_info_version); |
| 885 | } |
| 886 | if ((flags & 262144) != 0) { |
| 887 | stream->writeInt32(0x1cb5c415); |
| 888 | uint32_t count = (uint32_t) restriction_reason.size(); |
| 889 | stream->writeInt32(count); |
| 890 | for (int a = 0; a < count; a++) { |
| 891 | restriction_reason[a]->serializeToStream(stream); |
| 892 | } |
| 893 | } |
| 894 | if ((flags & 524288) != 0) { |
| 895 | stream->writeString(bot_inline_placeholder); |
| 896 | } |
| 897 | if ((flags & 4194304) != 0) { |
| 898 | stream->writeString(lang_code); |
| 899 | } |
| 900 | if ((flags & 1073741824) != 0) { |
| 901 | emoji_status->serializeToStream(stream); |
| 902 | } |
| 903 | if ((flags2 & 1) != 0) { |
| 904 | stream->writeInt32(0x1cb5c415); |
| 905 | int32_t count = (int32_t) usernames.size(); |
| 906 | stream->writeInt32(count); |
| 907 | for (int a = 0; a < count; a++) { |
| 908 | usernames[a]->serializeToStream(stream); |
| 909 | } |
| 910 | } |
| 911 | if ((flags2 & 32) != 0) { |
| 912 | stream->writeInt32(stories_max_id ? stories_max_id->max_id : 0); |
| 913 | } |
| 914 | if ((flags2 & 256) != 0) { |
| 915 | color->serializeToStream(stream); |
| 916 | } |
| 917 | if ((flags2 & 512) != 0) { |
| 918 | profile_color->serializeToStream(stream); |
| 919 | } |
| 920 | if ((flags2 & 4096) != 0) { |
| 921 | stream->writeInt32(bot_active_users); |
| 922 | } |
| 923 | if ((flags2 & 16384) != 0) { |
| 924 | stream->writeInt64(bot_verification_icon); |
| 925 | } |
| 926 | if ((flags2 & 32768) != 0) { |
| 927 | stream->writeInt64(send_paid_messages_stars); |
| 928 | } |
| 929 | } |
| 930 |
| 931 | InputPeer *InputPeer::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 932 | InputPeer *result = nullptr; |
| 933 | switch (constructor) { |
| 934 | case 0x7da07ec9: |
| 935 | result = new TL_inputPeerSelf(); |
| 936 | break; |
| 937 | case 0xdde8a54c: |
| 938 | result = new TL_inputPeerUser(); |
| 939 | break; |
| 940 | case 0x35a95cb9: |
| 941 | result = new TL_inputPeerChat(); |
| 942 | break; |
| 943 | case 0xa87b0a1c: |
| 944 | result = new TL_inputPeerUserFromMessage(); |
| 945 | break; |
| 946 | case 0xbd2a0840: |
| 947 | result = new TL_inputPeerChannelFromMessage(); |
| 948 | break; |
| 949 | case 0x27bcbbfc: |
| 950 | result = new TL_inputPeerChannel(); |
| 951 | break; |
| 952 | case 0x7f3b18ea: |
| 953 | result = new TL_inputPeerEmpty(); |
| 954 | break; |
| 955 | default: |
| 956 | error = true; |
| 957 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in InputPeer", constructor); |
| 958 | return nullptr; |
| 959 | } |
| 960 | result->readParams(stream, instanceNum, error); |
| 961 | return result; |
| 962 | } |
| 963 |
| 964 | void TL_inputPeerSelf::serializeToStream(NativeByteBuffer *stream) { |
| 965 | stream->writeInt32(constructor); |
| 966 | } |
| 967 |
| 968 | void TL_inputPeerUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 969 | user_id = stream->readInt64(&error); |
| 970 | access_hash = stream->readInt64(&error); |
| 971 | } |
| 972 |
| 973 | void TL_inputPeerUser::serializeToStream(NativeByteBuffer *stream) { |
| 974 | stream->writeInt32(constructor); |
| 975 | stream->writeInt64(user_id); |
| 976 | stream->writeInt64(access_hash); |
| 977 | } |
| 978 |
| 979 | void TL_inputPeerChat::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 980 | chat_id = stream->readInt64(&error); |
| 981 | } |
| 982 |
| 983 | void TL_inputPeerChat::serializeToStream(NativeByteBuffer *stream) { |
| 984 | stream->writeInt32(constructor); |
| 985 | stream->writeInt64(chat_id); |
| 986 | } |
| 987 |
| 988 | void TL_inputPeerUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 989 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 990 | msg_id = stream->readInt32(&error); |
| 991 | user_id = stream->readInt64(&error); |
| 992 | } |
| 993 |
| 994 | void TL_inputPeerUserFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 995 | stream->writeInt32(constructor); |
| 996 | peer->serializeToStream(stream); |
| 997 | stream->writeInt32(msg_id); |
| 998 | stream->writeInt64(user_id); |
| 999 | } |
| 1000 |
| 1001 | void TL_inputPeerChannelFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1002 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1003 | msg_id = stream->readInt32(&error); |
| 1004 | channel_id = stream->readInt64(&error); |
| 1005 | } |
| 1006 |
| 1007 | void TL_inputPeerChannelFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 1008 | stream->writeInt32(constructor); |
| 1009 | peer->serializeToStream(stream); |
| 1010 | stream->writeInt32(msg_id); |
| 1011 | stream->writeInt64(channel_id); |
| 1012 | } |
| 1013 |
| 1014 | void TL_inputPeerChannel::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1015 | channel_id = stream->readInt64(&error); |
| 1016 | access_hash = stream->readInt64(&error); |
| 1017 | } |
| 1018 |
| 1019 | void TL_inputPeerChannel::serializeToStream(NativeByteBuffer *stream) { |
| 1020 | stream->writeInt32(constructor); |
| 1021 | stream->writeInt64(channel_id); |
| 1022 | stream->writeInt64(access_hash); |
| 1023 | } |
| 1024 |
| 1025 | void TL_inputPeerEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1026 | stream->writeInt32(constructor); |
| 1027 | } |
| 1028 |
| 1029 | InputUser *InputUser::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1030 | InputUser *result = nullptr; |
| 1031 | switch (constructor) { |
| 1032 | case 0xf7c1b13f: |
| 1033 | result = new TL_inputUserSelf(); |
| 1034 | break; |
| 1035 | case 0xf21158c6: |
| 1036 | result = new TL_inputUser(); |
| 1037 | break; |
| 1038 | case 0xb98886cf: |
| 1039 | result = new TL_inputUserEmpty(); |
| 1040 | break; |
| 1041 | case 0x1da448e2: |
| 1042 | result = new TL_inputUserFromMessage(); |
| 1043 | break; |
| 1044 | default: |
| 1045 | error = true; |
| 1046 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in InputUser", constructor); |
| 1047 | return nullptr; |
| 1048 | } |
| 1049 | result->readParams(stream, instanceNum, error); |
| 1050 | return result; |
| 1051 | } |
| 1052 |
| 1053 | void TL_inputUserSelf::serializeToStream(NativeByteBuffer *stream) { |
| 1054 | stream->writeInt32(constructor); |
| 1055 | } |
| 1056 |
| 1057 | void TL_inputUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1058 | user_id = stream->readInt64(&error); |
| 1059 | access_hash = stream->readInt64(&error); |
| 1060 | } |
| 1061 |
| 1062 | void TL_inputUser::serializeToStream(NativeByteBuffer *stream) { |
| 1063 | stream->writeInt32(constructor); |
| 1064 | stream->writeInt64(user_id); |
| 1065 | stream->writeInt64(access_hash); |
| 1066 | } |
| 1067 |
| 1068 | void TL_inputUserEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1069 | stream->writeInt32(constructor); |
| 1070 | } |
| 1071 |
| 1072 | void TL_inputUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1073 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1074 | msg_id = stream->readInt32(&error); |
| 1075 | user_id = stream->readInt64(&error); |
| 1076 | } |
| 1077 |
| 1078 | void TL_inputUserFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 1079 | stream->writeInt32(constructor); |
| 1080 | peer->serializeToStream(stream); |
| 1081 | stream->writeInt32(msg_id); |
| 1082 | stream->writeInt64(user_id); |
| 1083 | } |
| 1084 |
| 1085 | MessageEntity *MessageEntity::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1086 | MessageEntity *result = nullptr; |
| 1087 | switch (constructor) { |
| 1088 | case 0x76a6d327: |
| 1089 | result = new TL_messageEntityTextUrl(); |
| 1090 | break; |
| 1091 | case 0x6cef8ac7: |
| 1092 | result = new TL_messageEntityBotCommand(); |
| 1093 | break; |
| 1094 | case 0x64e475c2: |
| 1095 | result = new TL_messageEntityEmail(); |
| 1096 | break; |
| 1097 | case 0x73924be0: |
| 1098 | result = new TL_messageEntityPre(); |
| 1099 | break; |
| 1100 | case 0xbb92ba95: |
| 1101 | result = new TL_messageEntityUnknown(); |
| 1102 | break; |
| 1103 | case 0x6ed02538: |
| 1104 | result = new TL_messageEntityUrl(); |
| 1105 | break; |
| 1106 | case 0x826f8b60: |
| 1107 | result = new TL_messageEntityItalic(); |
| 1108 | break; |
| 1109 | case 0xfa04579d: |
| 1110 | result = new TL_messageEntityMention(); |
| 1111 | break; |
| 1112 | case 0xdc7b1140: |
| 1113 | result = new TL_messageEntityMentionName(); |
| 1114 | break; |
| 1115 | case 0x208e68c9: |
| 1116 | result = new TL_inputMessageEntityMentionName(); |
| 1117 | break; |
| 1118 | case 0x4c4e743f: |
| 1119 | result = new TL_messageEntityCashtag(); |
| 1120 | break; |
| 1121 | case 0xbd610bc9: |
| 1122 | result = new TL_messageEntityBold(); |
| 1123 | break; |
| 1124 | case 0x6f635b0d: |
| 1125 | result = new TL_messageEntityHashtag(); |
| 1126 | break; |
| 1127 | case 0x28a20571: |
| 1128 | result = new TL_messageEntityCode(); |
| 1129 | break; |
| 1130 | case 0xbf0693d4: |
| 1131 | result = new TL_messageEntityStrike(); |
| 1132 | break; |
| 1133 | case 0x20df5d0: |
| 1134 | result = new TL_messageEntityBlockquote_layer180(); |
| 1135 | break; |
| 1136 | case 0xf1ccaaac: |
| 1137 | result = new TL_messageEntityBlockquote(); |
| 1138 | break; |
| 1139 | case 0x9c4e7e8b: |
| 1140 | result = new TL_messageEntityUnderline(); |
| 1141 | break; |
| 1142 | case 0x9b69e34b: |
| 1143 | result = new TL_messageEntityPhone(); |
| 1144 | break; |
| 1145 | default: |
| 1146 | error = true; |
| 1147 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in MessageEntity", constructor); |
| 1148 | return nullptr; |
| 1149 | } |
| 1150 | result->readParams(stream, instanceNum, error); |
| 1151 | return result; |
| 1152 | } |
| 1153 |
| 1154 | void TL_messageEntityTextUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1155 | offset = stream->readInt32(&error); |
| 1156 | length = stream->readInt32(&error); |
| 1157 | url = stream->readString(&error); |
| 1158 | } |
| 1159 |
| 1160 | void TL_messageEntityTextUrl::serializeToStream(NativeByteBuffer *stream) { |
| 1161 | stream->writeInt32(constructor); |
| 1162 | stream->writeInt32(offset); |
| 1163 | stream->writeInt32(length); |
| 1164 | stream->writeString(url); |
| 1165 | } |
| 1166 |
| 1167 | void TL_messageEntityBotCommand::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1168 | offset = stream->readInt32(&error); |
| 1169 | length = stream->readInt32(&error); |
| 1170 | } |
| 1171 |
| 1172 | void TL_messageEntityBotCommand::serializeToStream(NativeByteBuffer *stream) { |
| 1173 | stream->writeInt32(constructor); |
| 1174 | stream->writeInt32(offset); |
| 1175 | stream->writeInt32(length); |
| 1176 | } |
| 1177 |
| 1178 | void TL_messageEntityEmail::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1179 | offset = stream->readInt32(&error); |
| 1180 | length = stream->readInt32(&error); |
| 1181 | } |
| 1182 |
| 1183 | void TL_messageEntityEmail::serializeToStream(NativeByteBuffer *stream) { |
| 1184 | stream->writeInt32(constructor); |
| 1185 | stream->writeInt32(offset); |
| 1186 | stream->writeInt32(length); |
| 1187 | } |
| 1188 |
| 1189 | void TL_messageEntityPre::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1190 | offset = stream->readInt32(&error); |
| 1191 | length = stream->readInt32(&error); |
| 1192 | language = stream->readString(&error); |
| 1193 | } |
| 1194 |
| 1195 | void TL_messageEntityPre::serializeToStream(NativeByteBuffer *stream) { |
| 1196 | stream->writeInt32(constructor); |
| 1197 | stream->writeInt32(offset); |
| 1198 | stream->writeInt32(length); |
| 1199 | stream->writeString(language); |
| 1200 | } |
| 1201 |
| 1202 | void TL_messageEntityUnknown::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1203 | offset = stream->readInt32(&error); |
| 1204 | length = stream->readInt32(&error); |
| 1205 | } |
| 1206 |
| 1207 | void TL_messageEntityUnknown::serializeToStream(NativeByteBuffer *stream) { |
| 1208 | stream->writeInt32(constructor); |
| 1209 | stream->writeInt32(offset); |
| 1210 | stream->writeInt32(length); |
| 1211 | } |
| 1212 |
| 1213 | void TL_messageEntityUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1214 | offset = stream->readInt32(&error); |
| 1215 | length = stream->readInt32(&error); |
| 1216 | } |
| 1217 |
| 1218 | void TL_messageEntityUrl::serializeToStream(NativeByteBuffer *stream) { |
| 1219 | stream->writeInt32(constructor); |
| 1220 | stream->writeInt32(offset); |
| 1221 | stream->writeInt32(length); |
| 1222 | } |
| 1223 |
| 1224 | void TL_messageEntityItalic::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1225 | offset = stream->readInt32(&error); |
| 1226 | length = stream->readInt32(&error); |
| 1227 | } |
| 1228 |
| 1229 | void TL_messageEntityItalic::serializeToStream(NativeByteBuffer *stream) { |
| 1230 | stream->writeInt32(constructor); |
| 1231 | stream->writeInt32(offset); |
| 1232 | stream->writeInt32(length); |
| 1233 | } |
| 1234 |
| 1235 | void TL_messageEntityMention::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1236 | offset = stream->readInt32(&error); |
| 1237 | length = stream->readInt32(&error); |
| 1238 | } |
| 1239 |
| 1240 | void TL_messageEntityMention::serializeToStream(NativeByteBuffer *stream) { |
| 1241 | stream->writeInt32(constructor); |
| 1242 | stream->writeInt32(offset); |
| 1243 | stream->writeInt32(length); |
| 1244 | } |
| 1245 |
| 1246 | void TL_messageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1247 | offset = stream->readInt32(&error); |
| 1248 | length = stream->readInt32(&error); |
| 1249 | user_id = stream->readInt64(&error); |
| 1250 | } |
| 1251 |
| 1252 | void TL_messageEntityMentionName::serializeToStream(NativeByteBuffer *stream) { |
| 1253 | stream->writeInt32(constructor); |
| 1254 | stream->writeInt32(offset); |
| 1255 | stream->writeInt32(length); |
| 1256 | stream->writeInt64(user_id); |
| 1257 | } |
| 1258 |
| 1259 | void TL_inputMessageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1260 | offset = stream->readInt32(&error); |
| 1261 | length = stream->readInt32(&error); |
| 1262 | user_id = std::unique_ptr<InputUser>(InputUser::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1263 | } |
| 1264 |
| 1265 | void TL_inputMessageEntityMentionName::serializeToStream(NativeByteBuffer *stream) { |
| 1266 | stream->writeInt32(constructor); |
| 1267 | stream->writeInt32(offset); |
| 1268 | stream->writeInt32(length); |
| 1269 | user_id->serializeToStream(stream); |
| 1270 | } |
| 1271 |
| 1272 | void TL_messageEntityCashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1273 | offset = stream->readInt32(&error); |
| 1274 | length = stream->readInt32(&error); |
| 1275 | } |
| 1276 |
| 1277 | void TL_messageEntityCashtag::serializeToStream(NativeByteBuffer *stream) { |
| 1278 | stream->writeInt32(constructor); |
| 1279 | stream->writeInt32(offset); |
| 1280 | stream->writeInt32(length); |
| 1281 | } |
| 1282 |
| 1283 | void TL_messageEntityBold::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1284 | offset = stream->readInt32(&error); |
| 1285 | length = stream->readInt32(&error); |
| 1286 | } |
| 1287 |
| 1288 | void TL_messageEntityBold::serializeToStream(NativeByteBuffer *stream) { |
| 1289 | stream->writeInt32(constructor); |
| 1290 | stream->writeInt32(offset); |
| 1291 | stream->writeInt32(length); |
| 1292 | } |
| 1293 |
| 1294 | void TL_messageEntityHashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1295 | offset = stream->readInt32(&error); |
| 1296 | length = stream->readInt32(&error); |
| 1297 | } |
| 1298 |
| 1299 | void TL_messageEntityHashtag::serializeToStream(NativeByteBuffer *stream) { |
| 1300 | stream->writeInt32(constructor); |
| 1301 | stream->writeInt32(offset); |
| 1302 | stream->writeInt32(length); |
| 1303 | } |
| 1304 |
| 1305 | void TL_messageEntityCode::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1306 | offset = stream->readInt32(&error); |
| 1307 | length = stream->readInt32(&error); |
| 1308 | } |
| 1309 |
| 1310 | void TL_messageEntityCode::serializeToStream(NativeByteBuffer *stream) { |
| 1311 | stream->writeInt32(constructor); |
| 1312 | stream->writeInt32(offset); |
| 1313 | stream->writeInt32(length); |
| 1314 | } |
| 1315 |
| 1316 | void TL_messageEntityStrike::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1317 | offset = stream->readInt32(&error); |
| 1318 | length = stream->readInt32(&error); |
| 1319 | } |
| 1320 |
| 1321 | void TL_messageEntityStrike::serializeToStream(NativeByteBuffer *stream) { |
| 1322 | stream->writeInt32(constructor); |
| 1323 | stream->writeInt32(offset); |
| 1324 | stream->writeInt32(length); |
| 1325 | } |
| 1326 |
| 1327 | void TL_messageEntityBlockquote::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1328 | flags = stream->readInt32(&error); |
| 1329 | offset = stream->readInt32(&error); |
| 1330 | length = stream->readInt32(&error); |
| 1331 | } |
| 1332 |
| 1333 | void TL_messageEntityBlockquote_layer180::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1334 | offset = stream->readInt32(&error); |
| 1335 | length = stream->readInt32(&error); |
| 1336 | } |
| 1337 |
| 1338 | void TL_messageEntityBlockquote::serializeToStream(NativeByteBuffer *stream) { |
| 1339 | stream->writeInt32(constructor); |
| 1340 | stream->writeInt32(flags); |
| 1341 | stream->writeInt32(offset); |
| 1342 | stream->writeInt32(length); |
| 1343 | } |
| 1344 |
| 1345 | void TL_messageEntityBlockquote_layer180::serializeToStream(NativeByteBuffer *stream) { |
| 1346 | stream->writeInt32(constructor); |
| 1347 | stream->writeInt32(offset); |
| 1348 | stream->writeInt32(length); |
| 1349 | } |
| 1350 |
| 1351 | void TL_messageEntityUnderline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1352 | offset = stream->readInt32(&error); |
| 1353 | length = stream->readInt32(&error); |
| 1354 | } |
| 1355 |
| 1356 | void TL_messageEntityUnderline::serializeToStream(NativeByteBuffer *stream) { |
| 1357 | stream->writeInt32(constructor); |
| 1358 | stream->writeInt32(offset); |
| 1359 | stream->writeInt32(length); |
| 1360 | } |
| 1361 |
| 1362 | void TL_messageEntityPhone::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1363 | offset = stream->readInt32(&error); |
| 1364 | length = stream->readInt32(&error); |
| 1365 | } |
| 1366 |
| 1367 | void TL_messageEntityPhone::serializeToStream(NativeByteBuffer *stream) { |
| 1368 | stream->writeInt32(constructor); |
| 1369 | stream->writeInt32(offset); |
| 1370 | stream->writeInt32(length); |
| 1371 | } |
| 1372 |
| 1373 | TL_dataJSON *TL_dataJSON::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1374 | if (TL_dataJSON::constructor != constructor) { |
| 1375 | error = true; |
| 1376 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_dataJSON", constructor); |
| 1377 | return nullptr; |
| 1378 | } |
| 1379 | TL_dataJSON *result = new TL_dataJSON(); |
| 1380 | result->readParams(stream, instanceNum, error); |
| 1381 | return result; |
| 1382 | } |
| 1383 |
| 1384 | void TL_dataJSON::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1385 | data = stream->readString(&error); |
| 1386 | } |
| 1387 |
| 1388 | void TL_dataJSON::serializeToStream(NativeByteBuffer *stream) { |
| 1389 | stream->writeInt32(constructor); |
| 1390 | stream->writeString(data); |
| 1391 | } |
| 1392 |
| 1393 | TL_help_termsOfService *TL_help_termsOfService::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1394 | if (TL_help_termsOfService::constructor != constructor) { |
| 1395 | error = true; |
| 1396 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_help_termsOfService", constructor); |
| 1397 | return nullptr; |
| 1398 | } |
| 1399 | TL_help_termsOfService *result = new TL_help_termsOfService(); |
| 1400 | result->readParams(stream, instanceNum, error); |
| 1401 | return result; |
| 1402 | } |
| 1403 |
| 1404 | void TL_help_termsOfService::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1405 | flags = stream->readInt32(&error); |
| 1406 | popup = (flags & 1) != 0; |
| 1407 | id = std::unique_ptr<TL_dataJSON>(TL_dataJSON::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1408 | text = stream->readString(&error); |
| 1409 | int magic = stream->readInt32(&error); |
| 1410 | if (magic != 0x1cb5c415) { |
| 1411 | error = true; |
| 1412 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_help_termsOfService, got %x", magic); |
| 1413 | return; |
| 1414 | } |
| 1415 | int count = stream->readInt32(&error); |
| 1416 | for (int a = 0; a < count; a++) { |
| 1417 | MessageEntity *object = MessageEntity::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 1418 | if (object == nullptr) { |
| 1419 | return; |
| 1420 | } |
| 1421 | entities.push_back(std::unique_ptr<MessageEntity>(object)); |
| 1422 | } |
| 1423 | if ((flags & 2) != 0) { |
| 1424 | min_age_confirm = stream->readInt32(&error); |
| 1425 | } |
| 1426 | } |
| 1427 |
| 1428 | void TL_help_termsOfService::serializeToStream(NativeByteBuffer *stream) { |
| 1429 | stream->writeInt32(constructor); |
| 1430 | flags = popup ? (flags | 1) : (flags & ~1); |
| 1431 | stream->writeInt32(flags); |
| 1432 | id->serializeToStream(stream); |
| 1433 | stream->writeString(text); |
| 1434 | stream->writeInt32(0x1cb5c415); |
| 1435 | int32_t count = (int32_t) entities.size(); |
| 1436 | stream->writeInt32(count); |
| 1437 | for (int a = 0; a < count; a++) { |
| 1438 | entities[a]->serializeToStream(stream); |
| 1439 | } |
| 1440 | if ((flags & 2) != 0) { |
| 1441 | stream->writeInt32(min_age_confirm); |
| 1442 | } |
| 1443 | } |
| 1444 |
| 1445 | auth_Authorization *auth_Authorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1446 | auth_Authorization *result = nullptr; |
| 1447 | switch (constructor) { |
| 1448 | case 0x44747e9a: |
| 1449 | result = new TL_auth_authorizationSignUpRequired(); |
| 1450 | break; |
| 1451 | case 0x2ea2c0d4: |
| 1452 | result = new TL_auth_authorization(); |
| 1453 | break; |
| 1454 | default: |
| 1455 | error = true; |
| 1456 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in auth_Authorization", constructor); |
| 1457 | return nullptr; |
| 1458 | } |
| 1459 | result->readParams(stream, instanceNum, error); |
| 1460 | return result; |
| 1461 | } |
| 1462 |
| 1463 | void TL_auth_authorizationSignUpRequired::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1464 | flags = stream->readInt32(&error); |
| 1465 | if ((flags & 1) != 0) { |
| 1466 | terms_of_service = std::unique_ptr<TL_help_termsOfService>(TL_help_termsOfService::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1467 | } |
| 1468 | } |
| 1469 |
| 1470 | void TL_auth_authorizationSignUpRequired::serializeToStream(NativeByteBuffer *stream) { |
| 1471 | stream->writeInt32(constructor); |
| 1472 | stream->writeInt32(flags); |
| 1473 | if ((flags & 1) != 0) { |
| 1474 | terms_of_service->serializeToStream(stream); |
| 1475 | } |
| 1476 | } |
| 1477 |
| 1478 | void TL_auth_authorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1479 | flags = stream->readInt32(&error); |
| 1480 | if ((flags & 2) != 0) { |
| 1481 | otherwise_relogin_days = stream->readInt32(&error); |
| 1482 | } |
| 1483 | if ((flags & 1) != 0) { |
| 1484 | tmp_sessions = stream->readInt32(&error); |
| 1485 | } |
| 1486 | if ((flags & 4) != 0) { |
| 1487 | future_auth_token = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1488 | } |
| 1489 | user = std::unique_ptr<User>(User::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1490 | } |
| 1491 |
| 1492 | void TL_auth_authorization::serializeToStream(NativeByteBuffer *stream) { |
| 1493 | stream->writeInt32(constructor); |
| 1494 | stream->writeInt32(flags); |
| 1495 | if ((flags & 1) != 0) { |
| 1496 | stream->writeInt32(tmp_sessions); |
| 1497 | } |
| 1498 | user->serializeToStream(stream); |
| 1499 | } |
| 1500 |
| 1501 | TL_auth_exportedAuthorization *TL_auth_exportedAuthorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1502 | if (TL_auth_exportedAuthorization::constructor != constructor) { |
| 1503 | error = true; |
| 1504 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_auth_exportedAuthorization", constructor); |
| 1505 | return nullptr; |
| 1506 | } |
| 1507 | TL_auth_exportedAuthorization *result = new TL_auth_exportedAuthorization(); |
| 1508 | result->readParams(stream, instanceNum, error); |
| 1509 | return result; |
| 1510 | } |
| 1511 |
| 1512 | void TL_auth_exportedAuthorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1513 | id = stream->readInt64(&error); |
| 1514 | bytes = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1515 | } |
| 1516 |
| 1517 | bool TL_auth_exportAuthorization::isNeedLayer() { |
| 1518 | return true; |
| 1519 | } |
| 1520 |
| 1521 | TLObject *TL_auth_exportAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1522 | return TL_auth_exportedAuthorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 1523 | } |
| 1524 |
| 1525 | void TL_auth_exportAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 1526 | stream->writeInt32(constructor); |
| 1527 | stream->writeInt32(dc_id); |
| 1528 | } |
| 1529 |
| 1530 | bool TL_auth_importAuthorization::isNeedLayer() { |
| 1531 | return true; |
| 1532 | } |
| 1533 |
| 1534 | TLObject *TL_auth_importAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1535 | return auth_Authorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 1536 | } |
| 1537 |
| 1538 | void TL_auth_importAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 1539 | stream->writeInt32(constructor); |
| 1540 | stream->writeInt64(id); |
| 1541 | stream->writeByteArray(bytes.get()); |
| 1542 | } |
| 1543 |
| 1544 | UserStatus *UserStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1545 | UserStatus *result = nullptr; |
| 1546 | switch (constructor) { |
| 1547 | case 0x8c703f: |
| 1548 | result = new TL_userStatusOffline(); |
| 1549 | break; |
| 1550 | case 0x9d05049: |
| 1551 | result = new TL_userStatusEmpty(); |
| 1552 | break; |
| 1553 | case 0xedb93949: |
| 1554 | result = new TL_userStatusOnline(); |
| 1555 | break; |
| 1556 | case 0x7b197dc8: |
| 1557 | result = new TL_userStatusRecently(); |
| 1558 | break; |
| 1559 | case 0x541a1d1a: |
| 1560 | result = new TL_userStatusLastWeek(); |
| 1561 | break; |
| 1562 | case 0x65899777: |
| 1563 | result = new TL_userStatusLastMonth(); |
| 1564 | break; |
| 1565 | case 0xe26f42f1: |
| 1566 | result = new TL_userStatusRecently_layer171(); |
| 1567 | break; |
| 1568 | case 0x7bf09fc: |
| 1569 | result = new TL_userStatusLastWeek_layer171(); |
| 1570 | break; |
| 1571 | case 0x77ebc742: |
| 1572 | result = new TL_userStatusLastMonth_layer171(); |
| 1573 | break; |
| 1574 | default: |
| 1575 | error = true; |
| 1576 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in UserStatus", constructor); |
| 1577 | return nullptr; |
| 1578 | } |
| 1579 | result->readParams(stream, instanceNum, error); |
| 1580 | return result; |
| 1581 | } |
| 1582 |
| 1583 | void TL_userStatusOffline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1584 | expires = stream->readInt32(&error); |
| 1585 | } |
| 1586 |
| 1587 | void TL_userStatusOffline::serializeToStream(NativeByteBuffer *stream) { |
| 1588 | stream->writeInt32(constructor); |
| 1589 | stream->writeInt32(expires); |
| 1590 | } |
| 1591 |
| 1592 | void TL_userStatusLastWeek_layer171::serializeToStream(NativeByteBuffer *stream) { |
| 1593 | stream->writeInt32(constructor); |
| 1594 | } |
| 1595 |
| 1596 | void TL_userStatusLastWeek::serializeToStream(NativeByteBuffer *stream) { |
| 1597 | stream->writeInt32(constructor); |
| 1598 | flags = by_me ? flags | 1 : flags &~ 1; |
| 1599 | stream->writeInt32(flags); |
| 1600 | } |
| 1601 |
| 1602 | void TL_userStatusLastWeek::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1603 | flags = stream->readInt32(&error); |
| 1604 | by_me = (flags & 1) != 0; |
| 1605 | } |
| 1606 |
| 1607 | void TL_userStatusEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1608 | stream->writeInt32(constructor); |
| 1609 | } |
| 1610 |
| 1611 | void TL_userStatusLastMonth::serializeToStream(NativeByteBuffer *stream) { |
| 1612 | stream->writeInt32(constructor); |
| 1613 | flags = by_me ? flags | 1 : flags &~ 1; |
| 1614 | stream->writeInt32(flags); |
| 1615 | } |
| 1616 |
| 1617 | void TL_userStatusLastMonth::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1618 | flags = stream->readInt32(&error); |
| 1619 | by_me = (flags & 1) != 0; |
| 1620 | } |
| 1621 |
| 1622 | void TL_userStatusLastMonth_layer171::serializeToStream(NativeByteBuffer *stream) { |
| 1623 | stream->writeInt32(constructor); |
| 1624 | } |
| 1625 |
| 1626 | void TL_userStatusOnline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1627 | expires = stream->readInt32(&error); |
| 1628 | } |
| 1629 |
| 1630 | void TL_userStatusOnline::serializeToStream(NativeByteBuffer *stream) { |
| 1631 | stream->writeInt32(constructor); |
| 1632 | stream->writeInt32(expires); |
| 1633 | } |
| 1634 |
| 1635 | void TL_userStatusRecently::serializeToStream(NativeByteBuffer *stream) { |
| 1636 | stream->writeInt32(constructor); |
| 1637 | flags = by_me ? flags | 1 : flags &~ 1; |
| 1638 | stream->writeInt32(flags); |
| 1639 | } |
| 1640 |
| 1641 | void TL_userStatusRecently::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1642 | flags = stream->readInt32(&error); |
| 1643 | by_me = (flags & 1) != 0; |
| 1644 | } |
| 1645 |
| 1646 | void TL_userStatusRecently_layer171::serializeToStream(NativeByteBuffer *stream) { |
| 1647 | stream->writeInt32(constructor); |
| 1648 | } |
| 1649 |
| 1650 | void TL_userStatusHidden::serializeToStream(NativeByteBuffer *stream) { |
| 1651 | stream->writeInt32(constructor); |
| 1652 | } |
| 1653 |
| 1654 | FileLocation *FileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1655 | FileLocation *result = nullptr; |
| 1656 | switch (constructor) { |
| 1657 | case 0xbc7fc6cd: |
| 1658 | result = new TL_fileLocationToBeDeprecated(); |
| 1659 | break; |
| 1660 | default: |
| 1661 | error = true; |
| 1662 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in FileLocation", constructor); |
| 1663 | return nullptr; |
| 1664 | } |
| 1665 | result->readParams(stream, instanceNum, error); |
| 1666 | return result; |
| 1667 | } |
| 1668 |
| 1669 | void TL_fileLocationToBeDeprecated::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1670 | volume_id = stream->readInt64(&error); |
| 1671 | local_id = stream->readInt32(&error); |
| 1672 | } |
| 1673 |
| 1674 | void TL_fileLocationToBeDeprecated::serializeToStream(NativeByteBuffer *stream) { |
| 1675 | stream->writeInt32(constructor); |
| 1676 | stream->writeInt64(volume_id); |
| 1677 | stream->writeInt32(local_id); |
| 1678 | } |
| 1679 |
| 1680 | UserProfilePhoto *UserProfilePhoto::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1681 | UserProfilePhoto *result = nullptr; |
| 1682 | switch (constructor) { |
| 1683 | case 0x4f11bae1: |
| 1684 | result = new TL_userProfilePhotoEmpty(); |
| 1685 | break; |
| 1686 | case 0x82d1f706: |
| 1687 | result = new TL_userProfilePhoto(); |
| 1688 | break; |
| 1689 | default: |
| 1690 | error = true; |
| 1691 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in UserProfilePhoto", constructor); |
| 1692 | return nullptr; |
| 1693 | } |
| 1694 | result->readParams(stream, instanceNum, error); |
| 1695 | return result; |
| 1696 | } |
| 1697 |
| 1698 | void TL_userProfilePhotoEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1699 | stream->writeInt32(constructor); |
| 1700 | } |
| 1701 |
| 1702 | void TL_userProfilePhoto::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1703 | flags = stream->readInt32(&error); |
| 1704 | has_video = (flags & 1) != 0; |
| 1705 | photo_id = stream->readInt64(&error); |
| 1706 | if ((flags & 2) != 0) { |
| 1707 | stripped_thumb = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1708 | } |
| 1709 | dc_id = stream->readInt32(&error); |
| 1710 | } |
| 1711 |
| 1712 | void TL_userProfilePhoto::serializeToStream(NativeByteBuffer *stream) { |
| 1713 | stream->writeInt32(constructor); |
| 1714 | flags = has_video ? (flags | 1) : (flags &~ 1); |
| 1715 | stream->writeInt32(flags); |
| 1716 | stream->writeInt64(photo_id); |
| 1717 | if ((flags & 2) != 0) { |
| 1718 | stream->writeByteArray(stripped_thumb.get()); |
| 1719 | } |
| 1720 | stream->writeInt32(dc_id); |
| 1721 | } |
| 1722 |
| 1723 | void TL_updatesTooLong::serializeToStream(NativeByteBuffer *stream) { |
| 1724 | stream->writeInt32(constructor); |
| 1725 | } |
| 1726 |
| 1727 | Reaction *Reaction::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1728 | Reaction *result = nullptr; |
| 1729 | switch (constructor) { |
| 1730 | case 0x79f5d419: |
| 1731 | result = new TL_reactionEmpty(); |
| 1732 | break; |
| 1733 | case 0x8935fc73: |
| 1734 | result = new TL_reactionCustomEmoji(); |
| 1735 | break; |
| 1736 | case 0x1b2286b8: |
| 1737 | result = new TL_reactionEmoji(); |
| 1738 | break; |
| 1739 | default: |
| 1740 | error = true; |
| 1741 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in Reaction", constructor); |
| 1742 | return nullptr; |
| 1743 | } |
| 1744 | result->readParams(stream, instanceNum, error); |
| 1745 | return result; |
| 1746 | } |
| 1747 |
| 1748 | void TL_reactionEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1749 |
| 1750 | } |
| 1751 |
| 1752 | void TL_reactionEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1753 | stream->writeInt32(constructor); |
| 1754 | } |
| 1755 |
| 1756 | void TL_reactionCustomEmoji::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1757 | document_id = stream->readInt64(&error); |
| 1758 | } |
| 1759 |
| 1760 | void TL_reactionCustomEmoji::serializeToStream(NativeByteBuffer *stream) { |
| 1761 | stream->writeInt32(constructor); |
| 1762 | stream->writeInt64(document_id); |
| 1763 | } |
| 1764 |
| 1765 | void TL_reactionEmoji::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1766 | emoticon = stream->readString(&error); |
| 1767 | } |
| 1768 |
| 1769 | void TL_reactionEmoji::serializeToStream(NativeByteBuffer *stream) { |
| 1770 | stream->writeInt32(constructor); |
| 1771 | stream->writeString(emoticon); |
| 1772 | } |
| 1773 |
| 1774 |
| 1775 |