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