Commit b70f868e authored by Vysheng's avatar Vysheng

Added search query. But it seems, that search does not use stemmer

parent 970cbcd3
...@@ -231,6 +231,7 @@ char *commands[] = { ...@@ -231,6 +231,7 @@ char *commands[] = {
"add_contact", "add_contact",
"rename_contact", "rename_contact",
"show_license", "show_license",
"search",
0 }; 0 };
int commands_flags[] = { int commands_flags[] = {
...@@ -256,6 +257,7 @@ int commands_flags[] = { ...@@ -256,6 +257,7 @@ int commands_flags[] = {
07, 07,
071, 071,
07, 07,
072,
}; };
int get_complete_mode (void) { int get_complete_mode (void) {
...@@ -671,6 +673,18 @@ void interpreter (char *line UU) { ...@@ -671,6 +673,18 @@ void interpreter (char *line UU) {
#include "LICENSE.h" #include "LICENSE.h"
; ;
printf ("%s", b); printf ("%s", b);
} else if (IS_WORD ("search")) {
GET_PEER;
int from = 0;
int to = 0;
int limit = 40;
int t;
char *s = next_token (&t);
if (!s) {
printf ("Empty message\n");
RET;
}
do_msg_search (id, from, to, limit, s);
} }
#undef IS_WORD #undef IS_WORD
#undef RET #undef RET
......
...@@ -261,6 +261,7 @@ static inline void out_bignum (BIGNUM *n) { ...@@ -261,6 +261,7 @@ static inline void out_bignum (BIGNUM *n) {
extern int *in_ptr, *in_end; extern int *in_ptr, *in_end;
void fetch_pts (void);
static inline int prefetch_strlen (void) { static inline int prefetch_strlen (void) {
if (in_ptr >= in_end) { if (in_ptr >= in_end) {
return -1; return -1;
......
...@@ -607,12 +607,12 @@ int msg_send_on_answer (struct query *q UU) { ...@@ -607,12 +607,12 @@ int msg_send_on_answer (struct query *q UU) {
assert (fetch_int () == (int)CODE_messages_sent_message); assert (fetch_int () == (int)CODE_messages_sent_message);
int id = fetch_int (); // id int id = fetch_int (); // id
int date = fetch_int (); // date int date = fetch_int (); // date
int ptr = fetch_int (); // ptr fetch_pts ();
int seq = fetch_int (); // seq int seq = fetch_int (); // seq
struct message *M = q->extra; struct message *M = q->extra;
M->id = id; M->id = id;
message_insert (M); message_insert (M);
logprintf ("Sent: id = %d, date = %d, ptr = %d, seq = %d\n", id, date, ptr, seq); logprintf ("Sent: id = %d, date = %d, seq = %d\n", id, date, seq);
return 0; return 0;
} }
...@@ -725,7 +725,7 @@ int get_history_on_answer (struct query *q UU) { ...@@ -725,7 +725,7 @@ int get_history_on_answer (struct query *q UU) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
fetch_alloc_user (); fetch_alloc_user ();
} }
if (sn > 0) { if (sn > 0 && q->extra) {
do_messages_mark_read (*(peer_id_t *)&(q->extra), ML[0]->id); do_messages_mark_read (*(peer_id_t *)&(q->extra), ML[0]->id);
} }
return 0; return 0;
...@@ -1447,3 +1447,25 @@ void do_add_contact (const char *phone, int phone_len, const char *first_name, i ...@@ -1447,3 +1447,25 @@ void do_add_contact (const char *phone, int phone_len, const char *first_name, i
out_int (force ? CODE_bool_true : CODE_bool_false); out_int (force ? CODE_bool_true : CODE_bool_false);
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &add_contact_methods, 0); send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &add_contact_methods, 0);
} }
int msg_search_on_answer (struct query *q UU) {
return get_history_on_answer (q);
}
struct query_methods msg_search_methods = {
.on_answer = msg_search_on_answer
};
void do_msg_search (peer_id_t id, int from, int to, int limit, const char *s) {
clear_packet ();
out_int (CODE_messages_search);
out_peer_id (id);
out_string (s);
out_int (CODE_input_messages_filter_empty);
out_int (from);
out_int (to);
out_int (0); // offset
out_int (0); // max_id
out_int (limit);
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &msg_search_methods, 0);
}
...@@ -92,5 +92,6 @@ int do_send_code_result_auth (const char *code, const char *first_name, const ch ...@@ -92,5 +92,6 @@ int do_send_code_result_auth (const char *code, const char *first_name, const ch
void do_import_auth (int num); void do_import_auth (int num);
void do_export_auth (int num); void do_export_auth (int num);
void do_add_contact (const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, int force); void do_add_contact (const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, int force);
void do_msg_search (peer_id_t id, int from, int to, int limit, const char *s);
#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