Commit 49eb2291 authored by vvaltman's avatar vvaltman

interface updates

parent 7bcc3737
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
char *default_prompt = "> "; char *default_prompt = "> ";
int msg_num_mode; int msg_num_mode;
int disable_colors;
int alert_sound; int alert_sound;
extern int binlog_read; extern int binlog_read;
...@@ -1629,12 +1630,14 @@ int color_stack_pos; ...@@ -1629,12 +1630,14 @@ int color_stack_pos;
const char *color_stack[10]; const char *color_stack[10];
void push_color (const char *color) { void push_color (const char *color) {
if (disable_colors) { return; }
assert (color_stack_pos < 10); assert (color_stack_pos < 10);
color_stack[color_stack_pos ++] = color; color_stack[color_stack_pos ++] = color;
printf ("%s", color); printf ("%s", color);
} }
void pop_color (void) { void pop_color (void) {
if (disable_colors) { return; }
assert (color_stack_pos > 0); assert (color_stack_pos > 0);
color_stack_pos --; color_stack_pos --;
if (color_stack_pos >= 1) { if (color_stack_pos >= 1) {
......
...@@ -394,6 +394,10 @@ void read_auth_file (void) { ...@@ -394,6 +394,10 @@ void read_auth_file (void) {
close (auth_file_fd); close (auth_file_fd);
} }
void dlist_cb (void *callback_extra, int success, int size, tgl_peer_id_t peers[], int last_msg_id[], int unread_count[]) {
d_got_ok = 1;
}
int loop (void) { int loop (void) {
//on_start (); //on_start ();
tgl_set_callback (&upd_cb); tgl_set_callback (&upd_cb);
...@@ -544,6 +548,11 @@ int loop (void) { ...@@ -544,6 +548,11 @@ int loop (void) {
tgl_do_get_difference (sync_from_start, get_difference_callback, 0); tgl_do_get_difference (sync_from_start, get_difference_callback, 0);
net_loop (0, dgot); net_loop (0, dgot);
assert (!(tgl_state.locks & TGL_LOCK_DIFF)); assert (!(tgl_state.locks & TGL_LOCK_DIFF));
if (wait_dialog_list) {
d_got_ok = 0;
tgl_do_get_dialog_list (dlist_cb, 0);
net_loop (0, dgot);
}
#ifdef USE_LUA #ifdef USE_LUA
lua_diff_end (); lua_diff_end ();
#endif #endif
......
...@@ -92,6 +92,7 @@ extern int log_level; ...@@ -92,6 +92,7 @@ extern int log_level;
int sync_from_start; int sync_from_start;
int allow_weak_random; int allow_weak_random;
char *lua_file; char *lua_file;
int disable_colors;
void set_default_username (const char *s) { void set_default_username (const char *s) {
if (default_username) { if (default_username) {
...@@ -374,23 +375,25 @@ void inner_main (void) { ...@@ -374,23 +375,25 @@ void inner_main (void) {
void usage (void) { void usage (void) {
printf ("%s Usage\n", PROGNAME); printf ("%s Usage\n", PROGNAME);
printf (" -h this help list\n"); printf (" -u specify username (would not be asked during authorization)\n");
printf (" -u username specify username\n"); printf (" -k specify location of public key (possible multiple entries)\n");
printf (" -k public-key specify server public key\n"); printf (" -v increase verbosity (0-ERROR 1-WARNIN 2-NOTICE 3+-DEBUG-levels)\n");
printf (" -v verbose\n"); printf (" -N message num mode\n");
printf (" -l [1-3] log level\n"); #ifdef HAVE_LIBCONFIG
printf (" -L log-file log net file\n"); printf (" -c config file name\n");
printf (" -N message num mode\n"); printf (" -p use specified profile\n");
printf (" -c config-file specify config file\n"); #else
printf (" -p prefix specify prefix\n"); printf (" -B enable binlog\n");
printf (" -f sync from start\n"); #endif
printf (" -B enable binlog\n"); printf (" -l log level\n");
printf (" -E disable auto accept\n"); printf (" -f during authorization fetch all messages since registration\n");
printf (" -w allow weak random\n"); printf (" -E diable auto accept of encrypted chats\n");
printf (" -s specify lua script\n"); #ifdef USE_LUA
printf (" -W wait dialog list\n"); printf (" -s lua script file\n");
printf ("\n"); #endif
printf (" -W send dialog_list query and wait for answer before reading input\n");
printf (" -C disable color output\n");
exit (1); exit (1);
} }
...@@ -408,7 +411,17 @@ int wait_dialog_list; ...@@ -408,7 +411,17 @@ int wait_dialog_list;
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:Nc:p:l:fBEs:wW")) != -1) { while ((opt = getopt (argc, argv, "u:hk:vNl:fEwWC"
#ifdef HAVE_LIBCONFIG
"c:p:"
#else
"B"
#endif
#ifdef USE_LUA
"c"
#endif
)) != -1) {
switch (opt) { switch (opt) {
case 'u': case 'u':
set_default_username (optarg); set_default_username (optarg);
...@@ -424,6 +437,7 @@ void args_parse (int argc, char **argv) { ...@@ -424,6 +437,7 @@ void args_parse (int argc, char **argv) {
case 'N': case 'N':
msg_num_mode ++; msg_num_mode ++;
break; break;
#ifdef HAVE_LIBCONFIG
case 'c': case 'c':
config_filename = tstrdup (optarg); config_filename = tstrdup (optarg);
break; break;
...@@ -431,6 +445,11 @@ void args_parse (int argc, char **argv) { ...@@ -431,6 +445,11 @@ void args_parse (int argc, char **argv) {
prefix = tstrdup (optarg); prefix = tstrdup (optarg);
assert (strlen (prefix) <= 100); assert (strlen (prefix) <= 100);
break; break;
#else
case 'B':
binlog_enabled = 1;
break;
#endif
case 'l': case 'l':
log_level = atoi (optarg); log_level = atoi (optarg);
break; break;
...@@ -440,9 +459,6 @@ void args_parse (int argc, char **argv) { ...@@ -440,9 +459,6 @@ void args_parse (int argc, char **argv) {
case 'f': case 'f':
sync_from_start = 1; sync_from_start = 1;
break; break;
case 'B':
binlog_enabled = 1;
break;
//case 'L': //case 'L':
// if (log_net_file) { // if (log_net_file) {
// usage (); // usage ();
...@@ -457,12 +473,17 @@ void args_parse (int argc, char **argv) { ...@@ -457,12 +473,17 @@ void args_parse (int argc, char **argv) {
case 'w': case 'w':
allow_weak_random = 1; allow_weak_random = 1;
break; break;
#ifdef USE_LUA
case 's': case 's':
lua_file = tstrdup (optarg); lua_file = tstrdup (optarg);
break; break;
#endif
case 'W': case 'W':
wait_dialog_list = 1; wait_dialog_list = 1;
break; break;
case 'C':
disable_colors ++;
break;
case 'h': case 'h':
default: default:
usage (); usage ();
......
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