1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-03 03:36:45 +02:00

Merge pull request #174 from mannol1/master

Make closing window end call
This commit is contained in:
mannol1
2014-07-06 22:52:11 +02:00
4 changed files with 56 additions and 28 deletions

View File

@ -94,6 +94,8 @@ void callback_call_ended ( int32_t call_index, void *arg );
void callback_requ_timeout ( int32_t call_index, void *arg );
void callback_peer_timeout ( int32_t call_index, void *arg );
int stop_transmission(int call_index);
static void print_err (ToxWindow *self, uint8_t *error_str)
{
line_info_add(self, NULL, NULL, NULL, error_str, SYS_MSG, 0, 0);
@ -245,17 +247,17 @@ int start_transmission(ToxWindow *self)
}
if ( !toxav_capability_supported(ASettins.av, self->call_idx, AudioDecoding) ||
!toxav_capability_supported(ASettins.av, self->call_idx, AudioEncoding) )
!toxav_capability_supported(ASettins.av, self->call_idx, AudioEncoding) )
return -1;
set_call(&ASettins.calls[self->call_idx], _True);
if ( 0 != pthread_create(&ASettins.calls[self->call_idx].ttid, NULL, transmission, self ) &&
0 != pthread_detach(ASettins.calls[self->call_idx].ttid) ) {
0 != pthread_detach(ASettins.calls[self->call_idx].ttid) ) {
return -1;
}
return 0;
}
return 0;
}
int stop_transmission(int call_index)
@ -265,7 +267,7 @@ int stop_transmission(int call_index)
ASettins.calls[call_index].ttas = _False;
return 0;
}
return -1;
}
/*
@ -309,13 +311,11 @@ void callback_recv_ending ( int32_t call_index, void* arg )
{
CB_BODY(call_index, arg, onEnding);
stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
}
void callback_recv_error ( int32_t call_index, void* arg )
{
CB_BODY(call_index, arg, onError);
stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
}
void callback_call_started ( int32_t call_index, void* arg )
{
@ -336,7 +336,6 @@ void callback_call_canceled ( int32_t call_index, void* arg )
/* In case call is active */
stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
}
void callback_call_rejected ( int32_t call_index, void* arg )
{
@ -346,13 +345,11 @@ void callback_call_ended ( int32_t call_index, void* arg )
{
CB_BODY(call_index, arg, onEnd);
stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
}
void callback_requ_timeout ( int32_t call_index, void* arg )
{
CB_BODY(call_index, arg, onRequestTimeout);
((ToxWindow*)arg)->call_idx = -1;
}
void callback_peer_timeout ( int32_t call_index, void* arg )
{
@ -362,7 +359,6 @@ void callback_peer_timeout ( int32_t call_index, void* arg )
* actions that one can possibly take on timeout
*/
toxav_stop_call(ASettins.av, call_index);
((ToxWindow*)arg)->call_idx = -1;
}
/*
* End of Callbacks
@ -762,3 +758,27 @@ void cmd_sense(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)
on_error:
print_err (self, error_str);
}
void stop_current_call(ToxWindow* self)
{
ToxAvCallState callstate;
if ( ASettins.av != NULL && self->call_idx != -1 &&
( callstate = toxav_get_call_state(ASettins.av, self->call_idx) ) != av_CallNonExistant) {
switch (callstate)
{
case av_CallActive:
case av_CallHold:
toxav_hangup(ASettins.av, self->call_idx);
break;
case av_CallInviting:
toxav_cancel(ASettins.av, self->call_idx, 0, "Not interested anymore");
break;
case av_CallStarting:
toxav_reject(ASettins.av, self->call_idx, "Not interested");
break;
default:
break;
}
}
}