mirror of
https://github.com/Tha14/toxic.git
synced 2026-01-26 06:33:16 +01:00
Merge new_av from upstream
This commit is contained in:
76
src/chat.c
76
src/chat.c
@@ -618,32 +618,31 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, uint32_t friendnumber, c
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/gaccept\" to join the chat.");
|
||||
}
|
||||
|
||||
/* Av Stuff */
|
||||
/* AV Stuff */
|
||||
#ifdef AUDIO
|
||||
|
||||
void chat_onInvite (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onInvite (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
/* call_index is set here and reset on call end */
|
||||
/* call is flagged active here */
|
||||
self->is_call = true;
|
||||
|
||||
self->call_idx = call_index;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Incoming audio call! Type: \"/answer\" or \"/reject\"");
|
||||
|
||||
if (self->ringing_sound == -1)
|
||||
sound_notify(self, call_incoming, NT_LOOP, &self->ringing_sound);
|
||||
|
||||
|
||||
if (self->active_box != -1)
|
||||
box_silent_notify2(self, NT_NOFOCUS | NT_WNDALERT_0, self->active_box, "Incoming audio call!");
|
||||
else
|
||||
box_silent_notify(self, NT_NOFOCUS | NT_WNDALERT_0, &self->active_box, self->name, "Incoming audio call!");
|
||||
}
|
||||
|
||||
void chat_onRinging (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onRinging (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ringing...type \"/hangup\" to cancel it.");
|
||||
@@ -654,40 +653,44 @@ void chat_onRinging (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onStarting (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onStarting (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
init_infobox(self);
|
||||
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it.");
|
||||
|
||||
/* call is flagged active here */
|
||||
self->is_call = true;
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
stop_sound(self->ringing_sound);
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onEnding (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onEnding (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
kill_infobox(self);
|
||||
self->call_idx = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
|
||||
|
||||
self->is_call = false;
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
stop_sound(self->ringing_sound);
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onError (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onError (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
self->call_idx = -1;
|
||||
self->is_call = false;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@@ -695,11 +698,14 @@ void chat_onError (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onStart (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onStart (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
/* call is flagged active here */
|
||||
self->is_call = true;
|
||||
|
||||
init_infobox(self);
|
||||
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it.");
|
||||
@@ -709,13 +715,13 @@ void chat_onStart (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onCancel (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onCancel (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
self->is_call = false;
|
||||
kill_infobox(self);
|
||||
self->call_idx = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call canceled!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@@ -723,39 +729,39 @@ void chat_onCancel (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onReject (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onReject (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
self->call_idx = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Rejected!");
|
||||
self->is_call = false;
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
stop_sound(self->ringing_sound);
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onEnd (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onEnd (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
kill_infobox(self);
|
||||
self->call_idx = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
|
||||
self->is_call = false;
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
stop_sound(self->ringing_sound);
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onRequestTimeout (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onRequestTimeout (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
self->call_idx = -1;
|
||||
self->is_call = false;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No answer!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@@ -763,13 +769,13 @@ void chat_onRequestTimeout (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onPeerTimeout (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onPeerTimeout (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
self->is_call = false;
|
||||
kill_infobox(self);
|
||||
self->call_idx = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer disconnected; call ended!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@@ -1201,10 +1207,8 @@ ToxWindow new_chat(Tox *m, uint32_t friendnum)
|
||||
ret.onCancel = &chat_onCancel;
|
||||
ret.onReject = &chat_onReject;
|
||||
ret.onEnd = &chat_onEnd;
|
||||
ret.onRequestTimeout = &chat_onRequestTimeout;
|
||||
ret.onPeerTimeout = &chat_onPeerTimeout;
|
||||
|
||||
ret.call_idx = -1;
|
||||
ret.is_call = false;
|
||||
ret.device_selection[0] = ret.device_selection[1] = -1;
|
||||
ret.ringing_sound = -1;
|
||||
#endif /* AUDIO */
|
||||
|
||||
Reference in New Issue
Block a user