From a6c00cde52ee9ffbbd199e1eac1b0a2fec75dc35 Mon Sep 17 00:00:00 2001 From: vvaltman Date: Sun, 12 Oct 2014 19:53:57 +0400 Subject: [PATCH] Added support for layer 18 --- binlog.c | 27 +++ binlog.h | 1 + binlog.tl | 1 + interface.c | 18 ++ lua-tg.c | 3 + queries.c | 52 ++++- scheme.tl | 2 +- scheme18.tl | 535 +++++++++++++++++++++++++++++++++++++++++++++++++++ structures.c | 9 + tgl-layout.h | 1 + tgl.h | 5 +- updates.c | 15 ++ 12 files changed, 666 insertions(+), 3 deletions(-) create mode 100644 scheme18.tl diff --git a/binlog.c b/binlog.c index 3557c8e..3a6e428 100644 --- a/binlog.c +++ b/binlog.c @@ -326,6 +326,20 @@ static int fetch_comb_binlog_user_set_name (void *extra) { return 0; } +static int fetch_comb_binlog_user_set_username (void *extra) { + tgl_peer_id_t id = TGL_MK_USER (fetch_int ()); + tgl_peer_t *U = tgl_peer_get (id); + assert (U); + + if (U->user.username) { tfree_str (U->user.username); } + U->user.username = fetch_str_dup (); + + if (tgl_state.callback.user_update) { + tgl_state.callback.user_update ((void *)U, TGL_UPDATE_USERNAME); + } + return 0; +} + static int fetch_comb_binlog_user_set_photo (void *extra) { tgl_peer_id_t id = TGL_MK_USER (fetch_int ()); tgl_peer_t *U = tgl_peer_get (id); @@ -1270,6 +1284,7 @@ static void replay_log_event (void) { FETCH_COMBINATOR_FUNCTION (binlog_user_set_full_photo) FETCH_COMBINATOR_FUNCTION (binlog_user_set_blocked) FETCH_COMBINATOR_FUNCTION (binlog_user_set_name) + FETCH_COMBINATOR_FUNCTION (binlog_user_set_username) FETCH_COMBINATOR_FUNCTION (binlog_user_set_photo) FETCH_COMBINATOR_FUNCTION (binlog_user_set_real_name) @@ -1567,6 +1582,18 @@ void bl_do_user_set_name (struct tgl_user *U, const char *f, int fl, const char add_log_event (packet_buffer, 4 * (packet_ptr - packet_buffer)); } +void bl_do_user_set_username (struct tgl_user *U, const char *f, int l) { + if ((U->username && (int)strlen (U->username) == l && !strncmp (U->username, f, l)) || + (!l && !U->username)) { + return; + } + clear_packet (); + out_int (CODE_binlog_user_set_username); + out_int (tgl_get_peer_id (U->id)); + out_cstring (f, l); + add_log_event (packet_buffer, 4 * (packet_ptr - packet_buffer)); +} + void bl_do_user_set_access_hash (struct tgl_user *U, long long access_token) { if (U->access_hash == access_token) { return; } int *ev = alloc_log_event (16); diff --git a/binlog.h b/binlog.h index fd38496..dba71ce 100644 --- a/binlog.h +++ b/binlog.h @@ -32,6 +32,7 @@ void bl_do_user_add (int id, const char *f, int fl, const char *l, int ll, long void bl_do_user_delete (struct tgl_user *U); void bl_do_set_user_profile_photo (struct tgl_user *U, long long photo_id, struct tgl_file_location *big, struct tgl_file_location *small); void bl_do_user_set_name (struct tgl_user *U, const char *f, int fl, const char *l, int ll); +void bl_do_user_set_username (struct tgl_user *U, const char *f, int l); void bl_do_user_set_access_hash (struct tgl_user *U, long long access_token); void bl_do_user_set_phone (struct tgl_user *U, const char *p, int pl); void bl_do_user_set_friend (struct tgl_user *U, int friend); diff --git a/binlog.tl b/binlog.tl index 1df1c17..6de503f 100644 --- a/binlog.tl +++ b/binlog.tl @@ -27,6 +27,7 @@ binlog.userSetBlocked id:int blocked:int = binlog.Update; binlog.userSetRealName id:int real_first_name:string real_last_name:string = binlog.Update; binlog.userSetName id:int first_name:string last_name:string = binlog.Update; binlog.userSetPhoto id:int photo:UserProfilePhoto = binlog.Update; +binlog.userSetUsername id:int username:string = binlog.Update; binlog.encrChatDelete id:int = binlog.Update; binlog.encrChatRequested id:int hash:long date:int admin:int user:int key:64*[int] nonce:64*[int] = binlog.Update; diff --git a/interface.c b/interface.c index fbf65e3..1dd61c7 100644 --- a/interface.c +++ b/interface.c @@ -925,6 +925,16 @@ void do_set_profile_name (int arg_num, struct arg args[], struct in_ev *ev) { tgl_do_set_profile_name (args[0].str, args[1].str, print_user_gw, ev); } +void do_set_username (int arg_num, struct arg args[], struct in_ev *ev) { + assert (arg_num == 1); + tgl_do_set_username (args[0].str, print_user_gw, ev); +} + +void do_contact_search (int arg_num, struct arg args[], struct in_ev *ev) { + assert (arg_num == 2); + tgl_do_contact_search (args[0].str, args[1].num == NOT_FOUND ? args[1].num : 10, print_user_list_gw, ev); +} + void do_accept_secret_chat (int arg_num, struct arg args[], struct in_ev *ev) { assert (arg_num == 1); tgl_do_accept_encr_chat_request (&args[0].P->encr_chat, 0, 0); @@ -1061,6 +1071,7 @@ struct command commands[] = { {"show_license", {ca_none}, do_show_license, "show_license\tPrints contents of GPL license"}, {"search", {ca_peer | ca_optional, ca_number | ca_optional, ca_number | ca_optional, ca_number | ca_optional, ca_number | ca_optional, ca_string_end}, do_search, "search [peer] [limit] [from] [to] [offset] pattern\tSearch for pattern in messages from date from to date to (unixtime) in messages with peer (if peer not present, in all messages)"}, {"mark_read", {ca_peer, ca_none}, do_mark_read, "mark_read \tMarks messages with peer as read"}, + {"contact_search", {ca_string, ca_number | ca_optional, ca_none}, do_contact_search, "contact_search username [limit]\tSearches contacts by username"}, {"visualize_key", {ca_secret_chat, ca_none}, do_visualize_key, "visualize_key \tPrints visualization of encryption key (first 16 bytes sha1 of it in fact}"}, {"create_secret_chat", {ca_user, ca_none}, do_create_secret_chat, "create_secret_chat \tStarts creation of secret chat"}, {"chat_add_user", {ca_chat, ca_user, ca_number | ca_optional, ca_none}, do_chat_add_user, "chat_add_user [msgs-to-forward]\tAdds user to chat. Sends him last msgs-to-forward message from this chat. Default 100"}, @@ -1077,6 +1088,7 @@ struct command commands[] = { {"chat_set_photo", {ca_chat, ca_file_name_end, ca_none}, do_chat_set_photo, "chat_set_photo \tSets chat photo. Photo will be cropped to square"}, {"set_profile_photo", {ca_file_name_end, ca_none}, do_set_profile_photo, "set_profile_photo \tSets profile photo. Photo will be cropped to square"}, {"set_profile_name", {ca_string, ca_string, ca_none}, do_set_profile_name, "set_profile_name \tSets profile name."}, + {"set_username", {ca_string, ca_none}, do_set_username, "set_username \tSets username."}, {"accept_secret_chat", {ca_secret_chat, ca_none}, do_accept_secret_chat, "accept_secret_chat \tAccepts secret chat. Only useful with -E option"}, {"set_ttl", {ca_secret_chat, ca_number, ca_none}, do_set_ttl, "set_ttl \tSets secret chat ttl. Client itself ignores ttl"}, {"export_card", {ca_none}, do_export_card, "export_card\tPrints card that can be imported by another user with import_card method"}, @@ -1460,6 +1472,9 @@ void print_user_info_gw (void *extra, int success, struct tgl_user *U) { mpush_color (ev, COLOR_YELLOW); mprintf (ev, "User "); print_user_name (ev, U->id, C); + if (U->username) { + mprintf (ev, " @%s", U->username); + } mprintf (ev, " (#%d):\n", tgl_get_peer_id (U->id)); mprintf (ev, "\treal name: %s %s\n", U->real_first_name, U->real_last_name); mprintf (ev, "\tphone: %s\n", U->phone); @@ -1766,6 +1781,9 @@ void print_peer_updates (struct in_ev *ev, int flags) { if (flags & TGL_UPDATE_ACCESS_HASH) { mprintf (ev, " access_hash"); } + if (flags & TGL_UPDATE_USERNAME) { + mprintf (ev, " username"); + } } void user_update_gw (struct tgl_user *U, unsigned flags) { diff --git a/lua-tg.c b/lua-tg.c index 16b0ee4..0b73d38 100644 --- a/lua-tg.c +++ b/lua-tg.c @@ -184,6 +184,9 @@ void push_update_types (unsigned flags) { if (flags & TGL_UPDATE_ACCESS_HASH) { lua_add_string_field_arr (cc++, "access_hash"); } + if (flags & TGL_UPDATE_USERNAME) { + lua_add_string_field_arr (cc++, "username"); + } } diff --git a/queries.c b/queries.c index 0254d96..7ee13ab 100644 --- a/queries.c +++ b/queries.c @@ -337,7 +337,8 @@ static void out_random (int n) { int allow_send_linux_version; void tgl_do_insert_header (void) { - out_int (CODE_invoke_with_layer17); + out_int (CODE_invoke_with_layer18); + //out_int (0x50858a19); out_int (CODE_init_connection); out_int (TG_APP_ID); if (allow_send_linux_version) { @@ -1921,6 +1922,55 @@ void tgl_do_set_profile_name (char *first_name, char *last_name, void (*callback tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &set_profile_name_methods, 0, callback, callback_extra); } + +void tgl_do_set_username (char *name, void (*callback)(void *callback_extra, int success, struct tgl_user *U), void *callback_extra) { + clear_packet (); + out_int (CODE_account_update_username); + out_string (name); + + tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &set_profile_name_methods, 0, callback, callback_extra); +} +/* }}} */ + +/* {{{ Contacts search */ + +int contact_search_on_answer (struct query *q) { + assert (fetch_int () == CODE_contacts_found); + assert (fetch_int () == CODE_vector); + int n = fetch_int (); + int i; + for (i = 0; i < n; i++) { + assert (fetch_int () == (int)CODE_contact_found); + fetch_int (); + } + assert (fetch_int () == CODE_vector); + n = fetch_int (); + + struct tgl_user **UL = talloc (sizeof (void *) * n); + for (i = 0; i < n; i++) { + UL[i] = tglf_fetch_alloc_user (); + } + + if (q->callback) { + ((void (*)(void *, int, int, struct tgl_user **))q->callback) (q->callback_extra, 1, n, UL); + } + tfree (UL, sizeof (void *) * n); + return 0; +} + +static struct query_methods contact_search_methods = { + .on_answer = contact_search_on_answer, + .type = TYPE_TO_PARAM(contacts_found) +}; + +void tgl_do_contact_search (char *name, int limit, void (*callback)(void *callback_extra, int success, int cnt, struct tgl_user *U[]), void *callback_extra) { + clear_packet (); + out_int (CODE_contacts_search); + out_string (name); + out_int (limit); + + tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &contact_search_methods, 0, callback, callback_extra); +} /* }}} */ /* {{{ Forward */ diff --git a/scheme.tl b/scheme.tl index be87a03..40329f0 120000 --- a/scheme.tl +++ b/scheme.tl @@ -1 +1 @@ -scheme17.tl \ No newline at end of file +scheme18.tl \ No newline at end of file diff --git a/scheme18.tl b/scheme18.tl new file mode 100644 index 0000000..6b7fdd5 --- /dev/null +++ b/scheme18.tl @@ -0,0 +1,535 @@ +int ?= Int; +long ?= Long; +double ?= Double; +string ?= String; + +bytes string = Bytes; + +boolFalse#bc799737 = Bool; +boolTrue#997275b5 = Bool; + +vector#1cb5c415 {t:Type} # [ t ] = Vector t; + +error#c4b9f9bb code:int text:string = Error; + +null#56730bcc = Null; + +inputPeerEmpty#7f3b18ea = InputPeer; +inputPeerSelf#7da07ec9 = InputPeer; +inputPeerContact#1023dbe8 user_id:int = InputPeer; +inputPeerForeign#9b447325 user_id:int access_hash:long = InputPeer; +inputPeerChat#179be863 chat_id:int = InputPeer; + +inputUserEmpty#b98886cf = InputUser; +inputUserSelf#f7c1b13f = InputUser; +inputUserContact#86e94f65 user_id:int = InputUser; +inputUserForeign#655e74ff user_id:int access_hash:long = InputUser; + +inputPhoneContact#f392b7f4 client_id:long phone:string first_name:string last_name:string = InputContact; + +inputFile#f52ff27f id:long parts:int name:string md5_checksum:string = InputFile; + +inputMediaEmpty#9664f57f = InputMedia; +inputMediaUploadedPhoto#2dc53a7d file:InputFile = InputMedia; +inputMediaPhoto#8f2ab2ec id:InputPhoto = InputMedia; +inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia; +inputMediaContact#a6e45987 phone_number:string first_name:string last_name:string = InputMedia; +inputMediaUploadedVideo#133ad6f6 file:InputFile duration:int w:int h:int mime_type:string = InputMedia; +inputMediaUploadedThumbVideo#9912dabf file:InputFile thumb:InputFile duration:int w:int h:int mime_type:string = InputMedia; +inputMediaVideo#7f023ae6 id:InputVideo = InputMedia; + +inputChatPhotoEmpty#1ca48f57 = InputChatPhoto; +inputChatUploadedPhoto#94254732 file:InputFile crop:InputPhotoCrop = InputChatPhoto; +inputChatPhoto#b2e1bf08 id:InputPhoto crop:InputPhotoCrop = InputChatPhoto; + +inputGeoPointEmpty#e4c123d6 = InputGeoPoint; +inputGeoPoint#f3b7acc9 lat:double long:double = InputGeoPoint; + +inputPhotoEmpty#1cd7bf0d = InputPhoto; +inputPhoto#fb95c6c4 id:long access_hash:long = InputPhoto; + +inputVideoEmpty#5508ec75 = InputVideo; +inputVideo#ee579652 id:long access_hash:long = InputVideo; + +inputFileLocation#14637196 volume_id:long local_id:int secret:long = InputFileLocation; +inputVideoFileLocation#3d0364ec id:long access_hash:long = InputFileLocation; + +inputPhotoCropAuto#ade6b004 = InputPhotoCrop; +inputPhotoCrop#d9915325 crop_left:double crop_top:double crop_width:double = InputPhotoCrop; + +inputAppEvent#770656a8 time:double type:string peer:long data:string = InputAppEvent; + +peerUser#9db1bc6d user_id:int = Peer; +peerChat#bad0e5bb chat_id:int = Peer; + +storage.fileUnknown#aa963b05 = storage.FileType; +storage.fileJpeg#7efe0e = storage.FileType; +storage.fileGif#cae1aadf = storage.FileType; +storage.filePng#a4f63c0 = storage.FileType; +storage.filePdf#ae1e508d = storage.FileType; +storage.fileMp3#528a0677 = storage.FileType; +storage.fileMov#4b09ebbc = storage.FileType; +storage.filePartial#40bc6f52 = storage.FileType; +storage.fileMp4#b3cea0e4 = storage.FileType; +storage.fileWebp#1081464c = storage.FileType; + +fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileLocation; +fileLocation#53d69076 dc_id:int volume_id:long local_id:int secret:long = FileLocation; + +userEmpty#200250ba id:int = User; +userSelf#7007b451 id:int first_name:string last_name:string username:string phone:string photo:UserProfilePhoto status:UserStatus inactive:Bool = User; +userContact#cab35e18 id:int first_name:string last_name:string username:string access_hash:long phone:string photo:UserProfilePhoto status:UserStatus = User; +userRequest#d9ccc4ef id:int first_name:string last_name:string username:string access_hash:long phone:string photo:UserProfilePhoto status:UserStatus = User; +userForeign#75cf7a8 id:int first_name:string last_name:string username:string access_hash:long photo:UserProfilePhoto status:UserStatus = User; +userDeleted#d6016d7a id:int first_name:string last_name:string username:string = User; + + +userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; +userProfilePhoto#d559d8c8 photo_id:long photo_small:FileLocation photo_big:FileLocation = UserProfilePhoto; + +userStatusEmpty#9d05049 = UserStatus; +userStatusOnline#edb93949 expires:int = UserStatus; +userStatusOffline#8c703f was_online:int = UserStatus; + +chatEmpty#9ba2d800 id:int = Chat; +chat#6e9c9bc7 id:int title:string photo:ChatPhoto participants_count:int date:int left:Bool version:int = Chat; +chatForbidden#fb0ccc41 id:int title:string date:int = Chat; + +chatFull#630e61be id:int participants:ChatParticipants chat_photo:Photo notify_settings:PeerNotifySettings = ChatFull; + +chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; + +chatParticipantsForbidden#fd2bb8a chat_id:int = ChatParticipants; +chatParticipants#7841b415 chat_id:int admin_id:int participants:Vector version:int = ChatParticipants; + +chatPhotoEmpty#37c1011c = ChatPhoto; +chatPhoto#6153276a photo_small:FileLocation photo_big:FileLocation = ChatPhoto; + +messageEmpty#83e5de54 id:int = Message; +//message#22eb6aba id:int from_id:int to_id:Peer out:Bool unread:Bool date:int message:string media:MessageMedia = Message; +//messageForwarded#5f46804 id:int fwd_from_id:int fwd_date:int from_id:int to_id:Peer out:Bool unread:Bool date:int message:string media:MessageMedia = Message; +//messageService#9f8d60bb id:int from_id:int to_id:Peer out:Bool unread:Bool date:int action:MessageAction = Message; + +messageMediaEmpty#3ded6320 = MessageMedia; +messageMediaPhoto#c8c45a2a photo:Photo = MessageMedia; +messageMediaVideo#a2d24290 video:Video = MessageMedia; +messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia; +messageMediaContact#5e7d2f39 phone_number:string first_name:string last_name:string user_id:int = MessageMedia; +messageMediaUnsupported#29632a36 bytes:bytes = MessageMedia; + +messageActionEmpty#b6aef7b0 = MessageAction; +messageActionChatCreate#a6638b9a title:string users:Vector = MessageAction; +messageActionChatEditTitle#b5a1ce5a title:string = MessageAction; +messageActionChatEditPhoto#7fcb13a8 photo:Photo = MessageAction; +messageActionChatDeletePhoto#95e3fbef = MessageAction; +messageActionChatAddUser#5e3cfc4b user_id:int = MessageAction; +messageActionChatDeleteUser#b2ae9b0c user_id:int = MessageAction; + +dialog#ab3a99ac peer:Peer top_message:int unread_count:int notify_settings:PeerNotifySettings = Dialog; + +photoEmpty#2331b22d id:long = Photo; +photo#22b56751 id:long access_hash:long user_id:int date:int caption:string geo:GeoPoint sizes:Vector = Photo; + +photoSizeEmpty#e17e23c type:string = PhotoSize; +photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize; +photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize; + +videoEmpty#c10658a8 id:long = Video; +video#388fa391 id:long access_hash:long user_id:int date:int caption:string duration:int mime_type:string size:int thumb:PhotoSize dc_id:int w:int h:int = Video; + +geoPointEmpty#1117dd5f = GeoPoint; +geoPoint#2049d70c long:double lat:double = GeoPoint; + +auth.checkedPhone#e300cc3b phone_registered:Bool phone_invited:Bool = auth.CheckedPhone; + +auth.sentCode#efed51d9 phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode; + +auth.authorization#f6b673a4 expires:int user:User = auth.Authorization; + +auth.exportedAuthorization#df969c2d id:int bytes:bytes = auth.ExportedAuthorization; + +inputNotifyPeer#b8bc5b0c peer:InputPeer = InputNotifyPeer; +inputNotifyUsers#193b4417 = InputNotifyPeer; +inputNotifyChats#4a95e84e = InputNotifyPeer; +inputNotifyAll#a429b886 = InputNotifyPeer; + +inputPeerNotifyEventsEmpty#f03064d8 = InputPeerNotifyEvents; +inputPeerNotifyEventsAll#e86a2c74 = InputPeerNotifyEvents; + +inputPeerNotifySettings#46a2ce98 mute_until:int sound:string show_previews:Bool events_mask:int = InputPeerNotifySettings; + +peerNotifyEventsEmpty#add53cb3 = PeerNotifyEvents; +peerNotifyEventsAll#6d1ded88 = PeerNotifyEvents; + +peerNotifySettingsEmpty#70a68512 = PeerNotifySettings; +peerNotifySettings#8d5e11ee mute_until:int sound:string show_previews:Bool events_mask:int = PeerNotifySettings; + +wallPaper#ccb03657 id:int title:string sizes:Vector color:int = WallPaper; + +userFull#771095da user:User link:contacts.Link profile_photo:Photo notify_settings:PeerNotifySettings blocked:Bool real_first_name:string real_last_name:string = UserFull; + +contact#f911c994 user_id:int mutual:Bool = Contact; + +importedContact#d0028438 user_id:int client_id:long = ImportedContact; + +contactBlocked#561bc879 user_id:int date:int = ContactBlocked; + +contactFound#ea879f95 user_id:int = ContactFound; + +contactSuggested#3de191a1 user_id:int mutual_contacts:int = ContactSuggested; + +contactStatus#aa77b873 user_id:int expires:int = ContactStatus; + +chatLocated#3631cf4c chat_id:int distance:int = ChatLocated; + +contacts.foreignLinkUnknown#133421f8 = contacts.ForeignLink; +contacts.foreignLinkRequested#a7801f47 has_phone:Bool = contacts.ForeignLink; +contacts.foreignLinkMutual#1bea8ce1 = contacts.ForeignLink; + +contacts.myLinkEmpty#d22a1c60 = contacts.MyLink; +contacts.myLinkRequested#6c69efee contact:Bool = contacts.MyLink; +contacts.myLinkContact#c240ebd9 = contacts.MyLink; + +contacts.link#eccea3f5 my_link:contacts.MyLink foreign_link:contacts.ForeignLink user:User = contacts.Link; + +contacts.contacts#6f8b8cb2 contacts:Vector users:Vector = contacts.Contacts; +contacts.contactsNotModified#b74ba9d2 = contacts.Contacts; + +contacts.importedContacts#ad524315 imported:Vector retry_contacts:Vector users:Vector = contacts.ImportedContacts; + +contacts.blocked#1c138d15 blocked:Vector users:Vector = contacts.Blocked; +contacts.blockedSlice#900802a1 count:int blocked:Vector users:Vector = contacts.Blocked; + +contacts.found#566000e results:Vector users:Vector = contacts.Found; + +contacts.suggested#5649dcc5 results:Vector users:Vector = contacts.Suggested; + +messages.dialogs#15ba6c40 dialogs:Vector messages:Vector chats:Vector users:Vector = messages.Dialogs; +messages.dialogsSlice#71e094f3 count:int dialogs:Vector messages:Vector chats:Vector users:Vector = messages.Dialogs; + +messages.messages#8c718e87 messages:Vector chats:Vector users:Vector = messages.Messages; +messages.messagesSlice#b446ae3 count:int messages:Vector chats:Vector users:Vector = messages.Messages; + +messages.messageEmpty#3f4e0648 = messages.Message; +messages.message#ff90c417 message:Message chats:Vector users:Vector = messages.Message; + +messages.statedMessages#969478bb messages:Vector chats:Vector users:Vector pts:int seq:int = messages.StatedMessages; + +messages.statedMessage#d07ae726 message:Message chats:Vector users:Vector pts:int seq:int = messages.StatedMessage; + +messages.sentMessage#d1f4d35c id:int date:int pts:int seq:int = messages.SentMessage; + +messages.chat#40e9002a chat:Chat users:Vector = messages.Chat; + +messages.chats#8150cbd8 chats:Vector users:Vector = messages.Chats; + +messages.chatFull#e5d7d19c full_chat:ChatFull chats:Vector users:Vector = messages.ChatFull; + +messages.affectedHistory#b7de36f2 pts:int seq:int offset:int = messages.AffectedHistory; + +inputMessagesFilterEmpty#57e2f66c = MessagesFilter; +inputMessagesFilterPhotos#9609a51c = MessagesFilter; +inputMessagesFilterVideo#9fc00e65 = MessagesFilter; +inputMessagesFilterPhotoVideo#56e9f0e4 = MessagesFilter; +inputMessagesFilterDocument#9eddf188 = MessagesFilter; +inputMessagesFilterAudio#cfc87522 = MessagesFilter; + +updateNewMessage#13abdb3 message:Message pts:int = Update; +updateMessageID#4e90bfd6 id:int random_id:long = Update; +updateReadMessages#c6649e31 messages:Vector pts:int = Update; +updateDeleteMessages#a92bfe26 messages:Vector pts:int = Update; +updateRestoreMessages#d15de04d messages:Vector pts:int = Update; +//updateUserTyping#6baa8508 user_id:int = Update; +//updateChatUserTyping#3c46cfe6 chat_id:int user_id:int = Update; +updateChatParticipants#7761198 participants:ChatParticipants = Update; +updateUserStatus#1bfbd823 user_id:int status:UserStatus = Update; +updateUserPhoto#95313b0c user_id:int date:int photo:UserProfilePhoto previous:Bool = Update; +updateContactRegistered#2575bbb9 user_id:int date:int = Update; +updateContactLink#51a48a9a user_id:int my_link:contacts.MyLink foreign_link:contacts.ForeignLink = Update; +updateActivation#6f690963 user_id:int = Update; +updateNewAuthorization#8f06529a auth_key_id:long date:int device:string location:string = Update; + +updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; + +updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; +updates.difference#f49ca0 new_messages:Vector new_encrypted_messages:Vector other_updates:Vector chats:Vector users:Vector state:updates.State = updates.Difference; +updates.differenceSlice#a8fb1981 new_messages:Vector new_encrypted_messages:Vector other_updates:Vector chats:Vector users:Vector intermediate_state:updates.State = updates.Difference; + +updatesTooLong#e317af7e = Updates; +updateShortMessage#d3f45784 id:int from_id:int message:string pts:int date:int seq:int = Updates; +updateShortChatMessage#2b2fbd4e id:int from_id:int chat_id:int message:string pts:int date:int seq:int = Updates; +updateShort#78d4dec1 update:Update date:int = Updates; +updatesCombined#725b04c3 updates:Vector users:Vector chats:Vector date:int seq_start:int seq:int = Updates; +updates#74ae4240 updates:Vector users:Vector chats:Vector date:int seq:int = Updates; + +photos.photos#8dca6aa5 photos:Vector users:Vector = photos.Photos; +photos.photosSlice#15051f54 count:int photos:Vector users:Vector = photos.Photos; + +photos.photo#20212ca8 photo:Photo users:Vector = photos.Photo; + +upload.file#96a18d5 type:storage.FileType mtime:int bytes:bytes = upload.File; + +dcOption#2ec2a43c id:int hostname:string ip_address:string port:int = DcOption; + +config#2e54dd74 date:int test_mode:Bool this_dc:int dc_options:Vector chat_size_max:int broadcast_size_max:int = Config; + +nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc; + +help.appUpdate#8987f311 id:int critical:Bool url:string text:string = help.AppUpdate; +help.noAppUpdate#c45a6536 = help.AppUpdate; + +help.inviteText#18cb9f78 message:string = help.InviteText; + +messages.statedMessagesLinks#3e74f5c6 messages:Vector chats:Vector users:Vector links:Vector pts:int seq:int = messages.StatedMessages; + +messages.statedMessageLink#a9af2881 message:Message chats:Vector users:Vector links:Vector pts:int seq:int = messages.StatedMessage; + +messages.sentMessageLink#e9db4a3f id:int date:int pts:int seq:int links:Vector = messages.SentMessage; + +inputGeoChat#74d456fa chat_id:int access_hash:long = InputGeoChat; + +inputNotifyGeoChatPeer#4d8ddec8 peer:InputGeoChat = InputNotifyPeer; + +geoChat#75eaea5a id:int access_hash:long title:string address:string venue:string geo:GeoPoint photo:ChatPhoto participants_count:int date:int checked_in:Bool version:int = Chat; + +geoChatMessageEmpty#60311a9b chat_id:int id:int = GeoChatMessage; +geoChatMessage#4505f8e1 chat_id:int id:int from_id:int date:int message:string media:MessageMedia = GeoChatMessage; +geoChatMessageService#d34fa24e chat_id:int id:int from_id:int date:int action:MessageAction = GeoChatMessage; + +geochats.statedMessage#17b1578b message:GeoChatMessage chats:Vector users:Vector seq:int = geochats.StatedMessage; + +geochats.located#48feb267 results:Vector messages:Vector chats:Vector users:Vector = geochats.Located; + +geochats.messages#d1526db1 messages:Vector chats:Vector users:Vector = geochats.Messages; +geochats.messagesSlice#bc5863e8 count:int messages:Vector chats:Vector users:Vector = geochats.Messages; + +messageActionGeoChatCreate#6f038ebc title:string address:string = MessageAction; +messageActionGeoChatCheckin#c7d53de = MessageAction; + +updateNewGeoChatMessage#5a68e3f7 message:GeoChatMessage = Update; + +wallPaperSolid#63117f24 id:int title:string bg_color:int color:int = WallPaper; + +updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update; +updateEncryptedChatTyping#1710f156 chat_id:int = Update; +updateEncryption#b4a2e88d chat:EncryptedChat date:int = Update; +updateEncryptedMessagesRead#38fe25b7 chat_id:int max_date:int date:int = Update; + +encryptedChatEmpty#ab7ec0a0 id:int = EncryptedChat; +encryptedChatWaiting#3bf703dc id:int access_hash:long date:int admin_id:int participant_id:int = EncryptedChat; +encryptedChatRequested#c878527e id:int access_hash:long date:int admin_id:int participant_id:int g_a:bytes = EncryptedChat; +encryptedChat#fa56ce36 id:int access_hash:long date:int admin_id:int participant_id:int g_a_or_b:bytes key_fingerprint:long = EncryptedChat; +encryptedChatDiscarded#13d6dd27 id:int = EncryptedChat; + +inputEncryptedChat#f141b5e1 chat_id:int access_hash:long = InputEncryptedChat; + +encryptedFileEmpty#c21f497e = EncryptedFile; +encryptedFile#4a70994c id:long access_hash:long size:int dc_id:int key_fingerprint:int = EncryptedFile; + +inputEncryptedFileEmpty#1837c364 = InputEncryptedFile; +inputEncryptedFileUploaded#64bd0306 id:long parts:int md5_checksum:string key_fingerprint:int = InputEncryptedFile; +inputEncryptedFile#5a17b5e5 id:long access_hash:long = InputEncryptedFile; + +inputEncryptedFileLocation#f5235d55 id:long access_hash:long = InputFileLocation; + +encryptedMessage#ed18c118 random_id:long chat_id:int date:int bytes:bytes file:EncryptedFile = EncryptedMessage; +encryptedMessageService#23734b06 random_id:long chat_id:int date:int bytes:bytes = EncryptedMessage; + +messages.dhConfigNotModified#c0e24635 random:bytes = messages.DhConfig; +messages.dhConfig#2c221edd g:int p:bytes version:int random:bytes = messages.DhConfig; + +messages.sentEncryptedMessage#560f8935 date:int = messages.SentEncryptedMessage; +messages.sentEncryptedFile#9493ff32 date:int file:EncryptedFile = messages.SentEncryptedMessage; + +inputFileBig#fa4f0bb5 id:long parts:int name:string = InputFile; + +inputEncryptedFileBigUploaded#2dc173c8 id:long parts:int key_fingerprint:int = InputEncryptedFile; + +updateChatParticipantAdd#3a0eeb22 chat_id:int user_id:int inviter_id:int version:int = Update; +updateChatParticipantDelete#6e5f8c22 chat_id:int user_id:int version:int = Update; +updateDcOptions#8e5e9873 dc_options:Vector = Update; + +inputMediaUploadedAudio#4e498cab file:InputFile duration:int mime_type:string = InputMedia; +inputMediaAudio#89938781 id:InputAudio = InputMedia; +inputMediaUploadedDocument#34e794bd file:InputFile file_name:string mime_type:string = InputMedia; +inputMediaUploadedThumbDocument#3e46de5d file:InputFile thumb:InputFile file_name:string mime_type:string = InputMedia; +inputMediaDocument#d184e841 id:InputDocument = InputMedia; + +messageMediaDocument#2fda2204 document:Document = MessageMedia; +messageMediaAudio#c6b68300 audio:Audio = MessageMedia; + +inputAudioEmpty#d95adc84 = InputAudio; +inputAudio#77d440ff id:long access_hash:long = InputAudio; + +inputDocumentEmpty#72f0eaae = InputDocument; +inputDocument#18798952 id:long access_hash:long = InputDocument; + +inputAudioFileLocation#74dc404d id:long access_hash:long = InputFileLocation; +inputDocumentFileLocation#4e45abe9 id:long access_hash:long = InputFileLocation; + +audioEmpty#586988d8 id:long = Audio; +audio#c7ac6496 id:long access_hash:long user_id:int date:int duration:int mime_type:string size:int dc_id:int = Audio; + +documentEmpty#36f8c871 id:long = Document; +document#9efc6326 id:long access_hash:long user_id:int date:int file_name:string mime_type:string size:int thumb:PhotoSize dc_id:int = Document; + +help.support#17c6b5f6 phone_number:string user:User = help.Support; + +notifyPeer#9fd40bd8 peer:Peer = NotifyPeer; +notifyUsers#b4c83b4c = NotifyPeer; +notifyChats#c007cec3 = NotifyPeer; +notifyAll#74d07c60 = NotifyPeer; + +updateUserBlocked#80ece81a user_id:int blocked:Bool = Update; +updateNotifySettings#bec268ef peer:NotifyPeer notify_settings:PeerNotifySettings = Update; + +auth.sentAppCode#e325edcf phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode; + +updateUserTyping#5c486927 user_id:int action:SendMessageAction = Update; +updateChatUserTyping#9a65ea1f chat_id:int user_id:int action:SendMessageAction = Update; + +updateUserName user_id:int first_name:string last_name:string username:string = Update; +updateServiceNotification type:string message:string media:MessageMedia popup:Bool = Update; + +message#567699b3 flags:int id:int from_id:int to_id:Peer date:int message:string media:MessageMedia = Message; +messageForwarded#a367e716 flags:int id:int fwd_from_id:int fwd_date:int from_id:int to_id:Peer date:int message:string media:MessageMedia = Message; +messageService#1d86f70e flags:int id:int from_id:int to_id:Peer date:int action:MessageAction = Message; + + +sendMessageTypingAction#16bf744e = SendMessageAction; +sendMessageCancelAction#fd5ec8f5 = SendMessageAction; +sendMessageRecordVideoAction#a187d66f = SendMessageAction; +sendMessageUploadVideoAction#92042ff7 = SendMessageAction; +sendMessageRecordAudioAction#d52f73f7 = SendMessageAction; +sendMessageUploadAudioAction#e6ac8a6f = SendMessageAction; +sendMessageUploadPhotoAction#990a3c1a = SendMessageAction; +sendMessageUploadDocumentAction#8faee98e = SendMessageAction; +sendMessageGeoLocationAction#176f8ba1 = SendMessageAction; +sendMessageChooseContactAction#628cbc6f = SendMessageAction; + +---functions--- + +invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; + +invokeAfterMsgs#3dc4b4f0 {X:Type} msg_ids:Vector query:!X = X; + +auth.checkPhone#6fe51dfb phone_number:string = auth.CheckedPhone; +auth.sendCode#768d5f4d phone_number:string sms_type:int api_id:int api_hash:string lang_code:string = auth.SentCode; +auth.sendCall#3c51564 phone_number:string phone_code_hash:string = Bool; +auth.signUp#1b067634 phone_number:string phone_code_hash:string phone_code:string first_name:string last_name:string = auth.Authorization; +auth.signIn#bcd51581 phone_number:string phone_code_hash:string phone_code:string = auth.Authorization; +auth.logOut#5717da40 = Bool; +auth.resetAuthorizations#9fab0d1a = Bool; +auth.sendInvites#771c1d97 phone_numbers:Vector message:string = Bool; +auth.exportAuthorization#e5bfffcd dc_id:int = auth.ExportedAuthorization; +auth.importAuthorization#e3ef9613 id:int bytes:bytes = auth.Authorization; +auth.bindTempAuthKey#cdd42a05 perm_auth_key_id:long nonce:long expires_at:int encrypted_message:bytes = Bool; + +account.registerDevice#446c712c token_type:int token:string device_model:string system_version:string app_version:string app_sandbox:Bool lang_code:string = Bool; +account.unregisterDevice#65c55b40 token_type:int token:string = Bool; +account.updateNotifySettings#84be5b93 peer:InputNotifyPeer settings:InputPeerNotifySettings = Bool; +account.getNotifySettings#12b3ad31 peer:InputNotifyPeer = PeerNotifySettings; +account.resetNotifySettings#db7e1747 = Bool; +account.updateProfile#f0888d68 first_name:string last_name:string = User; +account.updateStatus#6628562c offline:Bool = Bool; +account.getWallPapers#c04cfac2 = Vector; + +users.getUsers#d91a548 id:Vector = Vector; +users.getFullUser#ca30a5b1 id:InputUser = UserFull; + +contacts.getStatuses#c4a353ee = Vector; +contacts.getContacts#22c6aa08 hash:string = contacts.Contacts; +contacts.importContacts#da30b32d contacts:Vector replace:Bool = contacts.ImportedContacts; +contacts.getSuggested#cd773428 limit:int = contacts.Suggested; +contacts.deleteContact#8e953744 id:InputUser = contacts.Link; +contacts.deleteContacts#59ab389e id:Vector = Bool; +contacts.block#332b49fc id:InputUser = Bool; +contacts.unblock#e54100bd id:InputUser = Bool; +contacts.getBlocked#f57c350f offset:int limit:int = contacts.Blocked; +contacts.exportCard#84e53737 = Vector; +contacts.importCard#4fe196fe export_card:Vector = User; + +messages.getMessages#4222fa74 id:Vector = messages.Messages; +messages.getDialogs#eccf1df6 offset:int max_id:int limit:int = messages.Dialogs; +messages.getHistory#92a1df2f peer:InputPeer offset:int max_id:int limit:int = messages.Messages; +messages.search#7e9f2ab peer:InputPeer q:string filter:MessagesFilter min_date:int max_date:int offset:int max_id:int limit:int = messages.Messages; +messages.readHistory#eed884c6 peer:InputPeer max_id:int offset:int read_contents:Bool = messages.AffectedHistory; +messages.deleteHistory#f4f8fb61 peer:InputPeer offset:int = messages.AffectedHistory; +messages.deleteMessages#14f2dd0a id:Vector = Vector; +messages.restoreMessages#395f9d7e id:Vector = Vector; +messages.receivedMessages#28abcb68 max_id:int = Vector; +messages.setTyping#a3825e50 peer:InputPeer action:SendMessageAction = Bool; +messages.sendMessage#4cde0aab peer:InputPeer message:string random_id:long = messages.SentMessage; +messages.sendMedia#a3c85d76 peer:InputPeer media:InputMedia random_id:long = messages.StatedMessage; +messages.forwardMessages#514cd10f peer:InputPeer id:Vector = messages.StatedMessages; +messages.getChats#3c6aa187 id:Vector = messages.Chats; +messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull; +messages.editChatTitle#b4bc68b5 chat_id:int title:string = messages.StatedMessage; +messages.editChatPhoto#d881821d chat_id:int photo:InputChatPhoto = messages.StatedMessage; +messages.addChatUser#2ee9ee9e chat_id:int user_id:InputUser fwd_limit:int = messages.StatedMessage; +messages.deleteChatUser#c3c5cd23 chat_id:int user_id:InputUser = messages.StatedMessage; +messages.createChat#419d9aee users:Vector title:string = messages.StatedMessage; + +updates.getState#edd4882a = updates.State; +updates.getDifference#a041495 pts:int date:int qts:int = updates.Difference; + +photos.updateProfilePhoto#eef579a0 id:InputPhoto crop:InputPhotoCrop = UserProfilePhoto; +photos.uploadProfilePhoto#d50f9c88 file:InputFile caption:string geo_point:InputGeoPoint crop:InputPhotoCrop = photos.Photo; + +upload.saveFilePart#b304a621 file_id:long file_part:int bytes:bytes = Bool; +upload.getFile#e3a6cfb5 location:InputFileLocation offset:int limit:int = upload.File; + +help.getConfig#c4f9186b = Config; +help.getNearestDc#1fb33026 = NearestDc; +help.getAppUpdate#c812ac7e device_model:string system_version:string app_version:string lang_code:string = help.AppUpdate; +help.saveAppLog#6f02f748 events:Vector = Bool; +help.getInviteText#a4a95186 lang_code:string = help.InviteText; + +photos.getUserPhotos#b7ee553c user_id:InputUser offset:int max_id:int limit:int = photos.Photos; + +messages.forwardMessage#3f3f4f2 peer:InputPeer id:int random_id:long = messages.StatedMessage; +messages.sendBroadcast#41bb0972 contacts:Vector message:string media:InputMedia = messages.StatedMessages; + +geochats.getLocated#7f192d8f geo_point:InputGeoPoint radius:int limit:int = geochats.Located; +geochats.getRecents#e1427e6f offset:int limit:int = geochats.Messages; +geochats.checkin#55b3e8fb peer:InputGeoChat = geochats.StatedMessage; +geochats.getFullChat#6722dd6f peer:InputGeoChat = messages.ChatFull; +geochats.editChatTitle#4c8e2273 peer:InputGeoChat title:string address:string = geochats.StatedMessage; +geochats.editChatPhoto#35d81a95 peer:InputGeoChat photo:InputChatPhoto = geochats.StatedMessage; +geochats.search#cfcdc44d peer:InputGeoChat q:string filter:MessagesFilter min_date:int max_date:int offset:int max_id:int limit:int = geochats.Messages; +geochats.getHistory#b53f7a68 peer:InputGeoChat offset:int max_id:int limit:int = geochats.Messages; +geochats.setTyping#8b8a729 peer:InputGeoChat typing:Bool = Bool; +geochats.sendMessage#61b0044 peer:InputGeoChat message:string random_id:long = geochats.StatedMessage; +geochats.sendMedia#b8f0deff peer:InputGeoChat media:InputMedia random_id:long = geochats.StatedMessage; +geochats.createGeoChat#e092e16 title:string geo_point:InputGeoPoint address:string venue:string = geochats.StatedMessage; + +messages.getDhConfig#26cf8950 version:int random_length:int = messages.DhConfig; +messages.requestEncryption#f64daf43 user_id:InputUser random_id:int g_a:bytes = EncryptedChat; +messages.acceptEncryption#3dbc0415 peer:InputEncryptedChat g_b:bytes key_fingerprint:long = EncryptedChat; +messages.discardEncryption#edd923c5 chat_id:int = Bool; +messages.setEncryptedTyping#791451ed peer:InputEncryptedChat typing:Bool = Bool; +messages.readEncryptedHistory#7f4b690a peer:InputEncryptedChat max_date:int = Bool; +messages.sendEncrypted#a9776773 peer:InputEncryptedChat random_id:long data:bytes = messages.SentEncryptedMessage; +messages.sendEncryptedFile#9a901b66 peer:InputEncryptedChat random_id:long data:bytes file:InputEncryptedFile = messages.SentEncryptedMessage; +messages.sendEncryptedService#32d439a4 peer:InputEncryptedChat random_id:long data:bytes = messages.SentEncryptedMessage; +messages.receivedQueue#55a5bb66 max_qts:int = Vector; + +upload.saveBigFilePart#de7b673d file_id:long file_part:int file_total_parts:int bytes:bytes = Bool; + +initConnection#69796de9 {X:Type} api_id:int device_model:string system_version:string app_version:string lang_code:string query:!X = X; + +help.getSupport#9cdf08cd = help.Support; + +auth.sendSms#da9f3e8 phone_number:string phone_code_hash:string = Bool; + +messages.readMessageContents id:Vector = Vector; + + +account.checkUsername username:string = Bool; +account.updateUsername username:string = User; + +contacts.search q:string limit:int = contacts.Found; + +//invokeWithLayer18 {X:Type} query:!X = X; +invokeWithLayer18#1c900537 {X:Type} query:!X = X; + diff --git a/structures.c b/structures.c index ba261a3..5f127fa 100644 --- a/structures.c +++ b/structures.c @@ -218,9 +218,13 @@ int tglf_fetch_user (struct tgl_user *U) { int l2 = prefetch_strlen (); assert (l2 >= 0); char *s2 = fetch_str (l2); + + int l3 = prefetch_strlen (); + char *s3 = fetch_str (l3); if (x == CODE_user_deleted && !(U->flags & FLAG_DELETED)) { bl_do_user_add (tgl_get_peer_id (U->id), s1, l1, s2, l2, 0, 0, 0, 0); + bl_do_user_set_username (U, s3, l3); bl_do_user_delete (U); } if (x != CODE_user_deleted) { @@ -236,6 +240,7 @@ int tglf_fetch_user (struct tgl_user *U) { phone = fetch_str (phone_len); } bl_do_user_add (tgl_get_peer_id (U->id), s1, l1, s2, l2, access_hash, phone, phone_len, x == CODE_user_contact); + bl_do_user_set_username (U, s3, l3); assert (tglf_fetch_user_photo (U) >= 0); assert (tglf_fetch_user_status (&U->status) >= 0); @@ -250,6 +255,10 @@ int tglf_fetch_user (struct tgl_user *U) { char *s2 = fetch_str (l2); bl_do_user_set_name (U, s1, l1, s2, l2); + + int l3 = prefetch_strlen (); + char *s3 = fetch_str (l3); + bl_do_user_set_username (U, s3, l3); if (x == CODE_user_deleted && !(U->flags & FLAG_DELETED)) { bl_do_user_delete (U); diff --git a/tgl-layout.h b/tgl-layout.h index ed470de..22add66 100644 --- a/tgl-layout.h +++ b/tgl-layout.h @@ -254,6 +254,7 @@ struct tgl_user { int blocked; char *real_first_name; char *real_last_name; + char *username; }; struct tgl_chat_user { diff --git a/tgl.h b/tgl.h index c7c3610..a1b4f79 100644 --- a/tgl.h +++ b/tgl.h @@ -61,6 +61,7 @@ struct tgl_dc; #define TGL_UPDATE_ADMIN 4096 #define TGL_UPDATE_MEMBERS 8192 #define TGL_UPDATE_ACCESS_HASH 16384 +#define TGL_UPDATE_USERNAME (1 << 15) struct tgl_allocator { void *(*alloc)(size_t size); @@ -262,6 +263,7 @@ void tgl_do_send_photo (enum tgl_message_media_type type, tgl_peer_id_t to_id, c void tgl_do_set_chat_photo (tgl_peer_id_t chat_id, char *file_name, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra); void tgl_do_set_profile_photo (char *file_name, void (*callback)(void *callback_extra, int success), void *callback_extra); void tgl_do_set_profile_name (char *first_name, char *last_name, void (*callback)(void *callback_extra, int success, struct tgl_user *U), void *callback_extra); +void tgl_do_set_username (char *name, void (*callback)(void *callback_extra, int success, struct tgl_user *U), void *callback_extra); void tgl_do_forward_message (tgl_peer_id_t id, int n, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra); void tgl_do_rename_chat (tgl_peer_id_t id, char *name, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra); void tgl_do_get_chat_info (tgl_peer_id_t id, int offline_mode, void (*callback)(void *callback_extra, int success, struct tgl_chat *C), void *callback_extra); @@ -276,7 +278,7 @@ void tgl_do_load_encr_video (struct tgl_encr_video *V, void (*callback)(void *ca void tgl_do_export_auth (int num, void (*callback) (void *callback_extra, int success), void *callback_extra); void tgl_do_add_contact (const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, int force, void (*callback)(void *callback_extra, int success, int size, struct tgl_user *users[]), void *callback_extra); void tgl_do_msg_search (tgl_peer_id_t id, int from, int to, int limit, int offset, const char *s, void (*callback)(void *callback_extra, int success, int size, struct tgl_message *list[]), void *callback_extra); -void tgl_do_contacts_search (int limit, const char *s, void (*callback) (void *callback_extra, int success, int size, struct tgl_user *users[]), void *callback_extra); +//void tgl_do_contacts_search (int limit, const char *s, void (*callback) (void *callback_extra, int success, int size, struct tgl_user *users[]), void *callback_extra); void tgl_do_create_encr_chat_request (int user_id, void (*callback)(void *callback_extra, int success, struct tgl_secret_chat *E), void *callback_extra); void tgl_do_create_secret_chat (tgl_peer_id_t id, void (*callback)(void *callback_extra, int success, struct tgl_secret_chat *E), void *callback_extra); void tgl_do_accept_encr_chat_request (struct tgl_secret_chat *E, void (*callback)(void *callback_extra, int success, struct tgl_secret_chat *E), void *callback_extra); @@ -297,6 +299,7 @@ void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callb void tgl_do_del_contact (tgl_peer_id_t id, void (*callback)(void *callback_extra, int success), void *callback_extra); void tgl_do_set_encr_chat_ttl (struct tgl_secret_chat *E, int ttl, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra); void tgl_do_send_location(tgl_peer_id_t id, double latitude, double longitude, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra); +void tgl_do_contact_search (char *name, int limit, void (*callback)(void *callback_extra, int success, int cnt, struct tgl_user *U[]), void *callback_extra); void tgl_do_visualize_key (tgl_peer_id_t id, unsigned char buf[16]); diff --git a/updates.c b/updates.c index 32e95ce..514bf87 100644 --- a/updates.c +++ b/updates.c @@ -152,9 +152,13 @@ void tglu_work_update (struct connection *c, long long msg_id) { char *l = fetch_str (l2); struct tgl_user *U = &UC->user; bl_do_user_set_real_name (U, f, l1, l, l2); + int l3 = prefetch_strlen (); + f = fetch_str (l3); + bl_do_user_set_username (U, f, l3); } else { fetch_skip_str (); fetch_skip_str (); + fetch_skip_str (); } } break; @@ -404,6 +408,17 @@ void tglu_work_update (struct connection *c, long long msg_id) { assert (skip_type_any (TYPE_TO_PARAM (peer_notify_settings)) >= 0); } break; + case CODE_update_service_notification: + { + int l1 = prefetch_strlen (); + char *type = fetch_str (l1); + int l2 = prefetch_strlen (); + char *message = fetch_str (l2); + skip_type_message_media (TYPE_TO_PARAM(message_media)); + fetch_bool (); + vlogprintf (E_ERROR, "Notification %.*s: %.*s\n", l1, type, l2, message); + } + break; default: vlogprintf (E_ERROR, "Unknown update type %08x\n", op); ;