]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
skypopen: indented
authorGiovanni Maruzzelli <gmaruzz@gmail.com>
Tue, 26 Oct 2010 10:07:22 +0000 (05:07 -0500)
committerGiovanni Maruzzelli <gmaruzz@gmail.com>
Wed, 27 Oct 2010 14:44:51 +0000 (09:44 -0500)
src/mod/endpoints/mod_skypopen/mod_skypopen.c
src/mod/endpoints/mod_skypopen/skypopen.h
src/mod/endpoints/mod_skypopen/skypopen_protocol.c

index 62461de115c8633a3ccfd923b65fc9d1ac06eb10..38d47eb50d8fae189c8342accea849317deff3e3 100644 (file)
@@ -172,7 +172,7 @@ int running = 0;
 // 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
 
@@ -204,9 +204,9 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 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;
 
@@ -243,7 +243,7 @@ static switch_status_t skypopen_codec(private_t * tech_pvt, int sample_rate, int
 
 }
 
-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);
@@ -349,7 +349,7 @@ static switch_status_t interface_exists(char *the_interface)
                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;
        }
@@ -376,8 +376,8 @@ static switch_status_t interface_exists(char *the_interface)
                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 */
@@ -387,7 +387,7 @@ static switch_status_t interface_exists(char *the_interface)
 
                        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
        }
@@ -470,42 +470,42 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
                        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;
@@ -538,73 +538,72 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
 
        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);
 
@@ -656,46 +655,47 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
        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));
        }
 
@@ -741,7 +741,7 @@ static switch_status_t channel_on_reset(switch_core_session_t *session)
                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);
        }
@@ -775,7 +775,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
        unsigned int i;
        unsigned int a;
        size_t bytes_read = 0;
-       int try=0;
+       int try = 0;
 
 
        *frame = NULL;
@@ -815,17 +815,17 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
 
 
 
-       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);
@@ -833,11 +833,11 @@ read:
                }
                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));
@@ -935,7 +935,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
 {
        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);
@@ -973,13 +973,13 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
                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;
        }
 
@@ -1001,13 +1001,13 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session)
        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;
                }
        }
@@ -1025,7 +1025,7 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session)
        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;
@@ -1048,15 +1048,15 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
        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);
                        }
                }
@@ -1064,25 +1064,25 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 
        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);
@@ -1095,46 +1095,46 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 
                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:
@@ -1322,7 +1322,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
  * \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;
@@ -1393,7 +1393,7 @@ static void *SWITCH_THREAD_FUNC skypopen_signaling_thread_func(switch_thread_t *
                        }
                }
        }
-       tech_pvt->skypopen_signaling_thread=NULL;
+       tech_pvt->skypopen_signaling_thread = NULL;
        DEBUGA_SKYPE("EXITING\n", SKYPOPEN_P_LOG);
        return NULL;
 }
@@ -1472,22 +1472,22 @@ static switch_status_t load_config(int reload_type)
                        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;
 
@@ -1653,7 +1653,8 @@ static switch_status_t load_config(int reload_type)
                                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);
 
@@ -1758,7 +1759,8 @@ static switch_status_t load_config(int reload_type)
                                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);
                        }
                }
@@ -1814,7 +1816,8 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
                                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;
                                }
@@ -1825,7 +1828,8 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
                                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;
                                }
@@ -1880,21 +1884,22 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypopen_load)
        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;
@@ -1919,7 +1924,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypopen_load)
 
                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 */
@@ -1960,15 +1966,15 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown)
 #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 */
@@ -1978,7 +1984,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown)
 
                                        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
                        }
@@ -2030,22 +2036,22 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown)
        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;
@@ -2082,7 +2088,7 @@ int dtmf_received(private_t * tech_pvt, char *value)
        return 0;
 }
 
-int start_audio_threads(private_t * tech_pvt)
+int start_audio_threads(private_t *tech_pvt)
 {
        switch_threadattr_t *thd_attr = NULL;
 
@@ -2113,7 +2119,7 @@ int start_audio_threads(private_t * tech_pvt)
        } 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);
@@ -2129,7 +2135,7 @@ int start_audio_threads(private_t * tech_pvt)
        } 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);
@@ -2144,7 +2150,7 @@ int start_audio_threads(private_t * tech_pvt)
        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;
@@ -2191,7 +2197,7 @@ int new_inbound_channel(private_t * tech_pvt)
        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;
@@ -2222,7 +2228,7 @@ int remote_party_is_ringing(private_t * tech_pvt)
        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;
@@ -2253,7 +2259,7 @@ int remote_party_is_early_media(private_t * tech_pvt)
        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;
@@ -2284,7 +2290,7 @@ int outbound_channel_answered(private_t * tech_pvt)
        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;
@@ -2309,7 +2315,7 @@ private_t *find_available_skypopen_interface_rr(private_t * tech_pvt_calling)
                        //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) {
@@ -2495,7 +2501,7 @@ SWITCH_STANDARD_API(skypopen_function)
 }
 
 
-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;
@@ -2518,7 +2524,10 @@ int skypopen_partner_handle_ring(private_t * tech_pvt)
                        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) {
@@ -2593,7 +2602,7 @@ int skypopen_partner_handle_ring(private_t * tech_pvt)
        return 0;
 }
 
-int skypopen_answer(private_t * tech_pvt)
+int skypopen_answer(private_t *tech_pvt)
 {
        char msg_to_skype[1024];
        int i;
@@ -2616,7 +2625,10 @@ int skypopen_answer(private_t * tech_pvt)
                        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) {
@@ -2691,8 +2703,9 @@ int skypopen_answer(private_t * tech_pvt)
        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;
@@ -2712,15 +2725,16 @@ int skypopen_transfer(private_t * tech_pvt)
                        /* 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;
@@ -2762,15 +2776,16 @@ int skypopen_transfer(private_t * tech_pvt)
                        /* 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;
@@ -2872,7 +2887,7 @@ int skypopen_transfer(private_t * tech_pvt)
        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;
@@ -3012,7 +3027,7 @@ int next_port(void)
 
 #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);
 
@@ -3027,8 +3042,8 @@ struct SkypopenHandles* skypopen_list_add(struct SkypopenList* list, struct Skyp
                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;
@@ -3044,36 +3059,36 @@ struct SkypopenHandles* skypopen_list_add(struct SkypopenList* list, struct Skyp
 }
 
 // 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 SkypopenHandlesiter;
-       struct SkypopenHandleshandle = 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;
@@ -3089,7 +3104,7 @@ struct SkypopenHandles* skypopen_list_remove_by_value(struct SkypopenList* list,
 }
 
 // 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);
 
@@ -3100,17 +3115,17 @@ struct SkypopenHandles* skypopen_list_remove_by_reference(struct SkypopenList* l
        }
 
        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;
@@ -3126,21 +3141,21 @@ struct SkypopenHandles* skypopen_list_remove_by_reference(struct SkypopenList* l
 
 // 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 SkypopenHandlesiter;
-       struct SkypopenHandleshandle = 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);
@@ -3150,7 +3165,7 @@ struct SkypopenHandles* skypopen_list_find(struct SkypopenList* list, struct Sky
 #endif
 
 // CLOUDTREE (THomas Hazel) - is there a capable freeswitch list? 
-int skypopen_list_size(struct SkypopenListlist)
+int skypopen_list_size(struct SkypopenList *list)
 {
        return list->entries;
 }
index a67bfb2876c183b58e1fca8899f9686420081be3..b49b6a799e51e8c324b3eee966ba648062438d2c 100644 (file)
 
 // CLOUDTREE (Thomas Hazel)
 #ifdef XIO_ERROR_BY_SETJMP
-       #include "setjmp.h"
+#include "setjmp.h"
 #endif
 // CLOUDTREE (Thomas Hazel)
 #ifdef XIO_ERROR_BY_UCONTEXT
-       #include "ucontext.h"
+#include "ucontext.h"
 #endif
 
 #endif //WIN32
@@ -176,32 +176,32 @@ struct SkypopenHandles {
        int fdesc[2];
 
        // CLOUDTREE (Thomas Hazel)
-       #ifdef XIO_ERROR_BY_SETJMP
-               jmp_buf ioerror_context;
-       #endif
-       #ifdef XIO_ERROR_BY_UCONTEXT
-               ucontext_t ioerror_context;
-       #endif
+#ifdef XIO_ERROR_BY_SETJMP
+       jmp_buf ioerror_context;
+#endif
+#ifdef XIO_ERROR_BY_UCONTEXT
+       ucontext_t ioerror_context;
+#endif
 
        // CLOUDTREE (Thomas Hazel) - is there a capable freeswitch list?
        switch_bool_t managed;
-       voidprev;
-       voidnext;
+       void *prev;
+       void *next;
 };
 
 // CLOUDTREE (Thomas Hazel) - is there a capable freeswitch list?
 struct SkypopenList {
        int entries;
-       voidhead;
-       voidtail;
+       void *head;
+       void *tail;
 };
 
 // CLOUDTREE (Thomas Hazel) - is there a capable freeswitch list?
-struct SkypopenHandles* skypopen_list_add(struct SkypopenList* list, struct SkypopenHandles* x);
-struct SkypopenHandles* skypopen_list_find(struct SkypopenList* list, struct SkypopenHandles* x);
-struct SkypopenHandles* skypopen_list_remove_by_value(struct SkypopenList* list, Display* display);
-struct SkypopenHandles* skypopen_list_remove_by_reference(struct SkypopenList* list, struct SkypopenHandles* x);
-int skypopen_list_size(struct SkypopenListlist);
+struct SkypopenHandles *skypopen_list_add(struct SkypopenList *list, struct SkypopenHandles *x);
+struct SkypopenHandles *skypopen_list_find(struct SkypopenList *list, struct SkypopenHandles *x);
+struct SkypopenHandles *skypopen_list_remove_by_value(struct SkypopenList *list, Display * display);
+struct SkypopenHandles *skypopen_list_remove_by_reference(struct SkypopenList *list, struct SkypopenHandles *x);
+int skypopen_list_size(struct SkypopenList *list);
 
 #else //WIN32
 
@@ -352,31 +352,31 @@ struct private_object {
 
 typedef struct private_object private_t;
 
-void *SWITCH_THREAD_FUNC skypopen_api_thread_func(switch_thread_t * thread, void *obj);
-int skypopen_audio_read(private_t * tech_pvt);
-int skypopen_audio_init(private_t * tech_pvt);
-int skypopen_signaling_write(private_t * tech_pvt, char *msg_to_skype);
-int skypopen_signaling_read(private_t * tech_pvt);
+void *SWITCH_THREAD_FUNC skypopen_api_thread_func(switch_thread_t *thread, void *obj);
+int skypopen_audio_read(private_t *tech_pvt);
+int skypopen_audio_init(private_t *tech_pvt);
+int skypopen_signaling_write(private_t *tech_pvt, char *msg_to_skype);
+int skypopen_signaling_read(private_t *tech_pvt);
 
-int skypopen_call(private_t * tech_pvt, char *idest, int timeout);
-int skypopen_senddigit(private_t * tech_pvt, char digit);
+int skypopen_call(private_t *tech_pvt, char *idest, int timeout);
+int skypopen_senddigit(private_t *tech_pvt, char digit);
 
 void *skypopen_do_tcp_srv_thread_func(void *obj);
-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);
 
 void *skypopen_do_tcp_cli_thread_func(void *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);
 
 void *skypopen_do_skypeapi_thread_func(void *obj);
-void *SWITCH_THREAD_FUNC skypopen_do_skypeapi_thread(switch_thread_t * thread, void *obj);
-int dtmf_received(private_t * tech_pvt, char *value);
-int start_audio_threads(private_t * tech_pvt);
-int new_inbound_channel(private_t * tech_pvt);
-int outbound_channel_answered(private_t * tech_pvt);
-int skypopen_signaling_write(private_t * tech_pvt, char *msg_to_skype);
+void *SWITCH_THREAD_FUNC skypopen_do_skypeapi_thread(switch_thread_t *thread, void *obj);
+int dtmf_received(private_t *tech_pvt, char *value);
+int start_audio_threads(private_t *tech_pvt);
+int new_inbound_channel(private_t *tech_pvt);
+int outbound_channel_answered(private_t *tech_pvt);
+int skypopen_signaling_write(private_t *tech_pvt, char *msg_to_skype);
 #if defined(WIN32) && !defined(__CYGWIN__)
-int skypopen_pipe_read(switch_file_t * pipe, short *buf, int howmany);
-int skypopen_pipe_write(switch_file_t * pipe, short *buf, int howmany);
+int skypopen_pipe_read(switch_file_t *pipe, short *buf, int howmany);
+int skypopen_pipe_write(switch_file_t *pipe, short *buf, int howmany);
 /* Visual C do not have strsep ? */
 char *strsep(char **stringp, const char *delim);
 #else
@@ -384,20 +384,20 @@ int skypopen_pipe_read(int pipe, short *buf, int howmany);
 int skypopen_pipe_write(int pipe, short *buf, int howmany);
 #endif /* WIN32 */
 int skypopen_close_socket(unsigned int fd);
-private_t *find_available_skypopen_interface_rr(private_t * tech_pvt_calling);
-int remote_party_is_ringing(private_t * tech_pvt);
-int remote_party_is_early_media(private_t * tech_pvt);
+private_t *find_available_skypopen_interface_rr(private_t *tech_pvt_calling);
+int remote_party_is_ringing(private_t *tech_pvt);
+int remote_party_is_early_media(private_t *tech_pvt);
 //int skypopen_answer(private_t * tech_pvt, char *id, char *value);
-int skypopen_answer(private_t * tech_pvt);
+int skypopen_answer(private_t *tech_pvt);
 //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);
 #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 incoming_chatmessage(private_t * tech_pvt, int which);
+int incoming_chatmessage(private_t *tech_pvt, int which);
 int next_port(void);
-int skypopen_partner_handle_ring(private_t * tech_pvt);
-int skypopen_answered(private_t * tech_pvt);
-int inbound_channel_answered(private_t * tech_pvt);
+int skypopen_partner_handle_ring(private_t *tech_pvt);
+int skypopen_answered(private_t *tech_pvt);
+int inbound_channel_answered(private_t *tech_pvt);
index f48d8559e698f4c255a3f8822c4706771ebe3533..0dc34b7d65439a28935e96e7b66fe0b00234658d 100644 (file)
@@ -30,9 +30,9 @@ extern switch_status_t remove_interface(char *the_interface, switch_bool_t force
 #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;
@@ -107,7 +107,7 @@ int skypopen_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_
        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);
        }
 
@@ -126,7 +126,7 @@ int skypopen_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_
        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);
        }
 
@@ -135,16 +135,16 @@ int skypopen_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_
        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);
 
 
 
@@ -152,7 +152,7 @@ int skypopen_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_
        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];
@@ -178,7 +178,7 @@ int skypopen_signaling_read(private_t * tech_pvt)
 
                        //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")) {
@@ -523,19 +523,19 @@ int skypopen_signaling_read(private_t * tech_pvt)
                                }
                                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);
@@ -571,7 +571,8 @@ int skypopen_signaling_read(private_t * tech_pvt)
                                                        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);
@@ -589,9 +590,10 @@ int skypopen_signaling_read(private_t * tech_pvt)
                                                                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);
@@ -634,11 +636,11 @@ int skypopen_signaling_read(private_t * tech_pvt)
                                                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);
@@ -889,7 +891,7 @@ void *skypopen_do_tcp_srv_thread_func(void *obj)
                                                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;
@@ -1045,11 +1047,11 @@ void *skypopen_do_tcp_cli_thread_func(void *obj)
                                                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;
                                                        }
                                                }
@@ -1088,7 +1090,7 @@ void *skypopen_do_tcp_cli_thread_func(void *obj)
        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];
 
@@ -1099,7 +1101,7 @@ int skypopen_senddigit(private_t * tech_pvt, char digit)
        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];
 
@@ -1117,7 +1119,7 @@ int skypopen_call(private_t * tech_pvt, char *rdest, int timeout)
 /* 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;
 
@@ -1130,7 +1132,7 @@ int skypopen_pipe_read(switch_file_t * pipe, short *buf, int howmany)
        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;
 
@@ -1152,7 +1154,7 @@ int skypopen_close_socket(unsigned int fd)
        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);
@@ -1185,7 +1187,7 @@ int skypopen_close_socket(unsigned int fd)
        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);
@@ -1248,7 +1250,7 @@ char
        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;
@@ -1355,7 +1357,7 @@ LRESULT APIENTRY skypopen_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
        return (lReturnCode);
 }
 
-int win32_Initialize_CreateWindowClass(private_t * tech_pvt)
+int win32_Initialize_CreateWindowClass(private_t *tech_pvt)
 {
        unsigned char *paucUUIDString;
        RPC_STATUS lUUIDResult;
@@ -1395,14 +1397,14 @@ int win32_Initialize_CreateWindowClass(private_t * tech_pvt)
        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,
@@ -1412,7 +1414,7 @@ int win32_Initialize_CreateMainWindow(private_t * tech_pvt)
        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;
@@ -1462,7 +1464,7 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
                        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;
 }
@@ -1470,24 +1472,24 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
 #else /* NOT WIN32 */
 
 // CLOUDTREE (Thomas Hazel)
-int xio_error_handler(Display *dpy)
+int xio_error_handler(Display * dpy)
 {
        private_t *tech_pvt = NULL;
-       struct SkypopenHandleshandle;
+       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;
 }
@@ -1502,7 +1504,7 @@ int X11_errors_handler(Display * dpy, XErrorEvent * err)
        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;
@@ -1516,8 +1518,8 @@ int skypopen_send_message(private_t * tech_pvt, const char *message_P)
        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;
@@ -1552,7 +1554,7 @@ skypopen_sleep(1000);//giovanni
        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);
@@ -1661,54 +1663,54 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
        }
 
        // 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);
@@ -1727,9 +1729,9 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
                        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;
@@ -1741,9 +1743,9 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
                        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;
@@ -1771,97 +1773,97 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
                        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
 
 
 
@@ -1876,18 +1878,18 @@ while(XPending(disp)){
        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;
@@ -1911,14 +1913,14 @@ int inbound_channel_answered(private_t * tech_pvt)
 }
 
 
-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) {