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