Merge github.com:vysheng/tg
Conflicts: interface.c
This commit is contained in:
commit
a8cc367a16
30
interface.c
30
interface.c
@ -50,6 +50,8 @@ int msg_num_mode;
|
||||
int in_readline;
|
||||
int readline_active;
|
||||
|
||||
int log_level;
|
||||
|
||||
long long cur_uploading_bytes;
|
||||
long long cur_uploaded_bytes;
|
||||
long long cur_downloading_bytes;
|
||||
@ -286,6 +288,7 @@ char *commands[] = {
|
||||
"view_document_thumb",
|
||||
"load_document",
|
||||
"view_document",
|
||||
"set",
|
||||
0 };
|
||||
|
||||
int commands_flags[] = {
|
||||
@ -327,6 +330,11 @@ int commands_flags[] = {
|
||||
07,
|
||||
07,
|
||||
0732,
|
||||
07,
|
||||
07,
|
||||
07,
|
||||
07,
|
||||
07,
|
||||
};
|
||||
|
||||
int get_complete_mode (void) {
|
||||
@ -781,6 +789,13 @@ void interpreter (char *line UU) {
|
||||
"rename_contact <user> <first-name> <last-name> - tries to rename contact. If you have another device it will be a fight\n"
|
||||
"suggested_contacts - print info about contacts, you have max common friends\n"
|
||||
"visualize_key <secret_chat> - prints visualization of encryption key. You should compare it to your partner's one\n"
|
||||
"set <param> <param-value>. Possible <param> values are:\n"
|
||||
"\tdebug_verbosity - just as it sounds. Debug verbosity\n"
|
||||
"\tlog_level - level of logging of new events. Lower is less verbose:\n"
|
||||
"\t\tLevel 1: prints info about read messages\n"
|
||||
"\t\tLevel 2: prints line, when somebody is typing in chat\n"
|
||||
"\t\tLevel 3: prints line, when somebody changes online status\n"
|
||||
"\tmsg_num - enables/disables numeration of messages\n"
|
||||
);
|
||||
pop_color ();
|
||||
} else if (IS_WORD ("show_license")) {
|
||||
@ -938,11 +953,26 @@ void interpreter (char *line UU) {
|
||||
printf ("Bad msg id\n");
|
||||
RET;
|
||||
}
|
||||
} else if (IS_WORD ("set")) {
|
||||
command = next_token (&l);
|
||||
long long num = next_token_int ();
|
||||
if (num == NOT_FOUND) {
|
||||
printf ("Bad msg id\n");
|
||||
RET;
|
||||
}
|
||||
if (IS_WORD ("debug_verbosity")) {
|
||||
verbosity = num;
|
||||
} else if (IS_WORD ("log_level")) {
|
||||
log_level = num;
|
||||
} else if (IS_WORD ("msg_num")) {
|
||||
msg_num_mode = num;
|
||||
}
|
||||
} else if (IS_WORD ("quit")) {
|
||||
exit (0);
|
||||
}
|
||||
#undef IS_WORD
|
||||
#undef RET
|
||||
update_prompt ();
|
||||
in_readline = 0;
|
||||
}
|
||||
|
||||
|
13
main.c
13
main.c
@ -76,6 +76,7 @@ char *downloads_directory;
|
||||
char *config_directory;
|
||||
char *binlog_file_name;
|
||||
int binlog_enabled;
|
||||
extern int log_level;
|
||||
|
||||
void set_default_username (const char *s) {
|
||||
if (default_username) {
|
||||
@ -260,6 +261,9 @@ void parse_config (void) {
|
||||
strcpy (buf + l, "test");
|
||||
config_lookup_bool (&conf, buf, &test_dc);
|
||||
|
||||
strcpy (buf + l, "log_level");
|
||||
config_lookup_int (&conf, buf, &log_level);
|
||||
|
||||
if (!msg_num_mode) {
|
||||
strcpy (buf + l, "msg_num");
|
||||
config_lookup_bool (&conf, buf, &msg_num_mode);
|
||||
@ -300,7 +304,7 @@ void inner_main (void) {
|
||||
}
|
||||
|
||||
void usage (void) {
|
||||
printf ("%s [-u username] [-h] [-k public key name] [-N] [-v]\n", PROGNAME);
|
||||
printf ("%s [-u username] [-h] [-k public key name] [-N] [-v] [-l log_level]\n", PROGNAME);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
@ -310,7 +314,7 @@ extern int default_dc_num;
|
||||
|
||||
void args_parse (int argc, char **argv) {
|
||||
int opt = 0;
|
||||
while ((opt = getopt (argc, argv, "u:hk:vn:Nc:p:")) != -1) {
|
||||
while ((opt = getopt (argc, argv, "u:hk:vn:Nc:p:l:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'u':
|
||||
set_default_username (optarg);
|
||||
@ -331,6 +335,9 @@ void args_parse (int argc, char **argv) {
|
||||
prefix = strdup (optarg);
|
||||
assert (strlen (prefix) <= 100);
|
||||
break;
|
||||
case 'l':
|
||||
log_level = atoi (optarg);
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
usage ();
|
||||
@ -356,6 +363,8 @@ void sig_handler (int signum) {
|
||||
int main (int argc, char **argv) {
|
||||
signal (SIGSEGV, sig_handler);
|
||||
signal (SIGABRT, sig_handler);
|
||||
|
||||
log_level = 10;
|
||||
|
||||
args_parse (argc, argv);
|
||||
printf (
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "mtproto-common.h"
|
||||
|
||||
#define MAX_NET_RES (1L << 16)
|
||||
extern int log_level;
|
||||
|
||||
int verbosity;
|
||||
int auth_success;
|
||||
@ -739,26 +740,30 @@ void work_update (struct connection *c UU, long long msg_id UU) {
|
||||
}
|
||||
}
|
||||
fetch_pts ();
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" %d messages marked as read\n", n);
|
||||
pop_color ();
|
||||
print_end ();
|
||||
if (log_level >= 1) {
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" %d messages marked as read\n", n);
|
||||
pop_color ();
|
||||
print_end ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CODE_update_user_typing:
|
||||
{
|
||||
peer_id_t id = MK_USER (fetch_int ());
|
||||
peer_t *U = user_chat_get (id);
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" User ");
|
||||
print_user_name (id, U);
|
||||
printf (" is typing....\n");
|
||||
pop_color ();
|
||||
print_end ();
|
||||
if (log_level >= 2) {
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" User ");
|
||||
print_user_name (id, U);
|
||||
printf (" is typing....\n");
|
||||
pop_color ();
|
||||
print_end ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CODE_update_chat_user_typing:
|
||||
@ -767,16 +772,18 @@ void work_update (struct connection *c UU, long long msg_id UU) {
|
||||
peer_id_t id = MK_USER (fetch_int ());
|
||||
peer_t *C = user_chat_get (chat_id);
|
||||
peer_t *U = user_chat_get (id);
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" User ");
|
||||
print_user_name (id, U);
|
||||
printf (" is typing in chat ");
|
||||
print_chat_name (chat_id, C);
|
||||
printf ("....\n");
|
||||
pop_color ();
|
||||
print_end ();
|
||||
if (log_level >= 2) {
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" User ");
|
||||
print_user_name (id, U);
|
||||
printf (" is typing in chat ");
|
||||
print_chat_name (chat_id, C);
|
||||
printf ("....\n");
|
||||
pop_color ();
|
||||
print_end ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CODE_update_user_status:
|
||||
@ -785,15 +792,17 @@ void work_update (struct connection *c UU, long long msg_id UU) {
|
||||
peer_t *U = user_chat_get (user_id);
|
||||
if (U) {
|
||||
fetch_user_status (&U->user.status);
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" User ");
|
||||
print_user_name (user_id, U);
|
||||
printf (" is now ");
|
||||
printf ("%s\n", (U->user.status.online > 0) ? "online" : "offline");
|
||||
pop_color ();
|
||||
print_end ();
|
||||
if (log_level >= 3) {
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" User ");
|
||||
print_user_name (user_id, U);
|
||||
printf (" is now ");
|
||||
printf ("%s\n", (U->user.status.online > 0) ? "online" : "offline");
|
||||
pop_color ();
|
||||
print_end ();
|
||||
}
|
||||
} else {
|
||||
struct user_status t;
|
||||
fetch_user_status (&t);
|
||||
@ -876,6 +885,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
|
||||
if (y == CODE_user_profile_photo_empty) {
|
||||
} else {
|
||||
assert (y == CODE_user_profile_photo);
|
||||
fetch_long (); // photo_id
|
||||
fetch_file_location (&t);
|
||||
fetch_file_location (&t);
|
||||
}
|
||||
@ -1096,14 +1106,16 @@ void work_update (struct connection *c UU, long long msg_id UU) {
|
||||
M = M->next;
|
||||
}
|
||||
}
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" Encrypted chat ");
|
||||
print_encr_chat_name_full (id, user_chat_get (id));
|
||||
printf (": %d messages marked read \n", x);
|
||||
pop_color ();
|
||||
print_end ();
|
||||
if (log_level >= 1) {
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
print_date (time (0));
|
||||
printf (" Encrypted chat ");
|
||||
print_encr_chat_name_full (id, user_chat_get (id));
|
||||
printf (": %d messages marked read \n", x);
|
||||
pop_color ();
|
||||
print_end ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CODE_update_chat_participant_add:
|
||||
|
@ -76,6 +76,7 @@
|
||||
|
||||
#define CODE_input_peer_notify_settings_old 0x3cf4b1be
|
||||
#define CODE_peer_notify_settings_old 0xddbcd4a5
|
||||
#define CODE_user_profile_photo_old 0x990d1493
|
||||
|
||||
#define CODE_msg_detained_info 0x276d3ec6
|
||||
/* not really a limit, for struct encrypted_message only */
|
||||
|
45
queries.c
45
queries.c
@ -303,6 +303,28 @@ void out_random (int n) {
|
||||
out_cstring (buf, n);
|
||||
}
|
||||
|
||||
int allow_send_linux_version;
|
||||
void do_insert_header (void) {
|
||||
out_int (CODE_invoke_with_layer9);
|
||||
out_int (CODE_init_connection);
|
||||
out_int (TG_APP_ID);
|
||||
if (allow_send_linux_version) {
|
||||
struct utsname st;
|
||||
uname (&st);
|
||||
out_string (st.machine);
|
||||
static char buf[1000000];
|
||||
sprintf (buf, "%s %s %s", st.sysname, st.release, st.version);
|
||||
out_string (buf);
|
||||
out_string (TG_VERSION " (build " TG_BUILD ")");
|
||||
out_string ("En");
|
||||
} else {
|
||||
out_string ("x86");
|
||||
out_string ("Linux");
|
||||
out_string (TG_VERSION);
|
||||
out_string ("en");
|
||||
}
|
||||
}
|
||||
|
||||
/* {{{ Get config */
|
||||
|
||||
void fetch_dc_option (void) {
|
||||
@ -413,7 +435,7 @@ void do_send_code (const char *user) {
|
||||
suser = strdup (user);
|
||||
want_dc_num = 0;
|
||||
clear_packet ();
|
||||
out_int (CODE_invoke_with_layer6);
|
||||
do_insert_header ();
|
||||
out_int (CODE_auth_send_code);
|
||||
out_string (user);
|
||||
out_int (0);
|
||||
@ -441,7 +463,7 @@ void do_send_code (const char *user) {
|
||||
logprintf ("send_code: dc_num = %d\n", dc_working_num);
|
||||
want_dc_num = 0;
|
||||
clear_packet ();
|
||||
out_int (CODE_invoke_with_layer6);
|
||||
do_insert_header ();
|
||||
out_int (CODE_auth_send_code);
|
||||
out_string (user);
|
||||
out_int (0);
|
||||
@ -2531,24 +2553,7 @@ struct query_methods get_difference_methods = {
|
||||
void do_get_difference (void) {
|
||||
difference_got = 0;
|
||||
clear_packet ();
|
||||
out_int (CODE_invoke_with_layer9);
|
||||
out_int (CODE_init_connection);
|
||||
out_int (TG_APP_ID);
|
||||
if (allow_send_linux_version) {
|
||||
struct utsname st;
|
||||
uname (&st);
|
||||
out_string (st.machine);
|
||||
static char buf[1000000];
|
||||
sprintf (buf, "%s %s %s", st.sysname, st.release, st.version);
|
||||
out_string (buf);
|
||||
out_string (TG_VERSION " (build " TG_BUILD ")");
|
||||
out_string ("En");
|
||||
} else {
|
||||
out_string ("x86");
|
||||
out_string ("Linux");
|
||||
out_string (TG_VERSION);
|
||||
out_string ("en");
|
||||
}
|
||||
do_insert_header ();
|
||||
if (seq > 0) {
|
||||
out_int (CODE_updates_get_difference);
|
||||
out_int (pts);
|
||||
|
@ -202,8 +202,10 @@ int fetch_user (struct user *U) {
|
||||
need_update |= set_update_int (&U->photo_small.dc, -2);
|
||||
need_update |= set_update_int (&U->photo_big.dc, -2);
|
||||
} else {
|
||||
assert (y == CODE_user_profile_photo);
|
||||
fetch_long ();
|
||||
assert (y == CODE_user_profile_photo || y == CODE_user_profile_photo_old);
|
||||
if (y == CODE_user_profile_photo) {
|
||||
fetch_long ();
|
||||
}
|
||||
need_update |= fetch_file_location (&U->photo_small);
|
||||
need_update |= fetch_file_location (&U->photo_big);
|
||||
}
|
||||
@ -396,6 +398,7 @@ void fetch_user_full (struct user *U) {
|
||||
free_photo (&U->photo);
|
||||
}
|
||||
fetch_photo (&U->photo);
|
||||
U->flags |= FLAG_HAS_PHOTO;
|
||||
fetch_notify_settings ();
|
||||
U->blocked = fetch_int ();
|
||||
if (U->real_first_name) { free (U->real_first_name); }
|
||||
|
Loading…
Reference in New Issue
Block a user