| 6 |
| * Copyright Nikolai Kudashov, 2015-2018. |
| 7 | */ |
| 8 |
| 9 | #include "ApiScheme.h" |
| 10 | #include "ByteArray.h" |
| 11 | #include "NativeByteBuffer.h" |
| 12 | #include "FileLog.h" |
| 13 |
| 14 | Bool *Bool::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 15 | Bool *result = nullptr; |
| 16 | switch (constructor) { |
| 17 | case 0x997275b5: |
| 18 | result = new TL_boolTrue(); |
| 19 | break; |
| 20 | case 0xbc799737: |
| 21 | result = new TL_boolFalse(); |
| 22 | break; |
| 23 | default: |
| 24 | error = true; |
| 25 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in Bool", constructor); |
| 26 | return nullptr; |
| 27 | } |
| 28 | result->readParams(stream, instanceNum, error); |
| 29 | return result; |
| 30 | } |
| 31 |
| 32 | void TL_boolTrue::serializeToStream(NativeByteBuffer *stream) { |
| 33 | stream->writeInt32(constructor); |
| 34 | } |
| 35 |
| 36 | void TL_boolFalse::serializeToStream(NativeByteBuffer *stream) { |
| 37 | stream->writeInt32(constructor); |
| 38 | } |
| 39 |
| 40 | TL_dcOption *TL_dcOption::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 41 | if (TL_dcOption::constructor != constructor) { |
| 42 | error = true; |
| 43 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_dcOption", constructor); |
| 44 | return nullptr; |
| 45 | } |
| 46 | TL_dcOption *result = new TL_dcOption(); |
| 47 | result->readParams(stream, instanceNum, error); |
| 48 | return result; |
| 49 | } |
| 50 |
| 51 | void TL_dcOption::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 52 | flags = stream->readInt32(&error); |
| 53 | ipv6 = (flags & 1) != 0; |
| 54 | media_only = (flags & 2) != 0; |
| 55 | tcpo_only = (flags & 4) != 0; |
| 56 | cdn = (flags & 8) != 0; |
| 57 | isStatic = (flags & 16) != 0; |
| 58 | id = stream->readInt32(&error); |
| 59 | ip_address = stream->readString(&error); |
| 60 | port = stream->readInt32(&error); |
| 61 | if ((flags & 1024) != 0) { |
| 62 | secret = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 63 | } |
| 64 | } |
| 65 |
| 66 | void TL_dcOption::serializeToStream(NativeByteBuffer *stream) { |
| 67 | stream->writeInt32(constructor); |
| 68 | flags = ipv6 ? (flags | 1) : (flags &~ 1); |
| 69 | flags = media_only ? (flags | 2) : (flags &~ 2); |
| 70 | flags = tcpo_only ? (flags | 4) : (flags &~ 4); |
| 71 | flags = cdn ? (flags | 8) : (flags &~ 8); |
| 72 | flags = isStatic ? (flags | 16) : (flags &~ 16); |
| 73 | stream->writeInt32(flags); |
| 74 | stream->writeInt32(id); |
| 75 | stream->writeString(ip_address); |
| 76 | stream->writeInt32(port); |
| 77 | if ((flags & 1024) != 0) { |
| 78 | stream->writeByteArray(secret.get()); |
| 79 | } |
| 80 | } |
| 81 |
| 82 | TL_cdnPublicKey *TL_cdnPublicKey::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 83 | if (TL_cdnPublicKey::constructor != constructor) { |
| 84 | error = true; |
| 85 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_cdnPublicKey", constructor); |
| 86 | return nullptr; |
| 87 | } |
| 88 | TL_cdnPublicKey *result = new TL_cdnPublicKey(); |
| 89 | result->readParams(stream, instanceNum, error); |
| 90 | return result; |
| 91 | } |
| 92 |
| 93 | void TL_cdnPublicKey::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 94 | dc_id = stream->readInt32(&error); |
| 95 | public_key = stream->readString(&error); |
| 96 | } |
| 97 |
| 98 | void TL_cdnPublicKey::serializeToStream(NativeByteBuffer *stream) { |
| 99 | stream->writeInt32(constructor); |
| 100 | stream->writeInt32(dc_id); |
| 101 | stream->writeString(public_key); |
| 102 | } |
| 103 |
| 104 | TL_cdnConfig *TL_cdnConfig::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 105 | if (TL_cdnConfig::constructor != constructor) { |
| 106 | error = true; |
| 107 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_cdnConfig", constructor); |
| 108 | return nullptr; |
| 109 | } |
| 110 | TL_cdnConfig *result = new TL_cdnConfig(); |
| 111 | result->readParams(stream, instanceNum, error); |
| 112 | return result; |
| 113 | } |
| 114 |
| 115 | void TL_cdnConfig::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 116 | int magic = stream->readInt32(&error); |
| 117 | if (magic != 0x1cb5c415) { |
| 118 | error = true; |
| 119 | if (LOGS_ENABLED) DEBUG_E("wrong Vector magic, got %x", magic); |
| 120 | return; |
| 121 | } |
| 122 | int count = stream->readInt32(&error); |
| 123 | for (int32_t a = 0; a < count; a++) { |
| 124 | TL_cdnPublicKey *object = TL_cdnPublicKey::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 125 | if (object == nullptr) { |
| 126 | return; |
| 127 | } |
| 128 | public_keys.push_back(std::unique_ptr<TL_cdnPublicKey>(object)); |
| 129 | } |
| 130 | } |
| 131 |
| 132 | void TL_cdnConfig::serializeToStream(NativeByteBuffer *stream) { |
| 133 | stream->writeInt32(constructor); |
| 134 | stream->writeInt32(0x1cb5c415); |
| 135 | int32_t count = (int32_t) public_keys.size(); |
| 136 | stream->writeInt32(count); |
| 137 | for (int32_t a = 0; a < count; a++) { |
| 138 | public_keys[a]->serializeToStream(stream); |
| 139 | } |
| 140 | } |
| 141 |
| 142 | bool TL_help_getCdnConfig::isNeedLayer() { |
| 143 | return true; |
| 144 | } |
| 145 |
| 146 | TLObject *TL_help_getCdnConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 147 | return TL_cdnConfig::TLdeserialize(stream, constructor, instanceNum, error); |
| 148 | } |
| 149 |
| 150 | void TL_help_getCdnConfig::serializeToStream(NativeByteBuffer *stream) { |
| 151 | stream->writeInt32(constructor); |
| 152 | } |
| 153 |
| 154 | TL_config *TL_config::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 155 | if (TL_config::constructor != constructor) { |
| 156 | error = true; |
| 157 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_config", constructor); |
| 158 | return nullptr; |
| 159 | } |
| 160 | TL_config *result = new TL_config(); |
| 161 | result->readParams(stream, instanceNum, error); |
| 162 | return result; |
| 163 | } |
| 164 |
| 165 | void TL_config::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 166 | flags = stream->readInt32(&error); |
| 167 | date = stream->readInt32(&error); |
| 168 | expires = stream->readInt32(&error); |
| 169 | test_mode = stream->readBool(&error); |
| 170 | this_dc = stream->readInt32(&error); |
| 171 | uint32_t magic = stream->readUint32(&error); |
| 172 | if (magic != 0x1cb5c415) { |
| 173 | error = true; |
| 174 | if (LOGS_ENABLED) DEBUG_E("wrong Vector magic, got %x", magic); |
| 175 | return; |
| 176 | } |
| 177 | int32_t count = stream->readInt32(&error); |
| 178 | for (int32_t a = 0; a < count; a++) { |
| 179 | TL_dcOption *object = TL_dcOption::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error); |
| 180 | if (object == nullptr) { |
| 181 | return; |
| 182 | } |
| 183 | dc_options.push_back(std::unique_ptr<TL_dcOption>(object)); |
| 184 | } |
| 185 | dc_txt_domain_name = stream->readString(&error); |
| 186 | chat_size_max = stream->readInt32(&error); |
| 187 | megagroup_size_max = stream->readInt32(&error); |
| 188 | forwarded_count_max = stream->readInt32(&error); |
| 189 | online_update_period_ms = stream->readInt32(&error); |
| 190 | offline_blur_timeout_ms = stream->readInt32(&error); |
| 191 | offline_idle_timeout_ms = stream->readInt32(&error); |
| 192 | online_cloud_timeout_ms = stream->readInt32(&error); |
| 193 | notify_cloud_delay_ms = stream->readInt32(&error); |
| 194 | notify_default_delay_ms = stream->readInt32(&error); |
| 195 | push_chat_period_ms = stream->readInt32(&error); |
| 196 | push_chat_limit = stream->readInt32(&error); |
| 197 | saved_gifs_limit = stream->readInt32(&error); |
| 198 | edit_time_limit = stream->readInt32(&error); |
| 199 | revoke_time_limit = stream->readInt32(&error); |
| 200 | revoke_pm_time_limit = stream->readInt32(&error); |
| 201 | rating_e_decay = stream->readInt32(&error); |
| 202 | stickers_recent_limit = stream->readInt32(&error); |
| 203 | stickers_faved_limit = stream->readInt32(&error); |
| 204 | channels_read_media_period = stream->readInt32(&error); |
| 205 | if ((flags & 1) != 0) { |
| 206 | tmp_sessions = stream->readInt32(&error); |
| 207 | } |
| 208 | pinned_dialogs_count_max = stream->readInt32(&error); |
| 209 | call_receive_timeout_ms = stream->readInt32(&error); |
| 210 | call_ring_timeout_ms = stream->readInt32(&error); |
| 211 | call_connect_timeout_ms = stream->readInt32(&error); |
| 212 | call_packet_timeout_ms = stream->readInt32(&error); |
| 213 | me_url_prefix = stream->readString(&error); |
| 214 | if ((flags & 128) != 0) { |
| 215 | autoupdate_url_prefix = stream->readString(&error); |
| 216 | } |
| 217 | if ((flags & 512) != 0) { |
| 218 | gif_search_username = stream->readString(&error); |
| 219 | } |
| 220 | if ((flags & 1024) != 0) { |
| 221 | venue_search_username = stream->readString(&error); |
| 222 | } |
| 223 | if ((flags & 2048) != 0) { |
| 224 | img_search_username = stream->readString(&error); |
| 225 | } |
| 226 | if ((flags & 4096) != 0) { |
| 227 | static_maps_provider = stream->readString(&error); |
| 228 | } |
| 229 | caption_length_max = stream->readInt32(&error); |
| 230 | message_length_max = stream->readInt32(&error); |
| 231 | webfile_dc_id = stream->readInt32(&error); |
| 232 | if ((flags & 4) != 0) { |
| 233 | suggested_lang_code = stream->readString(&error); |
| 234 | } |
| 235 | if ((flags & 4) != 0) { |
| 236 | lang_pack_version = stream->readInt32(&error); |
| 237 | } |
| 238 | if ((flags & 4) != 0) { |
| 239 | base_lang_pack_version = stream->readInt32(&error); |
| 240 | } |
| 241 | } |
| 242 |
| 243 | void TL_config::serializeToStream(NativeByteBuffer *stream) { |
| 244 | stream->writeInt32(constructor); |
| 245 | stream->writeInt32(flags); |
| 246 | stream->writeInt32(date); |
| 247 | stream->writeInt32(expires); |
| 248 | stream->writeBool(test_mode); |
| 249 | stream->writeInt32(this_dc); |
| 250 | stream->writeInt32(0x1cb5c415); |
| 251 | uint32_t count = (uint32_t) dc_options.size(); |
| 252 | stream->writeInt32(count); |
| 253 | for (uint32_t a = 0; a < count; a++) { |
| 254 | dc_options[a]->serializeToStream(stream); |
| 255 | } |
| 256 | stream->writeString(dc_txt_domain_name); |
| 257 | stream->writeInt32(chat_size_max); |
| 258 | stream->writeInt32(megagroup_size_max); |
| 259 | stream->writeInt32(forwarded_count_max); |
| 260 | stream->writeInt32(online_update_period_ms); |
| 261 | stream->writeInt32(offline_blur_timeout_ms); |
| 262 | stream->writeInt32(offline_idle_timeout_ms); |
| 263 | stream->writeInt32(online_cloud_timeout_ms); |
| 264 | stream->writeInt32(notify_cloud_delay_ms); |
| 265 | stream->writeInt32(notify_default_delay_ms); |
| 266 | stream->writeInt32(push_chat_period_ms); |
| 267 | stream->writeInt32(push_chat_limit); |
| 268 | stream->writeInt32(saved_gifs_limit); |
| 269 | stream->writeInt32(edit_time_limit); |
| 270 | stream->writeInt32(revoke_time_limit); |
| 271 | stream->writeInt32(revoke_pm_time_limit); |
| 272 | stream->writeInt32(rating_e_decay); |
| 273 | stream->writeInt32(stickers_recent_limit); |
| 274 | stream->writeInt32(stickers_faved_limit); |
| 275 | stream->writeInt32(channels_read_media_period); |
| 276 | if ((flags & 1) != 0) { |
| 277 | stream->writeInt32(tmp_sessions); |
| 278 | } |
| 279 | stream->writeInt32(pinned_dialogs_count_max); |
| 280 | stream->writeInt32(call_receive_timeout_ms); |
| 281 | stream->writeInt32(call_ring_timeout_ms); |
| 282 | stream->writeInt32(call_connect_timeout_ms); |
| 283 | stream->writeInt32(call_packet_timeout_ms); |
| 284 | stream->writeString(me_url_prefix); |
| 285 | if ((flags & 128) != 0) { |
| 286 | stream->writeString(autoupdate_url_prefix); |
| 287 | } |
| 288 | if ((flags & 512) != 0) { |
| 289 | stream->writeString(gif_search_username); |
| 290 | } |
| 291 | if ((flags & 1024) != 0) { |
| 292 | stream->writeString(venue_search_username); |
| 293 | } |
| 294 | if ((flags & 2048) != 0) { |
| 295 | stream->writeString(img_search_username); |
| 296 | } |
| 297 | if ((flags & 4096) != 0) { |
| 298 | stream->writeString(static_maps_provider); |
| 299 | } |
| 300 | stream->writeInt32(caption_length_max); |
| 301 | stream->writeInt32(message_length_max); |
| 302 | stream->writeInt32(webfile_dc_id); |
| 303 | if ((flags & 4) != 0) { |
| 304 | stream->writeString(suggested_lang_code); |
| 305 | } |
| 306 | if ((flags & 4) != 0) { |
| 307 | stream->writeInt32(lang_pack_version); |
| 308 | } |
| 309 | if ((flags & 4) != 0) { |
| 310 | stream->writeInt32(base_lang_pack_version); |
| 311 | } |
| 312 | } |
| 313 |
| 314 | TLObject *TL_help_getConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 315 | return TL_config::TLdeserialize(stream, constructor, instanceNum, error); |
| 316 | } |
| 317 |
| 318 | void TL_help_getConfig::serializeToStream(NativeByteBuffer *stream) { |
| 319 | stream->writeInt32(constructor); |
| 320 | } |
| 321 |
| 322 | bool TL_help_getConfig::isNeedLayer() { |
| 323 | return true; |
| 324 | } |
| 325 |
| 326 | bool TL_account_registerDevice::isNeedLayer() { |
| 327 | return true; |
| 328 | } |
| 329 |
| 330 | TLObject *TL_account_registerDevice::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 331 | return Bool::TLdeserialize(stream, constructor, instanceNum, error); |
| 332 | } |
| 333 |
| 334 | void TL_account_registerDevice::serializeToStream(NativeByteBuffer *stream) { |
| 335 | stream->writeInt32(constructor); |
| 336 | stream->writeInt32(token_type); |
| 337 | stream->writeString(token); |
| 338 | } |
| 339 |
| 340 | User *User::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 341 | User *result = nullptr; |
| 342 | switch (constructor) { |
| 343 | case 0x200250ba: |
| 344 | result = new TL_userEmpty(); |
| 345 | break; |
| 346 | case 0x2e13f4c3: |
| 347 | result = new TL_user(); |
| 348 | break; |
| 349 | default: |
| 350 | error = true; |
| 351 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in User", constructor); |
| 352 | return nullptr; |
| 353 | } |
| 354 | result->readParams(stream, instanceNum, error); |
| 355 | return result; |
| 356 | } |
| 357 |
| 358 | void TL_userEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 359 | id = stream->readInt32(&error); |
| 360 | } |
| 361 |
| 362 | void TL_userEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 363 | stream->writeInt32(constructor); |
| 364 | stream->writeInt32(id); |
| 365 | } |
| 366 |
| 367 | void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 368 | flags = stream->readInt32(&error); |
| 369 | id = stream->readInt32(&error); |
| 370 | if ((flags & 1) != 0) { |
| 371 | access_hash = stream->readInt64(&error); |
| 372 | } |
| 373 | if ((flags & 2) != 0) { |
| 374 | first_name = stream->readString(&error); |
| 375 | } |
| 376 | if ((flags & 4) != 0) { |
| 377 | last_name = stream->readString(&error); |
| 378 | } |
| 379 | if ((flags & 8) != 0) { |
| 380 | username = stream->readString(&error); |
| 381 | } |
| 382 | if ((flags & 16) != 0) { |
| 383 | phone = stream->readString(&error); |
| 384 | } |
| 385 | if ((flags & 32) != 0) { |
| 386 | photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 387 | } |
| 388 | if ((flags & 64) != 0) { |
| 389 | status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 390 | } |
| 391 | if ((flags & 16384) != 0) { |
| 392 | bot_info_version = stream->readInt32(&error); |
| 393 | } |
| 394 | if ((flags & 262144) != 0) { |
| 395 | restriction_reason = stream->readString(&error); |
| 396 | } |
| 397 | if ((flags & 524288) != 0) { |
| 398 | bot_inline_placeholder = stream->readString(&error); |
| 399 | } |
| 400 | if ((flags & 4194304) != 0) { |
| 401 | lang_code = stream->readString(&error); |
| 402 | } |
| 403 | } |
| 404 |
| 405 | void TL_user::serializeToStream(NativeByteBuffer *stream) { |
| 406 | stream->writeInt32(constructor); |
| 407 | stream->writeInt32(flags); |
| 408 | stream->writeInt32(id); |
| 409 | if ((flags & 1) != 0) { |
| 410 | stream->writeInt64(access_hash); |
| 411 | } |
| 412 | if ((flags & 2) != 0) { |
| 413 | stream->writeString(first_name); |
| 414 | } |
| 415 | if ((flags & 4) != 0) { |
| 416 | stream->writeString(last_name); |
| 417 | } |
| 418 | if ((flags & 8) != 0) { |
| 419 | stream->writeString(username); |
| 420 | } |
| 421 | if ((flags & 16) != 0) { |
| 422 | stream->writeString(phone); |
| 423 | } |
| 424 | if ((flags & 32) != 0) { |
| 425 | photo->serializeToStream(stream); |
| 426 | } |
| 427 | if ((flags & 64) != 0) { |
| 428 | status->serializeToStream(stream); |
| 429 | } |
| 430 | if ((flags & 16384) != 0) { |
| 431 | stream->writeInt32(bot_info_version); |
| 432 | } |
| 433 | if ((flags & 262144) != 0) { |
| 434 | stream->writeString(restriction_reason); |
| 435 | } |
| 436 | if ((flags & 524288) != 0) { |
| 437 | stream->writeString(bot_inline_placeholder); |
| 438 | } |
| 439 | if ((flags & 4194304) != 0) { |
| 440 | stream->writeString(lang_code); |
| 441 | } |
| 442 | } |
| 443 |
| 444 | TL_auth_authorization *TL_auth_authorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 445 | if (TL_auth_authorization::constructor != constructor) { |
| 446 | error = true; |
| 447 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_auth_authorization", constructor); |
| 448 | return nullptr; |
| 449 | } |
| 450 | TL_auth_authorization *result = new TL_auth_authorization(); |
| 451 | result->readParams(stream, instanceNum, error); |
| 452 | return result; |
| 453 | } |
| 454 |
| 455 | void TL_auth_authorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 456 | flags = stream->readInt32(&error); |
| 457 | if ((flags & 1) != 0) { |
| 458 | tmp_sessions = stream->readInt32(&error); |
| 459 | } |
| 460 | user = std::unique_ptr<User>(User::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 461 | } |
| 462 |
| 463 | TL_auth_exportedAuthorization *TL_auth_exportedAuthorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 464 | if (TL_auth_exportedAuthorization::constructor != constructor) { |
| 465 | error = true; |
| 466 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_auth_exportedAuthorization", constructor); |
| 467 | return nullptr; |
| 468 | } |
| 469 | TL_auth_exportedAuthorization *result = new TL_auth_exportedAuthorization(); |
| 470 | result->readParams(stream, instanceNum, error); |
| 471 | return result; |
| 472 | } |
| 473 |
| 474 | void TL_auth_exportedAuthorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 475 | id = stream->readInt32(&error); |
| 476 | bytes = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 477 | } |
| 478 |
| 479 | bool TL_auth_exportAuthorization::isNeedLayer() { |
| 480 | return true; |
| 481 | } |
| 482 |
| 483 | TLObject *TL_auth_exportAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 484 | return TL_auth_exportedAuthorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 485 | } |
| 486 |
| 487 | void TL_auth_exportAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 488 | stream->writeInt32(constructor); |
| 489 | stream->writeInt32(dc_id); |
| 490 | } |
| 491 |
| 492 | bool TL_auth_importAuthorization::isNeedLayer() { |
| 493 | return true; |
| 494 | } |
| 495 |
| 496 | TLObject *TL_auth_importAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 497 | return TL_auth_authorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 498 | } |
| 499 |
| 500 | void TL_auth_importAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 501 | stream->writeInt32(constructor); |
| 502 | stream->writeInt32(id); |
| 503 | stream->writeByteArray(bytes.get()); |
| 504 | } |
| 505 |
| 506 | UserStatus *UserStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 507 | UserStatus *result = nullptr; |
| 508 | switch (constructor) { |
| 509 | case 0x8c703f: |
| 510 | result = new TL_userStatusOffline(); |
| 511 | break; |
| 512 | case 0x7bf09fc: |
| 513 | result = new TL_userStatusLastWeek(); |
| 514 | break; |
| 515 | case 0x9d05049: |
| 516 | result = new TL_userStatusEmpty(); |
| 517 | break; |
| 518 | case 0x77ebc742: |
| 519 | result = new TL_userStatusLastMonth(); |
| 520 | break; |
| 521 | case 0xedb93949: |
| 522 | result = new TL_userStatusOnline(); |
| 523 | break; |
| 524 | case 0xe26f42f1: |
| 525 | result = new TL_userStatusRecently(); |
| 526 | break; |
| 527 | default: |
| 528 | error = true; |
| 529 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in UserStatus", constructor); |
| 530 | return nullptr; |
| 531 | } |
| 532 | result->readParams(stream, instanceNum, error); |
| 533 | return result; |
| 534 | } |
| 535 |
| 536 | void TL_userStatusOffline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 537 | expires = stream->readInt32(&error); |
| 538 | } |
| 539 |
| 540 | void TL_userStatusOffline::serializeToStream(NativeByteBuffer *stream) { |
| 541 | stream->writeInt32(constructor); |
| 542 | stream->writeInt32(expires); |
| 543 | } |
| 544 |
| 545 | void TL_userStatusLastWeek::serializeToStream(NativeByteBuffer *stream) { |
| 546 | stream->writeInt32(constructor); |
| 547 | } |
| 548 |
| 549 | void TL_userStatusEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 550 | stream->writeInt32(constructor); |
| 551 | } |
| 552 |
| 553 | void TL_userStatusLastMonth::serializeToStream(NativeByteBuffer *stream) { |
| 554 | stream->writeInt32(constructor); |
| 555 | } |
| 556 |
| 557 | void TL_userStatusOnline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 558 | expires = stream->readInt32(&error); |
| 559 | } |
| 560 |
| 561 | void TL_userStatusOnline::serializeToStream(NativeByteBuffer *stream) { |
| 562 | stream->writeInt32(constructor); |
| 563 | stream->writeInt32(expires); |
| 564 | } |
| 565 |
| 566 | void TL_userStatusRecently::serializeToStream(NativeByteBuffer *stream) { |
| 567 | stream->writeInt32(constructor); |
| 568 | } |
| 569 |
| 570 | FileLocation *FileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 571 | FileLocation *result = nullptr; |
| 572 | switch (constructor) { |
| 573 | case 0x91d11eb: |
| 574 | result = new TL_fileLocation(); |
| 575 | break; |
| 576 | case 0x7c596b46: |
| 577 | result = new TL_fileLocationUnavailable(); |
| 578 | break; |
| 579 | case 0x55555554: |
| 580 | result = new TL_fileEncryptedLocation(); |
| 581 | break; |
| 582 | default: |
| 583 | error = true; |
| 584 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in FileLocation", constructor); |
| 585 | return nullptr; |
| 586 | } |
| 587 | result->readParams(stream, instanceNum, error); |
| 588 | return result; |
| 589 | } |
| 590 |
| 591 | void TL_fileLocation::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 592 | dc_id = stream->readInt32(&error); |
| 593 | volume_id = stream->readInt64(&error); |
| 594 | local_id = stream->readInt32(&error); |
| 595 | secret = stream->readInt64(&error); |
| 596 | file_reference = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 597 | } |
| 598 |
| 599 | void TL_fileLocation::serializeToStream(NativeByteBuffer *stream) { |
| 600 | stream->writeInt32(constructor); |
| 601 | stream->writeInt32(dc_id); |
| 602 | stream->writeInt64(volume_id); |
| 603 | stream->writeInt32(local_id); |
| 604 | stream->writeInt64(secret); |
| 605 | stream->writeByteArray(file_reference.get()); |
| 606 | } |
| 607 |
| 608 | void TL_fileLocationUnavailable::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 609 | volume_id = stream->readInt64(&error); |
| 610 | local_id = stream->readInt32(&error); |
| 611 | secret = stream->readInt64(&error); |
| 612 | } |
| 613 |
| 614 | void TL_fileLocationUnavailable::serializeToStream(NativeByteBuffer *stream) { |
| 615 | stream->writeInt32(constructor); |
| 616 | stream->writeInt64(volume_id); |
| 617 | stream->writeInt32(local_id); |
| 618 | stream->writeInt64(secret); |
| 619 | } |
| 620 |
| 621 | void TL_fileEncryptedLocation::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 622 | dc_id = stream->readInt32(&error); |
| 623 | volume_id = stream->readInt64(&error); |
| 624 | local_id = stream->readInt32(&error); |
| 625 | secret = stream->readInt64(&error); |
| 626 | key = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 627 | iv = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 628 | } |
| 629 |
| 630 | void TL_fileEncryptedLocation::serializeToStream(NativeByteBuffer *stream) { |
| 631 | stream->writeInt32(constructor); |
| 632 | stream->writeInt32(dc_id); |
| 633 | stream->writeInt64(volume_id); |
| 634 | stream->writeInt32(local_id); |
| 635 | stream->writeInt64(secret); |
| 636 | stream->writeByteArray(key.get()); |
| 637 | stream->writeByteArray(iv.get()); |
| 638 | } |
| 639 |
| 640 | UserProfilePhoto *UserProfilePhoto::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 641 | UserProfilePhoto *result = nullptr; |
| 642 | switch (constructor) { |
| 643 | case 0x4f11bae1: |
| 644 | result = new TL_userProfilePhotoEmpty(); |
| 645 | break; |
| 646 | case 0xd559d8c8: |
| 647 | result = new TL_userProfilePhoto(); |
| 648 | break; |
| 649 | default: |
| 650 | error = true; |
| 651 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in UserProfilePhoto", constructor); |
| 652 | return nullptr; |
| 653 | } |
| 654 | result->readParams(stream, instanceNum, error); |
| 655 | return result; |
| 656 | } |
| 657 |
| 658 | void TL_userProfilePhotoEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 659 | stream->writeInt32(constructor); |
| 660 | } |
| 661 |
| 662 | void TL_userProfilePhoto::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 663 | photo_id = stream->readInt64(&error); |
| 664 | photo_small = std::unique_ptr<FileLocation>(FileLocation::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 665 | photo_big = std::unique_ptr<FileLocation>(FileLocation::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 666 | } |
| 667 |
| 668 | void TL_userProfilePhoto::serializeToStream(NativeByteBuffer *stream) { |
| 669 | stream->writeInt32(constructor); |
| 670 | stream->writeInt64(photo_id); |
| 671 | photo_small->serializeToStream(stream); |
| 672 | photo_big->serializeToStream(stream); |
| 673 | } |
| 674 |
| 675 | auth_SentCode *auth_SentCode::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 676 | auth_SentCode *result = nullptr; |
| 677 | switch (constructor) { |
| 678 | case 0xe325edcf: |
| 679 | result = new TL_auth_sentAppCode(); |
| 680 | break; |
| 681 | case 0xefed51d9: |
| 682 | result = new TL_auth_sentCode(); |
| 683 | break; |
| 684 | default: |
| 685 | error = true; |
| 686 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in auth_SentCode", constructor); |
| 687 | return nullptr; |
| 688 | } |
| 689 | result->readParams(stream, instanceNum, error); |
| 690 | return result; |
| 691 | } |
| 692 |
| 693 | void TL_auth_sentAppCode::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 694 | phone_registered = stream->readBool(&error); |
| 695 | phone_code_hash = stream->readString(&error); |
| 696 | send_call_timeout = stream->readInt32(&error); |
| 697 | is_password = stream->readBool(&error); |
| 698 | } |
| 699 |
| 700 | void TL_auth_sentAppCode::serializeToStream(NativeByteBuffer *stream) { |
| 701 | stream->writeInt32(constructor); |
| 702 | stream->writeBool(phone_registered); |
| 703 | stream->writeString(phone_code_hash); |
| 704 | stream->writeInt32(send_call_timeout); |
| 705 | stream->writeBool(is_password); |
| 706 | } |
| 707 |
| 708 | void TL_auth_sentCode::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 709 | phone_registered = stream->readBool(&error); |
| 710 | phone_code_hash = stream->readString(&error); |
| 711 | send_call_timeout = stream->readInt32(&error); |
| 712 | is_password = stream->readBool(&error); |
| 713 | } |
| 714 |
| 715 | void TL_auth_sentCode::serializeToStream(NativeByteBuffer *stream) { |
| 716 | stream->writeInt32(constructor); |
| 717 | stream->writeBool(phone_registered); |
| 718 | stream->writeString(phone_code_hash); |
| 719 | stream->writeInt32(send_call_timeout); |
| 720 | stream->writeBool(is_password); |
| 721 | } |
| 722 |
| 723 | TLObject *TL_auth_sendCode::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 724 | return auth_SentCode::TLdeserialize(stream, constructor, instanceNum, error); |
| 725 | } |
| 726 |
| 727 | void TL_auth_sendCode::serializeToStream(NativeByteBuffer *stream) { |
| 728 | stream->writeInt32(constructor); |
| 729 | stream->writeString(phone_number); |
| 730 | stream->writeInt32(sms_type); |
| 731 | stream->writeInt32(api_id); |
| 732 | stream->writeString(api_hash); |
| 733 | stream->writeString(lang_code); |
| 734 | } |
| 735 |
| 736 | void TL_updatesTooLong::serializeToStream(NativeByteBuffer *stream) { |
| 737 | stream->writeInt32(constructor); |
| 738 | } |
| 739 |
| 740 | TL_upload_file *TL_upload_file::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 741 | if (TL_upload_file::constructor != constructor) { |
| 742 | error = true; |
| 743 | FileLog::e("can't parse magic %x in TL_upload_file", constructor); |
| 744 | return nullptr; |
| 745 | } |
| 746 | TL_upload_file *result = new TL_upload_file(); |
| 747 | result->readParams(stream, instanceNum, error); |
| 748 | return result; |
| 749 | } |
| 750 |
| 751 | TL_upload_file::~TL_upload_file() { |
| 752 | if (bytes != nullptr) { |
| 753 | bytes->reuse(); |
| 754 | bytes = nullptr; |
| 755 | } |
| 756 | } |
| 757 |
| 758 | void TL_upload_file::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 759 | type = std::unique_ptr<storage_FileType>(storage_FileType::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 760 | mtime = stream->readInt32(&error); |
| 761 | bytes = stream->readByteBuffer(true, &error); |
| 762 | } |
| 763 |
| 764 | InputFileLocation *InputFileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 765 | InputFileLocation *result = nullptr; |
| 766 | switch (constructor) { |
| 767 | case 0x430f0724: |
| 768 | result = new TL_inputDocumentFileLocation(); |
| 769 | break; |
| 770 | case 0x14637196: |
| 771 | result = new TL_inputFileLocation(); |
| 772 | break; |
| 773 | case 0xf5235d55: |
| 774 | result = new TL_inputEncryptedFileLocation(); |
| 775 | break; |
| 776 | default: |
| 777 | error = true; |
| 778 | FileLog::e("can't parse magic %x in InputFileLocation", constructor); |
| 779 | return nullptr; |
| 780 | } |
| 781 | result->readParams(stream, instanceNum, error); |
| 782 | return result; |
| 783 | } |
| 784 |
| 785 | void TL_inputDocumentFileLocation::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 786 | id = stream->readInt64(&error); |
| 787 | access_hash = stream->readInt64(&error); |
| 788 | version = stream->readInt32(&error); |
| 789 | } |
| 790 |
| 791 | void TL_inputDocumentFileLocation::serializeToStream(NativeByteBuffer *stream) { |
| 792 | stream->writeInt32(constructor); |
| 793 | stream->writeInt64(id); |
| 794 | stream->writeInt64(access_hash); |
| 795 | stream->writeInt32(version); |
| 796 | } |
| 797 |
| 798 | void TL_inputFileLocation::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 799 | volume_id = stream->readInt64(&error); |
| 800 | local_id = stream->readInt32(&error); |
| 801 | secret = stream->readInt64(&error); |
| 802 | } |
| 803 |
| 804 | void TL_inputFileLocation::serializeToStream(NativeByteBuffer *stream) { |
| 805 | stream->writeInt32(constructor); |
| 806 | stream->writeInt64(volume_id); |
| 807 | stream->writeInt32(local_id); |
| 808 | stream->writeInt64(secret); |
| 809 | } |
| 810 |
| 811 | void TL_inputEncryptedFileLocation::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 812 | id = stream->readInt64(&error); |
| 813 | access_hash = stream->readInt64(&error); |
| 814 | } |
| 815 |
| 816 | void TL_inputEncryptedFileLocation::serializeToStream(NativeByteBuffer *stream) { |
| 817 | stream->writeInt32(constructor); |
| 818 | stream->writeInt64(id); |
| 819 | stream->writeInt64(access_hash); |
| 820 | } |
| 821 |
| 822 | storage_FileType *storage_FileType::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 823 | storage_FileType *result = nullptr; |
| 824 | switch (constructor) { |
| 825 | case 0xaa963b05: |
| 826 | result = new TL_storage_fileUnknown(); |
| 827 | break; |
| 828 | case 0xb3cea0e4: |
| 829 | result = new TL_storage_fileMp4(); |
| 830 | break; |
| 831 | case 0x1081464c: |
| 832 | result = new TL_storage_fileWebp(); |
| 833 | break; |
| 834 | case 0xa4f63c0: |
| 835 | result = new TL_storage_filePng(); |
| 836 | break; |
| 837 | case 0xcae1aadf: |
| 838 | result = new TL_storage_fileGif(); |
| 839 | break; |
| 840 | case 0xae1e508d: |
| 841 | result = new TL_storage_filePdf(); |
| 842 | break; |
| 843 | case 0x528a0677: |
| 844 | result = new TL_storage_fileMp3(); |
| 845 | break; |
| 846 | case 0x7efe0e: |
| 847 | result = new TL_storage_fileJpeg(); |
| 848 | break; |
| 849 | case 0x4b09ebbc: |
| 850 | result = new TL_storage_fileMov(); |
| 851 | break; |
| 852 | case 0x40bc6f52: |
| 853 | result = new TL_storage_filePartial(); |
| 854 | break; |
| 855 | default: |
| 856 | error = true; |
| 857 | FileLog::e("can't parse magic %x in storage_FileType", constructor); |
| 858 | return nullptr; |
| 859 | } |
| 860 | result->readParams(stream, instanceNum, error); |
| 861 | return result; |
| 862 | } |
| 863 |
| 864 | void TL_storage_fileUnknown::serializeToStream(NativeByteBuffer *stream) { |
| 865 | stream->writeInt32(constructor); |
| 866 | } |
| 867 |
| 868 | void TL_storage_fileMp4::serializeToStream(NativeByteBuffer *stream) { |
| 869 | stream->writeInt32(constructor); |
| 870 | } |
| 871 |
| 872 | void TL_storage_fileWebp::serializeToStream(NativeByteBuffer *stream) { |
| 873 | stream->writeInt32(constructor); |
| 874 | } |
| 875 |
| 876 | void TL_storage_filePng::serializeToStream(NativeByteBuffer *stream) { |
| 877 | stream->writeInt32(constructor); |
| 878 | } |
| 879 |
| 880 | void TL_storage_fileGif::serializeToStream(NativeByteBuffer *stream) { |
| 881 | stream->writeInt32(constructor); |
| 882 | } |
| 883 |
| 884 | void TL_storage_filePdf::serializeToStream(NativeByteBuffer *stream) { |
| 885 | stream->writeInt32(constructor); |
| 886 | } |
| 887 |
| 888 | void TL_storage_fileMp3::serializeToStream(NativeByteBuffer *stream) { |
| 889 | stream->writeInt32(constructor); |
| 890 | } |
| 891 |
| 892 | void TL_storage_fileJpeg::serializeToStream(NativeByteBuffer *stream) { |
| 893 | stream->writeInt32(constructor); |
| 894 | } |
| 895 |
| 896 | void TL_storage_fileMov::serializeToStream(NativeByteBuffer *stream) { |
| 897 | stream->writeInt32(constructor); |
| 898 | } |
| 899 |
| 900 | void TL_storage_filePartial::serializeToStream(NativeByteBuffer *stream) { |
| 901 | stream->writeInt32(constructor); |
| 902 | } |
| 903 |
| 904 | TLObject *TL_upload_saveFilePart::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 905 | return Bool::TLdeserialize(stream, constructor, instanceNum, error); |
| 906 | } |
| 907 |
| 908 | void TL_upload_saveFilePart::serializeToStream(NativeByteBuffer *stream) { |
| 909 | stream->writeInt32(constructor); |
| 910 | stream->writeInt64(file_id); |
| 911 | stream->writeInt32(file_part); |
| 912 | stream->writeByteArray(bytes.get()); |
| 913 | } |
| 914 |
| 915 | bool TL_upload_saveFilePart::isNeedLayer() { |
| 916 | return true; |
| 917 | } |
| 918 |
| 919 | TLObject *TL_upload_getFile::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 920 | return TL_upload_file::TLdeserialize(stream, constructor, instanceNum, error); |
| 921 | } |
| 922 |
| 923 | void TL_upload_getFile::serializeToStream(NativeByteBuffer *stream) { |
| 924 | stream->writeInt32(constructor); |
| 925 | location->serializeToStream(stream); |
| 926 | stream->writeInt32(offset); |
| 927 | stream->writeInt32(limit); |
| 928 | } |
| 929 |
| 930 | bool TL_upload_getFile::isNeedLayer() { |
| 931 | return true; |
| 932 | } |
| 933 |