| 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 | PeerColor *PeerColor::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 392 | PeerColor *result = nullptr; |
| 393 | switch (constructor) { |
| 394 | case TL_peerColor::constructor: |
| 395 | result = new TL_peerColor(); |
| 396 | break; |
| 397 | case TL_peerColorCollectible::constructor: |
| 398 | result = new TL_peerColorCollectible(); |
| 399 | break; |
| 400 | default: |
| 401 | error = true; |
| 402 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in PeerColor", constructor); |
| 403 | return nullptr; |
| 404 | } |
| 405 | result->readParams(stream, instanceNum, error); |
| 406 | return result; |
| 407 | } |
| 408 |
| 409 | void TL_restrictionReason::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 410 | platform = stream->readString(&error); |
| 411 | reason = stream->readString(&error); |
| 412 | text = stream->readString(&error); |
| 413 | } |
| 414 |
| 415 | void TL_restrictionReason::serializeToStream(NativeByteBuffer *stream) { |
| 416 | stream->writeInt32(constructor); |
| 417 | stream->writeString(platform); |
| 418 | stream->writeString(reason); |
| 419 | stream->writeString(text); |
| 420 | } |
| 421 |
| 422 | void TL_recentStory::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 423 | flags = stream->readInt32(&error); |
| 424 | is_live = (flags & 1) != 0; |
| 425 | if ((flags & 2) != 0) { |
| 426 | max_id = stream->readInt32(&error); |
| 427 | } |
| 428 | } |
| 429 |
| 430 | void TL_recentStory::serializeToStream(NativeByteBuffer *stream) { |
| 431 | stream->writeInt32(constructor); |
| 432 | flags = is_live ? flags | 1 : flags &~ 1; |
| 433 | stream->writeInt32(flags); |
| 434 | if ((flags & 2) != 0) { |
| 435 | stream->writeInt32(max_id); |
| 436 | } |
| 437 | } |
| 438 |
| 439 | void TL_username::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 440 | flags = stream->readInt32(&error); |
| 441 | editable = (flags & 1) != 0; |
| 442 | active = (flags & 2) != 0; |
| 443 | username = stream->readString(&error); |
| 444 | } |
| 445 |
| 446 | void TL_username::serializeToStream(NativeByteBuffer *stream) { |
| 447 | stream->writeInt32(constructor); |
| 448 | flags = editable ? (flags | 1) : (flags &~ 1); |
| 449 | flags = active ? (flags | 2) : (flags &~ 2); |
| 450 | stream->writeInt32(flags); |
| 451 | stream->writeString(username); |
| 452 | } |
| 453 |
| 454 | void TL_peerColor::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 455 | flags = stream->readInt32(&error); |
| 456 | if ((flags & 1) != 0) { |
| 457 | color = stream->readInt32(&error); |
| 458 | } |
| 459 | if ((flags & 2) != 0) { |
| 460 | background_emoji_id = stream->readInt64(&error); |
| 461 | } |
| 462 | } |
| 463 |
| 464 | void TL_peerColor::serializeToStream(NativeByteBuffer *stream) { |
| 465 | stream->writeInt32(constructor); |
| 466 | stream->writeInt32(flags); |
| 467 | if ((flags & 1) != 0) { |
| 468 | stream->writeInt32(color); |
| 469 | } |
| 470 | if ((flags & 2) != 0) { |
| 471 | stream->writeInt64(background_emoji_id); |
| 472 | } |
| 473 | } |
| 474 |
| 475 | void TL_peerColorCollectible::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 476 | flags = stream->readInt32(&error); |
| 477 | collectible_id = stream->readInt64(&error); |
| 478 | gift_emoji_id = stream->readInt64(&error); |
| 479 | background_emoji_id = stream->readInt64(&error); |
| 480 | accent_color = stream->readInt32(&error); |
| 481 | { |
| 482 | uint32_t magic = stream->readUint32(&error); |
| 483 | if (magic != 0x1cb5c415) { |
| 484 | error = true; |
| 485 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_peerColorCollectible, got %x", magic); |
| 486 | return; |
| 487 | } |
| 488 | int32_t count = stream->readInt32(&error); |
| 489 | colors.clear(); |
| 490 | for (int32_t a = 0; a < count; a++) { |
| 491 | colors.push_back(stream->readInt32(&error)); |
| 492 | } |
| 493 | } |
| 494 | if ((flags & 1) != 0) { |
| 495 | dark_accent_color = stream->readInt32(&error); |
| 496 | } |
| 497 | if ((flags & 2) != 0) { |
| 498 | uint32_t magic = stream->readUint32(&error); |
| 499 | if (magic != 0x1cb5c415) { |
| 500 | error = true; |
| 501 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_peerColorCollectible, got %x", magic); |
| 502 | return; |
| 503 | } |
| 504 | int32_t count = stream->readInt32(&error); |
| 505 | dark_colors.clear(); |
| 506 | for (int32_t a = 0; a < count; a++) { |
| 507 | dark_colors.push_back(stream->readInt32(&error)); |
| 508 | } |
| 509 | } |
| 510 | } |
| 511 |
| 512 | void TL_peerColorCollectible::serializeToStream(NativeByteBuffer *stream) { |
| 513 | stream->writeInt32(constructor); |
| 514 | stream->writeInt32(flags); |
| 515 | stream->writeInt64(collectible_id); |
| 516 | stream->writeInt64(gift_emoji_id); |
| 517 | stream->writeInt64(background_emoji_id); |
| 518 | stream->writeInt32(accent_color); |
| 519 | stream->writeInt32(0x1cb5c415); |
| 520 | stream->writeInt32(colors.size()); |
| 521 | for (int32_t x : colors) { |
| 522 | stream->writeInt32(x); |
| 523 | } |
| 524 | if ((flags & 1) != 0) { |
| 525 | stream->writeInt32(dark_accent_color); |
| 526 | } |
| 527 | if ((flags & 2) != 0) { |
| 528 | stream->writeInt32(0x1cb5c415); |
| 529 | stream->writeInt32(dark_colors.size()); |
| 530 | for (int32_t x: dark_colors) { |
| 531 | stream->writeInt32(x); |
| 532 | } |
| 533 | } |
| 534 | } |
| 535 |
| 536 | EmojiStatus *EmojiStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 537 | EmojiStatus *result = nullptr; |
| 538 | switch (constructor) { |
| 539 | case TL_emojiStatusEmpty::constructor: |
| 540 | result = new TL_emojiStatusEmpty(); |
| 541 | break; |
| 542 | case TL_emojiStatus::constructor: |
| 543 | result = new TL_emojiStatus(); |
| 544 | break; |
| 545 | case TL_emojiStatusCollectible::constructor: |
| 546 | result = new TL_emojiStatusCollectible(); |
| 547 | break; |
| 548 | case TL_inputEmojiStatusCollectible::constructor: |
| 549 | result = new TL_inputEmojiStatusCollectible(); |
| 550 | break; |
| 551 | case TL_emojiStatus_layer197::constructor: |
| 552 | result = new TL_emojiStatus_layer197(); |
| 553 | break; |
| 554 | case TL_emojiStatusUntil_layer197::constructor: |
| 555 | result = new TL_emojiStatusUntil_layer197(); |
| 556 | break; |
| 557 | default: |
| 558 | error = true; |
| 559 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in EmojiStatus", constructor); |
| 560 | return nullptr; |
| 561 | } |
| 562 | result->readParams(stream, instanceNum, error); |
| 563 | return result; |
| 564 | } |
| 565 |
| 566 | void TL_emojiStatusEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 567 |
| 568 | } |
| 569 |
| 570 | void TL_emojiStatusEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 571 | stream->writeInt32(constructor); |
| 572 | } |
| 573 |
| 574 | void TL_emojiStatus::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 575 | flags = stream->readInt32(&error); |
| 576 | document_id = stream->readInt64(&error); |
| 577 | if ((flags & 1) != 0) { |
| 578 | until = stream->readInt32(&error); |
| 579 | } |
| 580 | } |
| 581 |
| 582 | void TL_emojiStatus::serializeToStream(NativeByteBuffer *stream) { |
| 583 | stream->writeInt32(constructor); |
| 584 | stream->writeInt32(flags); |
| 585 | stream->writeInt64(document_id); |
| 586 | if ((flags & 1) != 0) { |
| 587 | stream->writeInt32(until); |
| 588 | } |
| 589 | } |
| 590 |
| 591 | void TL_emojiStatus_layer197::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 592 | document_id = stream->readInt64(&error); |
| 593 | } |
| 594 |
| 595 | void TL_emojiStatus_layer197::serializeToStream(NativeByteBuffer *stream) { |
| 596 | stream->writeInt32(constructor); |
| 597 | stream->writeInt64(document_id); |
| 598 | } |
| 599 |
| 600 | void TL_emojiStatusUntil_layer197::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 601 | document_id = stream->readInt64(&error); |
| 602 | until = stream->readInt32(&error); |
| 603 | } |
| 604 |
| 605 | void TL_emojiStatusUntil_layer197::serializeToStream(NativeByteBuffer *stream) { |
| 606 | stream->writeInt32(constructor); |
| 607 | stream->writeInt64(document_id); |
| 608 | stream->writeInt32(until); |
| 609 | } |
| 610 |
| 611 | void TL_emojiStatusCollectible::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 612 | flags = stream->readInt32(&error); |
| 613 | collectible_id = stream->readInt64(&error); |
| 614 | document_id = stream->readInt64(&error); |
| 615 | title = stream->readString(&error); |
| 616 | slug = stream->readString(&error); |
| 617 | pattern_document_id = stream->readInt64(&error); |
| 618 | center_color = stream->readInt32(&error); |
| 619 | edge_color = stream->readInt32(&error); |
| 620 | pattern_color = stream->readInt32(&error); |
| 621 | text_color = stream->readInt32(&error); |
| 622 | if ((flags & 1) != 0) { |
| 623 | until = stream->readInt32(&error); |
| 624 | } |
| 625 | } |
| 626 |
| 627 | void TL_emojiStatusCollectible::serializeToStream(NativeByteBuffer *stream) { |
| 628 | stream->writeInt32(constructor); |
| 629 | stream->writeInt32(flags); |
| 630 | stream->writeInt64(collectible_id); |
| 631 | stream->writeInt64(document_id); |
| 632 | stream->writeString(title); |
| 633 | stream->writeString(slug); |
| 634 | stream->writeInt64(pattern_document_id); |
| 635 | stream->writeInt32(center_color); |
| 636 | stream->writeInt32(edge_color); |
| 637 | stream->writeInt32(pattern_color); |
| 638 | stream->writeInt32(text_color); |
| 639 | if ((flags & 1) != 0) { |
| 640 | stream->writeInt32(until); |
| 641 | } |
| 642 | } |
| 643 |
| 644 |
| 645 | void TL_inputEmojiStatusCollectible::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 646 | flags = stream->readInt32(&error); |
| 647 | collectible_id = stream->readInt64(&error); |
| 648 | if ((flags & 1) != 0) { |
| 649 | until = stream->readInt32(&error); |
| 650 | } |
| 651 | } |
| 652 |
| 653 | void TL_inputEmojiStatusCollectible::serializeToStream(NativeByteBuffer *stream) { |
| 654 | stream->writeInt32(constructor); |
| 655 | stream->writeInt32(flags); |
| 656 | stream->writeInt64(collectible_id); |
| 657 | if ((flags & 1) != 0) { |
| 658 | stream->writeInt32(until); |
| 659 | } |
| 660 | } |
| 661 |
| 662 | User *User::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 663 | User *result = nullptr; |
| 664 | switch (constructor) { |
| 665 | case TL_userEmpty::constructor: |
| 666 | result = new TL_userEmpty(); |
| 667 | break; |
| 668 | case TL_user::constructor: |
| 669 | result = new TL_user(); |
| 670 | break; |
| 671 | case TL_user_layer227::constructor: |
| 672 | result = new TL_user_layer227(); |
| 673 | break; |
| 674 | case TL_user_layer216::constructor: |
| 675 | result = new TL_user_layer216(); |
| 676 | break; |
| 677 | default: |
| 678 | error = true; |
| 679 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in User", constructor); |
| 680 | return nullptr; |
| 681 | } |
| 682 | result->readParams(stream, instanceNum, error); |
| 683 | return result; |
| 684 | } |
| 685 |
| 686 | void TL_userEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 687 | id = stream->readInt64(&error); |
| 688 | } |
| 689 |
| 690 | void TL_userEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 691 | stream->writeInt32(constructor); |
| 692 | stream->writeInt64(id); |
| 693 | } |
| 694 |
| 695 | void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 696 | flags = stream->readInt32(&error); |
| 697 | flags2 = stream->readInt32(&error); |
| 698 | id = stream->readInt64(&error); |
| 699 | if ((flags & 1) != 0) { |
| 700 | access_hash = stream->readInt64(&error); |
| 701 | } |
| 702 | if ((flags & 2) != 0) { |
| 703 | first_name = stream->readString(&error); |
| 704 | } |
| 705 | if ((flags & 4) != 0) { |
| 706 | last_name = stream->readString(&error); |
| 707 | } |
| 708 | if ((flags & 8) != 0) { |
| 709 | username = stream->readString(&error); |
| 710 | } |
| 711 | if ((flags & 16) != 0) { |
| 712 | phone = stream->readString(&error); |
| 713 | } |
| 714 | if ((flags & 32) != 0) { |
| 715 | photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 716 | } |
| 717 | if ((flags & 64) != 0) { |
| 718 | status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 719 | } |
| 720 | if ((flags & 16384) != 0) { |
| 721 | bot_info_version = stream->readInt32(&error); |
| 722 | } |
| 723 | if ((flags & 262144) != 0) { |
| 724 | uint32_t magic = stream->readUint32(&error); |
| 725 | if (magic != 0x1cb5c415) { |
| 726 | error = true; |
| 727 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user, got %x", magic); |
| 728 | return; |
| 729 | } |
| 730 | int32_t count = stream->readInt32(&error); |
| 731 | for (int32_t a = 0; a < count; a++) { |
| 732 | TL_restrictionReason *object = TL_restrictionReason::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 733 | if (object == nullptr) { |
| 734 | return; |
| 735 | } |
| 736 | restriction_reason.push_back(std::unique_ptr<TL_restrictionReason>(object)); |
| 737 | } |
| 738 | } |
| 739 | if ((flags & 524288) != 0) { |
| 740 | bot_inline_placeholder = stream->readString(&error); |
| 741 | } |
| 742 | if ((flags & 4194304) != 0) { |
| 743 | lang_code = stream->readString(&error); |
| 744 | } |
| 745 | if ((flags & 1073741824) != 0) { |
| 746 | emoji_status = std::unique_ptr<EmojiStatus>(EmojiStatus::TLdeserialize(stream, stream->readInt32(&error), instanceNum, error)); |
| 747 | } |
| 748 | if ((flags2 & 1) != 0) { |
| 749 | uint32_t magic = stream->readUint32(&error); |
| 750 | if (magic != 0x1cb5c415) { |
| 751 | error = true; |
| 752 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user (2), got %x", magic); |
| 753 | return; |
| 754 | } |
| 755 | int32_t count = stream->readInt32(&error); |
| 756 | for (int32_t a = 0; a < count; a++) { |
| 757 | TL_username *object = TL_username::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 758 | if (object == nullptr) { |
| 759 | return; |
| 760 | } |
| 761 | usernames.push_back(std::unique_ptr<TL_username>(object)); |
| 762 | } |
| 763 | } |
| 764 | if ((flags2 & 32) != 0) { |
| 765 | stories_max_id = std::unique_ptr<TL_recentStory>(TL_recentStory::TLdeserialize(stream, stream->readInt32(&error), instanceNum, error)); |
| 766 | } |
| 767 | if ((flags2 & 256) != 0) { |
| 768 | color = std::unique_ptr<PeerColor>(PeerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 769 | } |
| 770 | if ((flags2 & 512) != 0) { |
| 771 | profile_color = std::unique_ptr<PeerColor>(PeerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 772 | } |
| 773 | if ((flags2 & 4096) != 0) { |
| 774 | bot_active_users = stream->readInt32(&error); |
| 775 | } |
| 776 | if ((flags2 & 16384) != 0) { |
| 777 | bot_verification_icon = stream->readInt64(&error); |
| 778 | } |
| 779 | if ((flags2 & 32768) != 0) { |
| 780 | send_paid_messages_stars = stream->readInt64(&error); |
| 781 | } |
| 782 | if ((flags2 & 2097152) != 0) { |
| 783 | linked_community_id = stream->readInt64(&error); |
| 784 | } |
| 785 | } |
| 786 |
| 787 | void TL_user::serializeToStream(NativeByteBuffer *stream) { |
| 788 | stream->writeInt32(constructor); |
| 789 | stream->writeInt32(flags); |
| 790 | stream->writeInt32(flags2); |
| 791 | stream->writeInt64(id); |
| 792 | if ((flags & 1) != 0) { |
| 793 | stream->writeInt64(access_hash); |
| 794 | } |
| 795 | if ((flags & 2) != 0) { |
| 796 | stream->writeString(first_name); |
| 797 | } |
| 798 | if ((flags & 4) != 0) { |
| 799 | stream->writeString(last_name); |
| 800 | } |
| 801 | if ((flags & 8) != 0) { |
| 802 | stream->writeString(username); |
| 803 | } |
| 804 | if ((flags & 16) != 0) { |
| 805 | stream->writeString(phone); |
| 806 | } |
| 807 | if ((flags & 32) != 0) { |
| 808 | photo->serializeToStream(stream); |
| 809 | } |
| 810 | if ((flags & 64) != 0) { |
| 811 | status->serializeToStream(stream); |
| 812 | } |
| 813 | if ((flags & 16384) != 0) { |
| 814 | stream->writeInt32(bot_info_version); |
| 815 | } |
| 816 | if ((flags & 262144) != 0) { |
| 817 | stream->writeInt32(0x1cb5c415); |
| 818 | uint32_t count = (uint32_t) restriction_reason.size(); |
| 819 | stream->writeInt32(count); |
| 820 | for (int a = 0; a < count; a++) { |
| 821 | restriction_reason[a]->serializeToStream(stream); |
| 822 | } |
| 823 | } |
| 824 | if ((flags & 524288) != 0) { |
| 825 | stream->writeString(bot_inline_placeholder); |
| 826 | } |
| 827 | if ((flags & 4194304) != 0) { |
| 828 | stream->writeString(lang_code); |
| 829 | } |
| 830 | if ((flags & 1073741824) != 0) { |
| 831 | emoji_status->serializeToStream(stream); |
| 832 | } |
| 833 | if ((flags2 & 1) != 0) { |
| 834 | stream->writeInt32(0x1cb5c415); |
| 835 | int32_t count = (int32_t) usernames.size(); |
| 836 | stream->writeInt32(count); |
| 837 | for (int a = 0; a < count; a++) { |
| 838 | usernames[a]->serializeToStream(stream); |
| 839 | } |
| 840 | } |
| 841 | if ((flags2 & 32) != 0) { |
| 842 | stories_max_id->serializeToStream(stream); |
| 843 | } |
| 844 | if ((flags2 & 256) != 0) { |
| 845 | color->serializeToStream(stream); |
| 846 | } |
| 847 | if ((flags2 & 512) != 0) { |
| 848 | profile_color->serializeToStream(stream); |
| 849 | } |
| 850 | if ((flags2 & 4096) != 0) { |
| 851 | stream->writeInt32(bot_active_users); |
| 852 | } |
| 853 | if ((flags2 & 16384) != 0) { |
| 854 | stream->writeInt64(bot_verification_icon); |
| 855 | } |
| 856 | if ((flags2 & 32768) != 0) { |
| 857 | stream->writeInt64(send_paid_messages_stars); |
| 858 | } |
| 859 | if ((flags2 & 2097152) != 0) { |
| 860 | stream->writeInt64(linked_community_id); |
| 861 | } |
| 862 | } |
| 863 |
| 864 | void TL_user_layer227::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 865 | flags = stream->readInt32(&error); |
| 866 | flags2 = stream->readInt32(&error); |
| 867 | id = stream->readInt64(&error); |
| 868 | if ((flags & 1) != 0) { |
| 869 | access_hash = stream->readInt64(&error); |
| 870 | } |
| 871 | if ((flags & 2) != 0) { |
| 872 | first_name = stream->readString(&error); |
| 873 | } |
| 874 | if ((flags & 4) != 0) { |
| 875 | last_name = stream->readString(&error); |
| 876 | } |
| 877 | if ((flags & 8) != 0) { |
| 878 | username = stream->readString(&error); |
| 879 | } |
| 880 | if ((flags & 16) != 0) { |
| 881 | phone = stream->readString(&error); |
| 882 | } |
| 883 | if ((flags & 32) != 0) { |
| 884 | photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 885 | } |
| 886 | if ((flags & 64) != 0) { |
| 887 | status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 888 | } |
| 889 | if ((flags & 16384) != 0) { |
| 890 | bot_info_version = stream->readInt32(&error); |
| 891 | } |
| 892 | if ((flags & 262144) != 0) { |
| 893 | uint32_t magic = stream->readUint32(&error); |
| 894 | if (magic != 0x1cb5c415) { |
| 895 | error = true; |
| 896 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user, got %x", magic); |
| 897 | return; |
| 898 | } |
| 899 | int32_t count = stream->readInt32(&error); |
| 900 | for (int32_t a = 0; a < count; a++) { |
| 901 | TL_restrictionReason *object = TL_restrictionReason::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 902 | if (object == nullptr) { |
| 903 | return; |
| 904 | } |
| 905 | restriction_reason.push_back(std::unique_ptr<TL_restrictionReason>(object)); |
| 906 | } |
| 907 | } |
| 908 | if ((flags & 524288) != 0) { |
| 909 | bot_inline_placeholder = stream->readString(&error); |
| 910 | } |
| 911 | if ((flags & 4194304) != 0) { |
| 912 | lang_code = stream->readString(&error); |
| 913 | } |
| 914 | if ((flags & 1073741824) != 0) { |
| 915 | emoji_status = std::unique_ptr<EmojiStatus>(EmojiStatus::TLdeserialize(stream, stream->readInt32(&error), instanceNum, error)); |
| 916 | } |
| 917 | if ((flags2 & 1) != 0) { |
| 918 | uint32_t magic = stream->readUint32(&error); |
| 919 | if (magic != 0x1cb5c415) { |
| 920 | error = true; |
| 921 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user (2), got %x", magic); |
| 922 | return; |
| 923 | } |
| 924 | int32_t count = stream->readInt32(&error); |
| 925 | for (int32_t a = 0; a < count; a++) { |
| 926 | TL_username *object = TL_username::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 927 | if (object == nullptr) { |
| 928 | return; |
| 929 | } |
| 930 | usernames.push_back(std::unique_ptr<TL_username>(object)); |
| 931 | } |
| 932 | } |
| 933 | if ((flags2 & 32) != 0) { |
| 934 | stories_max_id = std::unique_ptr<TL_recentStory>(TL_recentStory::TLdeserialize(stream, stream->readInt32(&error), instanceNum, error)); |
| 935 | } |
| 936 | if ((flags2 & 256) != 0) { |
| 937 | color = std::unique_ptr<PeerColor>(PeerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 938 | } |
| 939 | if ((flags2 & 512) != 0) { |
| 940 | profile_color = std::unique_ptr<PeerColor>(PeerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 941 | } |
| 942 | if ((flags2 & 4096) != 0) { |
| 943 | bot_active_users = stream->readInt32(&error); |
| 944 | } |
| 945 | if ((flags2 & 16384) != 0) { |
| 946 | bot_verification_icon = stream->readInt64(&error); |
| 947 | } |
| 948 | if ((flags2 & 32768) != 0) { |
| 949 | send_paid_messages_stars = stream->readInt64(&error); |
| 950 | } |
| 951 | } |
| 952 |
| 953 | void TL_user_layer227::serializeToStream(NativeByteBuffer *stream) { |
| 954 | stream->writeInt32(constructor); |
| 955 | stream->writeInt32(flags); |
| 956 | stream->writeInt32(flags2); |
| 957 | stream->writeInt64(id); |
| 958 | if ((flags & 1) != 0) { |
| 959 | stream->writeInt64(access_hash); |
| 960 | } |
| 961 | if ((flags & 2) != 0) { |
| 962 | stream->writeString(first_name); |
| 963 | } |
| 964 | if ((flags & 4) != 0) { |
| 965 | stream->writeString(last_name); |
| 966 | } |
| 967 | if ((flags & 8) != 0) { |
| 968 | stream->writeString(username); |
| 969 | } |
| 970 | if ((flags & 16) != 0) { |
| 971 | stream->writeString(phone); |
| 972 | } |
| 973 | if ((flags & 32) != 0) { |
| 974 | photo->serializeToStream(stream); |
| 975 | } |
| 976 | if ((flags & 64) != 0) { |
| 977 | status->serializeToStream(stream); |
| 978 | } |
| 979 | if ((flags & 16384) != 0) { |
| 980 | stream->writeInt32(bot_info_version); |
| 981 | } |
| 982 | if ((flags & 262144) != 0) { |
| 983 | stream->writeInt32(0x1cb5c415); |
| 984 | uint32_t count = (uint32_t) restriction_reason.size(); |
| 985 | stream->writeInt32(count); |
| 986 | for (int a = 0; a < count; a++) { |
| 987 | restriction_reason[a]->serializeToStream(stream); |
| 988 | } |
| 989 | } |
| 990 | if ((flags & 524288) != 0) { |
| 991 | stream->writeString(bot_inline_placeholder); |
| 992 | } |
| 993 | if ((flags & 4194304) != 0) { |
| 994 | stream->writeString(lang_code); |
| 995 | } |
| 996 | if ((flags & 1073741824) != 0) { |
| 997 | emoji_status->serializeToStream(stream); |
| 998 | } |
| 999 | if ((flags2 & 1) != 0) { |
| 1000 | stream->writeInt32(0x1cb5c415); |
| 1001 | int32_t count = (int32_t) usernames.size(); |
| 1002 | stream->writeInt32(count); |
| 1003 | for (int a = 0; a < count; a++) { |
| 1004 | usernames[a]->serializeToStream(stream); |
| 1005 | } |
| 1006 | } |
| 1007 | if ((flags2 & 32) != 0) { |
| 1008 | stories_max_id->serializeToStream(stream); |
| 1009 | } |
| 1010 | if ((flags2 & 256) != 0) { |
| 1011 | color->serializeToStream(stream); |
| 1012 | } |
| 1013 | if ((flags2 & 512) != 0) { |
| 1014 | profile_color->serializeToStream(stream); |
| 1015 | } |
| 1016 | if ((flags2 & 4096) != 0) { |
| 1017 | stream->writeInt32(bot_active_users); |
| 1018 | } |
| 1019 | if ((flags2 & 16384) != 0) { |
| 1020 | stream->writeInt64(bot_verification_icon); |
| 1021 | } |
| 1022 | if ((flags2 & 32768) != 0) { |
| 1023 | stream->writeInt64(send_paid_messages_stars); |
| 1024 | } |
| 1025 | } |
| 1026 |
| 1027 | void TL_user_layer216::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1028 | flags = stream->readInt32(&error); |
| 1029 | flags2 = stream->readInt32(&error); |
| 1030 | id = stream->readInt64(&error); |
| 1031 | if ((flags & 1) != 0) { |
| 1032 | access_hash = stream->readInt64(&error); |
| 1033 | } |
| 1034 | if ((flags & 2) != 0) { |
| 1035 | first_name = stream->readString(&error); |
| 1036 | } |
| 1037 | if ((flags & 4) != 0) { |
| 1038 | last_name = stream->readString(&error); |
| 1039 | } |
| 1040 | if ((flags & 8) != 0) { |
| 1041 | username = stream->readString(&error); |
| 1042 | } |
| 1043 | if ((flags & 16) != 0) { |
| 1044 | phone = stream->readString(&error); |
| 1045 | } |
| 1046 | if ((flags & 32) != 0) { |
| 1047 | photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1048 | } |
| 1049 | if ((flags & 64) != 0) { |
| 1050 | status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1051 | } |
| 1052 | if ((flags & 16384) != 0) { |
| 1053 | bot_info_version = stream->readInt32(&error); |
| 1054 | } |
| 1055 | if ((flags & 262144) != 0) { |
| 1056 | uint32_t magic = stream->readUint32(&error); |
| 1057 | if (magic != 0x1cb5c415) { |
| 1058 | error = true; |
| 1059 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user, got %x", magic); |
| 1060 | return; |
| 1061 | } |
| 1062 | int32_t count = stream->readInt32(&error); |
| 1063 | for (int32_t a = 0; a < count; a++) { |
| 1064 | TL_restrictionReason *object = TL_restrictionReason::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 1065 | if (object == nullptr) { |
| 1066 | return; |
| 1067 | } |
| 1068 | restriction_reason.push_back(std::unique_ptr<TL_restrictionReason>(object)); |
| 1069 | } |
| 1070 | } |
| 1071 | if ((flags & 524288) != 0) { |
| 1072 | bot_inline_placeholder = stream->readString(&error); |
| 1073 | } |
| 1074 | if ((flags & 4194304) != 0) { |
| 1075 | lang_code = stream->readString(&error); |
| 1076 | } |
| 1077 | if ((flags & 1073741824) != 0) { |
| 1078 | emoji_status = std::unique_ptr<EmojiStatus>(EmojiStatus::TLdeserialize(stream, stream->readInt32(&error), instanceNum, error)); |
| 1079 | } |
| 1080 | if ((flags2 & 1) != 0) { |
| 1081 | uint32_t magic = stream->readUint32(&error); |
| 1082 | if (magic != 0x1cb5c415) { |
| 1083 | error = true; |
| 1084 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_user (2), got %x", magic); |
| 1085 | return; |
| 1086 | } |
| 1087 | int32_t count = stream->readInt32(&error); |
| 1088 | for (int32_t a = 0; a < count; a++) { |
| 1089 | TL_username *object = TL_username::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 1090 | if (object == nullptr) { |
| 1091 | return; |
| 1092 | } |
| 1093 | usernames.push_back(std::unique_ptr<TL_username>(object)); |
| 1094 | } |
| 1095 | } |
| 1096 | if ((flags2 & 32) != 0) { |
| 1097 | stories_max_id = std::make_unique<TL_recentStory>(); |
| 1098 | stories_max_id->flags |= 2; |
| 1099 | stories_max_id->max_id = stream->readInt32(&error); |
| 1100 | } |
| 1101 | if ((flags2 & 256) != 0) { |
| 1102 | color = std::unique_ptr<PeerColor>(PeerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1103 | } |
| 1104 | if ((flags2 & 512) != 0) { |
| 1105 | profile_color = std::unique_ptr<PeerColor>(PeerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1106 | } |
| 1107 | if ((flags2 & 4096) != 0) { |
| 1108 | bot_active_users = stream->readInt32(&error); |
| 1109 | } |
| 1110 | if ((flags2 & 16384) != 0) { |
| 1111 | bot_verification_icon = stream->readInt64(&error); |
| 1112 | } |
| 1113 | if ((flags2 & 32768) != 0) { |
| 1114 | send_paid_messages_stars = stream->readInt64(&error); |
| 1115 | } |
| 1116 | } |
| 1117 |
| 1118 | void TL_user_layer216::serializeToStream(NativeByteBuffer *stream) { |
| 1119 | stream->writeInt32(constructor); |
| 1120 | stream->writeInt32(flags); |
| 1121 | stream->writeInt32(flags2); |
| 1122 | stream->writeInt64(id); |
| 1123 | if ((flags & 1) != 0) { |
| 1124 | stream->writeInt64(access_hash); |
| 1125 | } |
| 1126 | if ((flags & 2) != 0) { |
| 1127 | stream->writeString(first_name); |
| 1128 | } |
| 1129 | if ((flags & 4) != 0) { |
| 1130 | stream->writeString(last_name); |
| 1131 | } |
| 1132 | if ((flags & 8) != 0) { |
| 1133 | stream->writeString(username); |
| 1134 | } |
| 1135 | if ((flags & 16) != 0) { |
| 1136 | stream->writeString(phone); |
| 1137 | } |
| 1138 | if ((flags & 32) != 0) { |
| 1139 | photo->serializeToStream(stream); |
| 1140 | } |
| 1141 | if ((flags & 64) != 0) { |
| 1142 | status->serializeToStream(stream); |
| 1143 | } |
| 1144 | if ((flags & 16384) != 0) { |
| 1145 | stream->writeInt32(bot_info_version); |
| 1146 | } |
| 1147 | if ((flags & 262144) != 0) { |
| 1148 | stream->writeInt32(0x1cb5c415); |
| 1149 | uint32_t count = (uint32_t) restriction_reason.size(); |
| 1150 | stream->writeInt32(count); |
| 1151 | for (int a = 0; a < count; a++) { |
| 1152 | restriction_reason[a]->serializeToStream(stream); |
| 1153 | } |
| 1154 | } |
| 1155 | if ((flags & 524288) != 0) { |
| 1156 | stream->writeString(bot_inline_placeholder); |
| 1157 | } |
| 1158 | if ((flags & 4194304) != 0) { |
| 1159 | stream->writeString(lang_code); |
| 1160 | } |
| 1161 | if ((flags & 1073741824) != 0) { |
| 1162 | emoji_status->serializeToStream(stream); |
| 1163 | } |
| 1164 | if ((flags2 & 1) != 0) { |
| 1165 | stream->writeInt32(0x1cb5c415); |
| 1166 | int32_t count = (int32_t) usernames.size(); |
| 1167 | stream->writeInt32(count); |
| 1168 | for (int a = 0; a < count; a++) { |
| 1169 | usernames[a]->serializeToStream(stream); |
| 1170 | } |
| 1171 | } |
| 1172 | if ((flags2 & 32) != 0) { |
| 1173 | stream->writeInt32(stories_max_id ? stories_max_id->max_id : 0); |
| 1174 | } |
| 1175 | if ((flags2 & 256) != 0) { |
| 1176 | color->serializeToStream(stream); |
| 1177 | } |
| 1178 | if ((flags2 & 512) != 0) { |
| 1179 | profile_color->serializeToStream(stream); |
| 1180 | } |
| 1181 | if ((flags2 & 4096) != 0) { |
| 1182 | stream->writeInt32(bot_active_users); |
| 1183 | } |
| 1184 | if ((flags2 & 16384) != 0) { |
| 1185 | stream->writeInt64(bot_verification_icon); |
| 1186 | } |
| 1187 | if ((flags2 & 32768) != 0) { |
| 1188 | stream->writeInt64(send_paid_messages_stars); |
| 1189 | } |
| 1190 | } |
| 1191 |
| 1192 | InputPeer *InputPeer::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1193 | InputPeer *result = nullptr; |
| 1194 | switch (constructor) { |
| 1195 | case 0x7da07ec9: |
| 1196 | result = new TL_inputPeerSelf(); |
| 1197 | break; |
| 1198 | case 0xdde8a54c: |
| 1199 | result = new TL_inputPeerUser(); |
| 1200 | break; |
| 1201 | case 0x35a95cb9: |
| 1202 | result = new TL_inputPeerChat(); |
| 1203 | break; |
| 1204 | case 0xa87b0a1c: |
| 1205 | result = new TL_inputPeerUserFromMessage(); |
| 1206 | break; |
| 1207 | case 0xbd2a0840: |
| 1208 | result = new TL_inputPeerChannelFromMessage(); |
| 1209 | break; |
| 1210 | case 0x27bcbbfc: |
| 1211 | result = new TL_inputPeerChannel(); |
| 1212 | break; |
| 1213 | case 0x7f3b18ea: |
| 1214 | result = new TL_inputPeerEmpty(); |
| 1215 | break; |
| 1216 | default: |
| 1217 | error = true; |
| 1218 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in InputPeer", constructor); |
| 1219 | return nullptr; |
| 1220 | } |
| 1221 | result->readParams(stream, instanceNum, error); |
| 1222 | return result; |
| 1223 | } |
| 1224 |
| 1225 | void TL_inputPeerSelf::serializeToStream(NativeByteBuffer *stream) { |
| 1226 | stream->writeInt32(constructor); |
| 1227 | } |
| 1228 |
| 1229 | void TL_inputPeerUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1230 | user_id = stream->readInt64(&error); |
| 1231 | access_hash = stream->readInt64(&error); |
| 1232 | } |
| 1233 |
| 1234 | void TL_inputPeerUser::serializeToStream(NativeByteBuffer *stream) { |
| 1235 | stream->writeInt32(constructor); |
| 1236 | stream->writeInt64(user_id); |
| 1237 | stream->writeInt64(access_hash); |
| 1238 | } |
| 1239 |
| 1240 | void TL_inputPeerChat::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1241 | chat_id = stream->readInt64(&error); |
| 1242 | } |
| 1243 |
| 1244 | void TL_inputPeerChat::serializeToStream(NativeByteBuffer *stream) { |
| 1245 | stream->writeInt32(constructor); |
| 1246 | stream->writeInt64(chat_id); |
| 1247 | } |
| 1248 |
| 1249 | void TL_inputPeerUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1250 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1251 | msg_id = stream->readInt32(&error); |
| 1252 | user_id = stream->readInt64(&error); |
| 1253 | } |
| 1254 |
| 1255 | void TL_inputPeerUserFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 1256 | stream->writeInt32(constructor); |
| 1257 | peer->serializeToStream(stream); |
| 1258 | stream->writeInt32(msg_id); |
| 1259 | stream->writeInt64(user_id); |
| 1260 | } |
| 1261 |
| 1262 | void TL_inputPeerChannelFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1263 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1264 | msg_id = stream->readInt32(&error); |
| 1265 | channel_id = stream->readInt64(&error); |
| 1266 | } |
| 1267 |
| 1268 | void TL_inputPeerChannelFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 1269 | stream->writeInt32(constructor); |
| 1270 | peer->serializeToStream(stream); |
| 1271 | stream->writeInt32(msg_id); |
| 1272 | stream->writeInt64(channel_id); |
| 1273 | } |
| 1274 |
| 1275 | void TL_inputPeerChannel::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1276 | channel_id = stream->readInt64(&error); |
| 1277 | access_hash = stream->readInt64(&error); |
| 1278 | } |
| 1279 |
| 1280 | void TL_inputPeerChannel::serializeToStream(NativeByteBuffer *stream) { |
| 1281 | stream->writeInt32(constructor); |
| 1282 | stream->writeInt64(channel_id); |
| 1283 | stream->writeInt64(access_hash); |
| 1284 | } |
| 1285 |
| 1286 | void TL_inputPeerEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1287 | stream->writeInt32(constructor); |
| 1288 | } |
| 1289 |
| 1290 | InputUser *InputUser::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1291 | InputUser *result = nullptr; |
| 1292 | switch (constructor) { |
| 1293 | case 0xf7c1b13f: |
| 1294 | result = new TL_inputUserSelf(); |
| 1295 | break; |
| 1296 | case 0xf21158c6: |
| 1297 | result = new TL_inputUser(); |
| 1298 | break; |
| 1299 | case 0xb98886cf: |
| 1300 | result = new TL_inputUserEmpty(); |
| 1301 | break; |
| 1302 | case 0x1da448e2: |
| 1303 | result = new TL_inputUserFromMessage(); |
| 1304 | break; |
| 1305 | default: |
| 1306 | error = true; |
| 1307 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in InputUser", constructor); |
| 1308 | return nullptr; |
| 1309 | } |
| 1310 | result->readParams(stream, instanceNum, error); |
| 1311 | return result; |
| 1312 | } |
| 1313 |
| 1314 | void TL_inputUserSelf::serializeToStream(NativeByteBuffer *stream) { |
| 1315 | stream->writeInt32(constructor); |
| 1316 | } |
| 1317 |
| 1318 | void TL_inputUser::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1319 | user_id = stream->readInt64(&error); |
| 1320 | access_hash = stream->readInt64(&error); |
| 1321 | } |
| 1322 |
| 1323 | void TL_inputUser::serializeToStream(NativeByteBuffer *stream) { |
| 1324 | stream->writeInt32(constructor); |
| 1325 | stream->writeInt64(user_id); |
| 1326 | stream->writeInt64(access_hash); |
| 1327 | } |
| 1328 |
| 1329 | void TL_inputUserEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1330 | stream->writeInt32(constructor); |
| 1331 | } |
| 1332 |
| 1333 | void TL_inputUserFromMessage::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1334 | peer = std::unique_ptr<InputPeer>(InputPeer::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1335 | msg_id = stream->readInt32(&error); |
| 1336 | user_id = stream->readInt64(&error); |
| 1337 | } |
| 1338 |
| 1339 | void TL_inputUserFromMessage::serializeToStream(NativeByteBuffer *stream) { |
| 1340 | stream->writeInt32(constructor); |
| 1341 | peer->serializeToStream(stream); |
| 1342 | stream->writeInt32(msg_id); |
| 1343 | stream->writeInt64(user_id); |
| 1344 | } |
| 1345 |
| 1346 | MessageEntity *MessageEntity::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1347 | MessageEntity *result = nullptr; |
| 1348 | switch (constructor) { |
| 1349 | case 0x76a6d327: |
| 1350 | result = new TL_messageEntityTextUrl(); |
| 1351 | break; |
| 1352 | case 0x6cef8ac7: |
| 1353 | result = new TL_messageEntityBotCommand(); |
| 1354 | break; |
| 1355 | case 0x64e475c2: |
| 1356 | result = new TL_messageEntityEmail(); |
| 1357 | break; |
| 1358 | case 0x73924be0: |
| 1359 | result = new TL_messageEntityPre(); |
| 1360 | break; |
| 1361 | case 0xbb92ba95: |
| 1362 | result = new TL_messageEntityUnknown(); |
| 1363 | break; |
| 1364 | case 0x6ed02538: |
| 1365 | result = new TL_messageEntityUrl(); |
| 1366 | break; |
| 1367 | case 0x826f8b60: |
| 1368 | result = new TL_messageEntityItalic(); |
| 1369 | break; |
| 1370 | case 0xfa04579d: |
| 1371 | result = new TL_messageEntityMention(); |
| 1372 | break; |
| 1373 | case 0xdc7b1140: |
| 1374 | result = new TL_messageEntityMentionName(); |
| 1375 | break; |
| 1376 | case 0x208e68c9: |
| 1377 | result = new TL_inputMessageEntityMentionName(); |
| 1378 | break; |
| 1379 | case 0x4c4e743f: |
| 1380 | result = new TL_messageEntityCashtag(); |
| 1381 | break; |
| 1382 | case 0xbd610bc9: |
| 1383 | result = new TL_messageEntityBold(); |
| 1384 | break; |
| 1385 | case 0x6f635b0d: |
| 1386 | result = new TL_messageEntityHashtag(); |
| 1387 | break; |
| 1388 | case 0x28a20571: |
| 1389 | result = new TL_messageEntityCode(); |
| 1390 | break; |
| 1391 | case 0xbf0693d4: |
| 1392 | result = new TL_messageEntityStrike(); |
| 1393 | break; |
| 1394 | case 0x20df5d0: |
| 1395 | result = new TL_messageEntityBlockquote_layer180(); |
| 1396 | break; |
| 1397 | case 0xf1ccaaac: |
| 1398 | result = new TL_messageEntityBlockquote(); |
| 1399 | break; |
| 1400 | case 0x9c4e7e8b: |
| 1401 | result = new TL_messageEntityUnderline(); |
| 1402 | break; |
| 1403 | case 0x9b69e34b: |
| 1404 | result = new TL_messageEntityPhone(); |
| 1405 | break; |
| 1406 | default: |
| 1407 | error = true; |
| 1408 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in MessageEntity", constructor); |
| 1409 | return nullptr; |
| 1410 | } |
| 1411 | result->readParams(stream, instanceNum, error); |
| 1412 | return result; |
| 1413 | } |
| 1414 |
| 1415 | void TL_messageEntityTextUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1416 | offset = stream->readInt32(&error); |
| 1417 | length = stream->readInt32(&error); |
| 1418 | url = stream->readString(&error); |
| 1419 | } |
| 1420 |
| 1421 | void TL_messageEntityTextUrl::serializeToStream(NativeByteBuffer *stream) { |
| 1422 | stream->writeInt32(constructor); |
| 1423 | stream->writeInt32(offset); |
| 1424 | stream->writeInt32(length); |
| 1425 | stream->writeString(url); |
| 1426 | } |
| 1427 |
| 1428 | void TL_messageEntityBotCommand::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1429 | offset = stream->readInt32(&error); |
| 1430 | length = stream->readInt32(&error); |
| 1431 | } |
| 1432 |
| 1433 | void TL_messageEntityBotCommand::serializeToStream(NativeByteBuffer *stream) { |
| 1434 | stream->writeInt32(constructor); |
| 1435 | stream->writeInt32(offset); |
| 1436 | stream->writeInt32(length); |
| 1437 | } |
| 1438 |
| 1439 | void TL_messageEntityEmail::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1440 | offset = stream->readInt32(&error); |
| 1441 | length = stream->readInt32(&error); |
| 1442 | } |
| 1443 |
| 1444 | void TL_messageEntityEmail::serializeToStream(NativeByteBuffer *stream) { |
| 1445 | stream->writeInt32(constructor); |
| 1446 | stream->writeInt32(offset); |
| 1447 | stream->writeInt32(length); |
| 1448 | } |
| 1449 |
| 1450 | void TL_messageEntityPre::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1451 | offset = stream->readInt32(&error); |
| 1452 | length = stream->readInt32(&error); |
| 1453 | language = stream->readString(&error); |
| 1454 | } |
| 1455 |
| 1456 | void TL_messageEntityPre::serializeToStream(NativeByteBuffer *stream) { |
| 1457 | stream->writeInt32(constructor); |
| 1458 | stream->writeInt32(offset); |
| 1459 | stream->writeInt32(length); |
| 1460 | stream->writeString(language); |
| 1461 | } |
| 1462 |
| 1463 | void TL_messageEntityUnknown::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1464 | offset = stream->readInt32(&error); |
| 1465 | length = stream->readInt32(&error); |
| 1466 | } |
| 1467 |
| 1468 | void TL_messageEntityUnknown::serializeToStream(NativeByteBuffer *stream) { |
| 1469 | stream->writeInt32(constructor); |
| 1470 | stream->writeInt32(offset); |
| 1471 | stream->writeInt32(length); |
| 1472 | } |
| 1473 |
| 1474 | void TL_messageEntityUrl::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1475 | offset = stream->readInt32(&error); |
| 1476 | length = stream->readInt32(&error); |
| 1477 | } |
| 1478 |
| 1479 | void TL_messageEntityUrl::serializeToStream(NativeByteBuffer *stream) { |
| 1480 | stream->writeInt32(constructor); |
| 1481 | stream->writeInt32(offset); |
| 1482 | stream->writeInt32(length); |
| 1483 | } |
| 1484 |
| 1485 | void TL_messageEntityItalic::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1486 | offset = stream->readInt32(&error); |
| 1487 | length = stream->readInt32(&error); |
| 1488 | } |
| 1489 |
| 1490 | void TL_messageEntityItalic::serializeToStream(NativeByteBuffer *stream) { |
| 1491 | stream->writeInt32(constructor); |
| 1492 | stream->writeInt32(offset); |
| 1493 | stream->writeInt32(length); |
| 1494 | } |
| 1495 |
| 1496 | void TL_messageEntityMention::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1497 | offset = stream->readInt32(&error); |
| 1498 | length = stream->readInt32(&error); |
| 1499 | } |
| 1500 |
| 1501 | void TL_messageEntityMention::serializeToStream(NativeByteBuffer *stream) { |
| 1502 | stream->writeInt32(constructor); |
| 1503 | stream->writeInt32(offset); |
| 1504 | stream->writeInt32(length); |
| 1505 | } |
| 1506 |
| 1507 | void TL_messageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1508 | offset = stream->readInt32(&error); |
| 1509 | length = stream->readInt32(&error); |
| 1510 | user_id = stream->readInt64(&error); |
| 1511 | } |
| 1512 |
| 1513 | void TL_messageEntityMentionName::serializeToStream(NativeByteBuffer *stream) { |
| 1514 | stream->writeInt32(constructor); |
| 1515 | stream->writeInt32(offset); |
| 1516 | stream->writeInt32(length); |
| 1517 | stream->writeInt64(user_id); |
| 1518 | } |
| 1519 |
| 1520 | void TL_inputMessageEntityMentionName::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1521 | offset = stream->readInt32(&error); |
| 1522 | length = stream->readInt32(&error); |
| 1523 | user_id = std::unique_ptr<InputUser>(InputUser::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1524 | } |
| 1525 |
| 1526 | void TL_inputMessageEntityMentionName::serializeToStream(NativeByteBuffer *stream) { |
| 1527 | stream->writeInt32(constructor); |
| 1528 | stream->writeInt32(offset); |
| 1529 | stream->writeInt32(length); |
| 1530 | user_id->serializeToStream(stream); |
| 1531 | } |
| 1532 |
| 1533 | void TL_messageEntityCashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1534 | offset = stream->readInt32(&error); |
| 1535 | length = stream->readInt32(&error); |
| 1536 | } |
| 1537 |
| 1538 | void TL_messageEntityCashtag::serializeToStream(NativeByteBuffer *stream) { |
| 1539 | stream->writeInt32(constructor); |
| 1540 | stream->writeInt32(offset); |
| 1541 | stream->writeInt32(length); |
| 1542 | } |
| 1543 |
| 1544 | void TL_messageEntityBold::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1545 | offset = stream->readInt32(&error); |
| 1546 | length = stream->readInt32(&error); |
| 1547 | } |
| 1548 |
| 1549 | void TL_messageEntityBold::serializeToStream(NativeByteBuffer *stream) { |
| 1550 | stream->writeInt32(constructor); |
| 1551 | stream->writeInt32(offset); |
| 1552 | stream->writeInt32(length); |
| 1553 | } |
| 1554 |
| 1555 | void TL_messageEntityHashtag::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1556 | offset = stream->readInt32(&error); |
| 1557 | length = stream->readInt32(&error); |
| 1558 | } |
| 1559 |
| 1560 | void TL_messageEntityHashtag::serializeToStream(NativeByteBuffer *stream) { |
| 1561 | stream->writeInt32(constructor); |
| 1562 | stream->writeInt32(offset); |
| 1563 | stream->writeInt32(length); |
| 1564 | } |
| 1565 |
| 1566 | void TL_messageEntityCode::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1567 | offset = stream->readInt32(&error); |
| 1568 | length = stream->readInt32(&error); |
| 1569 | } |
| 1570 |
| 1571 | void TL_messageEntityCode::serializeToStream(NativeByteBuffer *stream) { |
| 1572 | stream->writeInt32(constructor); |
| 1573 | stream->writeInt32(offset); |
| 1574 | stream->writeInt32(length); |
| 1575 | } |
| 1576 |
| 1577 | void TL_messageEntityStrike::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1578 | offset = stream->readInt32(&error); |
| 1579 | length = stream->readInt32(&error); |
| 1580 | } |
| 1581 |
| 1582 | void TL_messageEntityStrike::serializeToStream(NativeByteBuffer *stream) { |
| 1583 | stream->writeInt32(constructor); |
| 1584 | stream->writeInt32(offset); |
| 1585 | stream->writeInt32(length); |
| 1586 | } |
| 1587 |
| 1588 | void TL_messageEntityBlockquote::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1589 | flags = stream->readInt32(&error); |
| 1590 | offset = stream->readInt32(&error); |
| 1591 | length = stream->readInt32(&error); |
| 1592 | } |
| 1593 |
| 1594 | void TL_messageEntityBlockquote_layer180::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1595 | offset = stream->readInt32(&error); |
| 1596 | length = stream->readInt32(&error); |
| 1597 | } |
| 1598 |
| 1599 | void TL_messageEntityBlockquote::serializeToStream(NativeByteBuffer *stream) { |
| 1600 | stream->writeInt32(constructor); |
| 1601 | stream->writeInt32(flags); |
| 1602 | stream->writeInt32(offset); |
| 1603 | stream->writeInt32(length); |
| 1604 | } |
| 1605 |
| 1606 | void TL_messageEntityBlockquote_layer180::serializeToStream(NativeByteBuffer *stream) { |
| 1607 | stream->writeInt32(constructor); |
| 1608 | stream->writeInt32(offset); |
| 1609 | stream->writeInt32(length); |
| 1610 | } |
| 1611 |
| 1612 | void TL_messageEntityUnderline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1613 | offset = stream->readInt32(&error); |
| 1614 | length = stream->readInt32(&error); |
| 1615 | } |
| 1616 |
| 1617 | void TL_messageEntityUnderline::serializeToStream(NativeByteBuffer *stream) { |
| 1618 | stream->writeInt32(constructor); |
| 1619 | stream->writeInt32(offset); |
| 1620 | stream->writeInt32(length); |
| 1621 | } |
| 1622 |
| 1623 | void TL_messageEntityPhone::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1624 | offset = stream->readInt32(&error); |
| 1625 | length = stream->readInt32(&error); |
| 1626 | } |
| 1627 |
| 1628 | void TL_messageEntityPhone::serializeToStream(NativeByteBuffer *stream) { |
| 1629 | stream->writeInt32(constructor); |
| 1630 | stream->writeInt32(offset); |
| 1631 | stream->writeInt32(length); |
| 1632 | } |
| 1633 |
| 1634 | TL_dataJSON *TL_dataJSON::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1635 | if (TL_dataJSON::constructor != constructor) { |
| 1636 | error = true; |
| 1637 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_dataJSON", constructor); |
| 1638 | return nullptr; |
| 1639 | } |
| 1640 | TL_dataJSON *result = new TL_dataJSON(); |
| 1641 | result->readParams(stream, instanceNum, error); |
| 1642 | return result; |
| 1643 | } |
| 1644 |
| 1645 | void TL_dataJSON::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1646 | data = stream->readString(&error); |
| 1647 | } |
| 1648 |
| 1649 | void TL_dataJSON::serializeToStream(NativeByteBuffer *stream) { |
| 1650 | stream->writeInt32(constructor); |
| 1651 | stream->writeString(data); |
| 1652 | } |
| 1653 |
| 1654 | TL_help_termsOfService *TL_help_termsOfService::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1655 | if (TL_help_termsOfService::constructor != constructor) { |
| 1656 | error = true; |
| 1657 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_help_termsOfService", constructor); |
| 1658 | return nullptr; |
| 1659 | } |
| 1660 | TL_help_termsOfService *result = new TL_help_termsOfService(); |
| 1661 | result->readParams(stream, instanceNum, error); |
| 1662 | return result; |
| 1663 | } |
| 1664 |
| 1665 | void TL_help_termsOfService::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1666 | flags = stream->readInt32(&error); |
| 1667 | popup = (flags & 1) != 0; |
| 1668 | id = std::unique_ptr<TL_dataJSON>(TL_dataJSON::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1669 | text = stream->readString(&error); |
| 1670 | int magic = stream->readInt32(&error); |
| 1671 | if (magic != 0x1cb5c415) { |
| 1672 | error = true; |
| 1673 | if (LOGS_ENABLED) DEBUG_FATAL("wrong Vector magic in TL_help_termsOfService, got %x", magic); |
| 1674 | return; |
| 1675 | } |
| 1676 | int count = stream->readInt32(&error); |
| 1677 | for (int a = 0; a < count; a++) { |
| 1678 | MessageEntity *object = MessageEntity::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 1679 | if (object == nullptr) { |
| 1680 | return; |
| 1681 | } |
| 1682 | entities.push_back(std::unique_ptr<MessageEntity>(object)); |
| 1683 | } |
| 1684 | if ((flags & 2) != 0) { |
| 1685 | min_age_confirm = stream->readInt32(&error); |
| 1686 | } |
| 1687 | } |
| 1688 |
| 1689 | void TL_help_termsOfService::serializeToStream(NativeByteBuffer *stream) { |
| 1690 | stream->writeInt32(constructor); |
| 1691 | flags = popup ? (flags | 1) : (flags & ~1); |
| 1692 | stream->writeInt32(flags); |
| 1693 | id->serializeToStream(stream); |
| 1694 | stream->writeString(text); |
| 1695 | stream->writeInt32(0x1cb5c415); |
| 1696 | int32_t count = (int32_t) entities.size(); |
| 1697 | stream->writeInt32(count); |
| 1698 | for (int a = 0; a < count; a++) { |
| 1699 | entities[a]->serializeToStream(stream); |
| 1700 | } |
| 1701 | if ((flags & 2) != 0) { |
| 1702 | stream->writeInt32(min_age_confirm); |
| 1703 | } |
| 1704 | } |
| 1705 |
| 1706 | auth_Authorization *auth_Authorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1707 | auth_Authorization *result = nullptr; |
| 1708 | switch (constructor) { |
| 1709 | case 0x44747e9a: |
| 1710 | result = new TL_auth_authorizationSignUpRequired(); |
| 1711 | break; |
| 1712 | case 0x2ea2c0d4: |
| 1713 | result = new TL_auth_authorization(); |
| 1714 | break; |
| 1715 | default: |
| 1716 | error = true; |
| 1717 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in auth_Authorization", constructor); |
| 1718 | return nullptr; |
| 1719 | } |
| 1720 | result->readParams(stream, instanceNum, error); |
| 1721 | return result; |
| 1722 | } |
| 1723 |
| 1724 | void TL_auth_authorizationSignUpRequired::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1725 | flags = stream->readInt32(&error); |
| 1726 | if ((flags & 1) != 0) { |
| 1727 | terms_of_service = std::unique_ptr<TL_help_termsOfService>(TL_help_termsOfService::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1728 | } |
| 1729 | } |
| 1730 |
| 1731 | void TL_auth_authorizationSignUpRequired::serializeToStream(NativeByteBuffer *stream) { |
| 1732 | stream->writeInt32(constructor); |
| 1733 | stream->writeInt32(flags); |
| 1734 | if ((flags & 1) != 0) { |
| 1735 | terms_of_service->serializeToStream(stream); |
| 1736 | } |
| 1737 | } |
| 1738 |
| 1739 | void TL_auth_authorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1740 | flags = stream->readInt32(&error); |
| 1741 | if ((flags & 2) != 0) { |
| 1742 | otherwise_relogin_days = stream->readInt32(&error); |
| 1743 | } |
| 1744 | if ((flags & 1) != 0) { |
| 1745 | tmp_sessions = stream->readInt32(&error); |
| 1746 | } |
| 1747 | if ((flags & 4) != 0) { |
| 1748 | future_auth_token = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1749 | } |
| 1750 | user = std::unique_ptr<User>(User::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 1751 | } |
| 1752 |
| 1753 | void TL_auth_authorization::serializeToStream(NativeByteBuffer *stream) { |
| 1754 | stream->writeInt32(constructor); |
| 1755 | stream->writeInt32(flags); |
| 1756 | if ((flags & 1) != 0) { |
| 1757 | stream->writeInt32(tmp_sessions); |
| 1758 | } |
| 1759 | user->serializeToStream(stream); |
| 1760 | } |
| 1761 |
| 1762 | TL_auth_exportedAuthorization *TL_auth_exportedAuthorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1763 | if (TL_auth_exportedAuthorization::constructor != constructor) { |
| 1764 | error = true; |
| 1765 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_auth_exportedAuthorization", constructor); |
| 1766 | return nullptr; |
| 1767 | } |
| 1768 | TL_auth_exportedAuthorization *result = new TL_auth_exportedAuthorization(); |
| 1769 | result->readParams(stream, instanceNum, error); |
| 1770 | return result; |
| 1771 | } |
| 1772 |
| 1773 | void TL_auth_exportedAuthorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1774 | id = stream->readInt64(&error); |
| 1775 | bytes = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1776 | } |
| 1777 |
| 1778 | bool TL_auth_exportAuthorization::isNeedLayer() { |
| 1779 | return true; |
| 1780 | } |
| 1781 |
| 1782 | TLObject *TL_auth_exportAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1783 | return TL_auth_exportedAuthorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 1784 | } |
| 1785 |
| 1786 | void TL_auth_exportAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 1787 | stream->writeInt32(constructor); |
| 1788 | stream->writeInt32(dc_id); |
| 1789 | } |
| 1790 |
| 1791 | bool TL_auth_importAuthorization::isNeedLayer() { |
| 1792 | return true; |
| 1793 | } |
| 1794 |
| 1795 | TLObject *TL_auth_importAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1796 | return auth_Authorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 1797 | } |
| 1798 |
| 1799 | void TL_auth_importAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 1800 | stream->writeInt32(constructor); |
| 1801 | stream->writeInt64(id); |
| 1802 | stream->writeByteArray(bytes.get()); |
| 1803 | } |
| 1804 |
| 1805 | UserStatus *UserStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1806 | UserStatus *result = nullptr; |
| 1807 | switch (constructor) { |
| 1808 | case 0x8c703f: |
| 1809 | result = new TL_userStatusOffline(); |
| 1810 | break; |
| 1811 | case 0x9d05049: |
| 1812 | result = new TL_userStatusEmpty(); |
| 1813 | break; |
| 1814 | case 0xedb93949: |
| 1815 | result = new TL_userStatusOnline(); |
| 1816 | break; |
| 1817 | case 0x7b197dc8: |
| 1818 | result = new TL_userStatusRecently(); |
| 1819 | break; |
| 1820 | case 0x541a1d1a: |
| 1821 | result = new TL_userStatusLastWeek(); |
| 1822 | break; |
| 1823 | case 0x65899777: |
| 1824 | result = new TL_userStatusLastMonth(); |
| 1825 | break; |
| 1826 | case 0xe26f42f1: |
| 1827 | result = new TL_userStatusRecently_layer171(); |
| 1828 | break; |
| 1829 | case 0x7bf09fc: |
| 1830 | result = new TL_userStatusLastWeek_layer171(); |
| 1831 | break; |
| 1832 | case 0x77ebc742: |
| 1833 | result = new TL_userStatusLastMonth_layer171(); |
| 1834 | break; |
| 1835 | default: |
| 1836 | error = true; |
| 1837 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in UserStatus", constructor); |
| 1838 | return nullptr; |
| 1839 | } |
| 1840 | result->readParams(stream, instanceNum, error); |
| 1841 | return result; |
| 1842 | } |
| 1843 |
| 1844 | void TL_userStatusOffline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1845 | expires = stream->readInt32(&error); |
| 1846 | } |
| 1847 |
| 1848 | void TL_userStatusOffline::serializeToStream(NativeByteBuffer *stream) { |
| 1849 | stream->writeInt32(constructor); |
| 1850 | stream->writeInt32(expires); |
| 1851 | } |
| 1852 |
| 1853 | void TL_userStatusLastWeek_layer171::serializeToStream(NativeByteBuffer *stream) { |
| 1854 | stream->writeInt32(constructor); |
| 1855 | } |
| 1856 |
| 1857 | void TL_userStatusLastWeek::serializeToStream(NativeByteBuffer *stream) { |
| 1858 | stream->writeInt32(constructor); |
| 1859 | flags = by_me ? flags | 1 : flags &~ 1; |
| 1860 | stream->writeInt32(flags); |
| 1861 | } |
| 1862 |
| 1863 | void TL_userStatusLastWeek::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1864 | flags = stream->readInt32(&error); |
| 1865 | by_me = (flags & 1) != 0; |
| 1866 | } |
| 1867 |
| 1868 | void TL_userStatusEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1869 | stream->writeInt32(constructor); |
| 1870 | } |
| 1871 |
| 1872 | void TL_userStatusLastMonth::serializeToStream(NativeByteBuffer *stream) { |
| 1873 | stream->writeInt32(constructor); |
| 1874 | flags = by_me ? flags | 1 : flags &~ 1; |
| 1875 | stream->writeInt32(flags); |
| 1876 | } |
| 1877 |
| 1878 | void TL_userStatusLastMonth::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1879 | flags = stream->readInt32(&error); |
| 1880 | by_me = (flags & 1) != 0; |
| 1881 | } |
| 1882 |
| 1883 | void TL_userStatusLastMonth_layer171::serializeToStream(NativeByteBuffer *stream) { |
| 1884 | stream->writeInt32(constructor); |
| 1885 | } |
| 1886 |
| 1887 | void TL_userStatusOnline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1888 | expires = stream->readInt32(&error); |
| 1889 | } |
| 1890 |
| 1891 | void TL_userStatusOnline::serializeToStream(NativeByteBuffer *stream) { |
| 1892 | stream->writeInt32(constructor); |
| 1893 | stream->writeInt32(expires); |
| 1894 | } |
| 1895 |
| 1896 | void TL_userStatusRecently::serializeToStream(NativeByteBuffer *stream) { |
| 1897 | stream->writeInt32(constructor); |
| 1898 | flags = by_me ? flags | 1 : flags &~ 1; |
| 1899 | stream->writeInt32(flags); |
| 1900 | } |
| 1901 |
| 1902 | void TL_userStatusRecently::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1903 | flags = stream->readInt32(&error); |
| 1904 | by_me = (flags & 1) != 0; |
| 1905 | } |
| 1906 |
| 1907 | void TL_userStatusRecently_layer171::serializeToStream(NativeByteBuffer *stream) { |
| 1908 | stream->writeInt32(constructor); |
| 1909 | } |
| 1910 |
| 1911 | void TL_userStatusHidden::serializeToStream(NativeByteBuffer *stream) { |
| 1912 | stream->writeInt32(constructor); |
| 1913 | } |
| 1914 |
| 1915 | FileLocation *FileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1916 | FileLocation *result = nullptr; |
| 1917 | switch (constructor) { |
| 1918 | case 0xbc7fc6cd: |
| 1919 | result = new TL_fileLocationToBeDeprecated(); |
| 1920 | break; |
| 1921 | default: |
| 1922 | error = true; |
| 1923 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in FileLocation", constructor); |
| 1924 | return nullptr; |
| 1925 | } |
| 1926 | result->readParams(stream, instanceNum, error); |
| 1927 | return result; |
| 1928 | } |
| 1929 |
| 1930 | void TL_fileLocationToBeDeprecated::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1931 | volume_id = stream->readInt64(&error); |
| 1932 | local_id = stream->readInt32(&error); |
| 1933 | } |
| 1934 |
| 1935 | void TL_fileLocationToBeDeprecated::serializeToStream(NativeByteBuffer *stream) { |
| 1936 | stream->writeInt32(constructor); |
| 1937 | stream->writeInt64(volume_id); |
| 1938 | stream->writeInt32(local_id); |
| 1939 | } |
| 1940 |
| 1941 | UserProfilePhoto *UserProfilePhoto::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1942 | UserProfilePhoto *result = nullptr; |
| 1943 | switch (constructor) { |
| 1944 | case 0x4f11bae1: |
| 1945 | result = new TL_userProfilePhotoEmpty(); |
| 1946 | break; |
| 1947 | case 0x82d1f706: |
| 1948 | result = new TL_userProfilePhoto(); |
| 1949 | break; |
| 1950 | default: |
| 1951 | error = true; |
| 1952 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in UserProfilePhoto", constructor); |
| 1953 | return nullptr; |
| 1954 | } |
| 1955 | result->readParams(stream, instanceNum, error); |
| 1956 | return result; |
| 1957 | } |
| 1958 |
| 1959 | void TL_userProfilePhotoEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 1960 | stream->writeInt32(constructor); |
| 1961 | } |
| 1962 |
| 1963 | void TL_userProfilePhoto::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 1964 | flags = stream->readInt32(&error); |
| 1965 | has_video = (flags & 1) != 0; |
| 1966 | photo_id = stream->readInt64(&error); |
| 1967 | if ((flags & 2) != 0) { |
| 1968 | stripped_thumb = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 1969 | } |
| 1970 | dc_id = stream->readInt32(&error); |
| 1971 | } |
| 1972 |
| 1973 | void TL_userProfilePhoto::serializeToStream(NativeByteBuffer *stream) { |
| 1974 | stream->writeInt32(constructor); |
| 1975 | flags = has_video ? (flags | 1) : (flags &~ 1); |
| 1976 | stream->writeInt32(flags); |
| 1977 | stream->writeInt64(photo_id); |
| 1978 | if ((flags & 2) != 0) { |
| 1979 | stream->writeByteArray(stripped_thumb.get()); |
| 1980 | } |
| 1981 | stream->writeInt32(dc_id); |
| 1982 | } |
| 1983 |
| 1984 | void TL_updatesTooLong::serializeToStream(NativeByteBuffer *stream) { |
| 1985 | stream->writeInt32(constructor); |
| 1986 | } |
| 1987 |
| 1988 | Reaction *Reaction::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 1989 | Reaction *result = nullptr; |
| 1990 | switch (constructor) { |
| 1991 | case 0x79f5d419: |
| 1992 | result = new TL_reactionEmpty(); |
| 1993 | break; |
| 1994 | case 0x8935fc73: |
| 1995 | result = new TL_reactionCustomEmoji(); |
| 1996 | break; |
| 1997 | case 0x1b2286b8: |
| 1998 | result = new TL_reactionEmoji(); |
| 1999 | break; |
| 2000 | default: |
| 2001 | error = true; |
| 2002 | if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in Reaction", constructor); |
| 2003 | return nullptr; |
| 2004 | } |
| 2005 | result->readParams(stream, instanceNum, error); |
| 2006 | return result; |
| 2007 | } |
| 2008 |
| 2009 | void TL_reactionEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 2010 |
| 2011 | } |
| 2012 |
| 2013 | void TL_reactionEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 2014 | stream->writeInt32(constructor); |
| 2015 | } |
| 2016 |
| 2017 | void TL_reactionCustomEmoji::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 2018 | document_id = stream->readInt64(&error); |
| 2019 | } |
| 2020 |
| 2021 | void TL_reactionCustomEmoji::serializeToStream(NativeByteBuffer *stream) { |
| 2022 | stream->writeInt32(constructor); |
| 2023 | stream->writeInt64(document_id); |
| 2024 | } |
| 2025 |
| 2026 | void TL_reactionEmoji::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 2027 | emoticon = stream->readString(&error); |
| 2028 | } |
| 2029 |
| 2030 | void TL_reactionEmoji::serializeToStream(NativeByteBuffer *stream) { |
| 2031 | stream->writeInt32(constructor); |
| 2032 | stream->writeString(emoticon); |
| 2033 | } |
| 2034 |
| 2035 |
| 2036 |