| 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 | pinned_infolder_count_max = stream->readInt32(&error); |
| 210 | call_receive_timeout_ms = stream->readInt32(&error); |
| 211 | call_ring_timeout_ms = stream->readInt32(&error); |
| 212 | call_connect_timeout_ms = stream->readInt32(&error); |
| 213 | call_packet_timeout_ms = stream->readInt32(&error); |
| 214 | me_url_prefix = stream->readString(&error); |
| 215 | if ((flags & 128) != 0) { |
| 216 | autoupdate_url_prefix = stream->readString(&error); |
| 217 | } |
| 218 | if ((flags & 512) != 0) { |
| 219 | gif_search_username = stream->readString(&error); |
| 220 | } |
| 221 | if ((flags & 1024) != 0) { |
| 222 | venue_search_username = stream->readString(&error); |
| 223 | } |
| 224 | if ((flags & 2048) != 0) { |
| 225 | img_search_username = stream->readString(&error); |
| 226 | } |
| 227 | if ((flags & 4096) != 0) { |
| 228 | static_maps_provider = stream->readString(&error); |
| 229 | } |
| 230 | caption_length_max = stream->readInt32(&error); |
| 231 | message_length_max = stream->readInt32(&error); |
| 232 | webfile_dc_id = stream->readInt32(&error); |
| 233 | if ((flags & 4) != 0) { |
| 234 | suggested_lang_code = stream->readString(&error); |
| 235 | } |
| 236 | if ((flags & 4) != 0) { |
| 237 | lang_pack_version = stream->readInt32(&error); |
| 238 | } |
| 239 | if ((flags & 4) != 0) { |
| 240 | base_lang_pack_version = stream->readInt32(&error); |
| 241 | } |
| 242 | } |
| 243 |
| 244 | void TL_config::serializeToStream(NativeByteBuffer *stream) { |
| 245 | stream->writeInt32(constructor); |
| 246 | stream->writeInt32(flags); |
| 247 | stream->writeInt32(date); |
| 248 | stream->writeInt32(expires); |
| 249 | stream->writeBool(test_mode); |
| 250 | stream->writeInt32(this_dc); |
| 251 | stream->writeInt32(0x1cb5c415); |
| 252 | uint32_t count = (uint32_t) dc_options.size(); |
| 253 | stream->writeInt32(count); |
| 254 | for (uint32_t a = 0; a < count; a++) { |
| 255 | dc_options[a]->serializeToStream(stream); |
| 256 | } |
| 257 | stream->writeString(dc_txt_domain_name); |
| 258 | stream->writeInt32(chat_size_max); |
| 259 | stream->writeInt32(megagroup_size_max); |
| 260 | stream->writeInt32(forwarded_count_max); |
| 261 | stream->writeInt32(online_update_period_ms); |
| 262 | stream->writeInt32(offline_blur_timeout_ms); |
| 263 | stream->writeInt32(offline_idle_timeout_ms); |
| 264 | stream->writeInt32(online_cloud_timeout_ms); |
| 265 | stream->writeInt32(notify_cloud_delay_ms); |
| 266 | stream->writeInt32(notify_default_delay_ms); |
| 267 | stream->writeInt32(push_chat_period_ms); |
| 268 | stream->writeInt32(push_chat_limit); |
| 269 | stream->writeInt32(saved_gifs_limit); |
| 270 | stream->writeInt32(edit_time_limit); |
| 271 | stream->writeInt32(revoke_time_limit); |
| 272 | stream->writeInt32(revoke_pm_time_limit); |
| 273 | stream->writeInt32(rating_e_decay); |
| 274 | stream->writeInt32(stickers_recent_limit); |
| 275 | stream->writeInt32(stickers_faved_limit); |
| 276 | stream->writeInt32(channels_read_media_period); |
| 277 | if ((flags & 1) != 0) { |
| 278 | stream->writeInt32(tmp_sessions); |
| 279 | } |
| 280 | stream->writeInt32(pinned_dialogs_count_max); |
| 281 | stream->writeInt32(pinned_infolder_count_max); |
| 282 | stream->writeInt32(call_receive_timeout_ms); |
| 283 | stream->writeInt32(call_ring_timeout_ms); |
| 284 | stream->writeInt32(call_connect_timeout_ms); |
| 285 | stream->writeInt32(call_packet_timeout_ms); |
| 286 | stream->writeString(me_url_prefix); |
| 287 | if ((flags & 128) != 0) { |
| 288 | stream->writeString(autoupdate_url_prefix); |
| 289 | } |
| 290 | if ((flags & 512) != 0) { |
| 291 | stream->writeString(gif_search_username); |
| 292 | } |
| 293 | if ((flags & 1024) != 0) { |
| 294 | stream->writeString(venue_search_username); |
| 295 | } |
| 296 | if ((flags & 2048) != 0) { |
| 297 | stream->writeString(img_search_username); |
| 298 | } |
| 299 | if ((flags & 4096) != 0) { |
| 300 | stream->writeString(static_maps_provider); |
| 301 | } |
| 302 | stream->writeInt32(caption_length_max); |
| 303 | stream->writeInt32(message_length_max); |
| 304 | stream->writeInt32(webfile_dc_id); |
| 305 | if ((flags & 4) != 0) { |
| 306 | stream->writeString(suggested_lang_code); |
| 307 | } |
| 308 | if ((flags & 4) != 0) { |
| 309 | stream->writeInt32(lang_pack_version); |
| 310 | } |
| 311 | if ((flags & 4) != 0) { |
| 312 | stream->writeInt32(base_lang_pack_version); |
| 313 | } |
| 314 | } |
| 315 |
| 316 | TLObject *TL_help_getConfig::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 317 | return TL_config::TLdeserialize(stream, constructor, instanceNum, error); |
| 318 | } |
| 319 |
| 320 | void TL_help_getConfig::serializeToStream(NativeByteBuffer *stream) { |
| 321 | stream->writeInt32(constructor); |
| 322 | } |
| 323 |
| 324 | bool TL_help_getConfig::isNeedLayer() { |
| 325 | return true; |
| 326 | } |
| 327 |
| 328 | bool TL_account_registerDevice::isNeedLayer() { |
| 329 | return true; |
| 330 | } |
| 331 |
| 332 | TLObject *TL_account_registerDevice::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 333 | return Bool::TLdeserialize(stream, constructor, instanceNum, error); |
| 334 | } |
| 335 |
| 336 | void TL_account_registerDevice::serializeToStream(NativeByteBuffer *stream) { |
| 337 | stream->writeInt32(constructor); |
| 338 | stream->writeInt32(token_type); |
| 339 | stream->writeString(token); |
| 340 | } |
| 341 |
| 342 | User *User::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 343 | User *result = nullptr; |
| 344 | switch (constructor) { |
| 345 | case 0x200250ba: |
| 346 | result = new TL_userEmpty(); |
| 347 | break; |
| 348 | case 0x2e13f4c3: |
| 349 | result = new TL_user(); |
| 350 | break; |
| 351 | default: |
| 352 | error = true; |
| 353 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in User", constructor); |
| 354 | return nullptr; |
| 355 | } |
| 356 | result->readParams(stream, instanceNum, error); |
| 357 | return result; |
| 358 | } |
| 359 |
| 360 | void TL_userEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 361 | id = stream->readInt32(&error); |
| 362 | } |
| 363 |
| 364 | void TL_userEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 365 | stream->writeInt32(constructor); |
| 366 | stream->writeInt32(id); |
| 367 | } |
| 368 |
| 369 | void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 370 | flags = stream->readInt32(&error); |
| 371 | id = stream->readInt32(&error); |
| 372 | if ((flags & 1) != 0) { |
| 373 | access_hash = stream->readInt64(&error); |
| 374 | } |
| 375 | if ((flags & 2) != 0) { |
| 376 | first_name = stream->readString(&error); |
| 377 | } |
| 378 | if ((flags & 4) != 0) { |
| 379 | last_name = stream->readString(&error); |
| 380 | } |
| 381 | if ((flags & 8) != 0) { |
| 382 | username = stream->readString(&error); |
| 383 | } |
| 384 | if ((flags & 16) != 0) { |
| 385 | phone = stream->readString(&error); |
| 386 | } |
| 387 | if ((flags & 32) != 0) { |
| 388 | photo = std::unique_ptr<UserProfilePhoto>(UserProfilePhoto::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 389 | } |
| 390 | if ((flags & 64) != 0) { |
| 391 | status = std::unique_ptr<UserStatus>(UserStatus::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 392 | } |
| 393 | if ((flags & 16384) != 0) { |
| 394 | bot_info_version = stream->readInt32(&error); |
| 395 | } |
| 396 | if ((flags & 262144) != 0) { |
| 397 | restriction_reason = stream->readString(&error); |
| 398 | } |
| 399 | if ((flags & 524288) != 0) { |
| 400 | bot_inline_placeholder = stream->readString(&error); |
| 401 | } |
| 402 | if ((flags & 4194304) != 0) { |
| 403 | lang_code = stream->readString(&error); |
| 404 | } |
| 405 | } |
| 406 |
| 407 | void TL_user::serializeToStream(NativeByteBuffer *stream) { |
| 408 | stream->writeInt32(constructor); |
| 409 | stream->writeInt32(flags); |
| 410 | stream->writeInt32(id); |
| 411 | if ((flags & 1) != 0) { |
| 412 | stream->writeInt64(access_hash); |
| 413 | } |
| 414 | if ((flags & 2) != 0) { |
| 415 | stream->writeString(first_name); |
| 416 | } |
| 417 | if ((flags & 4) != 0) { |
| 418 | stream->writeString(last_name); |
| 419 | } |
| 420 | if ((flags & 8) != 0) { |
| 421 | stream->writeString(username); |
| 422 | } |
| 423 | if ((flags & 16) != 0) { |
| 424 | stream->writeString(phone); |
| 425 | } |
| 426 | if ((flags & 32) != 0) { |
| 427 | photo->serializeToStream(stream); |
| 428 | } |
| 429 | if ((flags & 64) != 0) { |
| 430 | status->serializeToStream(stream); |
| 431 | } |
| 432 | if ((flags & 16384) != 0) { |
| 433 | stream->writeInt32(bot_info_version); |
| 434 | } |
| 435 | if ((flags & 262144) != 0) { |
| 436 | stream->writeString(restriction_reason); |
| 437 | } |
| 438 | if ((flags & 524288) != 0) { |
| 439 | stream->writeString(bot_inline_placeholder); |
| 440 | } |
| 441 | if ((flags & 4194304) != 0) { |
| 442 | stream->writeString(lang_code); |
| 443 | } |
| 444 | } |
| 445 |
| 446 | TL_auth_authorization *TL_auth_authorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 447 | if (TL_auth_authorization::constructor != constructor) { |
| 448 | error = true; |
| 449 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_auth_authorization", constructor); |
| 450 | return nullptr; |
| 451 | } |
| 452 | TL_auth_authorization *result = new TL_auth_authorization(); |
| 453 | result->readParams(stream, instanceNum, error); |
| 454 | return result; |
| 455 | } |
| 456 |
| 457 | void TL_auth_authorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 458 | flags = stream->readInt32(&error); |
| 459 | if ((flags & 1) != 0) { |
| 460 | tmp_sessions = stream->readInt32(&error); |
| 461 | } |
| 462 | user = std::unique_ptr<User>(User::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 463 | } |
| 464 |
| 465 | TL_auth_exportedAuthorization *TL_auth_exportedAuthorization::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 466 | if (TL_auth_exportedAuthorization::constructor != constructor) { |
| 467 | error = true; |
| 468 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in TL_auth_exportedAuthorization", constructor); |
| 469 | return nullptr; |
| 470 | } |
| 471 | TL_auth_exportedAuthorization *result = new TL_auth_exportedAuthorization(); |
| 472 | result->readParams(stream, instanceNum, error); |
| 473 | return result; |
| 474 | } |
| 475 |
| 476 | void TL_auth_exportedAuthorization::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 477 | id = stream->readInt32(&error); |
| 478 | bytes = std::unique_ptr<ByteArray>(stream->readByteArray(&error)); |
| 479 | } |
| 480 |
| 481 | bool TL_auth_exportAuthorization::isNeedLayer() { |
| 482 | return true; |
| 483 | } |
| 484 |
| 485 | TLObject *TL_auth_exportAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 486 | return TL_auth_exportedAuthorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 487 | } |
| 488 |
| 489 | void TL_auth_exportAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 490 | stream->writeInt32(constructor); |
| 491 | stream->writeInt32(dc_id); |
| 492 | } |
| 493 |
| 494 | bool TL_auth_importAuthorization::isNeedLayer() { |
| 495 | return true; |
| 496 | } |
| 497 |
| 498 | TLObject *TL_auth_importAuthorization::deserializeResponse(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 499 | return TL_auth_authorization::TLdeserialize(stream, constructor, instanceNum, error); |
| 500 | } |
| 501 |
| 502 | void TL_auth_importAuthorization::serializeToStream(NativeByteBuffer *stream) { |
| 503 | stream->writeInt32(constructor); |
| 504 | stream->writeInt32(id); |
| 505 | stream->writeByteArray(bytes.get()); |
| 506 | } |
| 507 |
| 508 | UserStatus *UserStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 509 | UserStatus *result = nullptr; |
| 510 | switch (constructor) { |
| 511 | case 0x8c703f: |
| 512 | result = new TL_userStatusOffline(); |
| 513 | break; |
| 514 | case 0x7bf09fc: |
| 515 | result = new TL_userStatusLastWeek(); |
| 516 | break; |
| 517 | case 0x9d05049: |
| 518 | result = new TL_userStatusEmpty(); |
| 519 | break; |
| 520 | case 0x77ebc742: |
| 521 | result = new TL_userStatusLastMonth(); |
| 522 | break; |
| 523 | case 0xedb93949: |
| 524 | result = new TL_userStatusOnline(); |
| 525 | break; |
| 526 | case 0xe26f42f1: |
| 527 | result = new TL_userStatusRecently(); |
| 528 | break; |
| 529 | default: |
| 530 | error = true; |
| 531 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in UserStatus", constructor); |
| 532 | return nullptr; |
| 533 | } |
| 534 | result->readParams(stream, instanceNum, error); |
| 535 | return result; |
| 536 | } |
| 537 |
| 538 | void TL_userStatusOffline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 539 | expires = stream->readInt32(&error); |
| 540 | } |
| 541 |
| 542 | void TL_userStatusOffline::serializeToStream(NativeByteBuffer *stream) { |
| 543 | stream->writeInt32(constructor); |
| 544 | stream->writeInt32(expires); |
| 545 | } |
| 546 |
| 547 | void TL_userStatusLastWeek::serializeToStream(NativeByteBuffer *stream) { |
| 548 | stream->writeInt32(constructor); |
| 549 | } |
| 550 |
| 551 | void TL_userStatusEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 552 | stream->writeInt32(constructor); |
| 553 | } |
| 554 |
| 555 | void TL_userStatusLastMonth::serializeToStream(NativeByteBuffer *stream) { |
| 556 | stream->writeInt32(constructor); |
| 557 | } |
| 558 |
| 559 | void TL_userStatusOnline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 560 | expires = stream->readInt32(&error); |
| 561 | } |
| 562 |
| 563 | void TL_userStatusOnline::serializeToStream(NativeByteBuffer *stream) { |
| 564 | stream->writeInt32(constructor); |
| 565 | stream->writeInt32(expires); |
| 566 | } |
| 567 |
| 568 | void TL_userStatusRecently::serializeToStream(NativeByteBuffer *stream) { |
| 569 | stream->writeInt32(constructor); |
| 570 | } |
| 571 |
| 572 | FileLocation *FileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 573 | FileLocation *result = nullptr; |
| 574 | switch (constructor) { |
| 575 | case 0xbc7fc6cd: |
| 576 | result = new TL_fileLocationToBeDeprecated(); |
| 577 | break; |
| 578 | default: |
| 579 | error = true; |
| 580 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in FileLocation", constructor); |
| 581 | return nullptr; |
| 582 | } |
| 583 | result->readParams(stream, instanceNum, error); |
| 584 | return result; |
| 585 | } |
| 586 |
| 587 | void TL_fileLocationToBeDeprecated::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 588 | volume_id = stream->readInt64(&error); |
| 589 | local_id = stream->readInt32(&error); |
| 590 | } |
| 591 |
| 592 | void TL_fileLocationToBeDeprecated::serializeToStream(NativeByteBuffer *stream) { |
| 593 | stream->writeInt32(constructor); |
| 594 | stream->writeInt64(volume_id); |
| 595 | stream->writeInt32(local_id); |
| 596 | } |
| 597 |
| 598 | UserProfilePhoto *UserProfilePhoto::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { |
| 599 | UserProfilePhoto *result = nullptr; |
| 600 | switch (constructor) { |
| 601 | case 0x4f11bae1: |
| 602 | result = new TL_userProfilePhotoEmpty(); |
| 603 | break; |
| 604 | case 0xecd75d8c: |
| 605 | result = new TL_userProfilePhoto(); |
| 606 | break; |
| 607 | default: |
| 608 | error = true; |
| 609 | if (LOGS_ENABLED) DEBUG_E("can't parse magic %x in UserProfilePhoto", constructor); |
| 610 | return nullptr; |
| 611 | } |
| 612 | result->readParams(stream, instanceNum, error); |
| 613 | return result; |
| 614 | } |
| 615 |
| 616 | void TL_userProfilePhotoEmpty::serializeToStream(NativeByteBuffer *stream) { |
| 617 | stream->writeInt32(constructor); |
| 618 | } |
| 619 |
| 620 | void TL_userProfilePhoto::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) { |
| 621 | photo_id = stream->readInt64(&error); |
| 622 | photo_small = std::unique_ptr<FileLocation>(FileLocation::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 623 | photo_big = std::unique_ptr<FileLocation>(FileLocation::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); |
| 624 | dc_id = stream->readInt32(&error); |
| 625 | } |
| 626 |
| 627 | void TL_userProfilePhoto::serializeToStream(NativeByteBuffer *stream) { |
| 628 | stream->writeInt32(constructor); |
| 629 | stream->writeInt64(photo_id); |
| 630 | photo_small->serializeToStream(stream); |
| 631 | photo_big->serializeToStream(stream); |
| 632 | stream->writeInt32(dc_id); |
| 633 | } |
| 634 |
| 635 | void TL_updatesTooLong::serializeToStream(NativeByteBuffer *stream) { |
| 636 | stream->writeInt32(constructor); |
| 637 | } |
| 638 |