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