diff --git a/interface.c b/interface.c index fdfc94f..ffe107f 100644 --- a/interface.c +++ b/interface.c @@ -538,7 +538,7 @@ void print_user_name (int id, union user_chat *U) { unknown_user_list[unknown_user_list_pos ++] = id; } } else { - if (U->flags & 20) { + if (U->flags & (FLAG_USER_SELF | FLAG_USER_CONTACT)) { push_color (COLOR_REDB); } if (!U->user.first_name) { @@ -548,7 +548,7 @@ void print_user_name (int id, union user_chat *U) { } else { printf ("%s %s", U->user.first_name, U->user.last_name); } - if (U->flags & 20) { + if (U->flags & (FLAG_USER_SELF | FLAG_USER_CONTACT)) { pop_color (); } } @@ -575,6 +575,11 @@ void print_date (long t) { } } +void print_date_full (long t) { + struct tm *tm = localtime (&t); + printf ("[%04d/%02d/%02d %02d:%02d:%02d]", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); +} + int our_id; void print_service_message (struct message *M) { diff --git a/interface.h b/interface.h index eac0fff..4f14037 100644 --- a/interface.h +++ b/interface.h @@ -49,4 +49,5 @@ void pop_color (void); void push_color (const char *color); void print_start (void); void print_end (void); +void print_date_full (long t); #endif diff --git a/queries.c b/queries.c index a688e31..f044fe1 100644 --- a/queries.c +++ b/queries.c @@ -444,8 +444,19 @@ int get_contacts_on_answer (struct query *q UU) { push_color (COLOR_GREEN); printf (" ("); printf ("%s", U->print_name); - printf (")\n"); + printf (") "); pop_color (); + if (U->status.online > 0) { + printf ("online\n"); + } else { + if (U->status.online < 0) { + printf ("offline. Was online "); + print_date_full (U->status.when); + } else { + printf ("offline permanent"); + } + printf ("\n"); + } pop_color (); print_end (); } diff --git a/structures.c b/structures.c index f4c53fc..74ead3f 100644 --- a/structures.c +++ b/structures.c @@ -66,7 +66,7 @@ void fetch_user (struct user *U) { assert (x == CODE_user_empty || x == CODE_user_self || x == CODE_user_contact || x == CODE_user_request || x == CODE_user_foreign || x == CODE_user_deleted); U->id = fetch_int (); if (x == CODE_user_empty) { - U->flags = 1; + U->flags = FLAG_EMPTY; return; } if (x == CODE_user_self) { @@ -98,16 +98,16 @@ void fetch_user (struct user *U) { s++; } if (x == CODE_user_deleted) { - U->flags = 2; + U->flags = FLAG_DELETED; return; } if (x == CODE_user_self) { - U->flags = 4; + U->flags = FLAG_USER_SELF; } else { U->access_hash = fetch_long (); } if (x == CODE_user_foreign) { - U->flags |= 8; + U->flags |= FLAG_USER_FOREIGN; } else { U->phone = fetch_str_dup (); } @@ -125,7 +125,7 @@ void fetch_user (struct user *U) { assert (fetch_int () == (int)CODE_bool_false); } if (x == CODE_user_contact) { - U->flags |= 16; + U->flags |= FLAG_USER_CONTACT; } } @@ -135,11 +135,11 @@ void fetch_chat (struct chat *C) { assert (x == CODE_chat_empty || x == CODE_chat || x == CODE_chat_forbidden); C->id = -fetch_int (); if (x == CODE_chat_empty) { - C->flags = 1; + C->flags = FLAG_EMPTY; return; } if (x == CODE_chat_forbidden) { - C->flags |= 8; + C->flags |= FLAG_FORBIDDEN; } C->title = fetch_str_dup (); C->print_title = strdup (C->title); @@ -161,7 +161,7 @@ void fetch_chat (struct chat *C) { C->user_num = fetch_int (); C->date = fetch_int (); if (fetch_int () == (int)CODE_bool_true) { - C->flags |= 16; + C->flags |= FLAG_CHAT_IN_CHAT; } C->version = fetch_int (); } else { diff --git a/structures.h b/structures.h index db535cb..c700a6a 100644 --- a/structures.h +++ b/structures.h @@ -19,6 +19,16 @@ #ifndef __STRUCTURES_H__ #define __STRUCTURES_H__ +#define FLAG_EMPTY 1 +#define FLAG_DELETED 2 +#define FLAG_FORBIDDEN 4 + + +#define FLAG_USER_SELF 128 +#define FLAG_USER_FOREIGN 256 +#define FLAG_USER_CONTACT 512 + +#define FLAG_CHAT_IN_CHAT 128 struct file_location { int dc;