// CLOUDTREE (THomas Hazel)
#ifndef WIN32
struct SkypopenList global_handles_list;
-extern int xio_error_handler(Display *dpy);
+extern int xio_error_handler(Display * dpy);
extern int X11_errors_handler(Display * dpy, XErrorEvent * err);
#endif
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
-static switch_status_t skypopen_tech_init(private_t * tech_pvt, switch_core_session_t *session);
+static switch_status_t skypopen_tech_init(private_t *tech_pvt, switch_core_session_t *session);
-static switch_status_t skypopen_codec(private_t * tech_pvt, int sample_rate, int codec_ms)
+static switch_status_t skypopen_codec(private_t *tech_pvt, int sample_rate, int codec_ms)
{
switch_core_session_t *session = NULL;
}
-switch_status_t skypopen_tech_init(private_t * tech_pvt, switch_core_session_t *session)
+switch_status_t skypopen_tech_init(private_t *tech_pvt, switch_core_session_t *session)
{
switch_assert(tech_pvt != NULL);
goto end;
}
- if (/* CLOUDTREE (Thomas Hazel) */ (force == FALSE) && strlen(globals.SKYPOPEN_INTERFACES[interface_id].session_uuid_str)) {
+ if ( /* CLOUDTREE (Thomas Hazel) */ (force == FALSE) && strlen(globals.SKYPOPEN_INTERFACES[interface_id].session_uuid_str)) {
DEBUGA_SKYPE("interface '%s' is busy\n", SKYPOPEN_P_LOG, the_interface);
goto end;
}
if (tech_pvt->running && tech_pvt->SkypopenHandles.disp) {
XEvent e;
Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
- switch_sleep(1000);//giovanni
- XFlush(tech_pvt->SkypopenHandles.disp); //giovanni
+ switch_sleep(1000); //giovanni
+ XFlush(tech_pvt->SkypopenHandles.disp); //giovanni
memset(&e, 0, sizeof(e));
e.xclient.type = ClientMessage;
e.xclient.message_type = atom1; /* leading message */
XSendEvent(tech_pvt->SkypopenHandles.disp, tech_pvt->SkypopenHandles.win, False, 0, &e);
//giovanni XSync(tech_pvt->SkypopenHandles.disp, False);
- XFlush(tech_pvt->SkypopenHandles.disp); //giovanni
+ XFlush(tech_pvt->SkypopenHandles.disp); //giovanni
}
#endif
}
switch_core_codec_destroy(&tech_pvt->write_codec);
}
- if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
+ if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
switch_core_timer_destroy(&tech_pvt->timer_read);
}
- if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
+ if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) {
switch_core_timer_destroy(&tech_pvt->timer_write);
}
- if(tech_pvt->read_buffer){
+ if (tech_pvt->read_buffer) {
switch_buffer_destroy(&tech_pvt->read_buffer);
}
- if(tech_pvt->write_buffer){
+ if (tech_pvt->write_buffer) {
switch_buffer_destroy(&tech_pvt->write_buffer);
}
- DEBUGA_SKYPE("debugging_hangup 13\n", SKYPOPEN_P_LOG);
- switch_mutex_lock(tech_pvt->mutex_thread_audio_cli);
- DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG);
- if (tech_pvt->tcp_cli_thread) {
- DEBUGA_SKYPE("debugging_hangup 14\n", SKYPOPEN_P_LOG);
- switch_thread_join(&status, tech_pvt->tcp_cli_thread);
- tech_pvt->tcp_cli_thread = NULL;
- DEBUGA_SKYPE("debugging_hangup 15\n", SKYPOPEN_P_LOG);
- }
- switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli);
- DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG);
- switch_mutex_lock(tech_pvt->mutex_thread_audio_srv);
- DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG);
- if (tech_pvt->tcp_srv_thread) {
- DEBUGA_SKYPE("debugging_hangup 16\n", SKYPOPEN_P_LOG);
- switch_thread_join(&status, tech_pvt->tcp_srv_thread);
- tech_pvt->tcp_srv_thread = NULL;
- DEBUGA_SKYPE("debugging_hangup 17\n", SKYPOPEN_P_LOG);
- }
- switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv);
- DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG);
- DEBUGA_SKYPE("debugging_hangup 18\n", SKYPOPEN_P_LOG);
+ DEBUGA_SKYPE("debugging_hangup 13\n", SKYPOPEN_P_LOG);
+ switch_mutex_lock(tech_pvt->mutex_thread_audio_cli);
+ DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG);
+ if (tech_pvt->tcp_cli_thread) {
+ DEBUGA_SKYPE("debugging_hangup 14\n", SKYPOPEN_P_LOG);
+ switch_thread_join(&status, tech_pvt->tcp_cli_thread);
+ tech_pvt->tcp_cli_thread = NULL;
+ DEBUGA_SKYPE("debugging_hangup 15\n", SKYPOPEN_P_LOG);
+ }
+ switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli);
+ DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG);
+ switch_mutex_lock(tech_pvt->mutex_thread_audio_srv);
+ DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG);
+ if (tech_pvt->tcp_srv_thread) {
+ DEBUGA_SKYPE("debugging_hangup 16\n", SKYPOPEN_P_LOG);
+ switch_thread_join(&status, tech_pvt->tcp_srv_thread);
+ tech_pvt->tcp_srv_thread = NULL;
+ DEBUGA_SKYPE("debugging_hangup 17\n", SKYPOPEN_P_LOG);
+ }
+ switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv);
+ DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG);
+ DEBUGA_SKYPE("debugging_hangup 18\n", SKYPOPEN_P_LOG);
*tech_pvt->session_uuid_str = '\0';
tech_pvt->interface_state = SKYPOPEN_STATE_IDLE;
DEBUGA_SKYPE("debugging_hangup 1\n", SKYPOPEN_P_LOG);
- if(tech_pvt){
- if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
- if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
- tech_pvt->ob_failed_calls++;
- } else {
- tech_pvt->ib_failed_calls++;
+ if (tech_pvt) {
+ if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
+ if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
+ tech_pvt->ob_failed_calls++;
+ } else {
+ tech_pvt->ib_failed_calls++;
+ }
}
- }
- switch_clear_flag(tech_pvt, TFLAG_IO);
- switch_clear_flag(tech_pvt, TFLAG_VOICE);
+ switch_clear_flag(tech_pvt, TFLAG_IO);
+ switch_clear_flag(tech_pvt, TFLAG_VOICE);
- DEBUGA_SKYPE("debugging_hangup 2\n", SKYPOPEN_P_LOG);
- tech_pvt->interface_state = SKYPOPEN_STATE_HANGUP_REQUESTED;
-
- if (strlen(tech_pvt->skype_call_id)) {
- DEBUGA_SKYPE("hanging up skype call: %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id);
- sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id);
- skypopen_signaling_write(tech_pvt, msg_to_skype);
- sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
- skypopen_signaling_write(tech_pvt, msg_to_skype);
- }
+ DEBUGA_SKYPE("debugging_hangup 2\n", SKYPOPEN_P_LOG);
+ tech_pvt->interface_state = SKYPOPEN_STATE_HANGUP_REQUESTED;
+ if (strlen(tech_pvt->skype_call_id)) {
+ DEBUGA_SKYPE("hanging up skype call: %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id);
+ sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id);
+ skypopen_signaling_write(tech_pvt, msg_to_skype);
+ sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
+ skypopen_signaling_write(tech_pvt, msg_to_skype);
+ }
#if 0
- switch_sleep(1500000); //XXX 1.5 seconds, let's the audio tcp threads die XXX
- //FIXME must not allow using the tech_pvt while this sleeps, so must implement a check on interface_state
-
- DEBUGA_SKYPE("debugging_hangup 3\n", SKYPOPEN_P_LOG);
- switch_mutex_lock(tech_pvt->mutex_thread_audio_cli);
- DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG);
- if (tech_pvt->tcp_cli_thread) {
- DEBUGA_SKYPE("debugging_hangup 4\n", SKYPOPEN_P_LOG);
- switch_thread_join(&status, tech_pvt->tcp_cli_thread);
- tech_pvt->tcp_cli_thread = NULL;
- DEBUGA_SKYPE("debugging_hangup 5\n", SKYPOPEN_P_LOG);
- }
- switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli);
- DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG);
- switch_mutex_lock(tech_pvt->mutex_thread_audio_srv);
- DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG);
- if (tech_pvt->tcp_srv_thread) {
- DEBUGA_SKYPE("debugging_hangup 6\n", SKYPOPEN_P_LOG);
- switch_thread_join(&status, tech_pvt->tcp_srv_thread);
- tech_pvt->tcp_srv_thread = NULL;
- DEBUGA_SKYPE("debugging_hangup 7\n", SKYPOPEN_P_LOG);
- }
- switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv);
- DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG);
- DEBUGA_SKYPE("debugging_hangup 8\n", SKYPOPEN_P_LOG);
-#endif//0
- DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPOPEN_P_LOG, tech_pvt->name);
- switch_mutex_lock(globals.mutex);
- globals.calls--;
- if (globals.calls < 0) {
- globals.calls = 0;
- }
+ switch_sleep(1500000); //XXX 1.5 seconds, let's the audio tcp threads die XXX
+ //FIXME must not allow using the tech_pvt while this sleeps, so must implement a check on interface_state
+
+ DEBUGA_SKYPE("debugging_hangup 3\n", SKYPOPEN_P_LOG);
+ switch_mutex_lock(tech_pvt->mutex_thread_audio_cli);
+ DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG);
+ if (tech_pvt->tcp_cli_thread) {
+ DEBUGA_SKYPE("debugging_hangup 4\n", SKYPOPEN_P_LOG);
+ switch_thread_join(&status, tech_pvt->tcp_cli_thread);
+ tech_pvt->tcp_cli_thread = NULL;
+ DEBUGA_SKYPE("debugging_hangup 5\n", SKYPOPEN_P_LOG);
+ }
+ switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli);
+ DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG);
+ switch_mutex_lock(tech_pvt->mutex_thread_audio_srv);
+ DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG);
+ if (tech_pvt->tcp_srv_thread) {
+ DEBUGA_SKYPE("debugging_hangup 6\n", SKYPOPEN_P_LOG);
+ switch_thread_join(&status, tech_pvt->tcp_srv_thread);
+ tech_pvt->tcp_srv_thread = NULL;
+ DEBUGA_SKYPE("debugging_hangup 7\n", SKYPOPEN_P_LOG);
+ }
+ switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv);
+ DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG);
+ DEBUGA_SKYPE("debugging_hangup 8\n", SKYPOPEN_P_LOG);
+#endif //0
+ DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPOPEN_P_LOG, tech_pvt->name);
+ switch_mutex_lock(globals.mutex);
+ globals.calls--;
+ if (globals.calls < 0) {
+ globals.calls = 0;
+ }
- DEBUGA_SKYPE("debugging_hangup 9\n", SKYPOPEN_P_LOG);
- tech_pvt->interface_state = SKYPOPEN_STATE_IDLE;
- if (tech_pvt->skype_callflow == CALLFLOW_STATUS_FINISHED) {
- tech_pvt->skype_callflow = CALLFLOW_CALL_IDLE;
- }
- DEBUGA_SKYPE("debugging_hangup 10\n", SKYPOPEN_P_LOG);
- switch_mutex_unlock(globals.mutex);
- }else{
+ DEBUGA_SKYPE("debugging_hangup 9\n", SKYPOPEN_P_LOG);
+ tech_pvt->interface_state = SKYPOPEN_STATE_IDLE;
+ if (tech_pvt->skype_callflow == CALLFLOW_STATUS_FINISHED) {
+ tech_pvt->skype_callflow = CALLFLOW_CALL_IDLE;
+ }
+ DEBUGA_SKYPE("debugging_hangup 10\n", SKYPOPEN_P_LOG);
+ switch_mutex_unlock(globals.mutex);
+ } else {
WARNINGA("FYI %s CHANNEL has no tech_pvt in his private\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
- DEBUGA_SKYPE("debugging_hangup 11\n", SKYPOPEN_P_LOG);
+ DEBUGA_SKYPE("debugging_hangup 11\n", SKYPOPEN_P_LOG);
}
DEBUGA_SKYPE("debugging_hangup 12\n", SKYPOPEN_P_LOG);
tech_pvt = switch_core_session_get_private(session);
//DEBUGA_SKYPE("%s CHANNEL KILL_CHANNEL\n", SKYPOPEN_P_LOG, tech_pvt->name);
- if(tech_pvt){
- switch (sig) {
- case SWITCH_SIG_KILL:
- switch_mutex_lock(tech_pvt->flag_mutex);
- DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
- if (tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD) {
- DEBUGA_SKYPE("FYI %s CHANNEL in CALLFLOW_STATUS_REMOTEHOLD got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
- }
- if (switch_channel_get_state(channel) == CS_NEW) {
- WARNINGA("FYI %s CHANNEL in CS_NEW state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
- }
- if (switch_channel_get_state(channel) != CS_NEW && switch_channel_get_state(channel) < CS_EXECUTE) {
- WARNINGA("FYI %s CHANNEL in %d state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel), switch_channel_get_state(channel));
- }
- switch_clear_flag(tech_pvt, TFLAG_IO);
- switch_clear_flag(tech_pvt, TFLAG_VOICE);
- switch_set_flag(tech_pvt, TFLAG_HANGUP);
- if(switch_test_flag(tech_pvt, TFLAG_PROGRESS)){
- switch_clear_flag(tech_pvt, TFLAG_PROGRESS);
+ if (tech_pvt) {
+ switch (sig) {
+ case SWITCH_SIG_KILL:
+ switch_mutex_lock(tech_pvt->flag_mutex);
+ DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
+ if (tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD) {
+ DEBUGA_SKYPE("FYI %s CHANNEL in CALLFLOW_STATUS_REMOTEHOLD got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
+ }
+ if (switch_channel_get_state(channel) == CS_NEW) {
+ WARNINGA("FYI %s CHANNEL in CS_NEW state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
+ }
+ if (switch_channel_get_state(channel) != CS_NEW && switch_channel_get_state(channel) < CS_EXECUTE) {
+ WARNINGA("FYI %s CHANNEL in %d state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel),
+ switch_channel_get_state(channel));
+ }
+ switch_clear_flag(tech_pvt, TFLAG_IO);
+ switch_clear_flag(tech_pvt, TFLAG_VOICE);
+ switch_set_flag(tech_pvt, TFLAG_HANGUP);
+ if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) {
+ switch_clear_flag(tech_pvt, TFLAG_PROGRESS);
+ }
+ switch_mutex_unlock(tech_pvt->flag_mutex);
+ sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->ring_id);
+ skypopen_signaling_write(tech_pvt, msg_to_skype);
+ sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->ring_id);
+ skypopen_signaling_write(tech_pvt, msg_to_skype);
+ sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id);
+ skypopen_signaling_write(tech_pvt, msg_to_skype);
+ sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
+ skypopen_signaling_write(tech_pvt, msg_to_skype);
+ break;
+ case SWITCH_SIG_BREAK:
+ DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_BREAK\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
+ switch_mutex_lock(tech_pvt->flag_mutex);
+ switch_set_flag(tech_pvt, TFLAG_BREAK);
+ switch_mutex_unlock(tech_pvt->flag_mutex);
+ break;
+ default:
+ break;
}
- switch_mutex_unlock(tech_pvt->flag_mutex);
- sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->ring_id);
- skypopen_signaling_write(tech_pvt, msg_to_skype);
- sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->ring_id);
- skypopen_signaling_write(tech_pvt, msg_to_skype);
- sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id);
- skypopen_signaling_write(tech_pvt, msg_to_skype);
- sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
- skypopen_signaling_write(tech_pvt, msg_to_skype);
- break;
- case SWITCH_SIG_BREAK:
- DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_BREAK\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
- switch_mutex_lock(tech_pvt->flag_mutex);
- switch_set_flag(tech_pvt, TFLAG_BREAK);
- switch_mutex_unlock(tech_pvt->flag_mutex);
- break;
- default:
- break;
- }
- }else{
+ } else {
WARNINGA("FYI %s CHANNEL has no tech_pvt in his private\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
}
ERRORA("No session???\n", SKYPOPEN_P_LOG);
}
if (channel) {
- switch_channel_set_state(channel, CS_HANGUP);
+ switch_channel_set_state(channel, CS_HANGUP);
} else {
ERRORA("No channel???\n", SKYPOPEN_P_LOG);
}
unsigned int i;
unsigned int a;
size_t bytes_read = 0;
- int try=0;
+ int try = 0;
*frame = NULL;
- if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
+ if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
switch_core_timer_next(&tech_pvt->timer_read);
}
-read:
+ read:
if (tech_pvt && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN
- && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
- || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
- || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) {
+ && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) {
switch_mutex_lock(tech_pvt->mutex_audio_srv);
if (tech_pvt->read_buffer && switch_buffer_inuse(tech_pvt->read_buffer)) {
bytes_read = switch_buffer_read(tech_pvt->read_buffer, tech_pvt->read_frame.data, 640);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
- try=0;
+ try = 0;
if (!bytes_read) {
switch_sleep(1000);
try++;
- if(try < 5)
+ if (try < 5)
goto read;
DEBUGA_SKYPE("skypopen_audio_read Silence\n", SKYPOPEN_P_LOG);
memset(tech_pvt->read_frame.data, 255, SAMPLES_PER_FRAME * sizeof(short));
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
- int no_space=0;
+ int no_space = 0;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
DEBUGA_SKYPE("NO SPACE WRITE: %d\n", SKYPOPEN_P_LOG, frame->datalen);
//switch_buffer_toss(tech_pvt->write_buffer, frame->datalen);
switch_buffer_zero(tech_pvt->write_buffer);
- no_space=1;
+ no_space = 1;
}
switch_buffer_write(tech_pvt->write_buffer, frame->data, frame->datalen);
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
- if(no_space){
+ if (no_space) {
switch_sleep(20000);
- }else{
+ } else {
tech_pvt->begin_to_write = 1;
}
switch_clear_flag(tech_pvt, TFLAG_IO);
skypopen_answer(tech_pvt);
- while(!switch_test_flag(tech_pvt, TFLAG_IO)){ //FIXME that would be better with a timeout
- if(switch_channel_get_state(channel) == CS_RESET){
+ while (!switch_test_flag(tech_pvt, TFLAG_IO)) { //FIXME that would be better with a timeout
+ if (switch_channel_get_state(channel) == CS_RESET) {
return SWITCH_STATUS_FALSE;
}
switch_sleep(5000);
conta++;
- if(conta == 100){ //0.5 seconds
+ if (conta == 100) { //0.5 seconds
return SWITCH_STATUS_FALSE;
}
}
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
+static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t * msg)
{
switch_channel_t *channel;
private_t *tech_pvt;
case SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS:
{
DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
- if(switch_set_flag(tech_pvt, TFLAG_PROGRESS)){
+ if (switch_set_flag(tech_pvt, TFLAG_PROGRESS)) {
sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->ring_id);
skypopen_signaling_write(tech_pvt, msg_to_skype);
sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->ring_id);
skypopen_signaling_write(tech_pvt, msg_to_skype);
- sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id);
- skypopen_signaling_write(tech_pvt, msg_to_skype);
- sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
- skypopen_signaling_write(tech_pvt, msg_to_skype);
+ sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id);
+ skypopen_signaling_write(tech_pvt, msg_to_skype);
+ sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
+ skypopen_signaling_write(tech_pvt, msg_to_skype);
switch_clear_flag(tech_pvt, TFLAG_PROGRESS);
}
}
case SWITCH_MESSAGE_INDICATE_ANSWER:
{
- DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_ANSWER\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
+ DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_ANSWER\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
//switch_set_flag(tech_pvt, TFLAG_IO);
channel_answer_channel(session);
switch_clear_flag(tech_pvt, TFLAG_PROGRESS);
- if(tech_pvt->read_buffer){
+ if (tech_pvt->read_buffer) {
switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer);
- if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
+ if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
- if(tech_pvt->write_buffer){
+ if (tech_pvt->write_buffer) {
switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer);
- if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
+ if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_write);
}
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_AUDIO_SYNC\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
- if(tech_pvt->read_buffer){
- switch_mutex_lock(tech_pvt->mutex_audio_srv);
- switch_buffer_zero(tech_pvt->read_buffer);
- if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
- switch_core_timer_sync(&tech_pvt->timer_read);
- }
- switch_mutex_unlock(tech_pvt->mutex_audio_srv);
+ if (tech_pvt->read_buffer) {
+ switch_mutex_lock(tech_pvt->mutex_audio_srv);
+ switch_buffer_zero(tech_pvt->read_buffer);
+ if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
+ switch_core_timer_sync(&tech_pvt->timer_read);
}
+ switch_mutex_unlock(tech_pvt->mutex_audio_srv);
+ }
- if(tech_pvt->write_buffer){
- switch_mutex_lock(tech_pvt->mutex_audio_cli);
- switch_buffer_zero(tech_pvt->write_buffer);
- if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
- switch_core_timer_sync(&tech_pvt->timer_write);
- }
- switch_mutex_unlock(tech_pvt->mutex_audio_cli);
+ if (tech_pvt->write_buffer) {
+ switch_mutex_lock(tech_pvt->mutex_audio_cli);
+ switch_buffer_zero(tech_pvt->write_buffer);
+ if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) {
+ switch_core_timer_sync(&tech_pvt->timer_write);
}
- DEBUGA_SKYPE("Synching audio\n", SKYPOPEN_P_LOG);
+ switch_mutex_unlock(tech_pvt->mutex_audio_cli);
+ }
+ DEBUGA_SKYPE("Synching audio\n", SKYPOPEN_P_LOG);
break;
case SWITCH_MESSAGE_INDICATE_BRIDGE:
DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_BRIDGE\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
- if(tech_pvt->read_buffer){
- switch_mutex_lock(tech_pvt->mutex_audio_srv);
- switch_buffer_zero(tech_pvt->read_buffer);
- if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
- switch_core_timer_sync(&tech_pvt->timer_read);
- }
- switch_mutex_unlock(tech_pvt->mutex_audio_srv);
+ if (tech_pvt->read_buffer) {
+ switch_mutex_lock(tech_pvt->mutex_audio_srv);
+ switch_buffer_zero(tech_pvt->read_buffer);
+ if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
+ switch_core_timer_sync(&tech_pvt->timer_read);
}
+ switch_mutex_unlock(tech_pvt->mutex_audio_srv);
+ }
- if(tech_pvt->write_buffer){
- switch_mutex_lock(tech_pvt->mutex_audio_cli);
- switch_buffer_zero(tech_pvt->write_buffer);
- if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
- switch_core_timer_sync(&tech_pvt->timer_write);
- }
- switch_mutex_unlock(tech_pvt->mutex_audio_cli);
+ if (tech_pvt->write_buffer) {
+ switch_mutex_lock(tech_pvt->mutex_audio_cli);
+ switch_buffer_zero(tech_pvt->write_buffer);
+ if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) {
+ switch_core_timer_sync(&tech_pvt->timer_write);
}
- DEBUGA_SKYPE("Synching audio\n", SKYPOPEN_P_LOG);
+ switch_mutex_unlock(tech_pvt->mutex_audio_cli);
+ }
+ DEBUGA_SKYPE("Synching audio\n", SKYPOPEN_P_LOG);
break;
default:
* \brief This thread runs during a call, and monitor the interface for signaling, like hangup, caller id, etc most of signaling is handled inside the skypopen_signaling_read function
*
*/
-static void *SWITCH_THREAD_FUNC skypopen_signaling_thread_func(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC skypopen_signaling_thread_func(switch_thread_t *thread, void *obj)
{
private_t *tech_pvt = obj;
int res;
}
}
}
- tech_pvt->skypopen_signaling_thread=NULL;
+ tech_pvt->skypopen_signaling_thread = NULL;
DEBUGA_SKYPE("EXITING\n", SKYPOPEN_P_LOG);
return NULL;
}
char *setsockopt = "false";
uint32_t interface_id = 0;
- if(globals.context)
- context=globals.context;
- if(globals.dialplan)
- dialplan=globals.dialplan;
- if(globals.destination)
- destination=globals.destination;
- if(globals.skype_user)
- skype_user=globals.skype_user;
- if(globals.report_incoming_chatmessages)
- report_incoming_chatmessages=globals.report_incoming_chatmessages;
- if(globals.silent_mode)
- silent_mode=globals.silent_mode;
- if(globals.write_silence_when_idle)
- write_silence_when_idle=globals.write_silence_when_idle;
- if(globals.setsockopt)
- setsockopt=globals.setsockopt;
+ if (globals.context)
+ context = globals.context;
+ if (globals.dialplan)
+ dialplan = globals.dialplan;
+ if (globals.destination)
+ destination = globals.destination;
+ if (globals.skype_user)
+ skype_user = globals.skype_user;
+ if (globals.report_incoming_chatmessages)
+ report_incoming_chatmessages = globals.report_incoming_chatmessages;
+ if (globals.silent_mode)
+ silent_mode = globals.silent_mode;
+ if (globals.write_silence_when_idle)
+ write_silence_when_idle = globals.write_silence_when_idle;
+ if (globals.setsockopt)
+ setsockopt = globals.setsockopt;
tech_pvt = NULL;
switch_threadattr_detach_set(skypopen_api_thread_attr, 0);
switch_threadattr_stacksize_set(skypopen_api_thread_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread,
- skypopen_api_thread_attr, skypopen_do_skypeapi_thread, &globals.SKYPOPEN_INTERFACES[interface_id], skypopen_module_pool);
+ skypopen_api_thread_attr, skypopen_do_skypeapi_thread, &globals.SKYPOPEN_INTERFACES[interface_id],
+ skypopen_module_pool);
switch_sleep(100000);
DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].report_incoming_chatmessages=%d\n", SKYPOPEN_P_LOG, i, i,
globals.SKYPOPEN_INTERFACES[i].report_incoming_chatmessages);
DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].silent_mode=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].silent_mode);
- DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].write_silence_when_idle=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].write_silence_when_idle);
+ DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].write_silence_when_idle=%d\n", SKYPOPEN_P_LOG, i, i,
+ globals.SKYPOPEN_INTERFACES[i].write_silence_when_idle);
DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].setsockopt=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].setsockopt);
}
}
if (strlen(globals.SKYPOPEN_INTERFACES[i].name)
&& (strncmp(globals.SKYPOPEN_INTERFACES[i].name, hint, strlen(hint)) == 0)) {
tech_pvt = &globals.SKYPOPEN_INTERFACES[i];
- DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i, globals.SKYPOPEN_INTERFACES[i].name);
+ DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i,
+ globals.SKYPOPEN_INTERFACES[i].name);
found = 1;
break;
}
if (strlen(globals.SKYPOPEN_INTERFACES[i].name)
&& (strncmp(globals.SKYPOPEN_INTERFACES[i].skype_user, from, strlen(from)) == 0)) {
tech_pvt = &globals.SKYPOPEN_INTERFACES[i];
- DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i, globals.SKYPOPEN_INTERFACES[i].name);
+ DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i,
+ globals.SKYPOPEN_INTERFACES[i].name);
found = 1;
break;
}
memset(&globals, '\0', sizeof(globals));
// CLOUDTREE (Thomas Hazel)
- #ifndef WIN32
+#ifndef WIN32
// XXX: these assumes no one will override
XSetErrorHandler(X11_errors_handler);
XSetIOErrorHandler(xio_error_handler);
memset(&global_handles_list, 0, sizeof(global_handles_list));
switch_mutex_init(&globals.list_mutex, SWITCH_MUTEX_NESTED, skypopen_module_pool);
- #endif
+#endif
// CLOUDTREE (Thomas Hazel) - load_configs no longer locks things up, no need to fail load
- /*if (*/ load_config(FULL_RELOAD); /* != SWITCH_STATUS_SUCCESS) {
- running = 0;
- return SWITCH_STATUS_FALSE;
- }
- */
+ /*if ( */ load_config(FULL_RELOAD);
+ /* != SWITCH_STATUS_SUCCESS) {
+ running = 0;
+ return SWITCH_STATUS_FALSE;
+ }
+ */
// CLOUDTREE (Thomas Hazel) - setting "running = 1;" use to be located before "load_config"
running = 1;
SWITCH_ADD_API(commands_api_interface, "sk", "Skypopen console commands", sk_function, SK_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "skypopen", "Skypopen interface commands", skypopen_function, SKYPOPEN_SYNTAX);
- SWITCH_ADD_API(commands_api_interface, "skypopen_chat", "Skypopen_chat interface remote_skypename TEXT", skypopen_chat_function, SKYPOPEN_CHAT_SYNTAX);
+ SWITCH_ADD_API(commands_api_interface, "skypopen_chat", "Skypopen_chat interface remote_skypename TEXT", skypopen_chat_function,
+ SKYPOPEN_CHAT_SYNTAX);
SWITCH_ADD_CHAT(chat_interface, MDL_CHAT_PROTO, chat_send);
/* indicate that the module should continue to be loaded */
#ifdef WIN32
if (SendMessage(tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the skypopen_api_thread_func die
DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPOPEN_P_LOG, GetLastError());
- tech_pvt->skypopen_api_thread=NULL;
+ tech_pvt->skypopen_api_thread = NULL;
}
#else
if (tech_pvt->SkypopenHandles.disp) {
XEvent e;
Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN",
False);
- switch_sleep(1000);//giovanni
- XFlush(tech_pvt->SkypopenHandles.disp); //giovanni
+ switch_sleep(1000); //giovanni
+ XFlush(tech_pvt->SkypopenHandles.disp); //giovanni
memset(&e, 0, sizeof(e));
e.xclient.type = ClientMessage;
e.xclient.message_type = atom1; /* leading message */
XSendEvent(tech_pvt->SkypopenHandles.disp, tech_pvt->SkypopenHandles.win, False, 0, &e);
//giovanni XSync(tech_pvt->SkypopenHandles.disp, False);
- XFlush(tech_pvt->SkypopenHandles.disp); //giovanni
+ XFlush(tech_pvt->SkypopenHandles.disp); //giovanni
}
#endif
}
return SWITCH_STATUS_SUCCESS;
}
-void *SWITCH_THREAD_FUNC skypopen_do_tcp_srv_thread(switch_thread_t * thread, void *obj)
+void *SWITCH_THREAD_FUNC skypopen_do_tcp_srv_thread(switch_thread_t *thread, void *obj)
{
return skypopen_do_tcp_srv_thread_func(obj);
}
-void *SWITCH_THREAD_FUNC skypopen_do_tcp_cli_thread(switch_thread_t * thread, void *obj)
+void *SWITCH_THREAD_FUNC skypopen_do_tcp_cli_thread(switch_thread_t *thread, void *obj)
{
return skypopen_do_tcp_cli_thread_func(obj);
}
-void *SWITCH_THREAD_FUNC skypopen_do_skypeapi_thread(switch_thread_t * thread, void *obj)
+void *SWITCH_THREAD_FUNC skypopen_do_skypeapi_thread(switch_thread_t *thread, void *obj)
{
return skypopen_do_skypeapi_thread_func(obj);
}
-int dtmf_received(private_t * tech_pvt, char *value)
+int dtmf_received(private_t *tech_pvt, char *value)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
return 0;
}
-int start_audio_threads(private_t * tech_pvt)
+int start_audio_threads(private_t *tech_pvt)
{
switch_threadattr_t *thd_attr = NULL;
} else {
ERRORA("failed to start tcp_srv_thread thread.\n", SKYPOPEN_P_LOG);
switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv);
- DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG);
+ DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG);
return -1;
}
switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv);
} else {
ERRORA("failed to start tcp_cli_thread thread.\n", SKYPOPEN_P_LOG);
switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli);
- DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG);
+ DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG);
return -1;
}
switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli);
return 0;
}
-int new_inbound_channel(private_t * tech_pvt)
+int new_inbound_channel(private_t *tech_pvt)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
return 0;
}
-int remote_party_is_ringing(private_t * tech_pvt)
+int remote_party_is_ringing(private_t *tech_pvt)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
return 0;
}
-int remote_party_is_early_media(private_t * tech_pvt)
+int remote_party_is_early_media(private_t *tech_pvt)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
return 0;
}
-int outbound_channel_answered(private_t * tech_pvt)
+int outbound_channel_answered(private_t *tech_pvt)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
return 0;
}
-private_t *find_available_skypopen_interface_rr(private_t * tech_pvt_calling)
+private_t *find_available_skypopen_interface_rr(private_t *tech_pvt_calling)
{
private_t *tech_pvt = NULL;
int i;
//DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n", SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].name, skype_state);
if ((tech_pvt_calling ? strcmp(tech_pvt->skype_user, tech_pvt_calling->skype_user) : 1)
&& (SKYPOPEN_STATE_DOWN == skype_state || 0 == skype_state) && (tech_pvt->skype_callflow == CALLFLOW_STATUS_FINISHED
- || 0 == tech_pvt->skype_callflow)) {
+ || 0 == tech_pvt->skype_callflow)) {
DEBUGA_SKYPE("returning as available skype interface name: %s, state: %d callflow: %d\n", SKYPOPEN_P_LOG, tech_pvt->name, skype_state,
tech_pvt->skype_callflow);
if (tech_pvt_calling == NULL) {
}
-int skypopen_partner_handle_ring(private_t * tech_pvt)
+int skypopen_partner_handle_ring(private_t *tech_pvt)
{
char msg_to_skype[1024];
int i;
giovatech = &globals.SKYPOPEN_INTERFACES[i];
if ((giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->ring_value, value)) && ((((timenow.tv_sec - giovatech->ring_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->ring_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds
found = 1;
- DEBUGA_SKYPE ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value);
+ DEBUGA_SKYPE
+ ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
+ SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number,
+ value);
if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) {
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
} else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) {
return 0;
}
-int skypopen_answer(private_t * tech_pvt)
+int skypopen_answer(private_t *tech_pvt)
{
char msg_to_skype[1024];
int i;
giovatech = &globals.SKYPOPEN_INTERFACES[i];
if (strlen(giovatech->skype_call_id) && (giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->callid_number, value)) && ((((timenow.tv_sec - giovatech->answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->answer_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds
found = 1;
- DEBUGA_SKYPE ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value);
+ DEBUGA_SKYPE
+ ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
+ SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number,
+ value);
if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) {
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
} else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) {
switch_mutex_unlock(globals.mutex);
return 0;
}
+
//int skypopen_transfer(private_t * tech_pvt, char *id, char *value)
-int skypopen_transfer(private_t * tech_pvt)
+int skypopen_transfer(private_t *tech_pvt)
{
char msg_to_skype[1024];
int i;
/* let's look for a RINGING one */
if ((giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->ring_value, value)) && ((((timenow.tv_sec - giovatech->ring_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->ring_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds
found = 1;
- DEBUGA_SKYPE ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value);
+ DEBUGA_SKYPE
+ ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
+ SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number,
+ value);
if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) {
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
- }
-
-
-#if 0
-
-
+ }
+#if 0
+
+
else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) {
WARNINGA("Why an interface_state %d HERE?\n", SKYPOPEN_P_LOG, tech_pvt->interface_state);
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
/* let's look for a DOWN one */
if ((giovatech->interface_state == SKYPOPEN_STATE_DOWN || giovatech->interface_state == 0) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user))) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds
found = 1;
- DEBUGA_SKYPE ("FOUND (name=%s, giovatech->interface_state=%d == SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value);
+ DEBUGA_SKYPE
+ ("FOUND (name=%s, giovatech->interface_state=%d == SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
+ SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number,
+ value);
if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) {
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
- }
-
-
-#if 0
-
-
+ }
+#if 0
+
+
else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) {
WARNINGA("Why an interface_state %d HERE?\n", SKYPOPEN_P_LOG, tech_pvt->interface_state);
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
return 0;
}
-int incoming_chatmessage(private_t * tech_pvt, int which)
+int incoming_chatmessage(private_t *tech_pvt, int which)
{
switch_event_t *event;
switch_core_session_t *session = NULL;
#ifndef WIN32
// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list?
-struct SkypopenHandles* skypopen_list_add(struct SkypopenList* list, struct SkypopenHandles* handle)
+struct SkypopenHandles *skypopen_list_add(struct SkypopenList *list, struct SkypopenHandles *handle)
{
switch_mutex_lock(globals.list_mutex);
handle->prev = 0;
} else {
- ((struct SkypopenHandles*) list->tail)->next = handle;
- ((struct SkypopenHandles*) handle)->prev = list->tail;
+ ((struct SkypopenHandles *) list->tail)->next = handle;
+ ((struct SkypopenHandles *) handle)->prev = list->tail;
}
list->tail = handle;
}
// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list?
-struct SkypopenHandles* skypopen_list_remove_by_value(struct SkypopenList* list, Display* display)
+struct SkypopenHandles *skypopen_list_remove_by_value(struct SkypopenList *list, Display * display)
{
- struct SkypopenHandles* iter;
- struct SkypopenHandles* handle = 0;
+ struct SkypopenHandles *iter;
+ struct SkypopenHandles *handle = 0;
switch_mutex_lock(globals.list_mutex);
- iter = (struct SkypopenHandles*) list->head;
+ iter = (struct SkypopenHandles *) list->head;
while (iter != 0) {
if (iter->disp == display) {
handle = iter;
break;
}
- iter = (struct SkypopenHandles*) iter->next;
+ iter = (struct SkypopenHandles *) iter->next;
}
if ((handle != 0) && (handle->managed == SWITCH_TRUE)) {
if (handle->prev == 0) {
- list->head = ((struct SkypopenHandles*) handle)->next;
+ list->head = ((struct SkypopenHandles *) handle)->next;
} else {
- ((struct SkypopenHandles*) handle->prev)->next = ((struct SkypopenHandles*) handle)->next;
+ ((struct SkypopenHandles *) handle->prev)->next = ((struct SkypopenHandles *) handle)->next;
}
if (handle->next == 0) {
- list->tail = ((struct SkypopenHandles*) handle)->prev;
+ list->tail = ((struct SkypopenHandles *) handle)->prev;
} else {
- ((struct SkypopenHandles*) handle->next)->prev = ((struct SkypopenHandles*) handle)->prev;
+ ((struct SkypopenHandles *) handle->next)->prev = ((struct SkypopenHandles *) handle)->prev;
}
handle->managed = SWITCH_FALSE;
}
// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list?
-struct SkypopenHandles* skypopen_list_remove_by_reference(struct SkypopenList* list, struct SkypopenHandles* handle)
+struct SkypopenHandles *skypopen_list_remove_by_reference(struct SkypopenList *list, struct SkypopenHandles *handle)
{
switch_mutex_lock(globals.list_mutex);
}
if (handle->prev == 0) {
- list->head = ((struct SkypopenHandles*) handle)->next;
+ list->head = ((struct SkypopenHandles *) handle)->next;
} else {
- ((struct SkypopenHandles*) handle->prev)->next = ((struct SkypopenHandles*) handle)->next;
+ ((struct SkypopenHandles *) handle->prev)->next = ((struct SkypopenHandles *) handle)->next;
}
if (handle->next == 0) {
- list->tail = ((struct SkypopenHandles*) handle)->prev;
+ list->tail = ((struct SkypopenHandles *) handle)->prev;
} else {
- ((struct SkypopenHandles*) handle->next)->prev = ((struct SkypopenHandles*) handle)->prev;
+ ((struct SkypopenHandles *) handle->next)->prev = ((struct SkypopenHandles *) handle)->prev;
}
handle->managed = SWITCH_FALSE;
// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list?
#ifdef XIO_ERROR_BY_UCONTEXT
-struct SkypopenHandles* skypopen_list_find(struct SkypopenList* list, struct SkypopenHandles* find)
+struct SkypopenHandles *skypopen_list_find(struct SkypopenList *list, struct SkypopenHandles *find)
{
- struct SkypopenHandles* iter;
- struct SkypopenHandles* handle = NULL;
+ struct SkypopenHandles *iter;
+ struct SkypopenHandles *handle = NULL;
switch_mutex_lock(globals.list_mutex);
- iter = (struct SkypopenHandles*) list->head;
+ iter = (struct SkypopenHandles *) list->head;
while (iter != NULL) {
if (iter == find) {
handle = iter;
break;
}
- iter = (struct SkypopenHandles*) iter->next;
+ iter = (struct SkypopenHandles *) iter->next;
}
switch_mutex_unlock(globals.list_mutex);
#endif
// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list?
-int skypopen_list_size(struct SkypopenList* list)
+int skypopen_list_size(struct SkypopenList *list)
{
return list->entries;
}
#endif /* WIN32 */
/*************************************/
#ifndef WIN32
-int skypopen_socket_create_and_bind(private_t * tech_pvt, int *which_port)
+int skypopen_socket_create_and_bind(private_t *tech_pvt, int *which_port)
#else
-int skypopen_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_port)
+int skypopen_socket_create_and_bind(private_t *tech_pvt, unsigned short *which_port)
#endif //WIN32
{
int s = -1;
sockbufsize = SAMPLES_PER_FRAME * 8;
#endif //WIN32
size = sizeof(int);
- if(tech_pvt->setsockopt){
+ if (tech_pvt->setsockopt) {
setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, size);
}
sockbufsize = SAMPLES_PER_FRAME * 8;
#endif //WIN32
size = sizeof(int);
- if(tech_pvt->setsockopt){
+ if (tech_pvt->setsockopt) {
setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, size);
}
getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size);
DEBUGA_SKYPE("2 SO_SNDBUF is %d, size is %d\n", SKYPOPEN_P_LOG, sockbufsize, size);
- flag = 0;
- getsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, &size);
- DEBUGA_SKYPE("TCP_NODELAY is %d\n", SKYPOPEN_P_LOG, flag);
- flag = 1;
- if(tech_pvt->setsockopt){
- setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, size);
+ flag = 0;
+ getsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, &size);
+ DEBUGA_SKYPE("TCP_NODELAY is %d\n", SKYPOPEN_P_LOG, flag);
+ flag = 1;
+ if (tech_pvt->setsockopt) {
+ setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, size);
}
- flag = 0;
- getsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, &size);
- DEBUGA_SKYPE("TCP_NODELAY is %d\n", SKYPOPEN_P_LOG, flag);
+ flag = 0;
+ getsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, &size);
+ DEBUGA_SKYPE("TCP_NODELAY is %d\n", SKYPOPEN_P_LOG, flag);
return s;
}
-int skypopen_signaling_read(private_t * tech_pvt)
+int skypopen_signaling_read(private_t *tech_pvt)
{
char read_from_pipe[4096];
char message[4096];
//if (!strstr(message, "DURATION")) {
DEBUGA_SKYPE("READING: |||%s||| \n", SKYPOPEN_P_LOG, message);
- strncpy( tech_pvt->message, message, sizeof(tech_pvt->message) );
+ strncpy(tech_pvt->message, message, sizeof(tech_pvt->message));
//}
if (!strcasecmp(message, "SILENT_MODE OFF")) {
}
if (!strcasecmp(prop, "DURATION")) { /* each 20 seconds, we zero the buffers and sync the timers */
if (!((atoi(value) % 20))) {
- if(tech_pvt->read_buffer){
+ if (tech_pvt->read_buffer) {
switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer);
- if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
+ if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
- if(tech_pvt->write_buffer){
+ if (tech_pvt->write_buffer) {
switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer);
- if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
+ if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_write);
}
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
/* we are NOT inside an active call */
- DEBUGA_SKYPE("NO ACTIVE calls in this moment, skype_call %s is RINGING, to ask PARTNER_DISPNAME and PARTNER_HANDLE\n", SKYPOPEN_P_LOG, id);
+ DEBUGA_SKYPE("NO ACTIVE calls in this moment, skype_call %s is RINGING, to ask PARTNER_DISPNAME and PARTNER_HANDLE\n",
+ SKYPOPEN_P_LOG, id);
sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
skypopen_signaling_write(tech_pvt, msg_to_skype);
skypopen_sleep(100);
tech_pvt->interface_state = SKYPOPEN_STATE_RINGING;
skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n", SKYPOPEN_P_LOG, id);
- if( !remote_party_is_ringing(tech_pvt)){
+ if (!remote_party_is_ringing(tech_pvt)) {
- WARNINGA("We are getting the RINGING from a call we canceled, trying to get out hanging up call id: %s.\n", SKYPOPEN_P_LOG, id);
+ WARNINGA("We are getting the RINGING from a call we canceled, trying to get out hanging up call id: %s.\n",
+ SKYPOPEN_P_LOG, id);
sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
skypopen_signaling_write(tech_pvt, msg_to_skype);
sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id);
skypopen_signaling_write(tech_pvt, msg_to_skype);
remote_party_is_early_media(tech_pvt);
- /* CLOUDTREE (Thomas Hazel)
- } else if (!strcasecmp(value, "MISSED")) {
- DEBUGA_SKYPE("We missed skype_call %s\n", SKYPOPEN_P_LOG, id);
- */
- // CLOUDTREE (Thomas Hazel)
+ /* CLOUDTREE (Thomas Hazel)
+ } else if (!strcasecmp(value, "MISSED")) {
+ DEBUGA_SKYPE("We missed skype_call %s\n", SKYPOPEN_P_LOG, id);
+ */
+ // CLOUDTREE (Thomas Hazel)
} else if (!strcasecmp(value, "MISSED") || !strcasecmp(value, "FINISHED")) {
if (!strcasecmp(tech_pvt->skype_call_id, id)) {
DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n", SKYPOPEN_P_LOG, id);
nospace = 0;
if (len > 0) {
switch_mutex_lock(tech_pvt->mutex_audio_srv);
- if(tech_pvt->read_buffer){
+ if (tech_pvt->read_buffer) {
if (switch_buffer_freespace(tech_pvt->read_buffer) < len) {
switch_buffer_zero(tech_pvt->read_buffer);
nospace = 1;
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
if (!bytes_to_write) {
- if(tech_pvt->write_silence_when_idle){
+ if (tech_pvt->write_silence_when_idle) {
memset(cli_out, 255, sizeof(cli_out));
bytes_to_write = 640;
//DEBUGA_SKYPE("WRITE Silence!\n", SKYPOPEN_P_LOG);
- }else{
+ } else {
continue;
}
}
return NULL;
}
-int skypopen_senddigit(private_t * tech_pvt, char digit)
+int skypopen_senddigit(private_t *tech_pvt, char digit)
{
char msg_to_skype[1024];
return 0;
}
-int skypopen_call(private_t * tech_pvt, char *rdest, int timeout)
+int skypopen_call(private_t *tech_pvt, char *rdest, int timeout)
{
char msg_to_skype[1024];
/* PLATFORM SPECIFIC */
/***************************/
#if defined(WIN32) && !defined(__CYGWIN__)
-int skypopen_pipe_read(switch_file_t * pipe, short *buf, int howmany)
+int skypopen_pipe_read(switch_file_t *pipe, short *buf, int howmany)
{
switch_size_t quantity;
return howmany;
}
-int skypopen_pipe_write(switch_file_t * pipe, short *buf, int howmany)
+int skypopen_pipe_write(switch_file_t *pipe, short *buf, int howmany)
{
switch_size_t quantity;
return res;
}
-int skypopen_audio_init(private_t * tech_pvt)
+int skypopen_audio_init(private_t *tech_pvt)
{
switch_status_t rv;
rv = switch_file_pipe_create(&tech_pvt->audiopipe_srv[0], &tech_pvt->audiopipe_srv[1], skypopen_module_pool);
return res;
}
-int skypopen_audio_init(private_t * tech_pvt)
+int skypopen_audio_init(private_t *tech_pvt)
{
if (pipe(tech_pvt->audiopipe_srv)) {
fcntl(tech_pvt->audiopipe_srv[0], F_SETFL, O_NONBLOCK);
return res;
}
-int skypopen_signaling_write(private_t * tech_pvt, char *msg_to_skype)
+int skypopen_signaling_write(private_t *tech_pvt, char *msg_to_skype)
{
static char acInputRow[1024];
COPYDATASTRUCT oCopyData;
return (lReturnCode);
}
-int win32_Initialize_CreateWindowClass(private_t * tech_pvt)
+int win32_Initialize_CreateWindowClass(private_t *tech_pvt)
{
unsigned char *paucUUIDString;
RPC_STATUS lUUIDResult;
return (fReturnStatus);
}
-void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt)
+void win32_DeInitialize_DestroyWindowClass(private_t *tech_pvt)
{
UnregisterClass(tech_pvt->SkypopenHandles.win32_acInit_WindowClassName, tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle);
CloseHandle(tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle);
tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle = NULL;
}
-int win32_Initialize_CreateMainWindow(private_t * tech_pvt)
+int win32_Initialize_CreateMainWindow(private_t *tech_pvt)
{
tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle =
CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
return (tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0);
}
-void win32_DeInitialize_DestroyMainWindow(private_t * tech_pvt)
+void win32_DeInitialize_DestroyMainWindow(private_t *tech_pvt)
{
if (tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle != NULL)
DestroyWindow(tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle), tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle = NULL;
win32_DeInitialize_DestroyWindowClass(tech_pvt);
}
}
- tech_pvt->skypopen_api_thread=NULL;
+ tech_pvt->skypopen_api_thread = NULL;
DEBUGA_SKYPE("EXITING\n", SKYPOPEN_P_LOG);
return NULL;
}
#else /* NOT WIN32 */
// CLOUDTREE (Thomas Hazel)
-int xio_error_handler(Display *dpy)
+int xio_error_handler(Display * dpy)
{
private_t *tech_pvt = NULL;
- struct SkypopenHandles* handle;
+ struct SkypopenHandles *handle;
ERRORA("Fatal display error for %d, %s\n", SKYPOPEN_P_LOG, skypopen_list_size(&global_handles_list), dpy->display_name);
handle = skypopen_list_remove_by_value(&global_handles_list, dpy);
if (handle != NULL) {
- #ifdef XIO_ERROR_BY_SETJMP
- siglongjmp(handle->ioerror_context, 1);
- #endif
- #ifdef XIO_ERROR_BY_UCONTEXT
- setcontext(&handle->ioerror_context);
- #endif
+#ifdef XIO_ERROR_BY_SETJMP
+ siglongjmp(handle->ioerror_context, 1);
+#endif
+#ifdef XIO_ERROR_BY_UCONTEXT
+ setcontext(&handle->ioerror_context);
+#endif
}
- ERRORA("Fatal display error for %p, %s - failed to siglongjmp\n", SKYPOPEN_P_LOG, (void*) handle, dpy->display_name);
+ ERRORA("Fatal display error for %p, %s - failed to siglongjmp\n", SKYPOPEN_P_LOG, (void *) handle, dpy->display_name);
return 0;
}
return 0; /* ignore the error */
}
-int skypopen_send_message(private_t * tech_pvt, const char *message_P)
+int skypopen_send_message(private_t *tech_pvt, const char *message_P)
{
struct SkypopenHandles *SkypopenHandles = &tech_pvt->SkypopenHandles;
Window w_P = SkypopenHandles->skype_win;
unsigned int len = strlen(message_P);
XEvent e;
-skypopen_sleep(1000);//giovanni
- XFlush(disp);//giovanni
+ skypopen_sleep(1000); //giovanni
+ XFlush(disp); //giovanni
memset(&e, 0, sizeof(e));
e.xclient.type = ClientMessage;
return 1;
}
-int skypopen_signaling_write(private_t * tech_pvt, char *msg_to_skype)
+int skypopen_signaling_write(private_t *tech_pvt, char *msg_to_skype)
{
DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPOPEN_P_LOG, msg_to_skype);
}
// CLOUDTREE (Thomas Hazel)
- #ifndef WIN32
+#ifndef WIN32
{
skypopen_list_add(&global_handles_list, SkypopenHandles);
- #ifdef XIO_ERROR_BY_SETJMP
- if (sigsetjmp(SkypopenHandles->ioerror_context, 1) != 0) {
- switch_core_session_t *session = NULL;
- ERRORA("Fatal display error for %s - successed to jump\n", SKYPOPEN_P_LOG, tech_pvt->X11_display);
-
- session = switch_core_session_locate(tech_pvt->session_uuid_str);
- if (session) {
- switch_channel_t *channel = switch_core_session_get_channel(session);
- WARNINGA("Closing session %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_user);
- switch_channel_hangup(channel, SWITCH_CAUSE_CRASH);
- switch_core_session_rwunlock(session);
- }
-
- WARNINGA("Removing skype user %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_user);
- tech_pvt->skypopen_api_thread = NULL;
- remove_interface(tech_pvt->skype_user, TRUE);
- XCloseDisplay(disp);
- return NULL;
+#ifdef XIO_ERROR_BY_SETJMP
+ if (sigsetjmp(SkypopenHandles->ioerror_context, 1) != 0) {
+ switch_core_session_t *session = NULL;
+ ERRORA("Fatal display error for %s - successed to jump\n", SKYPOPEN_P_LOG, tech_pvt->X11_display);
+
+ session = switch_core_session_locate(tech_pvt->session_uuid_str);
+ if (session) {
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ WARNINGA("Closing session %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_user);
+ switch_channel_hangup(channel, SWITCH_CAUSE_CRASH);
+ switch_core_session_rwunlock(session);
}
- #endif
- #ifdef XIO_ERROR_BY_UCONTEXT
- getcontext(&SkypopenHandles->ioerror_context);
-
- if (skypopen_list_find(&global_handles_list, SkypopenHandles) == NULL) {
- switch_core_session_t *session = NULL;
- ERRORA("Fatal display error for %s - successed to jump\n", SKYPOPEN_P_LOG, tech_pvt->X11_display);
-
- session = switch_core_session_locate(tech_pvt->session_uuid_str);
- if (session) {
- switch_channel_t *channel = switch_core_session_get_channel(session);
- WARNINGA("Closing session %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_user);
- switch_channel_hangup(channel, SWITCH_CAUSE_CRASH);
- switch_core_session_rwunlock(session);
- }
- WARNINGA("Removing skype user %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_user);
- tech_pvt->skypopen_api_thread = NULL;
- remove_interface(tech_pvt->skype_user, TRUE);
- XCloseDisplay(disp);
- return NULL;
+ WARNINGA("Removing skype user %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_user);
+ tech_pvt->skypopen_api_thread = NULL;
+ remove_interface(tech_pvt->skype_user, TRUE);
+ XCloseDisplay(disp);
+ return NULL;
+ }
+#endif
+#ifdef XIO_ERROR_BY_UCONTEXT
+ getcontext(&SkypopenHandles->ioerror_context);
+
+ if (skypopen_list_find(&global_handles_list, SkypopenHandles) == NULL) {
+ switch_core_session_t *session = NULL;
+ ERRORA("Fatal display error for %s - successed to jump\n", SKYPOPEN_P_LOG, tech_pvt->X11_display);
+
+ session = switch_core_session_locate(tech_pvt->session_uuid_str);
+ if (session) {
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ WARNINGA("Closing session %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_user);
+ switch_channel_hangup(channel, SWITCH_CAUSE_CRASH);
+ switch_core_session_rwunlock(session);
}
- #endif
+
+ WARNINGA("Removing skype user %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_user);
+ tech_pvt->skypopen_api_thread = NULL;
+ remove_interface(tech_pvt->skype_user, TRUE);
+ XCloseDisplay(disp);
+ return NULL;
+ }
+#endif
}
- #endif /* NOT WIN32 */
+#endif /* NOT WIN32 */
xfd = XConnectionNumber(disp);
fcntl(xfd, F_SETFD, FD_CLOEXEC);
ERRORA("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypopen again\n", SKYPOPEN_P_LOG);
// CLOUDTREE (Thomas Hazel)
- #ifndef WIN32
+#ifndef WIN32
skypopen_list_remove_by_reference(&global_handles_list, SkypopenHandles);
- #endif
+#endif
XCloseDisplay(disp);
running = 0;
ERRORA("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypopen again\n", SKYPOPEN_P_LOG);
// CLOUDTREE (Thomas Hazel)
- #ifndef WIN32
+#ifndef WIN32
skypopen_list_remove_by_reference(&global_handles_list, SkypopenHandles);
- #endif
+#endif
XCloseDisplay(disp);
running = 0;
while (running && tech_pvt->running) {
- FD_ZERO(&xfds);
- FD_SET(xfd, &xfds);
+ FD_ZERO(&xfds);
+ FD_SET(xfd, &xfds);
- tv.tv_usec = 100000;
- tv.tv_sec = 0;
+ tv.tv_usec = 100000;
+ tv.tv_sec = 0;
-if (select(xfd+1, &xfds, 0, 0, &tv)){
+ if (select(xfd + 1, &xfds, 0, 0, &tv)) {
-while(XPending(disp)){
+ while (XPending(disp)) {
- XNextEvent(disp, &an_event);
- if (!(running && tech_pvt->running))
- break;
- switch (an_event.type) {
- case ClientMessage:
+ XNextEvent(disp, &an_event);
+ if (!(running && tech_pvt->running))
+ break;
+ switch (an_event.type) {
+ case ClientMessage:
- if (an_event.xclient.format != 8) {
- skypopen_sleep(1000); //0.1 msec
- break;
- }
+ if (an_event.xclient.format != 8) {
+ skypopen_sleep(1000); //0.1 msec
+ break;
+ }
- for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
- buf[i] = an_event.xclient.data.b[i];
+ for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
+ buf[i] = an_event.xclient.data.b[i];
- buf[i] = '\0';
+ buf[i] = '\0';
- if (an_event.xclient.message_type == atom_begin) {
- if (strlen(buffer)) {
- unsigned int howmany;
- howmany = strlen(b) + 1;
- howmany = write(SkypopenHandles->fdesc[1], b, howmany);
- WARNINGA
- ("A begin atom while the previous message is not closed???? value of previous message (between vertical bars) is=|||%s|||, will be lost\n",
- SKYPOPEN_P_LOG, buffer);
- memset(buffer, '\0', 17000);
- }
- if (continue_is_broken) {
- continue_is_broken = 0;
- there_were_continues = 1;
- }
- }
- if (an_event.xclient.message_type == atom_continue) {
- if (!strlen(buffer)) {
- WARNINGA
- ("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||, let's store it and hope next 'begin' will be the good one\n",
- SKYPOPEN_P_LOG, buf);
- strcat(continuebuffer, buf);
- continue_is_broken = 1;
- if (!strncmp(buf, "ognised identity", 15)) {
- WARNINGA
- ("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n",
- SKYPOPEN_P_LOG, buf);
- skypopen_sleep(1000000); //1 sec
+ if (an_event.xclient.message_type == atom_begin) {
+ if (strlen(buffer)) {
+ unsigned int howmany;
+ howmany = strlen(b) + 1;
+ howmany = write(SkypopenHandles->fdesc[1], b, howmany);
+ WARNINGA
+ ("A begin atom while the previous message is not closed???? value of previous message (between vertical bars) is=|||%s|||, will be lost\n",
+ SKYPOPEN_P_LOG, buffer);
+ memset(buffer, '\0', 17000);
+ }
+ if (continue_is_broken) {
+ continue_is_broken = 0;
+ there_were_continues = 1;
+ }
}
+ if (an_event.xclient.message_type == atom_continue) {
+ if (!strlen(buffer)) {
+ WARNINGA
+ ("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||, let's store it and hope next 'begin' will be the good one\n",
+ SKYPOPEN_P_LOG, buf);
+ strcat(continuebuffer, buf);
+ continue_is_broken = 1;
+ if (!strncmp(buf, "ognised identity", 15)) {
+ WARNINGA
+ ("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n",
+ SKYPOPEN_P_LOG, buf);
+ skypopen_sleep(1000000); //1 sec
+ }
+ skypopen_sleep(1000); //0.1 msec
+ break;
+ }
+ }
+ if (continue_is_broken) {
+ XFlush(disp);
+ skypopen_sleep(1000); //0.1 msec
+ continue;
+ }
+ strcat(buffer, buf);
+ strcat(buffer, continuebuffer);
+ memset(continuebuffer, '\0', 17000);
+
+ if (i < 20 || there_were_continues) { /* last fragment */
+ unsigned int howmany;
+
+ howmany = strlen(b) + 1;
+ howmany = write(SkypopenHandles->fdesc[1], b, howmany);
+ memset(buffer, '\0', 17000);
+ XFlush(disp);
+ there_were_continues = 0;
+ }
+
skypopen_sleep(1000); //0.1 msec
break;
- }
- }
- if (continue_is_broken) {
- XFlush(disp);
- skypopen_sleep(1000); //0.1 msec
- continue;
- }
- strcat(buffer, buf);
- strcat(buffer, continuebuffer);
- memset(continuebuffer, '\0', 17000);
-
- if (i < 20 || there_were_continues) { /* last fragment */
- unsigned int howmany;
-
- howmany = strlen(b) + 1;
- howmany = write(SkypopenHandles->fdesc[1], b, howmany);
- memset(buffer, '\0', 17000);
- XFlush(disp);
- there_were_continues = 0;
- }
-
- skypopen_sleep(1000); //0.1 msec
- break;
- default:
- skypopen_sleep(1000); //0.1 msec
- break;
- } //switch event.type
- } //while XPending
+ default:
+ skypopen_sleep(1000); //0.1 msec
+ break;
+ } //switch event.type
+ } //while XPending
-} // if select
-} //while running
+ } // if select
+ } //while running
NOTICA("EXITING\n", SKYPOPEN_P_LOG);
// CLOUDTREE (Thomas Hazel)
- #ifndef WIN32
+#ifndef WIN32
skypopen_list_remove_by_reference(&global_handles_list, SkypopenHandles);
- #endif
+#endif
- tech_pvt->skypopen_api_thread=NULL;
+ tech_pvt->skypopen_api_thread = NULL;
XCloseDisplay(disp);
return NULL;
}
#endif // WIN32
-int inbound_channel_answered(private_t * tech_pvt)
+int inbound_channel_answered(private_t *tech_pvt)
{
int res = 0;
switch_core_session_t *session = NULL;
}
-int skypopen_answered(private_t * tech_pvt)
+int skypopen_answered(private_t *tech_pvt)
{
int res = 0;
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
- //WARNINGA("ANSWERED tech_pvt->skype_call_id=%s, tech_pvt->skype_callflow=%d, tech_pvt->interface_state=%d, tech_pvt->skype_user=%s, tech_pvt->callid_number=%s, tech_pvt->ring_value=%s, tech_pvt->ring_id=%s, tech_pvt->answer_value=%s, tech_pvt->answer_id=%s\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id, tech_pvt->skype_callflow, tech_pvt->interface_state, tech_pvt->skype_user, tech_pvt->callid_number, tech_pvt->ring_value, tech_pvt->ring_id, tech_pvt->answer_value, tech_pvt->answer_id);
+ //WARNINGA("ANSWERED tech_pvt->skype_call_id=%s, tech_pvt->skype_callflow=%d, tech_pvt->interface_state=%d, tech_pvt->skype_user=%s, tech_pvt->callid_number=%s, tech_pvt->ring_value=%s, tech_pvt->ring_id=%s, tech_pvt->answer_value=%s, tech_pvt->answer_id=%s\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id, tech_pvt->skype_callflow, tech_pvt->interface_state, tech_pvt->skype_user, tech_pvt->callid_number, tech_pvt->ring_value, tech_pvt->ring_id, tech_pvt->answer_value, tech_pvt->answer_id);
session = switch_core_session_locate(tech_pvt->session_uuid_str);
if (session) {