Fixed some bugs. Fixed interface

This commit is contained in:
vysheng 2013-10-24 11:38:32 +04:00
parent fd8a13ecfd
commit f9cf392960
5 changed files with 38 additions and 11 deletions

View File

@ -538,7 +538,7 @@ void print_user_name (int id, union user_chat *U) {
unknown_user_list[unknown_user_list_pos ++] = id; unknown_user_list[unknown_user_list_pos ++] = id;
} }
} else { } else {
if (U->flags & 20) { if (U->flags & (FLAG_USER_SELF | FLAG_USER_CONTACT)) {
push_color (COLOR_REDB); push_color (COLOR_REDB);
} }
if (!U->user.first_name) { if (!U->user.first_name) {
@ -548,7 +548,7 @@ void print_user_name (int id, union user_chat *U) {
} else { } else {
printf ("%s %s", U->user.first_name, U->user.last_name); 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 (); 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; int our_id;
void print_service_message (struct message *M) { void print_service_message (struct message *M) {

View File

@ -49,4 +49,5 @@ void pop_color (void);
void push_color (const char *color); void push_color (const char *color);
void print_start (void); void print_start (void);
void print_end (void); void print_end (void);
void print_date_full (long t);
#endif #endif

View File

@ -444,8 +444,19 @@ int get_contacts_on_answer (struct query *q UU) {
push_color (COLOR_GREEN); push_color (COLOR_GREEN);
printf (" ("); printf (" (");
printf ("%s", U->print_name); printf ("%s", U->print_name);
printf (")\n"); printf (") ");
pop_color (); 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 (); pop_color ();
print_end (); print_end ();
} }

View File

@ -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); 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 (); U->id = fetch_int ();
if (x == CODE_user_empty) { if (x == CODE_user_empty) {
U->flags = 1; U->flags = FLAG_EMPTY;
return; return;
} }
if (x == CODE_user_self) { if (x == CODE_user_self) {
@ -98,16 +98,16 @@ void fetch_user (struct user *U) {
s++; s++;
} }
if (x == CODE_user_deleted) { if (x == CODE_user_deleted) {
U->flags = 2; U->flags = FLAG_DELETED;
return; return;
} }
if (x == CODE_user_self) { if (x == CODE_user_self) {
U->flags = 4; U->flags = FLAG_USER_SELF;
} else { } else {
U->access_hash = fetch_long (); U->access_hash = fetch_long ();
} }
if (x == CODE_user_foreign) { if (x == CODE_user_foreign) {
U->flags |= 8; U->flags |= FLAG_USER_FOREIGN;
} else { } else {
U->phone = fetch_str_dup (); U->phone = fetch_str_dup ();
} }
@ -125,7 +125,7 @@ void fetch_user (struct user *U) {
assert (fetch_int () == (int)CODE_bool_false); assert (fetch_int () == (int)CODE_bool_false);
} }
if (x == CODE_user_contact) { 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); assert (x == CODE_chat_empty || x == CODE_chat || x == CODE_chat_forbidden);
C->id = -fetch_int (); C->id = -fetch_int ();
if (x == CODE_chat_empty) { if (x == CODE_chat_empty) {
C->flags = 1; C->flags = FLAG_EMPTY;
return; return;
} }
if (x == CODE_chat_forbidden) { if (x == CODE_chat_forbidden) {
C->flags |= 8; C->flags |= FLAG_FORBIDDEN;
} }
C->title = fetch_str_dup (); C->title = fetch_str_dup ();
C->print_title = strdup (C->title); C->print_title = strdup (C->title);
@ -161,7 +161,7 @@ void fetch_chat (struct chat *C) {
C->user_num = fetch_int (); C->user_num = fetch_int ();
C->date = fetch_int (); C->date = fetch_int ();
if (fetch_int () == (int)CODE_bool_true) { if (fetch_int () == (int)CODE_bool_true) {
C->flags |= 16; C->flags |= FLAG_CHAT_IN_CHAT;
} }
C->version = fetch_int (); C->version = fetch_int ();
} else { } else {

View File

@ -19,6 +19,16 @@
#ifndef __STRUCTURES_H__ #ifndef __STRUCTURES_H__
#define __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 { struct file_location {
int dc; int dc;