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
f6fe5765
Commit
f6fe5765
authored
Feb 24, 2014
by
Jeroen Bobbeldijk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fully working phone call support, might need some tweaks and checks
parent
98d638b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
2 deletions
+47
-2
loop.c
loop.c
+14
-2
queries.c
queries.c
+32
-0
queries.h
queries.h
+1
-0
No files found.
loop.c
View file @
f6fe5765
...
...
@@ -517,12 +517,18 @@ int loop (void) {
do_send_code
(
default_username
);
char
*
code
=
0
;
size_t
size
=
0
;
printf
(
"Code from sms: "
);
printf
(
"Code from sms
(if you did not receive an SMS and want to be called, type 0)
: "
);
while
(
1
)
{
if
(
net_getline
(
&
code
,
&
size
)
==
-
1
)
{
perror
(
"getline()"
);
exit
(
EXIT_FAILURE
);
}
if
(
*
code
==
'0'
)
{
printf
(
"You typed 0, switching to phone system.
\n
"
);
do_phone_call
(
default_username
);
printf
(
"Calling you! Code: "
);
continue
;
}
if
(
do_send_code_result
(
code
)
>=
0
)
{
break
;
}
...
...
@@ -563,12 +569,18 @@ int loop (void) {
DC_working
=
DC_list
[
dc_working_num
];
do_send_code
(
default_username
);
printf
(
"Code from sms: "
);
printf
(
"Code from sms
(if you did not receive an SMS and want to be called, type 0)
: "
);
while
(
1
)
{
if
(
net_getline
(
&
code
,
&
size
)
==
-
1
)
{
perror
(
"getline()"
);
exit
(
EXIT_FAILURE
);
}
if
(
*
code
==
'0'
)
{
printf
(
"You typed 0, switching to phone system.
\n
"
);
do_phone_call
(
default_username
);
printf
(
"Calling you! Code: "
);
continue
;
}
if
(
do_send_code_result_auth
(
code
,
first_name
,
last_name
)
>=
0
)
{
break
;
}
...
...
queries.c
View file @
f6fe5765
...
...
@@ -468,6 +468,38 @@ void do_send_code (const char *user) {
net_loop
(
0
,
code_is_sent
);
assert
(
want_dc_num
==
-
1
);
}
int
phone_call_on_answer
(
struct
query
*
q
UU
)
{
fetch_bool
();
assert
(
1
);
return
0
;
}
int
phone_call_on_error
(
struct
query
*
q
UU
,
int
error_code
,
int
l
,
char
*
error
)
{
logprintf
(
"error_code = %d, error = %.*s
\n
"
,
error_code
,
l
,
error
);
assert
(
0
);
return
0
;
}
struct
query_methods
phone_call_methods
=
{
.
on_answer
=
phone_call_on_answer
,
.
on_error
=
phone_call_on_error
};
void
do_phone_call
(
const
char
*
user
)
{
logprintf
(
"calling user
\n
"
);
suser
=
tstrdup
(
user
);
want_dc_num
=
0
;
clear_packet
();
do_insert_header
();
out_int
(
CODE_auth_send_call
);
out_string
(
user
);
out_string
(
phone_code_hash
);
logprintf
(
"do_phone_call: dc_num = %d
\n
"
,
dc_working_num
);
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
phone_call_methods
,
0
);
}
/* }}} */
/* {{{ Check phone */
...
...
queries.h
View file @
f6fe5765
...
...
@@ -64,6 +64,7 @@ void work_timers (void);
extern
struct
query_methods
help_get_config_methods
;
void
do_send_code
(
const
char
*
user
);
void
do_phone_call
(
const
char
*
user
);
int
do_send_code_result
(
const
char
*
code
);
double
get_double_time
(
void
);
...
...
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