Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
8193960c
Commit
8193960c
authored
Nov 09, 2013
by
vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added queries online/offline/contacts_search
parent
c04a0f5d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
+76
-0
interface.c
interface.c
+18
-0
queries.c
queries.c
+56
-0
queries.h
queries.h
+2
-0
No files found.
interface.c
View file @
8193960c
...
...
@@ -258,6 +258,9 @@ char *commands[] = {
"global_search"
,
"chat_add_user"
,
"chat_del_user"
,
"status_online"
,
"status_offline"
,
"contacts_search"
,
0
};
int
commands_flags
[]
=
{
...
...
@@ -291,6 +294,9 @@ int commands_flags[] = {
07
,
0724
,
0724
,
07
,
07
,
07
,
};
int
get_complete_mode
(
void
)
{
...
...
@@ -789,6 +795,18 @@ void interpreter (char *line UU) {
do_create_secret_chat
(
id
);
}
else
if
(
IS_WORD
(
"suggested_contacts"
))
{
do_get_suggested
();
}
else
if
(
IS_WORD
(
"status_online"
))
{
do_update_status
(
1
);
}
else
if
(
IS_WORD
(
"status_offline"
))
{
do_update_status
(
0
);
}
else
if
(
IS_WORD
(
"contacts_search"
))
{
int
t
;
char
*
s
=
next_token
(
&
t
);
if
(
!
s
)
{
printf
(
"Empty search query
\n
"
);
RET
;
}
do_contacts_search
(
100
,
s
);
}
#undef IS_WORD
#undef RET
...
...
queries.c
View file @
8193960c
...
...
@@ -1988,6 +1988,46 @@ void do_msg_search (peer_id_t id, int from, int to, int limit, const char *s) {
}
/* }}} */
/* {{{ Contacts search */
int
contacts_search_on_answer
(
struct
query
*
q
UU
)
{
assert
(
fetch_int
()
==
CODE_contacts_found
);
assert
(
fetch_int
()
==
CODE_vector
);
int
n
=
fetch_int
();
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
assert
(
fetch_int
()
==
(
int
)
CODE_contact_found
);
fetch_int
();
}
assert
(
fetch_int
()
==
CODE_vector
);
n
=
fetch_int
();
print_start
();
push_color
(
COLOR_YELLOW
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
struct
user
*
U
=
fetch_alloc_user
();
printf
(
"User "
);
push_color
(
COLOR_RED
);
printf
(
"%s %s"
,
U
->
first_name
,
U
->
last_name
);
pop_color
();
printf
(
". Phone %s
\n
"
,
U
->
phone
);
}
pop_color
();
print_end
();
return
0
;
}
struct
query_methods
contacts_search_methods
=
{
.
on_answer
=
contacts_search_on_answer
};
void
do_contacts_search
(
int
limit
,
const
char
*
s
)
{
clear_packet
();
out_int
(
CODE_contacts_search
);
out_string
(
s
);
out_int
(
limit
);
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
contacts_search_methods
,
0
);
}
/* }}} */
/* {{{ Encr accept */
int
send_encr_accept_on_answer
(
struct
query
*
q
UU
)
{
struct
secret_chat
*
E
=
fetch_alloc_encrypted_chat
();
...
...
@@ -2499,3 +2539,19 @@ void do_create_secret_chat (peer_id_t id) {
do_create_encr_chat_request
(
&
P
->
encr_chat
);
}
/* }}} */
int
update_status_on_answer
(
struct
query
*
q
UU
)
{
fetch_bool
();
return
0
;
}
struct
query_methods
update_status_methods
=
{
.
on_answer
=
update_status_on_answer
};
void
do_update_status
(
int
online
UU
)
{
clear_packet
();
out_int
(
CODE_account_update_status
);
out_int
(
online
?
CODE_bool_false
:
CODE_bool_true
);
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
update_status_methods
,
0
);
}
queries.h
View file @
8193960c
...
...
@@ -105,5 +105,7 @@ void do_visualize_key (peer_id_t id);
void
do_create_keys_end
(
struct
secret_chat
*
U
);
void
do_add_user_to_chat
(
peer_id_t
chat_id
,
peer_id_t
id
,
int
limit
);
void
do_del_user_from_chat
(
peer_id_t
chat_id
,
peer_id_t
id
);
void
do_update_status
(
int
online
UU
);
void
do_contacts_search
(
int
limit
,
const
char
*
s
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment