Added new callback

This commit is contained in:
mannol 2014-03-14 23:10:10 +01:00
parent 3acf43b76a
commit e990f05817
4 changed files with 23 additions and 20 deletions

View File

@ -117,7 +117,7 @@ typedef struct _MSIMessage {
static struct _Callbacks { static struct _Callbacks {
MSICallback function; MSICallback function;
void* data; void* data;
} callbacks[10] = {0}; } callbacks[11] = {0};
inline__ void invoke_callback(MSICallbackID id) inline__ void invoke_callback(MSICallbackID id)
{ {
@ -653,7 +653,8 @@ void handle_remote_connection_change(Messenger *messenger, int friend_num, uint8
for ( ; i < session->call->peer_count; i ++ ) for ( ; i < session->call->peer_count; i ++ )
if ( session->call->peers[i] == friend_num ) { if ( session->call->peers[i] == friend_num ) {
msi_stopcall(session); /* Stop the call for now */ invoke_callback(MSI_OnPeerTimeout);
/*msi_stopcall(session); /* Stop the call for now */
return; return;
} }
} }
@ -747,10 +748,9 @@ void *handle_timeout ( void *arg )
} }
return NULL; pthread_exit(NULL);
} }
/** /**
* @brief Add peer to peer list. * @brief Add peer to peer list.
* *
@ -1244,13 +1244,12 @@ int msi_terminate_session ( MSISession *session )
assert ( session ); assert ( session );
int _status = 0; int _status = 0;
terminate_call ( session ); /* If have call, cancel it */
if ( session->call ) msi_cancel(session, 0, "MSI session terminated!");
m_callback_msi_packet((struct Messenger *) session->messenger_handle, NULL, NULL); m_callback_msi_packet((struct Messenger *) session->messenger_handle, NULL, NULL);
/* TODO: Clean it up more? */
free ( session ); free ( session );
return _status; return _status;
} }

View File

@ -131,7 +131,8 @@ typedef enum {
/* Protocol */ /* Protocol */
MSI_OnError, MSI_OnError,
MSI_OnRequestTimeout MSI_OnRequestTimeout,
MSI_OnPeerTimeout
} MSICallbackID; } MSICallbackID;

View File

@ -1147,18 +1147,21 @@ failed_init_ffmpeg: ;
int av_terminate_session(av_session_t *_phone) int av_terminate_session(av_session_t *_phone)
{ {
toxav_hangup(_phone->av); _phone->running_decaud = 0;
usleep(100000); /* Wait for tox_poll to end */
free(_phone->_friends);
pthread_mutex_destroy ( &_phone->_mutex ); toxav_kill(_phone->av);
printf("\r[i] KILLED AV ARGH!\n");
usleep(1000000); /* Wait for cancel request to be sent */
Tox *_p = _phone->_messenger; Tox *_p = _phone->_messenger;
_phone->_messenger = NULL; _phone->_messenger = NULL;
usleep(100000); /* Wait for tox_poll to end */
tox_kill(_p); tox_kill(_p);
toxav_kill(_phone->av);
free(_phone->_friends);
pthread_mutex_destroy ( &_phone->_mutex );
free(_phone); free(_phone);
printf("\r[i] Quit!\n"); printf("\r[i] Quit!\n");

View File

@ -70,8 +70,8 @@ typedef enum {
/* Protocol */ /* Protocol */
av_OnError, av_OnError,
av_OnRequestTimeout av_OnRequestTimeout,
av_OnPeerTimeout
} ToxAvCallbackID; } ToxAvCallbackID;