Commit 4f494a57 authored by vysheng's avatar vysheng

fwd message

parent ce919683
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
#define CODE_user_foreign 0x5214c89d #define CODE_user_foreign 0x5214c89d
#define CODE_user_deleted 0xb29ad7cc #define CODE_user_deleted 0xb29ad7cc
#define CODE_user_profile_photo_empty 0x4f11bae1 #define CODE_user_profile_photo_empty 0x4f11bae1
#define CODE_user_profile_photo 0x990d1493 #define CODE_user_profile_photo 0xd559d8c8
#define CODE_user_status_empty 0x9d05049 #define CODE_user_status_empty 0x9d05049
#define CODE_user_status_online 0xedb93949 #define CODE_user_status_online 0xedb93949
#define CODE_user_status_offline 0x8c703f #define CODE_user_status_offline 0x8c703f
...@@ -126,11 +126,11 @@ ...@@ -126,11 +126,11 @@
#define CODE_input_notify_all 0xa429b886 #define CODE_input_notify_all 0xa429b886
#define CODE_input_peer_notify_events_empty 0xf03064d8 #define CODE_input_peer_notify_events_empty 0xf03064d8
#define CODE_input_peer_notify_events_all 0xe86a2c74 #define CODE_input_peer_notify_events_all 0xe86a2c74
#define CODE_input_peer_notify_settings 0x3cf4b1be #define CODE_input_peer_notify_settings 0x46a2ce98
#define CODE_peer_notify_events_empty 0xadd53cb3 #define CODE_peer_notify_events_empty 0xadd53cb3
#define CODE_peer_notify_events_all 0x6d1ded88 #define CODE_peer_notify_events_all 0x6d1ded88
#define CODE_peer_notify_settings_empty 0x70a68512 #define CODE_peer_notify_settings_empty 0x70a68512
#define CODE_peer_notify_settings 0xddbcd4a5 #define CODE_peer_notify_settings 0x8d5e11ee
#define CODE_wall_paper 0xccb03657 #define CODE_wall_paper 0xccb03657
#define CODE_user_full 0x771095da #define CODE_user_full 0x771095da
#define CODE_contact 0xf911c994 #define CODE_contact 0xf911c994
...@@ -181,15 +181,15 @@ ...@@ -181,15 +181,15 @@
#define CODE_update_chat_participants 0x7761198 #define CODE_update_chat_participants 0x7761198
#define CODE_update_user_status 0x1bfbd823 #define CODE_update_user_status 0x1bfbd823
#define CODE_update_user_name 0xda22d9ad #define CODE_update_user_name 0xda22d9ad
#define CODE_update_user_photo 0xbb8ba607 #define CODE_update_user_photo 0x95313b0c
#define CODE_update_contact_registered 0x2575bbb9 #define CODE_update_contact_registered 0x2575bbb9
#define CODE_update_contact_link 0x51a48a9a #define CODE_update_contact_link 0x51a48a9a
#define CODE_update_activation 0x6f690963 #define CODE_update_activation 0x6f690963
#define CODE_update_new_authorization 0x8f06529a #define CODE_update_new_authorization 0x8f06529a
#define CODE_updates_state 0xa0d9c0c #define CODE_updates_state 0xa56c2a3e
#define CODE_updates_difference_empty 0x5d75a138 #define CODE_updates_difference_empty 0x5d75a138
#define CODE_updates_difference 0x8adb0077 #define CODE_updates_difference 0xf49ca0
#define CODE_updates_difference_slice 0xc5e839b4 #define CODE_updates_difference_slice 0xa8fb1981
#define CODE_updates_too_long 0xe317af7e #define CODE_updates_too_long 0xe317af7e
#define CODE_update_short_message 0xd3f45784 #define CODE_update_short_message 0xd3f45784
#define CODE_update_short_chat_message 0x2b2fbd4e #define CODE_update_short_chat_message 0x2b2fbd4e
...@@ -204,12 +204,60 @@ ...@@ -204,12 +204,60 @@
#define CODE_config 0x232d5905 #define CODE_config 0x232d5905
#define CODE_nearest_dc 0x8e1a1775 #define CODE_nearest_dc 0x8e1a1775
#define CODE_help_invite_text 0x18cb9f78 #define CODE_help_invite_text 0x18cb9f78
#define CODE_messages_stated_messages_links 0x3e74f5c6
#define CODE_messages_stated_message_link 0xa9af2881
#define CODE_messages_sent_message_link 0xe9db4a3f
#define CODE_input_geo_chat 0x74d456fa
#define CODE_input_notify_geo_chat_peer 0x4d8ddec8
#define CODE_geo_chat 0x75eaea5a
#define CODE_geo_chat_message_empty 0x60311a9b
#define CODE_geo_chat_message 0x4505f8e1
#define CODE_geo_chat_message_service 0xd34fa24e
#define CODE_geochats_stated_message 0x17b1578b
#define CODE_geochats_located 0x48feb267
#define CODE_geochats_messages 0xd1526db1
#define CODE_geochats_messages_slice 0xbc5863e8
#define CODE_message_action_geo_chat_create 0x6f038ebc
#define CODE_message_action_geo_chat_checkin 0xc7d53de
#define CODE_update_new_geo_chat_message 0x5a68e3f7
#define CODE_wall_paper_solid 0x63117f24
#define CODE_update_new_encrypted_message 0x12bcbd9a
#define CODE_update_encrypted_chat_typing 0x1710f156
#define CODE_update_encryption 0xb4a2e88d
#define CODE_update_encrypted_messages_read 0x38fe25b7
#define CODE_encrypted_chat_empty 0xab7ec0a0
#define CODE_encrypted_chat_waiting 0x3bf703dc
#define CODE_encrypted_chat_requested 0xfda9a7b7
#define CODE_encrypted_chat 0x6601d14f
#define CODE_encrypted_chat_discarded 0x13d6dd27
#define CODE_input_encrypted_chat 0xf141b5e1
#define CODE_encrypted_file_empty 0xc21f497e
#define CODE_encrypted_file 0x4a70994c
#define CODE_input_encrypted_file_empty 0x1837c364
#define CODE_input_encrypted_file_uploaded 0x64bd0306
#define CODE_input_encrypted_file 0x5a17b5e5
#define CODE_input_encrypted_file_location 0xf5235d55
#define CODE_encrypted_message 0xed18c118
#define CODE_encrypted_message_service 0x23734b06
#define CODE_decrypted_message_layer 0x99a438cf
#define CODE_decrypted_message 0x1f814f1f
#define CODE_decrypted_message_service 0xaa48327d
#define CODE_decrypted_message_media_empty 0x89f5c4a
#define CODE_decrypted_message_media_photo 0x32798a8c
#define CODE_decrypted_message_media_video 0x4cee6ef3
#define CODE_decrypted_message_media_geo_point 0x35480a59
#define CODE_decrypted_message_media_contact 0x588a0a97
#define CODE_decrypted_message_action_set_message_t_t_l 0xa1733aec
#define CODE_messages_dh_config_not_modified 0xc0e24635
#define CODE_messages_dh_config 0x2c221edd
#define CODE_messages_sent_encrypted_message 0x560f8935
#define CODE_messages_sent_encrypted_file 0x9493ff32
#define CODE_invoke_after_msg 0xcb9f372d #define CODE_invoke_after_msg 0xcb9f372d
#define CODE_invoke_after_msgs 0x3dc4b4f0 #define CODE_invoke_after_msgs 0x3dc4b4f0
#define CODE_invoke_with_layer1 0x53835315 #define CODE_invoke_with_layer1 0x53835315
#define CODE_init_connection 0x3fc12e08 #define CODE_init_connection 0x3fc12e08
#define CODE_auth_check_phone 0x6fe51dfb #define CODE_auth_check_phone 0x6fe51dfb
#define CODE_auth_send_code 0xd16ff372 #define CODE_auth_send_code 0x768d5f4d
#define CODE_auth_send_call 0x3c51564 #define CODE_auth_send_call 0x3c51564
#define CODE_auth_sign_up 0x1b067634 #define CODE_auth_sign_up 0x1b067634
#define CODE_auth_sign_in 0xbcd51581 #define CODE_auth_sign_in 0xbcd51581
...@@ -218,7 +266,7 @@ ...@@ -218,7 +266,7 @@
#define CODE_auth_send_invites 0x771c1d97 #define CODE_auth_send_invites 0x771c1d97
#define CODE_auth_export_authorization 0xe5bfffcd #define CODE_auth_export_authorization 0xe5bfffcd
#define CODE_auth_import_authorization 0xe3ef9613 #define CODE_auth_import_authorization 0xe3ef9613
#define CODE_account_register_device 0xa28557ac #define CODE_account_register_device 0x446c712c
#define CODE_account_unregister_device 0x65c55b40 #define CODE_account_unregister_device 0x65c55b40
#define CODE_account_update_notify_settings 0x84be5b93 #define CODE_account_update_notify_settings 0x84be5b93
#define CODE_account_get_notify_settings 0x12b3ad31 #define CODE_account_get_notify_settings 0x12b3ad31
...@@ -259,7 +307,7 @@ ...@@ -259,7 +307,7 @@
#define CODE_messages_delete_chat_user 0xc3c5cd23 #define CODE_messages_delete_chat_user 0xc3c5cd23
#define CODE_messages_create_chat 0x419d9aee #define CODE_messages_create_chat 0x419d9aee
#define CODE_updates_get_state 0xedd4882a #define CODE_updates_get_state 0xedd4882a
#define CODE_updates_get_difference 0x5b36855a #define CODE_updates_get_difference 0xa041495
#define CODE_photos_update_profile_photo 0xeef579a0 #define CODE_photos_update_profile_photo 0xeef579a0
#define CODE_photos_upload_profile_photo 0xd50f9c88 #define CODE_photos_upload_profile_photo 0xd50f9c88
#define CODE_upload_save_file_part 0xb304a621 #define CODE_upload_save_file_part 0xb304a621
...@@ -268,4 +316,36 @@ ...@@ -268,4 +316,36 @@
#define CODE_help_get_nearest_dc 0x1fb33026 #define CODE_help_get_nearest_dc 0x1fb33026
#define CODE_help_save_app_log 0x6f02f748 #define CODE_help_save_app_log 0x6f02f748
#define CODE_help_get_invite_text 0xa4a95186 #define CODE_help_get_invite_text 0xa4a95186
#define CODE_photos_get_user_photos 0xb7ee553c
#define CODE_invoke_with_layer2 0x289dd1f6
#define CODE_messages_forward_message 0x3f3f4f2
#define CODE_messages_send_broadcast 0x41bb0972
#define CODE_invoke_with_layer3 0xb7475268
#define CODE_geochats_get_located 0x7f192d8f
#define CODE_geochats_get_recents 0xe1427e6f
#define CODE_geochats_checkin 0x55b3e8fb
#define CODE_geochats_get_full_chat 0x6722dd6f
#define CODE_geochats_edit_chat_title 0x4c8e2273
#define CODE_geochats_edit_chat_photo 0x35d81a95
#define CODE_geochats_search 0xcfcdc44d
#define CODE_geochats_get_history 0xb53f7a68
#define CODE_geochats_set_typing 0x8b8a729
#define CODE_geochats_send_message 0x61b0044
#define CODE_geochats_send_media 0xb8f0deff
#define CODE_geochats_create_geo_chat 0xe092e16
#define CODE_invoke_with_layer4 0xdea0d430
#define CODE_invoke_with_layer5 0x417a57ae
#define CODE_invoke_with_layer6 0x3a64d54d
#define CODE_invoke_with_layer7 0xa5be56d3
#define CODE_messages_get_dh_config 0x26cf8950
#define CODE_messages_request_encryption 0xf64daf43
#define CODE_messages_accept_encryption 0x3dbc0415
#define CODE_messages_discard_encryption 0xedd923c5
#define CODE_messages_set_encrypted_typing 0x791451ed
#define CODE_messages_read_encrypted_history 0x7f4b690a
#define CODE_messages_send_encrypted 0xa9776773
#define CODE_messages_send_encrypted_file 0x9a901b66
#define CODE_messages_send_encrypted_service 0x32d439a4
#define CODE_messages_received_queue 0x55a5bb66
#define CODE_invoke_with_layer8 0xe9abd9fd
#endif #endif
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
char *default_prompt = "> "; char *default_prompt = "> ";
int unread_messages; int unread_messages;
int msg_num_mode;
char *get_default_prompt (void) { char *get_default_prompt (void) {
static char buf[100]; static char buf[100];
...@@ -65,6 +66,7 @@ char *commands[] = { ...@@ -65,6 +66,7 @@ char *commands[] = {
"send_text", "send_text",
"chat_info", "chat_info",
"user_info", "user_info",
"fwd",
"show_license", "show_license",
0 }; 0 };
...@@ -79,6 +81,7 @@ int commands_flags[] = { ...@@ -79,6 +81,7 @@ int commands_flags[] = {
0732, 0732,
0732, 0732,
074, 074,
071,
072, 072,
07, 07,
}; };
...@@ -321,6 +324,24 @@ void interpreter (char *line UU) { ...@@ -321,6 +324,24 @@ void interpreter (char *line UU) {
do_send_text (Peers[index], strndup (f, len)); do_send_text (Peers[index], strndup (f, len));
} }
} }
} else if (!memcmp (line, "fwd ", 4)) {
char *q = line + 4;
int len;
char *text = get_token (&q, &len);
int index = 0;
while (index < user_num + chat_num && (!Peers[index]->print_name || strncmp (Peers[index]->print_name, text, len))) {
index ++;
}
if (index < user_num + chat_num) {
int len = 0;
char *f = get_token (&q, &len);
if (f) {
int num = atoi (f);
if (num > 0) {
do_forward_message (Peers[index], num);
}
}
}
} else if (!memcmp (line, "chat_info", 9)) { } else if (!memcmp (line, "chat_info", 9)) {
char *q = line + 10; char *q = line + 10;
int len; int len;
...@@ -689,6 +710,9 @@ void print_message (struct message *M) { ...@@ -689,6 +710,9 @@ void print_message (struct message *M) {
if (M->to_id >= 0) { if (M->to_id >= 0) {
if (M->out) { if (M->out) {
push_color (COLOR_GREEN); push_color (COLOR_GREEN);
if (msg_num_mode) {
printf ("%d ", M->id);
}
print_date (M->date); print_date (M->date);
pop_color (); pop_color ();
printf (" "); printf (" ");
...@@ -701,6 +725,9 @@ void print_message (struct message *M) { ...@@ -701,6 +725,9 @@ void print_message (struct message *M) {
} }
} else { } else {
push_color (COLOR_BLUE); push_color (COLOR_BLUE);
if (msg_num_mode) {
printf ("%d ", M->id);
}
print_date (M->date); print_date (M->date);
pop_color (); pop_color ();
printf (" "); printf (" ");
...@@ -714,6 +741,9 @@ void print_message (struct message *M) { ...@@ -714,6 +741,9 @@ void print_message (struct message *M) {
} }
} else { } else {
push_color (COLOR_MAGENTA); push_color (COLOR_MAGENTA);
if (msg_num_mode) {
printf ("%d ", M->id);
}
print_date (M->date); print_date (M->date);
pop_color (); pop_color ();
printf (" "); printf (" ");
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
char *default_username; char *default_username;
int setup_mode; int setup_mode;
char *auth_token; char *auth_token;
int msg_num_mode;
void set_default_username (const char *s) { void set_default_username (const char *s) {
if (default_username) { if (default_username) {
...@@ -203,7 +204,7 @@ extern int default_dc_num; ...@@ -203,7 +204,7 @@ extern int default_dc_num;
void args_parse (int argc, char **argv) { void args_parse (int argc, char **argv) {
int opt = 0; int opt = 0;
while ((opt = getopt (argc, argv, "u:hk:vn:")) != -1) { while ((opt = getopt (argc, argv, "u:hk:vn:N")) != -1) {
switch (opt) { switch (opt) {
case 'u': case 'u':
set_default_username (optarg); set_default_username (optarg);
...@@ -217,6 +218,9 @@ void args_parse (int argc, char **argv) { ...@@ -217,6 +218,9 @@ void args_parse (int argc, char **argv) {
case 'n': case 'n':
default_dc_num = atoi (optarg); default_dc_num = atoi (optarg);
break; break;
case 'N':
msg_num_mode ++;
break;
case 'h': case 'h':
default: default:
usage (); usage ();
......
...@@ -879,6 +879,40 @@ void do_send_photo (int type, int to_id, char *file_name) { ...@@ -879,6 +879,40 @@ void do_send_photo (int type, int to_id, char *file_name) {
send_part (f); send_part (f);
} }
int fwd_msg_on_answer (struct query *q UU) {
assert (fetch_int () == (int)CODE_messages_stated_message);
struct message *M = fetch_alloc_message ();
assert (fetch_int () == CODE_vector);
int n, i;
n = fetch_int ();
for (i = 0; i < n; i++) {
fetch_alloc_chat ();
}
assert (fetch_int () == CODE_vector);
n = fetch_int ();
for (i = 0; i < n; i++) {
fetch_alloc_user ();
}
fetch_int (); // pts
fetch_int (); // seq
print_message (M);
return 0;
}
struct query_methods fwd_msg_methods = {
.on_answer = fwd_msg_on_answer
};
void do_forward_message (union user_chat *U, int n) {
clear_packet ();
out_int (CODE_invoke_with_layer3);
out_int (CODE_messages_forward_message);
out_peer_id (U->id);
out_int (n);
out_long (lrand48 () * (1ll << 32) + lrand48 ());
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0);
}
int chat_info_on_answer (struct query *q UU) { int chat_info_on_answer (struct query *q UU) {
struct chat *C = fetch_alloc_chat_full (); struct chat *C = fetch_alloc_chat_full ();
union user_chat *U = (void *)C; union user_chat *U = (void *)C;
......
...@@ -75,5 +75,6 @@ void do_send_photo (int type, int to_id, char *file_name); ...@@ -75,5 +75,6 @@ void do_send_photo (int type, int to_id, char *file_name);
void do_get_chat_info (union user_chat *chat); void do_get_chat_info (union user_chat *chat);
void do_get_user_list_info_silent (int num, int *list); void do_get_user_list_info_silent (int num, int *list);
void do_get_user_info (union user_chat *user); void do_get_user_info (union user_chat *user);
void do_forward_message (union user_chat *U, int n);
#endif #endif
...@@ -157,16 +157,22 @@ void fetch_user (struct user *U) { ...@@ -157,16 +157,22 @@ void fetch_user (struct user *U) {
} }
if (x == CODE_user_foreign) { if (x == CODE_user_foreign) {
U->flags |= FLAG_USER_FOREIGN; U->flags |= FLAG_USER_FOREIGN;
U->phone = 0;
} else { } else {
if (U->phone) { free (U->phone); } if (U->phone) { free (U->phone); }
U->phone = fetch_str_dup (); U->phone = fetch_str_dup ();
} }
//logprintf ("name = %s, surname = %s, phone = %s\n", U->first_name, U->last_name, U->phone);
unsigned y = fetch_int (); unsigned y = fetch_int ();
//fprintf (stderr, "y = 0x%08x\n", y);
if (y == CODE_user_profile_photo_empty) { if (y == CODE_user_profile_photo_empty) {
U->photo_small.dc = -2; U->photo_small.dc = -2;
U->photo_big.dc = -2; U->photo_big.dc = -2;
} else { } else {
assert (y == CODE_user_profile_photo); assert (y == CODE_user_profile_photo || y == 0x990d1493);
if (y == CODE_user_profile_photo) {
fetch_long ();
}
fetch_file_location (&U->photo_small); fetch_file_location (&U->photo_small);
fetch_file_location (&U->photo_big); fetch_file_location (&U->photo_big);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment