Fixed unread messages. Added output to dialoglist query

This commit is contained in:
vysheng 2013-10-23 14:25:41 +04:00
parent db8a7a774b
commit 121f0f1d14
2 changed files with 30 additions and 3 deletions

View File

@ -580,12 +580,20 @@ int get_dialogs_on_answer (struct query *q UU) {
assert (fetch_int () == CODE_vector); assert (fetch_int () == CODE_vector);
int n, i; int n, i;
n = fetch_int (); n = fetch_int ();
static int dlist[3 * 100];
int dl_size = n;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
assert (fetch_int () == CODE_dialog); assert (fetch_int () == CODE_dialog);
if (i < 100) {
dlist[3 * i + 0] = fetch_peer_id ();
dlist[3 * i + 1] = fetch_int ();
dlist[3 * i + 2] = fetch_int ();
} else {
fetch_peer_id (); fetch_peer_id ();
fetch_int (); fetch_int ();
fetch_int (); fetch_int ();
} }
}
assert (fetch_int () == CODE_vector); assert (fetch_int () == CODE_vector);
n = fetch_int (); n = fetch_int ();
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -601,6 +609,23 @@ int get_dialogs_on_answer (struct query *q UU) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
fetch_alloc_user (); fetch_alloc_user ();
} }
print_start ();
push_color (COLOR_YELLOW);
for (i = dl_size - 1; i >= 0; i--) {
if (dlist[3 * i] < 0) {
union user_chat *UC = user_chat_get (dlist[3 * i]);
printf ("Chat ");
print_chat_name (dlist[3 * i], UC);
printf (": %d unread\n", dlist[3 * i + 2]);
} else {
union user_chat *UC = user_chat_get (dlist[3 * i]);
printf ("User ");
print_user_name (dlist[3 * i], UC);
printf (": %d unread\n", dlist[3 * i + 2]);
}
}
pop_color ();
print_end ();
return 0; return 0;
} }

View File

@ -262,6 +262,7 @@ void fetch_message_short (struct message *M) {
M->date = fetch_int (); M->date = fetch_int ();
fetch_int (); // seq fetch_int (); // seq
M->media.type = CODE_message_media_empty; M->media.type = CODE_message_media_empty;
M->unread = 1;
} }
void fetch_message_short_chat (struct message *M) { void fetch_message_short_chat (struct message *M) {
@ -274,6 +275,7 @@ void fetch_message_short_chat (struct message *M) {
M->date = fetch_int (); M->date = fetch_int ();
fetch_int (); // seq fetch_int (); // seq
M->media.type = CODE_message_media_empty; M->media.type = CODE_message_media_empty;
M->unread = 1;
} }