1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 02:03:02 +01:00

Fix AV bug

Pending call now properly hangs up when you use the /hangup command or close the chat window
This commit is contained in:
Jfreegman 2015-11-19 23:49:58 -05:00
parent 9f0feb7223
commit b24c5d8cf8
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
3 changed files with 23 additions and 24 deletions

View File

@ -570,8 +570,8 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
{ {
const char *error_str = NULL; const char *error_str = NULL;
if ( !self->is_call ) { if ( !CallControl.av ) {
error_str = "Not in a call."; error_str = "Audio not supported!";
goto on_error; goto on_error;
} }
@ -580,8 +580,8 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
goto on_error; goto on_error;
} }
if ( !CallControl.av ) { if ( !self->is_call && !CallControl.pending_call ) {
error_str = "Audio not supported!"; error_str = "Not in a call.";
goto on_error; goto on_error;
} }
@ -589,18 +589,7 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
callback_video_end(self->num); callback_video_end(self->num);
#endif /* VIDEO */ #endif /* VIDEO */
if ( CallControl.pending_call ) { stop_current_call(self);
/* Manually send a cancel call control because call hasn't started */
toxav_call_control(CallControl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, NULL);
callback_call_canceled(self->num);
}
else {
stop_transmission(&CallControl.calls[self->num], self->num);
callback_call_ended(self->num);
}
CallControl.pending_call = false;
return; return;
on_error: on_error:
print_err (self, error_str); print_err (self, error_str);
@ -835,6 +824,16 @@ void stop_current_call(ToxWindow* self)
{ {
Call *this_call = &CallControl.calls[self->num]; Call *this_call = &CallControl.calls[self->num];
if (this_call && self->is_call) if ( !this_call )
stop_transmission(this_call, self->num); return;
if ( CallControl.pending_call ) {
toxav_call_control(CallControl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, NULL);
callback_call_canceled(self->num);
} else {
stop_transmission(&CallControl.calls[self->num], self->num);
callback_call_ended(self->num);
}
CallControl.pending_call = false;
} }

View File

@ -126,11 +126,6 @@ void kill_chat_window(ToxWindow *self, Tox *m)
ChatContext *ctx = self->chatwin; ChatContext *ctx = self->chatwin;
StatusBar *statusbar = self->stb; StatusBar *statusbar = self->stb;
kill_all_file_transfers_friend(m, self->num);
log_disable(ctx->log);
line_info_cleanup(ctx->hst);
cqueue_cleanup(ctx->cqueue);
#ifdef AUDIO #ifdef AUDIO
#ifdef VIDEO #ifdef VIDEO
stop_video_stream(self); stop_video_stream(self);
@ -138,6 +133,11 @@ void kill_chat_window(ToxWindow *self, Tox *m)
stop_current_call(self); stop_current_call(self);
#endif /* AUDIO */ #endif /* AUDIO */
kill_all_file_transfers_friend(m, self->num);
log_disable(ctx->log);
line_info_cleanup(ctx->hst);
cqueue_cleanup(ctx->cqueue);
delwin(ctx->linewin); delwin(ctx->linewin);
delwin(ctx->history); delwin(ctx->history);
delwin(statusbar->topline); delwin(statusbar->topline);

View File

@ -329,7 +329,7 @@ void *lookup_thread_func(void *data)
curl_easy_setopt(c_handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(c_handle, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(c_handle, CURLOPT_URL, real_domain); curl_easy_setopt(c_handle, CURLOPT_URL, real_domain);
curl_easy_setopt(c_handle, CURLOPT_WRITEFUNCTION, write_lookup_data); curl_easy_setopt(c_handle, CURLOPT_WRITEFUNCTION, write_lookup_data);
curl_easy_setopt(c_handle, CURLOPT_WRITEDATA, (void *) &recv_data); curl_easy_setopt(c_handle, CURLOPT_WRITEDATA, &recv_data);
curl_easy_setopt(c_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); curl_easy_setopt(c_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
curl_easy_setopt(c_handle, CURLOPT_POSTFIELDS, post_data); curl_easy_setopt(c_handle, CURLOPT_POSTFIELDS, post_data);