ApiScheme.cpp 43 KB

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