Commit d7b25cca authored by Vysheng's avatar Vysheng

Support for chat rename

parent 83972316
...@@ -67,6 +67,7 @@ char *commands[] = { ...@@ -67,6 +67,7 @@ char *commands[] = {
"chat_info", "chat_info",
"user_info", "user_info",
"fwd", "fwd",
"rename_chat",
"show_license", "show_license",
0 }; 0 };
...@@ -83,6 +84,7 @@ int commands_flags[] = { ...@@ -83,6 +84,7 @@ int commands_flags[] = {
074, 074,
071, 071,
072, 072,
074,
07, 07,
}; };
...@@ -277,6 +279,18 @@ void interpreter (char *line UU) { ...@@ -277,6 +279,18 @@ void interpreter (char *line UU) {
if (*q && index < user_num + chat_num) { if (*q && index < user_num + chat_num) {
do_send_message (Peers[index], q, strlen (q)); do_send_message (Peers[index], q, strlen (q));
} }
} else if (!memcmp (line, "rename_chat", 11)) {
char *q = line + 11;
int len;
char *text = get_token (&q, &len);
int index = 0;
while (index < user_num + chat_num && (!Peers[index]->print_name || strncmp (Peers[index]->print_name, text, len) || Peers[index]->id >= 0)) {
index ++;
}
while (*q && (*q == ' ' || *q == '\t')) { q ++; }
if (*q && index < user_num + chat_num) {
do_rename_chat (Peers[index], q);
}
} else if (!memcmp (line, "send_photo", 10)) { } else if (!memcmp (line, "send_photo", 10)) {
char *q = line + 10; char *q = line + 10;
int len; int len;
......
...@@ -923,6 +923,38 @@ void do_forward_message (union user_chat *U, int n) { ...@@ -923,6 +923,38 @@ void do_forward_message (union user_chat *U, int n) {
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0); send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0);
} }
int rename_chat_on_answer (struct query *q UU) {
assert (fetch_int () == (int)CODE_messages_stated_message);
struct message *M = fetch_alloc_message ();
assert (fetch_int () == CODE_vector);
int n, i;
n = fetch_int ();
for (i = 0; i < n; i++) {
fetch_alloc_chat ();
}
assert (fetch_int () == CODE_vector);
n = fetch_int ();
for (i = 0; i < n; i++) {
fetch_alloc_user ();
}
fetch_int (); // pts
fetch_int (); // seq
print_message (M);
return 0;
}
struct query_methods rename_chat_methods = {
.on_answer = rename_chat_on_answer
};
void do_rename_chat (union user_chat *U, char *name) {
clear_packet ();
out_int (CODE_messages_edit_chat_title);
out_int (-U->id);
out_string (name);
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &rename_chat_methods, 0);
}
int chat_info_on_answer (struct query *q UU) { int chat_info_on_answer (struct query *q UU) {
struct chat *C = fetch_alloc_chat_full (); struct chat *C = fetch_alloc_chat_full ();
union user_chat *U = (void *)C; union user_chat *U = (void *)C;
......
...@@ -77,5 +77,6 @@ void do_get_chat_info (union user_chat *chat); ...@@ -77,5 +77,6 @@ void do_get_chat_info (union user_chat *chat);
void do_get_user_list_info_silent (int num, int *list); void do_get_user_list_info_silent (int num, int *list);
void do_get_user_info (union user_chat *user); void do_get_user_info (union user_chat *user);
void do_forward_message (union user_chat *U, int n); void do_forward_message (union user_chat *U, int n);
void do_rename_chat (union user_chat *U, char *name);
#endif #endif
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