added /read and /history in chat_with_peer mode
This commit is contained in:
parent
47174fe7ec
commit
41fc7c2278
21
interface.c
21
interface.c
@ -264,6 +264,8 @@ char *modifiers[] = {
|
||||
char *in_chat_commands[] = {
|
||||
"/exit",
|
||||
"/quit",
|
||||
"/history",
|
||||
"/read",
|
||||
0
|
||||
};
|
||||
|
||||
@ -552,6 +554,17 @@ void interpreter_chat_mode (char *line) {
|
||||
update_prompt ();
|
||||
return;
|
||||
}
|
||||
if (!strncmp (line, "/history", 8)) {
|
||||
int limit = 40;
|
||||
sscanf (line, "/history %d", &limit);
|
||||
if (limit < 0 || limit > 1000) { limit = 40; }
|
||||
do_get_history (chat_mode_id, limit);
|
||||
return;
|
||||
}
|
||||
if (!strncmp (line, "/read", 5)) {
|
||||
do_mark_read (chat_mode_id);
|
||||
return;
|
||||
}
|
||||
do_send_message (chat_mode_id, line, strlen (line));
|
||||
}
|
||||
|
||||
@ -1153,6 +1166,7 @@ void pop_color (void) {
|
||||
}
|
||||
|
||||
void print_media (struct message_media *M) {
|
||||
assert (M);
|
||||
switch (M->type) {
|
||||
case CODE_message_media_empty:
|
||||
case CODE_decrypted_message_media_empty:
|
||||
@ -1250,6 +1264,7 @@ void print_user_name (peer_id_t id, peer_t *U) {
|
||||
}
|
||||
|
||||
void print_chat_name (peer_id_t id, peer_t *C) {
|
||||
assert (get_peer_type (id) == PEER_CHAT);
|
||||
push_color (COLOR_MAGENTA);
|
||||
if (!C) {
|
||||
printf ("chat#%d", get_peer_id (id));
|
||||
@ -1260,6 +1275,7 @@ void print_chat_name (peer_id_t id, peer_t *C) {
|
||||
}
|
||||
|
||||
void print_encr_chat_name (peer_id_t id, peer_t *C) {
|
||||
assert (get_peer_type (id) == PEER_ENCR_CHAT);
|
||||
push_color (COLOR_MAGENTA);
|
||||
if (!C) {
|
||||
printf ("encr_chat#%d", get_peer_id (id));
|
||||
@ -1270,6 +1286,7 @@ void print_encr_chat_name (peer_id_t id, peer_t *C) {
|
||||
}
|
||||
|
||||
void print_encr_chat_name_full (peer_id_t id, peer_t *C) {
|
||||
assert (get_peer_type (id) == PEER_ENCR_CHAT);
|
||||
push_color (COLOR_MAGENTA);
|
||||
if (!C) {
|
||||
printf ("encr_chat#%d", get_peer_id (id));
|
||||
@ -1297,6 +1314,7 @@ void print_date_full (long t) {
|
||||
int our_id;
|
||||
|
||||
void print_service_message (struct message *M) {
|
||||
assert (M);
|
||||
print_start ();
|
||||
push_color (COLOR_GREY);
|
||||
|
||||
@ -1310,6 +1328,7 @@ void print_service_message (struct message *M) {
|
||||
if (get_peer_type (M->to_id) == PEER_CHAT) {
|
||||
print_chat_name (M->to_id, user_chat_get (M->to_id));
|
||||
} else {
|
||||
assert (get_peer_type (M->to_id) == PEER_ENCR_CHAT);
|
||||
print_encr_chat_name (M->to_id, user_chat_get (M->to_id));
|
||||
}
|
||||
printf (" ");
|
||||
@ -1362,9 +1381,11 @@ peer_id_t last_from_id;
|
||||
peer_id_t last_to_id;
|
||||
|
||||
void print_message (struct message *M) {
|
||||
assert (M);
|
||||
if (M->flags & (FLAG_MESSAGE_EMPTY | FLAG_DELETED)) {
|
||||
return;
|
||||
}
|
||||
if (!(M->flags & FLAG_CREATED)) { return; }
|
||||
if (M->service) {
|
||||
print_service_message (M);
|
||||
return;
|
||||
|
@ -205,7 +205,7 @@ int rpc_send_message (struct connection *c, void *data, int len) {
|
||||
assert (write_out (c, &total_len, 4) == 4);
|
||||
}
|
||||
c->out_packet_num ++;
|
||||
write_out (c, data, len);
|
||||
assert (write_out (c, data, len) == len);
|
||||
flush_out (c);
|
||||
|
||||
total_packets_sent ++;
|
||||
@ -726,11 +726,8 @@ void work_update_binlog (void) {
|
||||
U->last_name = fetch_str_dup ();
|
||||
U->print_name = create_print_name (U->id, U->first_name, U->last_name, 0, 0);
|
||||
} else {
|
||||
int l;
|
||||
l = prefetch_strlen ();
|
||||
fetch_str (l);
|
||||
l = prefetch_strlen ();
|
||||
fetch_str (l);
|
||||
fetch_skip_str ();
|
||||
fetch_skip_str ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -778,6 +775,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
|
||||
case CODE_update_new_message:
|
||||
{
|
||||
struct message *M = fetch_alloc_message ();
|
||||
assert (M);
|
||||
fetch_pts ();
|
||||
unread_messages ++;
|
||||
print_message (M);
|
||||
@ -898,11 +896,8 @@ void work_update (struct connection *c UU, long long msg_id UU) {
|
||||
pop_color ();
|
||||
print_end ();
|
||||
} else {
|
||||
int l;
|
||||
l = prefetch_strlen ();
|
||||
fetch_str (l);
|
||||
l = prefetch_strlen ();
|
||||
fetch_str (l);
|
||||
fetch_skip_str ();
|
||||
fetch_skip_str ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -304,6 +304,7 @@ static inline char *fetch_str (int len) {
|
||||
|
||||
static inline char *fetch_str_dup (void) {
|
||||
int l = prefetch_strlen ();
|
||||
assert (l >= 0);
|
||||
char *s = malloc (l + 1);
|
||||
memcpy (s, fetch_str (l), l);
|
||||
s[l] = 0;
|
||||
@ -361,6 +362,12 @@ static inline void fetch_skip (int n) {
|
||||
in_ptr += n;
|
||||
}
|
||||
|
||||
static inline void fetch_skip_str (void) {
|
||||
int l = prefetch_strlen ();
|
||||
assert (l >= 0);
|
||||
fetch_str (l);
|
||||
}
|
||||
|
||||
static __inline__ unsigned long long rdtsc(void) {
|
||||
unsigned hi, lo;
|
||||
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
|
||||
|
@ -1592,7 +1592,7 @@ struct query_methods rename_chat_methods = {
|
||||
.on_answer = rename_chat_on_answer
|
||||
};
|
||||
|
||||
void do_rename_chat (peer_id_t id, char *name) {
|
||||
void do_rename_chat (peer_id_t id, char *name UU) {
|
||||
clear_packet ();
|
||||
out_int (CODE_messages_edit_chat_title);
|
||||
assert (get_peer_type (id) == PEER_CHAT);
|
||||
@ -2316,7 +2316,8 @@ void do_create_keys_end (struct secret_chat *U) {
|
||||
hexdump ((void *)U->g_key, (void *)(U->g_key + 256));
|
||||
hexdump ((void *)U->key, (void *)(U->key + 64));
|
||||
hexdump ((void *)t, (void *)(t + 256));
|
||||
logprintf ("!!Key fingerprint mismatch\n");
|
||||
hexdump ((void *)sha_buffer, (void *)(sha_buffer + 20));
|
||||
logprintf ("!!Key fingerprint mismatch (my 0x%llx 0x%llx)\n", (unsigned long long)k, (unsigned long long)U->key_fingerprint);
|
||||
U->state = sc_deleted;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user