<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14444] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14444">14444</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-07-31 21:47:35 -0500 (Fri, 31 Jul 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre><a href="http://jira.freeswitch.org/browse/MODSKYPIAX-35">MODSKYPIAX-35</a> (part1)</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh">freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_ioc">freeswitch/trunk/src/switch_core_io.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (14443 => 14444)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-08-01 01:02:02 UTC (rev 14443)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-08-01 02:47:35 UTC (rev 14444)
</span><span class="lines">@@ -48,35 +48,35 @@
</span><span class="cx"> #define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL
</span><span class="cx"> #endif /*  */
</span><span class="cx"> struct sk_timezone {
</span><del>-  int tz_minuteswest;           /* minutes W of Greenwich */
-  int tz_dsttime;               /* type of dst correction */
</del><ins>+        int tz_minuteswest;                        /* minutes W of Greenwich */
+        int tz_dsttime;                                /* type of dst correction */
</ins><span class="cx"> };
</span><span class="cx"> int gettimeofday(struct timeval *tv, struct sk_timezone *tz)
</span><span class="cx"> {
</span><del>-  FILETIME ft;
-  unsigned __int64 tmpres = 0;
-  static int tzflag;
-  if (NULL != tv) {
-    GetSystemTimeAsFileTime(&amp;ft);
-    tmpres |= ft.dwHighDateTime;
-    tmpres &lt;&lt;= 32;
-    tmpres |= ft.dwLowDateTime;
</del><ins>+        FILETIME ft;
+        unsigned __int64 tmpres = 0;
+        static int tzflag;
+        if (NULL != tv) {
+                GetSystemTimeAsFileTime(&amp;ft);
+                tmpres |= ft.dwHighDateTime;
+                tmpres &lt;&lt;= 32;
+                tmpres |= ft.dwLowDateTime;
</ins><span class="cx"> 
</span><del>-    /*converting file time to unix epoch */
-    tmpres /= 10;               /*convert into microseconds */
-    tmpres -= DELTA_EPOCH_IN_MICROSECS;
-    tv-&gt;tv_sec = (long) (tmpres / 1000000UL);
-    tv-&gt;tv_usec = (long) (tmpres % 1000000UL);
-  }
-  if (NULL != tz) {
-    if (!tzflag) {
-      _tzset();
-      tzflag++;
-    }
-    tz-&gt;tz_minuteswest = _timezone / 60;
-    tz-&gt;tz_dsttime = _daylight;
-  }
-  return 0;
</del><ins>+                /*converting file time to unix epoch */
+                tmpres /= 10;                        /*convert into microseconds */
+                tmpres -= DELTA_EPOCH_IN_MICROSECS;
+                tv-&gt;tv_sec = (long) (tmpres / 1000000UL);
+                tv-&gt;tv_usec = (long) (tmpres % 1000000UL);
+        }
+        if (NULL != tz) {
+                if (!tzflag) {
+                        _tzset();
+                        tzflag++;
+                }
+                tz-&gt;tz_minuteswest = _timezone / 60;
+                tz-&gt;tz_dsttime = _daylight;
+        }
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /***************/
</span><span class="lines">@@ -97,27 +97,27 @@
</span><span class="cx"> /* END: Changes heres */
</span><span class="cx"> 
</span><span class="cx"> static struct {
</span><del>-  int debug;
-  char *ip;
-  int port;
-  char *dialplan;
-  char *destination;
-  char *context;
-  char *codec_string;
-  char *codec_order[SWITCH_MAX_CODECS];
-  int codec_order_last;
-  char *codec_rates_string;
-  char *codec_rates[SWITCH_MAX_CODECS];
-  int codec_rates_last;
-  unsigned int flags;
-  int fd;
-  int calls;          
-  int real_interfaces;
-  int next_interface;
-  char hold_music[256];
-  private_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
-  switch_mutex_t *mutex;
-  private_t *sk_console;
</del><ins>+        int debug;
+        char *ip;
+        int port;
+        char *dialplan;
+        char *destination;
+        char *context;
+        char *codec_string;
+        char *codec_order[SWITCH_MAX_CODECS];
+        int codec_order_last;
+        char *codec_rates_string;
+        char *codec_rates[SWITCH_MAX_CODECS];
+        int codec_rates_last;
+        unsigned int flags;
+        int fd;
+        int calls;
+        int real_interfaces;
+        int next_interface;
+        char hold_music[256];
+        private_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
+        switch_mutex_t *mutex;
+        private_t *sk_console;
</ins><span class="cx"> } globals;
</span><span class="cx"> 
</span><span class="cx"> switch_endpoint_interface_t *skypiax_endpoint_interface;
</span><span class="lines">@@ -128,243 +128,223 @@
</span><span class="cx"> SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_context, globals.context);
</span><span class="cx"> SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_destination, globals.destination);
</span><span class="cx"> SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string);
</span><del>-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string,
-                                  globals.codec_rates_string);
</del><ins>+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string);
</ins><span class="cx"> 
</span><span class="cx"> /* BEGIN: Changes here */
</span><span class="cx"> static switch_status_t interface_exists(char *the_interface);
</span><span class="cx"> static switch_status_t remove_interface(char *the_interface);
</span><span class="cx"> /* END: Changes here */
</span><span class="cx"> 
</span><del>-static switch_status_t channel_on_init(switch_core_session_t * session);
-static switch_status_t channel_on_hangup(switch_core_session_t * session);
-static switch_status_t channel_on_destroy(switch_core_session_t * session);
-static switch_status_t channel_on_routing(switch_core_session_t * session);
-static switch_status_t channel_on_exchange_media(switch_core_session_t * session);
-static switch_status_t channel_on_soft_execute(switch_core_session_t * session);
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session,
-                                                    switch_event_t * var_event,
-                                                    switch_caller_profile_t *
-                                                    outbound_profile,
-                                                    switch_core_session_t ** new_session,
-                                                    switch_memory_pool_t ** pool,
-                                                    switch_originate_flag_t flags);
-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);
</del><ins>+static switch_status_t channel_on_init(switch_core_session_t *session);
+static switch_status_t channel_on_hangup(switch_core_session_t *session);
+static switch_status_t channel_on_destroy(switch_core_session_t *session);
+static switch_status_t channel_on_routing(switch_core_session_t *session);
+static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
+static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+                                                                                                        switch_event_t *var_event,
+                                                                                                        switch_caller_profile_t *outbound_profile,
+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
+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);
</ins><span class="cx"> 
</span><span class="cx"> static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms)
</span><span class="cx"> {
</span><del>-  switch_core_session_t *session = NULL;
</del><ins>+        switch_core_session_t *session = NULL;
</ins><span class="cx"> 
</span><del>-  if (switch_core_codec_init
-      (&amp;tech_pvt-&gt;read_codec, &quot;L16&quot;, NULL, sample_rate, codec_ms, 1,
-       SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
-       NULL) != SWITCH_STATUS_SUCCESS) {
-    ERRORA(&quot;Can't load codec?\n&quot;, SKYPIAX_P_LOG);
-    return SWITCH_STATUS_FALSE;
-  }
</del><ins>+        if (switch_core_codec_init
+                (&amp;tech_pvt-&gt;read_codec, &quot;L16&quot;, NULL, sample_rate, codec_ms, 1,
+                 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+                ERRORA(&quot;Can't load codec?\n&quot;, SKYPIAX_P_LOG);
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx"> 
</span><del>-  if (switch_core_codec_init
-      (&amp;tech_pvt-&gt;write_codec, &quot;L16&quot;, NULL, sample_rate, codec_ms, 1,
-       SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
-       NULL) != SWITCH_STATUS_SUCCESS) {
-    ERRORA(&quot;Can't load codec?\n&quot;, SKYPIAX_P_LOG);
-    switch_core_codec_destroy(&amp;tech_pvt-&gt;read_codec);
-    return SWITCH_STATUS_FALSE;
-  }
</del><ins>+        if (switch_core_codec_init
+                (&amp;tech_pvt-&gt;write_codec, &quot;L16&quot;, NULL, sample_rate, codec_ms, 1,
+                 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+                ERRORA(&quot;Can't load codec?\n&quot;, SKYPIAX_P_LOG);
+                switch_core_codec_destroy(&amp;tech_pvt-&gt;read_codec);
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx"> 
</span><del>-  tech_pvt-&gt;read_frame.rate = sample_rate;
-  tech_pvt-&gt;read_frame.codec = &amp;tech_pvt-&gt;read_codec;
</del><ins>+        tech_pvt-&gt;read_frame.rate = sample_rate;
+        tech_pvt-&gt;read_frame.codec = &amp;tech_pvt-&gt;read_codec;
</ins><span class="cx"> 
</span><del>-  session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
</del><ins>+        session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
</ins><span class="cx"> 
</span><del>-  switch_core_session_set_read_codec(session, &amp;tech_pvt-&gt;read_codec);
-  switch_core_session_set_write_codec(session, &amp;tech_pvt-&gt;write_codec);
</del><ins>+        switch_core_session_set_read_codec(session, &amp;tech_pvt-&gt;read_codec);
+        switch_core_session_set_write_codec(session, &amp;tech_pvt-&gt;write_codec);
</ins><span class="cx"> 
</span><del>-  switch_core_session_rwunlock(session);
</del><ins>+        switch_core_session_rwunlock(session);
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session)
</del><ins>+void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx"> 
</span><del>-  tech_pvt-&gt;read_frame.data = tech_pvt-&gt;databuf;
-  tech_pvt-&gt;read_frame.buflen = sizeof(tech_pvt-&gt;databuf);
-  switch_mutex_init(&amp;tech_pvt-&gt;mutex, SWITCH_MUTEX_NESTED,
-                    switch_core_session_get_pool(session));
-  switch_mutex_init(&amp;tech_pvt-&gt;flag_mutex, SWITCH_MUTEX_NESTED,
-                    switch_core_session_get_pool(session));
-  switch_core_session_set_private(session, tech_pvt);
-  switch_copy_string(tech_pvt-&gt;session_uuid_str, switch_core_session_get_uuid(session),
-                     sizeof(tech_pvt-&gt;session_uuid_str));
-  if (skypiax_codec(tech_pvt, SAMPLERATE_SKYPIAX, 20) != SWITCH_STATUS_SUCCESS) {
-    ERRORA(&quot;skypiax_codec FAILED\n&quot;, SKYPIAX_P_LOG);
-  } else {
-    DEBUGA_SKYPE(&quot;skypiax_codec SUCCESS\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        tech_pvt-&gt;read_frame.data = tech_pvt-&gt;databuf;
+        tech_pvt-&gt;read_frame.buflen = sizeof(tech_pvt-&gt;databuf);
+        switch_mutex_init(&amp;tech_pvt-&gt;mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+        switch_mutex_init(&amp;tech_pvt-&gt;flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+        switch_core_session_set_private(session, tech_pvt);
+        switch_copy_string(tech_pvt-&gt;session_uuid_str, switch_core_session_get_uuid(session), sizeof(tech_pvt-&gt;session_uuid_str));
+        if (skypiax_codec(tech_pvt, SAMPLERATE_SKYPIAX, 20) != SWITCH_STATUS_SUCCESS) {
+                ERRORA(&quot;skypiax_codec FAILED\n&quot;, SKYPIAX_P_LOG);
+        } else {
+                DEBUGA_SKYPE(&quot;skypiax_codec SUCCESS\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* BEGIN: Changes here */
</span><span class="cx"> static switch_status_t interface_exists(char *the_interface)
</span><span class="cx"> {
</span><del>-  int i;
-  int interface_id;
</del><ins>+        int i;
+        int interface_id;
</ins><span class="cx"> 
</span><del>-  if ( *the_interface == '#') { /* look by interface id or interface name */
-    the_interface++;
-    switch_assert(the_interface);
-    interface_id = atoi(the_interface);
</del><ins>+        if (*the_interface == '#') {        /* look by interface id or interface name */
+                the_interface++;
+                switch_assert(the_interface);
+                interface_id = atoi(the_interface);
</ins><span class="cx"> 
</span><del>-      /* take a number as interface id */
-    if ( interface_id &gt; 0 || (interface_id == 0 &amp;&amp; strcmp(the_interface, &quot;0&quot;) == 0 )) {
-        if (strlen(globals.SKYPIAX_INTERFACES[interface_id].name)) {
-          return SWITCH_STATUS_SUCCESS;
-        }
-    } else {
-      /* interface name */
-      for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
-        if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].name, the_interface) == 0) {
-          return SWITCH_STATUS_SUCCESS;
-          break;
-        }
-      }
-    }
-  } else { /* look by skype_user */
</del><ins>+                /* take a number as interface id */
+                if (interface_id &gt; 0 || (interface_id == 0 &amp;&amp; strcmp(the_interface, &quot;0&quot;) == 0)) {
+                        if (strlen(globals.SKYPIAX_INTERFACES[interface_id].name)) {
+                                return SWITCH_STATUS_SUCCESS;
+                        }
+                } else {
+                        /* interface name */
+                        for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
+                                if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].name, the_interface) == 0) {
+                                        return SWITCH_STATUS_SUCCESS;
+                                        break;
+                                }
+                        }
+                }
+        } else {                                        /* look by skype_user */
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-  for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-    if (strlen(globals.SKYPIAX_INTERFACES[i].skype_user)) {
-      if (strcmp(globals.SKYPIAX_INTERFACES[i].skype_user, the_interface) == 0) {
-        return SWITCH_STATUS_SUCCESS;
-      }
-    }
-  }
-  }
-  return SWITCH_STATUS_FALSE;
</del><ins>+                for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                        if (strlen(globals.SKYPIAX_INTERFACES[i].skype_user)) {
+                                if (strcmp(globals.SKYPIAX_INTERFACES[i].skype_user, the_interface) == 0) {
+                                        return SWITCH_STATUS_SUCCESS;
+                                }
+                        }
+                }
+        }
+        return SWITCH_STATUS_FALSE;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static switch_status_t remove_interface(char *the_interface)
</span><span class="cx"> {
</span><del>-  int x = 100;
-  unsigned int howmany = 8;
-  int interface_id = -1;
-  private_t *tech_pvt = NULL;
-  switch_status_t status;
</del><ins>+        int x = 100;
+        unsigned int howmany = 8;
+        int interface_id = -1;
+        private_t *tech_pvt = NULL;
+        switch_status_t status;
</ins><span class="cx"> 
</span><del>-  //running = 0;
</del><ins>+        //running = 0;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-  if ( *the_interface == '#') { /* remove by interface id or interface name */
-    the_interface++;
-    switch_assert(the_interface);
-    interface_id = atoi(the_interface);
</del><ins>+        if (*the_interface == '#') {        /* remove by interface id or interface name */
+                the_interface++;
+                switch_assert(the_interface);
+                interface_id = atoi(the_interface);
</ins><span class="cx"> 
</span><del>-    if ( interface_id &gt; 0 || (interface_id == 0 &amp;&amp; strcmp(the_interface, &quot;0&quot;) == 0 )) {
-      /* take a number as interface id */
-      tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
-    } else {
</del><ins>+                if (interface_id &gt; 0 || (interface_id == 0 &amp;&amp; strcmp(the_interface, &quot;0&quot;) == 0)) {
+                        /* take a number as interface id */
+                        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
+                } else {
</ins><span class="cx"> 
</span><del>-      for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
-        if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].name, the_interface) == 0) {
-          tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
-          break;
-        }
-      }
-    }
-  } else { /* remove by skype_user */
-    for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
-      if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].skype_user, the_interface) == 0) {
-        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
-        break;
-      }
-    }
-  }
</del><ins>+                        for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
+                                if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].name, the_interface) == 0) {
+                                        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
+                                        break;
+                                }
+                        }
+                }
+        } else {                                        /* remove by skype_user */
+                for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
+                        if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].skype_user, the_interface) == 0) {
+                                tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
+                                break;
+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (!tech_pvt) {
-    DEBUGA_SKYPE(&quot;interface '%s' does not exist\n&quot;, SKYPIAX_P_LOG,
-                 the_interface);
-    goto end;
-  }
</del><ins>+        if (!tech_pvt) {
+                DEBUGA_SKYPE(&quot;interface '%s' does not exist\n&quot;, SKYPIAX_P_LOG, the_interface);
+                goto end;
+        }
</ins><span class="cx"> 
</span><del>-  if (strlen(globals.SKYPIAX_INTERFACES[interface_id].session_uuid_str)) {
-    DEBUGA_SKYPE(&quot;interface '%s' is busy\n&quot;, SKYPIAX_P_LOG, the_interface);
-    goto end;
-  }
</del><ins>+        if (strlen(globals.SKYPIAX_INTERFACES[interface_id].session_uuid_str)) {
+                DEBUGA_SKYPE(&quot;interface '%s' is busy\n&quot;, SKYPIAX_P_LOG, the_interface);
+                goto end;
+        }
</ins><span class="cx"> 
</span><del>-  globals.SKYPIAX_INTERFACES[interface_id].running=0;
</del><ins>+        globals.SKYPIAX_INTERFACES[interface_id].running = 0;
</ins><span class="cx"> 
</span><del>-  if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
</del><ins>+        if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
</ins><span class="cx"> #ifdef WIN32
</span><del>-    switch_file_write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, &amp;howmany); // let's the controldev_thread die
</del><ins>+                switch_file_write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, &amp;howmany);        // let's the controldev_thread die
</ins><span class="cx"> #else /* WIN32 */
</span><del>-    howmany = write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, howmany);
</del><ins>+                howmany = write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, howmany);
</ins><span class="cx"> #endif /* WIN32 */
</span><del>-  }
</del><ins>+        }
</ins><span class="cx"> 
</span><del>-  if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
</del><ins>+        if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
</ins><span class="cx"> #ifdef WIN32
</span><del>-    if (SendMessage(tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) {    // let's the skypiax_api_thread_func die
-      DEBUGA_SKYPE
-        (&quot;got FALSE here, thread probably was already dead. GetLastError returned: %d\n&quot;,
-         SKYPIAX_P_LOG, GetLastError());
-      globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
-    }
</del><ins>+                if (SendMessage(tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) {        // let's the skypiax_api_thread_func die
+                        DEBUGA_SKYPE(&quot;got FALSE here, thread probably was already dead. GetLastError returned: %d\n&quot;, SKYPIAX_P_LOG, GetLastError());
+                        globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
+                }
</ins><span class="cx"> #else
</span><del>-    XEvent e;
-    Atom atom1 =
-      XInternAtom(tech_pvt-&gt;SkypiaxHandles.disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
-    memset(&amp;e, 0, sizeof(e));
-    e.xclient.type = ClientMessage;
-    e.xclient.message_type = atom1; /*  leading message */
-    e.xclient.display = tech_pvt-&gt;SkypiaxHandles.disp;
-    e.xclient.window = tech_pvt-&gt;SkypiaxHandles.skype_win;
-    e.xclient.format = 8;
</del><ins>+                XEvent e;
+                Atom atom1 = XInternAtom(tech_pvt-&gt;SkypiaxHandles.disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
+                memset(&amp;e, 0, sizeof(e));
+                e.xclient.type = ClientMessage;
+                e.xclient.message_type = atom1;        /*  leading message */
+                e.xclient.display = tech_pvt-&gt;SkypiaxHandles.disp;
+                e.xclient.window = tech_pvt-&gt;SkypiaxHandles.skype_win;
+                e.xclient.format = 8;
</ins><span class="cx"> 
</span><del>-    XSendEvent(tech_pvt-&gt;SkypiaxHandles.disp, tech_pvt-&gt;SkypiaxHandles.win, False, 0, &amp;e);
-    XSync(tech_pvt-&gt;SkypiaxHandles.disp, False);
</del><ins>+                XSendEvent(tech_pvt-&gt;SkypiaxHandles.disp, tech_pvt-&gt;SkypiaxHandles.win, False, 0, &amp;e);
+                XSync(tech_pvt-&gt;SkypiaxHandles.disp, False);
</ins><span class="cx"> #endif
</span><del>-  }
</del><ins>+        }
</ins><span class="cx"> 
</span><del>-  while (x) {                  
-    x--;
-    switch_yield(20000);
-  }
</del><ins>+        while (x) {
+                x--;
+                switch_yield(20000);
+        }
</ins><span class="cx"> 
</span><del>-  if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
-    switch_thread_join(&amp;status,
-                       globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread);
-  }
</del><ins>+        if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
+                switch_thread_join(&amp;status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread);
+        }
</ins><span class="cx"> 
</span><del>-  if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
-    switch_thread_join(&amp;status,
-                       globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
-  }
</del><ins>+        if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
+                switch_thread_join(&amp;status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
+        }
</ins><span class="cx"> 
</span><del>-  switch_mutex_lock(globals.mutex);
-  if(globals.sk_console == &amp;globals.SKYPIAX_INTERFACES[interface_id]){
-        DEBUGA_SKYPE(&quot;interface '%s' no more console\n&quot;, SKYPIAX_P_LOG, the_interface);
-        globals.sk_console = NULL;
-  } else {
-        DEBUGA_SKYPE(&quot;interface '%s' STILL console\n&quot;, SKYPIAX_P_LOG, the_interface);
-  }
-  memset(&amp;globals.SKYPIAX_INTERFACES[interface_id], '\0', sizeof(private_t));
-  globals.real_interfaces--;
-  switch_mutex_unlock(globals.mutex);
</del><ins>+        switch_mutex_lock(globals.mutex);
+        if (globals.sk_console == &amp;globals.SKYPIAX_INTERFACES[interface_id]) {
+                DEBUGA_SKYPE(&quot;interface '%s' no more console\n&quot;, SKYPIAX_P_LOG, the_interface);
+                globals.sk_console = NULL;
+        } else {
+                DEBUGA_SKYPE(&quot;interface '%s' STILL console\n&quot;, SKYPIAX_P_LOG, the_interface);
+        }
+        memset(&amp;globals.SKYPIAX_INTERFACES[interface_id], '\0', sizeof(private_t));
+        globals.real_interfaces--;
+        switch_mutex_unlock(globals.mutex);
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;interface '%s' deleted successfully\n&quot;, SKYPIAX_P_LOG,
-               the_interface);
-  globals.SKYPIAX_INTERFACES[interface_id].running=1;
-end:
-  //running = 1;
-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        DEBUGA_SKYPE(&quot;interface '%s' deleted successfully\n&quot;, SKYPIAX_P_LOG, the_interface);
+        globals.SKYPIAX_INTERFACES[interface_id].running = 1;
+  end:
+        //running = 1;
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* END: Changes here */
</span><span class="lines">@@ -374,1659 +354,1561 @@
</span><span class="cx">    returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
</span><span class="cx">    so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
</span><span class="cx"> */
</span><del>-static switch_status_t channel_on_init(switch_core_session_t * session)
</del><ins>+static switch_status_t channel_on_init(switch_core_session_t *session)
</ins><span class="cx"> {
</span><del>-  switch_channel_t *channel;
-  private_t *tech_pvt = NULL;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  tech_pvt = switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  channel = switch_core_session_get_channel(session);
-  switch_assert(channel != NULL);
-  switch_set_flag_locked(tech_pvt, TFLAG_IO);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel != NULL);
+        switch_set_flag_locked(tech_pvt, TFLAG_IO);
</ins><span class="cx"> 
</span><del>-  /* Move channel's state machine to ROUTING. This means the call is trying
-     to get from the initial start where the call because, to the point
-     where a destination has been identified. If the channel is simply
-     left in the initial state, nothing will happen. */
-  switch_channel_set_state(channel, CS_ROUTING);
-  switch_mutex_lock(globals.mutex);
-  globals.calls++;
</del><ins>+        /* Move channel's state machine to ROUTING. This means the call is trying
+           to get from the initial start where the call because, to the point
+           where a destination has been identified. If the channel is simply
+           left in the initial state, nothing will happen. */
+        switch_channel_set_state(channel, CS_ROUTING);
+        switch_mutex_lock(globals.mutex);
+        globals.calls++;
</ins><span class="cx"> 
</span><del>-  switch_mutex_unlock(globals.mutex);
</del><ins>+        switch_mutex_unlock(globals.mutex);
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;%s CHANNEL INIT\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        DEBUGA_SKYPE(&quot;%s CHANNEL INIT\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_on_destroy(switch_core_session_t * session)
</del><ins>+static switch_status_t channel_on_destroy(switch_core_session_t *session)
</ins><span class="cx"> {
</span><del>-  //switch_channel_t *channel = NULL;
-  private_t *tech_pvt = NULL;
</del><ins>+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  //channel = switch_core_session_get_channel(session);
-  //switch_assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
</ins><span class="cx"> 
</span><del>-  tech_pvt = switch_core_session_get_private(session);
</del><ins>+        if (tech_pvt) {
+                if (switch_core_codec_ready(&amp;tech_pvt-&gt;read_codec)) {
+                        switch_core_codec_destroy(&amp;tech_pvt-&gt;read_codec);
+                }
</ins><span class="cx"> 
</span><del>-  if (tech_pvt) {
-    if (switch_core_codec_ready(&amp;tech_pvt-&gt;read_codec)) {
-      switch_core_codec_destroy(&amp;tech_pvt-&gt;read_codec);
-    }
</del><ins>+                if (switch_core_codec_ready(&amp;tech_pvt-&gt;write_codec)) {
+                        switch_core_codec_destroy(&amp;tech_pvt-&gt;write_codec);
+                }
+                switch_core_session_set_private(session, NULL);
+        }
</ins><span class="cx"> 
</span><del>-    if (switch_core_codec_ready(&amp;tech_pvt-&gt;write_codec)) {
-      switch_core_codec_destroy(&amp;tech_pvt-&gt;write_codec);
-    }
-  }
-
-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_on_hangup(switch_core_session_t * session)
</del><ins>+static switch_status_t channel_on_hangup(switch_core_session_t *session)
</ins><span class="cx"> {
</span><del>-  switch_channel_t *channel = NULL;
-  private_t *tech_pvt = NULL;
-  char msg_to_skype[256];
</del><ins>+        switch_channel_t *channel = NULL;
+        private_t *tech_pvt = NULL;
+        char msg_to_skype[256];
</ins><span class="cx"> 
</span><del>-  channel = switch_core_session_get_channel(session);
-  switch_assert(channel != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel != NULL);
</ins><span class="cx"> 
</span><del>-  tech_pvt = switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-  switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
-  //switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
</del><ins>+        switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+        //switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
</ins><span class="cx"> 
</span><del>-  if (strlen(tech_pvt-&gt;skype_call_id)) {
-    //switch_thread_cond_signal(tech_pvt-&gt;cond);
-    DEBUGA_SKYPE(&quot;hanging up skype call: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id);
-    sprintf(msg_to_skype, &quot;ALTER CALL %s HANGUP&quot;, tech_pvt-&gt;skype_call_id);
-    skypiax_signaling_write(tech_pvt, msg_to_skype);
-  }
</del><ins>+        if (strlen(tech_pvt-&gt;skype_call_id)) {
+                //switch_thread_cond_signal(tech_pvt-&gt;cond);
+                DEBUGA_SKYPE(&quot;hanging up skype call: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id);
+                sprintf(msg_to_skype, &quot;ALTER CALL %s HANGUP&quot;, tech_pvt-&gt;skype_call_id);
+                skypiax_signaling_write(tech_pvt, msg_to_skype);
+        }
+        //memset(tech_pvt-&gt;session_uuid_str, '\0', sizeof(tech_pvt-&gt;session_uuid_str));
+        *tech_pvt-&gt;session_uuid_str = '\0';
+        DEBUGA_SKYPE(&quot;%s CHANNEL HANGUP\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
+        switch_mutex_lock(globals.mutex);
+        globals.calls--;
+        if (globals.calls &lt; 0) {
+                globals.calls = 0;
+        }
+        switch_mutex_unlock(globals.mutex);
</ins><span class="cx"> 
</span><del>-  memset(tech_pvt-&gt;session_uuid_str, '\0', sizeof(tech_pvt-&gt;session_uuid_str));
-  DEBUGA_SKYPE(&quot;%s CHANNEL HANGUP\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
-  switch_mutex_lock(globals.mutex);
-  globals.calls--;
-  if (globals.calls &lt; 0) {
-    globals.calls = 0;
-  }
-  switch_mutex_unlock(globals.mutex);
-
-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_on_routing(switch_core_session_t * session)
</del><ins>+static switch_status_t channel_on_routing(switch_core_session_t *session)
</ins><span class="cx"> {
</span><del>-  switch_channel_t *channel = NULL;
-  private_t *tech_pvt = NULL;
</del><ins>+        switch_channel_t *channel = NULL;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  channel = switch_core_session_get_channel(session);
-  switch_assert(channel != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel != NULL);
</ins><span class="cx"> 
</span><del>-  tech_pvt = switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;%s CHANNEL ROUTING\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</del><ins>+        DEBUGA_SKYPE(&quot;%s CHANNEL ROUTING\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_on_execute(switch_core_session_t * session)
</del><ins>+static switch_status_t channel_on_execute(switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx"> 
</span><del>-  switch_channel_t *channel = NULL;
-  private_t *tech_pvt = NULL;
</del><ins>+        switch_channel_t *channel = NULL;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  channel = switch_core_session_get_channel(session);
-  switch_assert(channel != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel != NULL);
</ins><span class="cx"> 
</span><del>-  tech_pvt = switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;%s CHANNEL EXECUTE\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</del><ins>+        DEBUGA_SKYPE(&quot;%s CHANNEL EXECUTE\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig)
</del><ins>+static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
</ins><span class="cx"> {
</span><del>-  switch_channel_t *channel = NULL;
-  private_t *tech_pvt = NULL;
</del><ins>+        switch_channel_t *channel = NULL;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  channel = switch_core_session_get_channel(session);
-  switch_assert(channel != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel != NULL);
</ins><span class="cx"> 
</span><del>-  tech_pvt = switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  switch (sig) {
-  case SWITCH_SIG_KILL:
-    DEBUGA_SKYPE(&quot;%s CHANNEL got SWITCH_SIG_KILL\n&quot;, SKYPIAX_P_LOG,
-                 switch_channel_get_name(channel));
-    switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-    switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
-    switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
-    break;
-  case SWITCH_SIG_BREAK:
-    DEBUGA_SKYPE(&quot;%s CHANNEL got SWITCH_SIG_BREAK\n&quot;, SKYPIAX_P_LOG,
-                 switch_channel_get_name(channel));
-    switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
-    break;
-  default:
-    break;
-  }
</del><ins>+        switch (sig) {
+        case SWITCH_SIG_KILL:
+                DEBUGA_SKYPE(&quot;%s CHANNEL got SWITCH_SIG_KILL\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
+                switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+                switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+                switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
+                break;
+        case SWITCH_SIG_BREAK:
+                DEBUGA_SKYPE(&quot;%s CHANNEL got SWITCH_SIG_BREAK\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
+                switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
+                break;
+        default:
+                break;
+        }
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_on_exchange_media(switch_core_session_t * session)
</del><ins>+static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
</ins><span class="cx"> {
</span><del>-  private_t *tech_pvt = NULL;
-  DEBUGA_SKYPE(&quot;CHANNEL LOOPBACK\n&quot;, SKYPIAX_P_LOG);
-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        private_t *tech_pvt = NULL;
+        DEBUGA_SKYPE(&quot;CHANNEL LOOPBACK\n&quot;, SKYPIAX_P_LOG);
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_on_soft_execute(switch_core_session_t * session)
</del><ins>+static switch_status_t channel_on_soft_execute(switch_core_session_t *session)
</ins><span class="cx"> {
</span><del>-  private_t *tech_pvt = NULL;
-  DEBUGA_SKYPE(&quot;CHANNEL TRANSMIT\n&quot;, SKYPIAX_P_LOG);
-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        private_t *tech_pvt = NULL;
+        DEBUGA_SKYPE(&quot;CHANNEL TRANSMIT\n&quot;, SKYPIAX_P_LOG);
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_send_dtmf(switch_core_session_t * session,
-                                         const switch_dtmf_t * dtmf)
</del><ins>+static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
</ins><span class="cx"> {
</span><del>-  private_t *tech_pvt = switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        private_t *tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;DTMF: %c\n&quot;, SKYPIAX_P_LOG, dtmf-&gt;digit);
</del><ins>+        DEBUGA_SKYPE(&quot;DTMF: %c\n&quot;, SKYPIAX_P_LOG, dtmf-&gt;digit);
</ins><span class="cx"> 
</span><del>-  skypiax_senddigit(tech_pvt, dtmf-&gt;digit);
</del><ins>+        skypiax_senddigit(tech_pvt, dtmf-&gt;digit);
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_read_frame(switch_core_session_t * session,
-                                          switch_frame_t ** frame, switch_io_flag_t flags,
-                                          int stream_id)
</del><ins>+static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
</ins><span class="cx"> {
</span><del>-  switch_channel_t *channel = NULL;
-  private_t *tech_pvt = NULL;
-  switch_byte_t *data;
</del><ins>+        switch_channel_t *channel = NULL;
+        private_t *tech_pvt = NULL;
+        switch_byte_t *data;
</ins><span class="cx"> 
</span><del>-  channel = switch_core_session_get_channel(session);
-  switch_assert(channel != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel != NULL);
</ins><span class="cx"> 
</span><del>-  tech_pvt = switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
-  tech_pvt-&gt;read_frame.flags = SFF_NONE;
-  *frame = NULL;
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  if (!skypiax_audio_read(tech_pvt)) {
</del><ins>+        if (!switch_channel_ready(channel) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
+                ERRORA(&quot;CIAPA \n&quot;, SKYPIAX_P_LOG);
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx"> 
</span><del>-    ERRORA(&quot;skypiax_audio_read ERROR\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        tech_pvt-&gt;read_frame.flags = SFF_NONE;
+        *frame = NULL;
</ins><span class="cx"> 
</span><del>-  } else {
-    switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
-  }
</del><ins>+        if (!skypiax_audio_read(tech_pvt)) {
</ins><span class="cx"> 
</span><del>-  while (switch_test_flag(tech_pvt, TFLAG_IO)) {
-    if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
-      switch_clear_flag(tech_pvt, TFLAG_BREAK);
-      DEBUGA_SKYPE(&quot;CHANNEL READ FRAME goto CNG\n&quot;, SKYPIAX_P_LOG);
-      goto cng;
-    }
</del><ins>+                ERRORA(&quot;skypiax_audio_read ERROR\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-    if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
-      DEBUGA_SKYPE(&quot;CHANNEL READ FRAME not IO\n&quot;, SKYPIAX_P_LOG);
-      return SWITCH_STATUS_FALSE;
-    }
</del><ins>+        } else {
+                switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
+        }
</ins><span class="cx"> 
</span><del>-    if (switch_test_flag(tech_pvt, TFLAG_IO) &amp;&amp; switch_test_flag(tech_pvt, TFLAG_VOICE)) {
-      switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
-      if (!tech_pvt-&gt;read_frame.datalen) {
-        DEBUGA_SKYPE(&quot;CHANNEL READ CONTINUE\n&quot;, SKYPIAX_P_LOG);
-        continue;
-      }
-      *frame = &amp;tech_pvt-&gt;read_frame;
</del><ins>+        while (switch_test_flag(tech_pvt, TFLAG_IO)) {
+                if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
+                        switch_clear_flag(tech_pvt, TFLAG_BREAK);
+                        DEBUGA_SKYPE(&quot;CHANNEL READ FRAME goto CNG\n&quot;, SKYPIAX_P_LOG);
+                        goto cng;
+                }
+
+                if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
+                        DEBUGA_SKYPE(&quot;CHANNEL READ FRAME not IO\n&quot;, SKYPIAX_P_LOG);
+                        return SWITCH_STATUS_FALSE;
+                }
+
+                if (switch_test_flag(tech_pvt, TFLAG_IO) &amp;&amp; switch_test_flag(tech_pvt, TFLAG_VOICE)) {
+                        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+                        if (!tech_pvt-&gt;read_frame.datalen) {
+                                DEBUGA_SKYPE(&quot;CHANNEL READ CONTINUE\n&quot;, SKYPIAX_P_LOG);
+                                continue;
+                        }
+                        *frame = &amp;tech_pvt-&gt;read_frame;
</ins><span class="cx"> #ifdef BIGENDIAN
</span><del>-      if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
-        switch_swap_linear((*frame)-&gt;data, (int) (*frame)-&gt;datalen / 2);
-      }
</del><ins>+                        if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
+                                switch_swap_linear((*frame)-&gt;data, (int) (*frame)-&gt;datalen / 2);
+                        }
</ins><span class="cx"> #endif
</span><del>-      return SWITCH_STATUS_SUCCESS;
-    }
</del><ins>+                        return SWITCH_STATUS_SUCCESS;
+                }
</ins><span class="cx"> 
</span><del>-    DEBUGA_SKYPE(&quot;CHANNEL READ no TFLAG_IO\n&quot;, SKYPIAX_P_LOG);
-    return SWITCH_STATUS_FALSE;
</del><ins>+                DEBUGA_SKYPE(&quot;CHANNEL READ no TFLAG_IO\n&quot;, SKYPIAX_P_LOG);
+                return SWITCH_STATUS_FALSE;
</ins><span class="cx"> 
</span><del>-  }
</del><ins>+        }
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;CHANNEL READ FALSE\n&quot;, SKYPIAX_P_LOG);
-  return SWITCH_STATUS_FALSE;
</del><ins>+        DEBUGA_SKYPE(&quot;CHANNEL READ FALSE\n&quot;, SKYPIAX_P_LOG);
+        return SWITCH_STATUS_FALSE;
</ins><span class="cx"> 
</span><del>-cng:
-  data = (switch_byte_t *) tech_pvt-&gt;read_frame.data;
-  data[0] = 65;
-  data[1] = 0;
-  tech_pvt-&gt;read_frame.datalen = 2;
-  tech_pvt-&gt;read_frame.flags = SFF_CNG;
-  *frame = &amp;tech_pvt-&gt;read_frame;
-  return SWITCH_STATUS_SUCCESS;
</del><ins>+  cng:
+        data = (switch_byte_t *) tech_pvt-&gt;read_frame.data;
+        data[0] = 65;
+        data[1] = 0;
+        tech_pvt-&gt;read_frame.datalen = 2;
+        tech_pvt-&gt;read_frame.flags = SFF_CNG;
+        *frame = &amp;tech_pvt-&gt;read_frame;
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_write_frame(switch_core_session_t * session,
-                                           switch_frame_t * frame, switch_io_flag_t flags,
-                                           int stream_id)
</del><ins>+static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
</ins><span class="cx"> {
</span><del>-  switch_channel_t *channel = NULL;
-  private_t *tech_pvt = NULL;
-  unsigned int sent;
</del><ins>+        switch_channel_t *channel = NULL;
+        private_t *tech_pvt = NULL;
+        unsigned int sent;
</ins><span class="cx"> 
</span><del>-  channel = switch_core_session_get_channel(session);
-  switch_assert(channel != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel != NULL);
</ins><span class="cx"> 
</span><del>-  tech_pvt = switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
-    ERRORA(&quot;CIAPA \n&quot;, SKYPIAX_P_LOG);
-    return SWITCH_STATUS_FALSE;
-  }
</del><ins>+        if (!switch_channel_ready(channel) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
+                ERRORA(&quot;CIAPA \n&quot;, SKYPIAX_P_LOG);
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx"> #ifdef BIGENDIAN
</span><del>-  if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
-    switch_swap_linear(frame-&gt;data, (int) frame-&gt;datalen / 2);
-  }
</del><ins>+        if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
+                switch_swap_linear(frame-&gt;data, (int) frame-&gt;datalen / 2);
+        }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-  sent = frame-&gt;datalen;
</del><ins>+        sent = frame-&gt;datalen;
</ins><span class="cx"> #ifdef WIN32
</span><del>-  switch_file_write(tech_pvt-&gt;audioskypepipe[1], frame-&gt;data, &amp;sent);
</del><ins>+        switch_file_write(tech_pvt-&gt;audioskypepipe[1], frame-&gt;data, &amp;sent);
</ins><span class="cx"> #else /* WIN32 */
</span><del>-  sent = write(tech_pvt-&gt;audioskypepipe[1], frame-&gt;data, sent);
</del><ins>+        sent = write(tech_pvt-&gt;audioskypepipe[1], frame-&gt;data, sent);
</ins><span class="cx"> #endif /* WIN32 */
</span><del>-  if (sent != frame-&gt;datalen &amp;&amp; sent != -1) {
-    DEBUGA_SKYPE(&quot;CLI PIPE write %d\n&quot;, SKYPIAX_P_LOG, sent);
-  }
</del><ins>+        if (sent != frame-&gt;datalen &amp;&amp; sent != -1) {
+                DEBUGA_SKYPE(&quot;CLI PIPE write %d\n&quot;, SKYPIAX_P_LOG, sent);
+        }
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_answer_channel(switch_core_session_t * session)
</del><ins>+static switch_status_t channel_answer_channel(switch_core_session_t *session)
</ins><span class="cx"> {
</span><del>-  private_t *tech_pvt;
-  switch_channel_t *channel = NULL;
</del><ins>+        private_t *tech_pvt;
+        switch_channel_t *channel = NULL;
</ins><span class="cx"> 
</span><del>-  channel = switch_core_session_get_channel(session);
-  switch_assert(channel != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel != NULL);
</ins><span class="cx"> 
</span><del>-  tech_pvt = switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;ANSWERED! \n&quot;, SKYPIAX_P_LOG);
</del><ins>+        DEBUGA_SKYPE(&quot;ANSWERED! \n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_receive_message(switch_core_session_t * session,
-                                               switch_core_session_message_t * msg)
</del><ins>+static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
</ins><span class="cx"> {
</span><del>-  switch_channel_t *channel;
-  private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx"> 
</span><del>-  channel = switch_core_session_get_channel(session);
-  switch_assert(channel != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel != NULL);
</ins><span class="cx"> 
</span><del>-  tech_pvt = (private_t *) switch_core_session_get_private(session);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        tech_pvt = (private_t *) switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  switch (msg-&gt;message_id) {
-  case SWITCH_MESSAGE_INDICATE_ANSWER:
-    {
-      DEBUGA_SKYPE(&quot;MSG_ID=%d, TO BE ANSWERED!\n&quot;, SKYPIAX_P_LOG, msg-&gt;message_id);
-      channel_answer_channel(session);
-    }
-    break;
-  default:
-    {
-      DEBUGA_SKYPE(&quot;MSG_ID=%d\n&quot;, SKYPIAX_P_LOG, msg-&gt;message_id);
-    }
-    break;
-  }
</del><ins>+        switch (msg-&gt;message_id) {
+        case SWITCH_MESSAGE_INDICATE_ANSWER:
+                {
+                        DEBUGA_SKYPE(&quot;MSG_ID=%d, TO BE ANSWERED!\n&quot;, SKYPIAX_P_LOG, msg-&gt;message_id);
+                        channel_answer_channel(session);
+                }
+                break;
+        default:
+                {
+                        DEBUGA_SKYPE(&quot;MSG_ID=%d\n&quot;, SKYPIAX_P_LOG, msg-&gt;message_id);
+                }
+                break;
+        }
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_receive_event(switch_core_session_t * session,
-                                             switch_event_t * event)
</del><ins>+static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
</ins><span class="cx"> {
</span><del>-  struct private_object *tech_pvt = switch_core_session_get_private(session);
-  char *body = switch_event_get_body(event);
-  switch_assert(tech_pvt != NULL);
</del><ins>+        struct private_object *tech_pvt = switch_core_session_get_private(session);
+        char *body = switch_event_get_body(event);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx"> 
</span><del>-  if (!body) {
-    body = &quot;&quot;;
-  }
</del><ins>+        if (!body) {
+                body = &quot;&quot;;
+        }
</ins><span class="cx"> 
</span><del>-  WARNINGA(&quot;event: |||%s|||\n&quot;, SKYPIAX_P_LOG, body);
</del><ins>+        WARNINGA(&quot;event: |||%s|||\n&quot;, SKYPIAX_P_LOG, body);
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> switch_state_handler_table_t skypiax_state_handlers = {
</span><del>-  /*.on_init */ channel_on_init,
-  /*.on_routing */ channel_on_routing,
-  /*.on_execute */ channel_on_execute,
-  /*.on_hangup */ channel_on_hangup,
-  /*.on_exchange_media */ channel_on_exchange_media,
-  /*.on_soft_execute */ channel_on_soft_execute,
-  /*.on_consume_media */ NULL,
-  /*.on_hibernate */ NULL,
-  /*.on_reset */ NULL,
-  /*.on_park */ NULL,
-  /*.on_reporting */ NULL,
-  /*.on_destroy */ channel_on_destroy
</del><ins>+        /*.on_init */ channel_on_init,
+        /*.on_routing */ channel_on_routing,
+        /*.on_execute */ channel_on_execute,
+        /*.on_hangup */ channel_on_hangup,
+        /*.on_exchange_media */ channel_on_exchange_media,
+        /*.on_soft_execute */ channel_on_soft_execute,
+        /*.on_consume_media */ NULL,
+        /*.on_hibernate */ NULL,
+        /*.on_reset */ NULL,
+        /*.on_park */ NULL,
+        /*.on_reporting */ NULL,
+        /*.on_destroy */ channel_on_destroy
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> switch_io_routines_t skypiax_io_routines = {
</span><del>-  /*.outgoing_channel */ channel_outgoing_channel,
-  /*.read_frame */ channel_read_frame,
-  /*.write_frame */ channel_write_frame,
-  /*.kill_channel */ channel_kill_channel,
-  /*.send_dtmf */ channel_send_dtmf,
-  /*.receive_message */ channel_receive_message,
-  /*.receive_event */ channel_receive_event
</del><ins>+        /*.outgoing_channel */ channel_outgoing_channel,
+        /*.read_frame */ channel_read_frame,
+        /*.write_frame */ channel_write_frame,
+        /*.kill_channel */ channel_kill_channel,
+        /*.send_dtmf */ channel_send_dtmf,
+        /*.receive_message */ channel_receive_message,
+        /*.receive_event */ channel_receive_event
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session,
-                                                    switch_event_t * var_event,
-                                                    switch_caller_profile_t *
-                                                    outbound_profile,
-                                                    switch_core_session_t ** new_session,
-                                                    switch_memory_pool_t ** pool,
-                                                    switch_originate_flag_t flags)
</del><ins>+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+                                                                                                        switch_event_t *var_event,
+                                                                                                        switch_caller_profile_t *outbound_profile,
+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
</ins><span class="cx"> {
</span><del>-  if ((*new_session =
-       switch_core_session_request(skypiax_endpoint_interface,
-                                   SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
-    private_t *tech_pvt;
-    switch_channel_t *channel;
-    switch_caller_profile_t *caller_profile;
-    char *rdest;
</del><ins>+        if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
+                private_t *tech_pvt = NULL;
+                switch_channel_t *channel;
+                switch_caller_profile_t *caller_profile;
+                char *rdest;
+                int found = 0;
+                char interface_name[256];
</ins><span class="cx"> 
</span><del>-    switch_core_session_add_stream(*new_session, NULL);
</del><ins>+                switch_core_session_add_stream(*new_session, NULL);
</ins><span class="cx"> 
</span><del>-    if ((tech_pvt =
-         (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
-      int found = 0;
-      char interface_name[256];
</del><span class="cx"> 
</span><del>-      if (!switch_strlen_zero(outbound_profile-&gt;destination_number)) {
-        int i;
-        char *slash;
</del><ins>+                if (!switch_strlen_zero(outbound_profile-&gt;destination_number)) {
+                        int i;
+                        char *slash;
</ins><span class="cx"> 
</span><del>-        switch_copy_string(interface_name, outbound_profile-&gt;destination_number, 255);
-        slash = strrchr(interface_name, '/');
-        *slash = '\0';
</del><ins>+                        switch_copy_string(interface_name, outbound_profile-&gt;destination_number, 255);
+                        slash = strrchr(interface_name, '/');
+                        *slash = '\0';
</ins><span class="cx"> 
</span><del>-  switch_mutex_lock(globals.mutex);
-        if (strncmp(&quot;ANY&quot;, interface_name, strlen(interface_name)) == 0) {
-          /* we've been asked for the &quot;ANY&quot; interface, let's find the first idle interface */
-          DEBUGA_SKYPE(&quot;Finding one available skype interface\n&quot;, SKYPIAX_P_LOG);
-          tech_pvt = find_available_skypiax_interface(NULL);
-          if (tech_pvt) found = 1;
-        } else if(strncmp(&quot;RR&quot;, interface_name, strlen(interface_name)) == 0) {
-          /* Find the first idle interface using Round Robin */
-          DEBUGA_SKYPE(&quot;Finding one available skype interface RR\n&quot;, SKYPIAX_P_LOG);
-          tech_pvt = find_available_skypiax_interface_rr();
-          if (tech_pvt) found = 1;
-        }
</del><ins>+                        switch_mutex_lock(globals.mutex);
+                        if (strncmp(&quot;ANY&quot;, interface_name, strlen(interface_name)) == 0) {
+                                /* we've been asked for the &quot;ANY&quot; interface, let's find the first idle interface */
+                                DEBUGA_SKYPE(&quot;Finding one available skype interface\n&quot;, SKYPIAX_P_LOG);
+                                tech_pvt = find_available_skypiax_interface(NULL);
+                                if (tech_pvt)
+                                        found = 1;
+                        } else if (strncmp(&quot;RR&quot;, interface_name, strlen(interface_name)) == 0) {
+                                /* Find the first idle interface using Round Robin */
+                                DEBUGA_SKYPE(&quot;Finding one available skype interface RR\n&quot;, SKYPIAX_P_LOG);
+                                tech_pvt = find_available_skypiax_interface_rr();
+                                if (tech_pvt)
+                                        found = 1;
+                        }
</ins><span class="cx"> 
</span><del>-        for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-          /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the &quot;ANY&quot; interface */
-          if (strlen(globals.SKYPIAX_INTERFACES[i].name)
-              &amp;&amp;
-              (strncmp
-               (globals.SKYPIAX_INTERFACES[i].name, interface_name,
-                strlen(interface_name)) == 0)) {
-            if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) {
-              DEBUGA_SKYPE
-                (&quot;globals.SKYPIAX_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n&quot;,
-                 SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name,
-                 globals.SKYPIAX_INTERFACES[i].session_uuid_str);
-              switch_core_session_destroy(new_session);
-  switch_mutex_unlock(globals.mutex);
-              return SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE;
-            }
</del><ins>+                        for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                                /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the &quot;ANY&quot; interface */
+                                if (strlen(globals.SKYPIAX_INTERFACES[i].name)
+                                        &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, interface_name, strlen(interface_name)) == 0)) {
+                                        if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) {
+                                                DEBUGA_SKYPE
+                                                        (&quot;globals.SKYPIAX_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n&quot;,
+                                                         SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str);
+                                                switch_core_session_destroy(new_session);
+                                                switch_mutex_unlock(globals.mutex);
+                                                return SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE;
+                                        }
</ins><span class="cx"> 
</span><del>-            DEBUGA_SKYPE(&quot;globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n&quot;, SKYPIAX_P_LOG,
-                         i, globals.SKYPIAX_INTERFACES[i].name);
-            tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
-            found = 1;
-            break;
-          }
</del><ins>+                                        DEBUGA_SKYPE(&quot;globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n&quot;, SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name);
+                                        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
+                                        found = 1;
+                                        break;
+                                }
</ins><span class="cx"> 
</span><del>-        }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-      } else {
-        ERRORA(&quot;Doh! no destination number?\n&quot;, SKYPIAX_P_LOG);
-        switch_core_session_destroy(new_session);
-        return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
-      }
</del><ins>+                } else {
+                        ERRORA(&quot;Doh! no destination number?\n&quot;, SKYPIAX_P_LOG);
+                        switch_core_session_destroy(new_session);
+                        return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+                }
</ins><span class="cx"> 
</span><del>-      if (!found) {
-        ERRORA(&quot;Doh! no matching interface for |||%s|||?\n&quot;, SKYPIAX_P_LOG,
-               interface_name);
-        switch_core_session_destroy(new_session);
-  switch_mutex_unlock(globals.mutex);
-        return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</del><ins>+                if (!found) {
+                        ERRORA(&quot;Doh! no matching interface for |||%s|||?\n&quot;, SKYPIAX_P_LOG, interface_name);
+                        switch_core_session_destroy(new_session);
+                        switch_mutex_unlock(globals.mutex);
+                        return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+                }
</ins><span class="cx"> 
</span><del>-      }
-      channel = switch_core_session_get_channel(*new_session);
-      skypiax_tech_init(tech_pvt, *new_session);
-    } else {
-      ERRORA(&quot;Hey where is my memory pool?\n&quot;, SKYPIAX_P_LOG);
-      switch_core_session_destroy(new_session);
-      return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
-    }
</del><ins>+                channel = switch_core_session_get_channel(*new_session);
+                skypiax_tech_init(tech_pvt, *new_session);
</ins><span class="cx"> 
</span><del>-    if (outbound_profile) {
-      char name[128];
</del><span class="cx"> 
</span><del>-      snprintf(name, sizeof(name), &quot;skypiax/%s&quot;, outbound_profile-&gt;destination_number);
-      //snprintf(name, sizeof(name), &quot;skypiax/%s&quot;, tech_pvt-&gt;name);
-      switch_channel_set_name(channel, name);
-      caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
-      switch_channel_set_caller_profile(channel, caller_profile);
-      tech_pvt-&gt;caller_profile = caller_profile;
-    } else {
-      ERRORA(&quot;Doh! no caller profile\n&quot;, SKYPIAX_P_LOG);
-      switch_core_session_destroy(new_session);
-  switch_mutex_unlock(globals.mutex);
-      return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
-    }
</del><ins>+                if (outbound_profile) {
+                        char name[128];
</ins><span class="cx"> 
</span><del>-    rdest = strchr(caller_profile-&gt;destination_number, '/');
-    *rdest++ = '\0';
</del><ins>+                        snprintf(name, sizeof(name), &quot;skypiax/%s&quot;, outbound_profile-&gt;destination_number);
+                        //snprintf(name, sizeof(name), &quot;skypiax/%s&quot;, tech_pvt-&gt;name);
+                        switch_channel_set_name(channel, name);
+                        caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
+                        switch_channel_set_caller_profile(channel, caller_profile);
+                        tech_pvt-&gt;caller_profile = caller_profile;
+                } else {
+                        ERRORA(&quot;Doh! no caller profile\n&quot;, SKYPIAX_P_LOG);
+                        switch_core_session_destroy(new_session);
+                        switch_mutex_unlock(globals.mutex);
+                        return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+                }
</ins><span class="cx"> 
</span><del>-    skypiax_call(tech_pvt, rdest, 30);
</del><ins>+                rdest = strchr(caller_profile-&gt;destination_number, '/');
+                *rdest++ = '\0';
</ins><span class="cx"> 
</span><del>-    switch_copy_string(tech_pvt-&gt;session_uuid_str,
-                       switch_core_session_get_uuid(*new_session),
-                       sizeof(tech_pvt-&gt;session_uuid_str));
-    caller_profile = tech_pvt-&gt;caller_profile;
-    caller_profile-&gt;destination_number = rdest;
</del><ins>+                skypiax_call(tech_pvt, rdest, 30);
</ins><span class="cx"> 
</span><del>-    switch_channel_set_flag(channel, CF_OUTBOUND);
-    switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
-    switch_channel_set_state(channel, CS_INIT);
-  switch_mutex_unlock(globals.mutex);
-    return SWITCH_CAUSE_SUCCESS;
-  }
</del><ins>+                switch_copy_string(tech_pvt-&gt;session_uuid_str, switch_core_session_get_uuid(*new_session), sizeof(tech_pvt-&gt;session_uuid_str));
+                caller_profile = tech_pvt-&gt;caller_profile;
+                caller_profile-&gt;destination_number = rdest;
</ins><span class="cx"> 
</span><del>-  return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</del><ins>+                switch_channel_set_flag(channel, CF_OUTBOUND);
+                switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
+                switch_channel_set_state(channel, CS_INIT);
+                switch_mutex_unlock(globals.mutex);
+                return SWITCH_CAUSE_SUCCESS;
+        }
+
+        return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /*!
</span><span class="cx">  * \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 skypiax_signaling_read function
</span><span class="cx">  *
</span><span class="cx">  */
</span><del>-static void *SWITCH_THREAD_FUNC skypiax_signaling_thread_func(switch_thread_t * thread,
-                                                              void *obj)
</del><ins>+static void *SWITCH_THREAD_FUNC skypiax_signaling_thread_func(switch_thread_t * thread, void *obj)
</ins><span class="cx"> {
</span><del>-  private_t *tech_pvt = obj;
-  int res;
-  int forever = 1;
</del><ins>+        private_t *tech_pvt = obj;
+        int res;
+        int forever = 1;
</ins><span class="cx"> 
</span><del>-  if (!tech_pvt) return NULL;
</del><ins>+        if (!tech_pvt)
+                return NULL;
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;In skypiax_signaling_thread_func: started, p=%p\n&quot;, SKYPIAX_P_LOG,
-               (void *) tech_pvt);
</del><ins>+        DEBUGA_SKYPE(&quot;In skypiax_signaling_thread_func: started, p=%p\n&quot;, SKYPIAX_P_LOG, (void *) tech_pvt);
</ins><span class="cx"> 
</span><del>-  while (forever) {
-    if (!(running &amp;&amp; tech_pvt-&gt;running))
-      break;
-    res = skypiax_signaling_read(tech_pvt);
-    if (res == CALLFLOW_INCOMING_HANGUP) {
-      switch_core_session_t *session = NULL;
-      //private_t *tech_pvt = NULL;
-      switch_channel_t *channel = NULL;
</del><ins>+        while (forever) {
+                if (!(running &amp;&amp; tech_pvt-&gt;running))
+                        break;
+                res = skypiax_signaling_read(tech_pvt);
+                if (res == CALLFLOW_INCOMING_HANGUP) {
+                        switch_core_session_t *session = NULL;
+                        //private_t *tech_pvt = NULL;
+                        switch_channel_t *channel = NULL;
</ins><span class="cx"> 
</span><del>-      DEBUGA_SKYPE(&quot;skype call ended\n&quot;, SKYPIAX_P_LOG);
</del><ins>+                        DEBUGA_SKYPE(&quot;skype call ended\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-      if (tech_pvt) {
-        session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
</del><ins>+                        if (tech_pvt) {
+                                session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
</ins><span class="cx"> 
</span><del>-        if (session) {
-          channel = switch_core_session_get_channel(session);
-          if (channel) {
-            switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-            switch_core_session_rwunlock(session);
-          } else {
-            ERRORA(&quot;no channel?\n&quot;, SKYPIAX_P_LOG);
-            switch_core_session_rwunlock(session);
-          }
-        } else {
-          DEBUGA_SKYPE(&quot;no session\n&quot;, SKYPIAX_P_LOG);
-        }
-        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-        memset(tech_pvt-&gt;session_uuid_str, '\0', sizeof(tech_pvt-&gt;session_uuid_str));
-      } else {
-        ERRORA(&quot;no tech_pvt?\n&quot;, SKYPIAX_P_LOG);
-      }
-    }
-  }
-  return NULL;
</del><ins>+                                if (session) {
+                                        channel = switch_core_session_get_channel(session);
+                                        if (channel) {
+                                                switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+                                                switch_core_session_rwunlock(session);
+                                        } else {
+                                                ERRORA(&quot;no channel?\n&quot;, SKYPIAX_P_LOG);
+                                                switch_core_session_rwunlock(session);
+                                        }
+                                } else {
+                                        DEBUGA_SKYPE(&quot;no session\n&quot;, SKYPIAX_P_LOG);
+                                }
+                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                *tech_pvt-&gt;session_uuid_str = '\0';
+                                //memset(tech_pvt-&gt;session_uuid_str, '\0', sizeof(tech_pvt-&gt;session_uuid_str));
+                        } else {
+                                ERRORA(&quot;no tech_pvt?\n&quot;, SKYPIAX_P_LOG);
+                        }
+                }
+        }
+        return NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* BEGIN: Changes heres */
</span><span class="cx"> static switch_status_t load_config(int reload_type)
</span><span class="cx"> /* END: Changes heres */
</span><span class="cx"> {
</span><del>-  char *cf = &quot;skypiax.conf&quot;;
-  switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
-  private_t *tech_pvt = NULL;
</del><ins>+        char *cf = &quot;skypiax.conf&quot;;
+        switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  switch_mutex_init(&amp;globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool);
-  if (!(xml = switch_xml_open_cfg(cf, &amp;cfg, NULL))) {
-    ERRORA(&quot;open of %s failed\n&quot;, SKYPIAX_P_LOG, cf);
-    running = 0;
-        switch_xml_free(xml);
-    return SWITCH_STATUS_TERM;
-  }
</del><ins>+        switch_mutex_init(&amp;globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool);
+        if (!(xml = switch_xml_open_cfg(cf, &amp;cfg, NULL))) {
+                ERRORA(&quot;open of %s failed\n&quot;, SKYPIAX_P_LOG, cf);
+                running = 0;
+                switch_xml_free(xml);
+                return SWITCH_STATUS_TERM;
+        }
</ins><span class="cx"> 
</span><del>-  switch_mutex_lock(globals.mutex);
-  if ((global_settings = switch_xml_child(cfg, &quot;global_settings&quot;))) {
-    for (param = switch_xml_child(global_settings, &quot;param&quot;); param; param = param-&gt;next) {
-      char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
-      char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</del><ins>+        switch_mutex_lock(globals.mutex);
+        if ((global_settings = switch_xml_child(cfg, &quot;global_settings&quot;))) {
+                for (param = switch_xml_child(global_settings, &quot;param&quot;); param; param = param-&gt;next) {
+                        char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
+                        char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</ins><span class="cx"> 
</span><del>-      if (!strcasecmp(var, &quot;debug&quot;)) {
-        DEBUGA_SKYPE(&quot;globals.debug=%d\n&quot;, SKYPIAX_P_LOG, globals.debug);
-        globals.debug = atoi(val);
-        DEBUGA_SKYPE(&quot;globals.debug=%d\n&quot;, SKYPIAX_P_LOG, globals.debug);
-      } else if (!strcasecmp(var, &quot;hold-music&quot;)) {
-        switch_set_string(globals.hold_music, val);
-        DEBUGA_SKYPE(&quot;globals.hold_music=%s\n&quot;, SKYPIAX_P_LOG, globals.hold_music);
-      } else if (!strcmp(var, &quot;port&quot;)) {
-        globals.port = atoi(val);
-        DEBUGA_SKYPE(&quot;globals.port=%d\n&quot;, SKYPIAX_P_LOG, globals.port);
-      } else if (!strcmp(var, &quot;codec-master&quot;)) {
-        if (!strcasecmp(val, &quot;us&quot;)) {
-          switch_set_flag(&amp;globals, GFLAG_MY_CODEC_PREFS);
-        }
-        DEBUGA_SKYPE(&quot;codec-master globals.debug=%d\n&quot;, SKYPIAX_P_LOG, globals.debug);
-      } else if (!strcmp(var, &quot;dialplan&quot;)) {
-        set_global_dialplan(val);
-        DEBUGA_SKYPE(&quot;globals.dialplan=%s\n&quot;, SKYPIAX_P_LOG, globals.dialplan);
-      } else if (!strcmp(var, &quot;destination&quot;)) {
-        set_global_destination(val);
-        DEBUGA_SKYPE(&quot;globals.destination=%s\n&quot;, SKYPIAX_P_LOG, globals.destination);
-      } else if (!strcmp(var, &quot;context&quot;)) {
-        set_global_context(val);
-        DEBUGA_SKYPE(&quot;globals.context=%s\n&quot;, SKYPIAX_P_LOG, globals.context);
-      } else if (!strcmp(var, &quot;codec-prefs&quot;)) {
-        set_global_codec_string(val);
-        DEBUGA_SKYPE(&quot;globals.codec_string=%s\n&quot;, SKYPIAX_P_LOG, globals.codec_string);
-        globals.codec_order_last =
-          switch_separate_string(globals.codec_string, ',', globals.codec_order,
-                                 SWITCH_MAX_CODECS);
-      } else if (!strcmp(var, &quot;codec-rates&quot;)) {
-        set_global_codec_rates_string(val);
-        DEBUGA_SKYPE(&quot;globals.codec_rates_string=%s\n&quot;, SKYPIAX_P_LOG,
-                     globals.codec_rates_string);
-        globals.codec_rates_last =
-          switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates,
-                                 SWITCH_MAX_CODECS);
-      }
</del><ins>+                        if (!strcasecmp(var, &quot;debug&quot;)) {
+                                DEBUGA_SKYPE(&quot;globals.debug=%d\n&quot;, SKYPIAX_P_LOG, globals.debug);
+                                globals.debug = atoi(val);
+                                DEBUGA_SKYPE(&quot;globals.debug=%d\n&quot;, SKYPIAX_P_LOG, globals.debug);
+                        } else if (!strcasecmp(var, &quot;hold-music&quot;)) {
+                                switch_set_string(globals.hold_music, val);
+                                DEBUGA_SKYPE(&quot;globals.hold_music=%s\n&quot;, SKYPIAX_P_LOG, globals.hold_music);
+                        } else if (!strcmp(var, &quot;port&quot;)) {
+                                globals.port = atoi(val);
+                                DEBUGA_SKYPE(&quot;globals.port=%d\n&quot;, SKYPIAX_P_LOG, globals.port);
+                        } else if (!strcmp(var, &quot;codec-master&quot;)) {
+                                if (!strcasecmp(val, &quot;us&quot;)) {
+                                        switch_set_flag(&amp;globals, GFLAG_MY_CODEC_PREFS);
+                                }
+                                DEBUGA_SKYPE(&quot;codec-master globals.debug=%d\n&quot;, SKYPIAX_P_LOG, globals.debug);
+                        } else if (!strcmp(var, &quot;dialplan&quot;)) {
+                                set_global_dialplan(val);
+                                DEBUGA_SKYPE(&quot;globals.dialplan=%s\n&quot;, SKYPIAX_P_LOG, globals.dialplan);
+                        } else if (!strcmp(var, &quot;destination&quot;)) {
+                                set_global_destination(val);
+                                DEBUGA_SKYPE(&quot;globals.destination=%s\n&quot;, SKYPIAX_P_LOG, globals.destination);
+                        } else if (!strcmp(var, &quot;context&quot;)) {
+                                set_global_context(val);
+                                DEBUGA_SKYPE(&quot;globals.context=%s\n&quot;, SKYPIAX_P_LOG, globals.context);
+                        } else if (!strcmp(var, &quot;codec-prefs&quot;)) {
+                                set_global_codec_string(val);
+                                DEBUGA_SKYPE(&quot;globals.codec_string=%s\n&quot;, SKYPIAX_P_LOG, globals.codec_string);
+                                globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
+                        } else if (!strcmp(var, &quot;codec-rates&quot;)) {
+                                set_global_codec_rates_string(val);
+                                DEBUGA_SKYPE(&quot;globals.codec_rates_string=%s\n&quot;, SKYPIAX_P_LOG, globals.codec_rates_string);
+                                globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
+                        }
</ins><span class="cx"> 
</span><del>-    }
-  }
</del><ins>+                }
+        }
</ins><span class="cx"> 
</span><del>-  if ((interfaces = switch_xml_child(cfg, &quot;per_interface_settings&quot;))) {
-    int i = 0;
</del><ins>+        if ((interfaces = switch_xml_child(cfg, &quot;per_interface_settings&quot;))) {
+                int i = 0;
</ins><span class="cx"> 
</span><del>-    for (myinterface = switch_xml_child(interfaces, &quot;interface&quot;); myinterface;
-         myinterface = myinterface-&gt;next) {
-      char *id = (char *) switch_xml_attr(myinterface, &quot;id&quot;);
-      char *name = (char *) switch_xml_attr(myinterface, &quot;name&quot;);
-      char *context = &quot;default&quot;;
-      char *dialplan = &quot;XML&quot;;
-      char *destination = &quot;5000&quot;;
-      char *tonegroup = NULL;
-      char *digit_timeout = NULL;
-      char *max_digits = NULL;
-      char *hotline = NULL;
-      char *dial_regex = NULL;
-      char *hold_music = NULL;
-      char *fail_dial_regex = NULL;
-      char *enable_callerid = &quot;true&quot;;
-      char *X11_display = NULL;
-      char *tcp_cli_port = NULL;
-      char *tcp_srv_port = NULL;
-      char *skype_user = NULL;
</del><ins>+                for (myinterface = switch_xml_child(interfaces, &quot;interface&quot;); myinterface; myinterface = myinterface-&gt;next) {
+                        char *id = (char *) switch_xml_attr(myinterface, &quot;id&quot;);
+                        char *name = (char *) switch_xml_attr(myinterface, &quot;name&quot;);
+                        char *context = &quot;default&quot;;
+                        char *dialplan = &quot;XML&quot;;
+                        char *destination = &quot;5000&quot;;
+                        char *tonegroup = NULL;
+                        char *digit_timeout = NULL;
+                        char *max_digits = NULL;
+                        char *hotline = NULL;
+                        char *dial_regex = NULL;
+                        char *hold_music = NULL;
+                        char *fail_dial_regex = NULL;
+                        char *enable_callerid = &quot;true&quot;;
+                        char *X11_display = NULL;
+                        char *tcp_cli_port = NULL;
+                        char *tcp_srv_port = NULL;
+                        char *skype_user = NULL;
</ins><span class="cx"> 
</span><del>-      uint32_t interface_id = 0, to = 0, max = 0;
</del><ins>+                        uint32_t interface_id = 0, to = 0, max = 0;
</ins><span class="cx"> 
</span><del>-      tech_pvt = NULL;
</del><ins>+                        tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-      for (param = switch_xml_child(myinterface, &quot;param&quot;); param; param = param-&gt;next) {
-        char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
-        char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</del><ins>+                        for (param = switch_xml_child(myinterface, &quot;param&quot;); param; param = param-&gt;next) {
+                                char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
+                                char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</ins><span class="cx"> 
</span><del>-        if (!strcasecmp(var, &quot;tonegroup&quot;)) {
-          tonegroup = val;
-        } else if (!strcasecmp(var, &quot;digit_timeout&quot;) || !strcasecmp(var, &quot;digit-timeout&quot;)) {
-          digit_timeout = val;
-        } else if (!strcasecmp(var, &quot;context&quot;)) {
-          context = val;
-        } else if (!strcasecmp(var, &quot;dialplan&quot;)) {
-          dialplan = val;
-        } else if (!strcasecmp(var, &quot;destination&quot;)) {
-          destination = val;
-        } else if (!strcasecmp(var, &quot;dial-regex&quot;)) {
-          dial_regex = val;
-        } else if (!strcasecmp(var, &quot;enable-callerid&quot;)) {
-          enable_callerid = val;
-        } else if (!strcasecmp(var, &quot;fail-dial-regex&quot;)) {
-          fail_dial_regex = val;
-        } else if (!strcasecmp(var, &quot;hold-music&quot;)) {
-          hold_music = val;
-        } else if (!strcasecmp(var, &quot;skype_user&quot;)) {
-          skype_user = val;
-        } else if (!strcasecmp(var, &quot;tcp_cli_port&quot;)) {
-          tcp_cli_port = val;
-        } else if (!strcasecmp(var, &quot;tcp_srv_port&quot;)) {
-          tcp_srv_port = val;
-        } else if (!strcasecmp(var, &quot;X11-display&quot;) || !strcasecmp(var, &quot;X11_display&quot;)) {
-          X11_display = val;
-        } else if (!strcasecmp(var, &quot;max_digits&quot;) || !strcasecmp(var, &quot;max-digits&quot;)) {
-          max_digits = val;
-        } else if (!strcasecmp(var, &quot;hotline&quot;)) {
-          hotline = val;
-        }
</del><ins>+                                if (!strcasecmp(var, &quot;tonegroup&quot;)) {
+                                        tonegroup = val;
+                                } else if (!strcasecmp(var, &quot;digit_timeout&quot;) || !strcasecmp(var, &quot;digit-timeout&quot;)) {
+                                        digit_timeout = val;
+                                } else if (!strcasecmp(var, &quot;context&quot;)) {
+                                        context = val;
+                                } else if (!strcasecmp(var, &quot;dialplan&quot;)) {
+                                        dialplan = val;
+                                } else if (!strcasecmp(var, &quot;destination&quot;)) {
+                                        destination = val;
+                                } else if (!strcasecmp(var, &quot;dial-regex&quot;)) {
+                                        dial_regex = val;
+                                } else if (!strcasecmp(var, &quot;enable-callerid&quot;)) {
+                                        enable_callerid = val;
+                                } else if (!strcasecmp(var, &quot;fail-dial-regex&quot;)) {
+                                        fail_dial_regex = val;
+                                } else if (!strcasecmp(var, &quot;hold-music&quot;)) {
+                                        hold_music = val;
+                                } else if (!strcasecmp(var, &quot;skype_user&quot;)) {
+                                        skype_user = val;
+                                } else if (!strcasecmp(var, &quot;tcp_cli_port&quot;)) {
+                                        tcp_cli_port = val;
+                                } else if (!strcasecmp(var, &quot;tcp_srv_port&quot;)) {
+                                        tcp_srv_port = val;
+                                } else if (!strcasecmp(var, &quot;X11-display&quot;) || !strcasecmp(var, &quot;X11_display&quot;)) {
+                                        X11_display = val;
+                                } else if (!strcasecmp(var, &quot;max_digits&quot;) || !strcasecmp(var, &quot;max-digits&quot;)) {
+                                        max_digits = val;
+                                } else if (!strcasecmp(var, &quot;hotline&quot;)) {
+                                        hotline = val;
+                                }
</ins><span class="cx"> 
</span><del>-      }
-      if (!skype_user) {
-        ERRORA(&quot;interface missing REQUIRED param 'skype_user'\n&quot;, SKYPIAX_P_LOG);
-        continue;
-      }
</del><ins>+                        }
+                        if (!skype_user) {
+                                ERRORA(&quot;interface missing REQUIRED param 'skype_user'\n&quot;, SKYPIAX_P_LOG);
+                                continue;
+                        }
</ins><span class="cx"> 
</span><del>-      /* BEGIN: Changes here */
-      if (reload_type == SOFT_RELOAD) {
-                  char the_interface[256];
-                  sprintf(the_interface, &quot;#%s&quot;, name);
</del><ins>+                        /* BEGIN: Changes here */
+                        if (reload_type == SOFT_RELOAD) {
+                                char the_interface[256];
+                                sprintf(the_interface, &quot;#%s&quot;, name);
</ins><span class="cx"> 
</span><del>-        if (interface_exists(the_interface) == SWITCH_STATUS_SUCCESS) {
-          continue;
-        }
-      }
-      /* END: Changes here */
</del><ins>+                                if (interface_exists(the_interface) == SWITCH_STATUS_SUCCESS) {
+                                        continue;
+                                }
+                        }
+                        /* END: Changes here */
</ins><span class="cx"> 
</span><del>-      if (!X11_display) {
-        ERRORA(&quot;interface missing REQUIRED param 'X11_display'\n&quot;, SKYPIAX_P_LOG);
-        continue;
-      }
-      if (!tcp_cli_port) {
-        ERRORA(&quot;interface missing REQUIRED param 'tcp_cli_port'\n&quot;, SKYPIAX_P_LOG);
-        continue;
-      }
</del><ins>+                        if (!X11_display) {
+                                ERRORA(&quot;interface missing REQUIRED param 'X11_display'\n&quot;, SKYPIAX_P_LOG);
+                                continue;
+                        }
+                        if (!tcp_cli_port) {
+                                ERRORA(&quot;interface missing REQUIRED param 'tcp_cli_port'\n&quot;, SKYPIAX_P_LOG);
+                                continue;
+                        }
</ins><span class="cx"> 
</span><del>-      if (!tcp_srv_port) {
-        ERRORA(&quot;interface missing REQUIRED param 'tcp_srv_port'\n&quot;, SKYPIAX_P_LOG);
-        continue;
-      }
-      if (!id) {
-        ERRORA(&quot;interface missing REQUIRED param 'id'\n&quot;, SKYPIAX_P_LOG);
-        continue;
-      }
-      if (switch_is_number(id)) {
-        interface_id = atoi(id);
-        DEBUGA_SKYPE(&quot;interface_id=%d\n&quot;, SKYPIAX_P_LOG, interface_id);
-      } else {
-        ERRORA(&quot;interface param 'id' MUST be a number, now id='%s'\n&quot;, SKYPIAX_P_LOG, id);
-        continue;
-      }
</del><ins>+                        if (!tcp_srv_port) {
+                                ERRORA(&quot;interface missing REQUIRED param 'tcp_srv_port'\n&quot;, SKYPIAX_P_LOG);
+                                continue;
+                        }
+                        if (!id) {
+                                ERRORA(&quot;interface missing REQUIRED param 'id'\n&quot;, SKYPIAX_P_LOG);
+                                continue;
+                        }
+                        if (switch_is_number(id)) {
+                                interface_id = atoi(id);
+                                DEBUGA_SKYPE(&quot;interface_id=%d\n&quot;, SKYPIAX_P_LOG, interface_id);
+                        } else {
+                                ERRORA(&quot;interface param 'id' MUST be a number, now id='%s'\n&quot;, SKYPIAX_P_LOG, id);
+                                continue;
+                        }
</ins><span class="cx"> 
</span><del>-      if (!name) {
-        WARNINGA(&quot;interface missing param 'name', not nice, but works\n&quot;, SKYPIAX_P_LOG);
-      }
</del><ins>+                        if (!name) {
+                                WARNINGA(&quot;interface missing param 'name', not nice, but works\n&quot;, SKYPIAX_P_LOG);
+                        }
</ins><span class="cx"> 
</span><del>-      if (!tonegroup) {
-        tonegroup = &quot;us&quot;;
-      }
</del><ins>+                        if (!tonegroup) {
+                                tonegroup = &quot;us&quot;;
+                        }
</ins><span class="cx"> 
</span><del>-      if (digit_timeout) {
-        to = atoi(digit_timeout);
-      }
</del><ins>+                        if (digit_timeout) {
+                                to = atoi(digit_timeout);
+                        }
</ins><span class="cx"> 
</span><del>-      if (max_digits) {
-        max = atoi(max_digits);
-      }
</del><ins>+                        if (max_digits) {
+                                max = atoi(max_digits);
+                        }
</ins><span class="cx"> 
</span><del>-      if (name) {
-        DEBUGA_SKYPE(&quot;name=%s\n&quot;, SKYPIAX_P_LOG, name);
-      }
</del><ins>+                        if (name) {
+                                DEBUGA_SKYPE(&quot;name=%s\n&quot;, SKYPIAX_P_LOG, name);
+                        }
</ins><span class="cx"> #ifndef WIN32
</span><del>-      if (!XInitThreads()) {
-        ERRORA(&quot;Not initialized XInitThreads!\n&quot;, SKYPIAX_P_LOG);
-      } else {
-        DEBUGA_SKYPE(&quot;Initialized XInitThreads!\n&quot;, SKYPIAX_P_LOG);
-      }
-      switch_sleep(100);
</del><ins>+                        if (!XInitThreads()) {
+                                ERRORA(&quot;Not initialized XInitThreads!\n&quot;, SKYPIAX_P_LOG);
+                        } else {
+                                DEBUGA_SKYPE(&quot;Initialized XInitThreads!\n&quot;, SKYPIAX_P_LOG);
+                        }
+                        switch_sleep(100);
</ins><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> 
</span><del>-      if (interface_id &amp;&amp; interface_id &lt; SKYPIAX_MAX_INTERFACES) {
-        private_t newconf;
-        switch_threadattr_t *skypiax_api_thread_attr = NULL;
-        switch_threadattr_t *skypiax_signaling_thread_attr = NULL;
</del><ins>+                        if (interface_id &amp;&amp; interface_id &lt; SKYPIAX_MAX_INTERFACES) {
+                                private_t newconf;
+                                switch_threadattr_t *skypiax_api_thread_attr = NULL;
+                                switch_threadattr_t *skypiax_signaling_thread_attr = NULL;
</ins><span class="cx"> 
</span><del>-        memset(&amp;newconf, '\0', sizeof(newconf));
-        globals.SKYPIAX_INTERFACES[interface_id] = newconf;
-                globals.SKYPIAX_INTERFACES[interface_id].running = 1;
</del><ins>+                                memset(&amp;newconf, '\0', sizeof(newconf));
+                                globals.SKYPIAX_INTERFACES[interface_id] = newconf;
+                                globals.SKYPIAX_INTERFACES[interface_id].running = 1;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
</del><ins>+                                tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
</ins><span class="cx"> 
</span><del>-        switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].interface_id, id);
-        if (name) {
-          switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, name);
-        } else {
-          switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, &quot;N/A&quot;);
-        }
-        DEBUGA_SKYPE(&quot;CONFIGURING interface_id=%d\n&quot;, SKYPIAX_P_LOG, interface_id);
</del><ins>+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].interface_id, id);
+                                if (name) {
+                                        switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, name);
+                                } else {
+                                        switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, &quot;N/A&quot;);
+                                }
+                                DEBUGA_SKYPE(&quot;CONFIGURING interface_id=%d\n&quot;, SKYPIAX_P_LOG, interface_id);
</ins><span class="cx"> #ifdef WIN32
</span><del>-        globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port =
-          (unsigned short) atoi(tcp_cli_port);
-        globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port =
-          (unsigned short) atoi(tcp_srv_port);
</del><ins>+                                globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = (unsigned short) atoi(tcp_cli_port);
+                                globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = (unsigned short) atoi(tcp_srv_port);
</ins><span class="cx"> #else /* WIN32 */
</span><del>-        globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = atoi(tcp_cli_port);
-        globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = atoi(tcp_srv_port);
</del><ins>+                                globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = atoi(tcp_cli_port);
+                                globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = atoi(tcp_srv_port);
</ins><span class="cx"> #endif /* WIN32 */
</span><del>-        switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].X11_display,
-                          X11_display);
-        switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].skype_user,
-                          skype_user);
-        switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
-        switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
-        switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].destination,
-                          destination);
-        switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
</del><ins>+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].X11_display, X11_display);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].skype_user, skype_user);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].destination, destination);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
</ins><span class="cx"> 
</span><del>-        DEBUGA_SKYPE
-          (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].X11_display=%s\n&quot;,
-           SKYPIAX_P_LOG, interface_id,
-           globals.SKYPIAX_INTERFACES[interface_id].X11_display);
-        DEBUGA_SKYPE
-          (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_user=%s\n&quot;,
-           SKYPIAX_P_LOG, interface_id,
-           globals.SKYPIAX_INTERFACES[interface_id].skype_user);
-        DEBUGA_SKYPE
-          (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port=%d\n&quot;,
-           SKYPIAX_P_LOG, interface_id,
-           globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port);
-        DEBUGA_SKYPE
-          (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port=%d\n&quot;,
-           SKYPIAX_P_LOG, interface_id,
-           globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port);
-        DEBUGA_SKYPE(&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n&quot;,
-                     SKYPIAX_P_LOG, interface_id,
-                     globals.SKYPIAX_INTERFACES[interface_id].name);
-        DEBUGA_SKYPE
-          (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n&quot;,
-           SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
-        DEBUGA_SKYPE
-          (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].dialplan=%s\n&quot;,
-           SKYPIAX_P_LOG, interface_id,
-           globals.SKYPIAX_INTERFACES[interface_id].dialplan);
-        DEBUGA_SKYPE
-          (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].destination=%s\n&quot;,
-           SKYPIAX_P_LOG, interface_id,
-           globals.SKYPIAX_INTERFACES[interface_id].destination);
-        DEBUGA_SKYPE
-          (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n&quot;,
-           SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
-        WARNINGA(&quot;STARTING interface_id=%d\n&quot;, SKYPIAX_P_LOG, interface_id);
</del><ins>+                                DEBUGA_SKYPE
+                                        (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].X11_display=%s\n&quot;,
+                                         SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].X11_display);
+                                DEBUGA_SKYPE
+                                        (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_user=%s\n&quot;,
+                                         SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user);
+                                DEBUGA_SKYPE
+                                        (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port=%d\n&quot;,
+                                         SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port);
+                                DEBUGA_SKYPE
+                                        (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port=%d\n&quot;,
+                                         SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port);
+                                DEBUGA_SKYPE(&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n&quot;,
+                                                         SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].name);
+                                DEBUGA_SKYPE
+                                        (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n&quot;,
+                                         SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
+                                DEBUGA_SKYPE
+                                        (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].dialplan=%s\n&quot;,
+                                         SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].dialplan);
+                                DEBUGA_SKYPE
+                                        (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].destination=%s\n&quot;,
+                                         SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].destination);
+                                DEBUGA_SKYPE
+                                        (&quot;interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n&quot;,
+                                         SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
+                                WARNINGA(&quot;STARTING interface_id=%d\n&quot;, SKYPIAX_P_LOG, interface_id);
</ins><span class="cx"> 
</span><del>-        switch_threadattr_create(&amp;skypiax_api_thread_attr, skypiax_module_pool);
-        switch_threadattr_stacksize_set(skypiax_api_thread_attr, SWITCH_THREAD_STACKSIZE);
-        switch_thread_create(&amp;globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread,
-                             skypiax_api_thread_attr, skypiax_do_skypeapi_thread,
-                             &amp;globals.SKYPIAX_INTERFACES[interface_id],
-                             skypiax_module_pool);
</del><ins>+                                switch_threadattr_create(&amp;skypiax_api_thread_attr, skypiax_module_pool);
+                                switch_threadattr_stacksize_set(skypiax_api_thread_attr, SWITCH_THREAD_STACKSIZE);
+                                switch_thread_create(&amp;globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread,
+                                                                         skypiax_api_thread_attr, skypiax_do_skypeapi_thread, &amp;globals.SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
</ins><span class="cx"> 
</span><del>-        switch_sleep(100000);
</del><ins>+                                switch_sleep(100000);
</ins><span class="cx"> 
</span><del>-        switch_threadattr_create(&amp;skypiax_signaling_thread_attr, skypiax_module_pool);
-        switch_threadattr_stacksize_set(skypiax_signaling_thread_attr,
-                                        SWITCH_THREAD_STACKSIZE);
-        switch_thread_create(&amp;globals.SKYPIAX_INTERFACES[interface_id].
-                             skypiax_signaling_thread, skypiax_signaling_thread_attr,
-                             skypiax_signaling_thread_func,
-                             &amp;globals.SKYPIAX_INTERFACES[interface_id],
-                             skypiax_module_pool);
</del><ins>+                                switch_threadattr_create(&amp;skypiax_signaling_thread_attr, skypiax_module_pool);
+                                switch_threadattr_stacksize_set(skypiax_signaling_thread_attr, SWITCH_THREAD_STACKSIZE);
+                                switch_thread_create(&amp;globals.SKYPIAX_INTERFACES[interface_id].
+                                                                         skypiax_signaling_thread, skypiax_signaling_thread_attr,
+                                                                         skypiax_signaling_thread_func, &amp;globals.SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
</ins><span class="cx"> 
</span><del>-        switch_sleep(100000);
</del><ins>+                                switch_sleep(100000);
</ins><span class="cx"> 
</span><del>-        skypiax_audio_init(&amp;globals.SKYPIAX_INTERFACES[interface_id]);
</del><ins>+                                skypiax_audio_init(&amp;globals.SKYPIAX_INTERFACES[interface_id]);
</ins><span class="cx"> 
</span><del>-        NOTICA
-          (&quot;WAITING roughly 10 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d\n&quot;,
-           SKYPIAX_P_LOG, interface_id);
-        i = 0;
-        while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 &amp;&amp; running &amp;&amp; i &lt; 200) {  // 10 seconds! thanks Jeff Lenk
-          switch_sleep(50000);
-          i++;
-        }
-        if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected) {
-          NOTICA
-            (&quot;Found a running Skype client, connected to its SKYPE API for interface_id=%d, waiting 60 seconds for CURRENTUSERHANDLE==%s\n&quot;,
-             SKYPIAX_P_LOG, interface_id,
-             globals.SKYPIAX_INTERFACES[interface_id].skype_user);
-        } else {
-          ERRORA
-            (&quot;Failed to connect to a SKYPE API for interface_id=%d, no SKYPE client running, please (re)start Skype client. Skypiax exiting\n&quot;,
-             SKYPIAX_P_LOG, interface_id);
-          running = 0;
-  switch_mutex_unlock(globals.mutex);
-                  switch_xml_free(xml);
-          return SWITCH_STATUS_FALSE;
-        }
</del><ins>+                                NOTICA
+                                        (&quot;WAITING roughly 10 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d\n&quot;,
+                                         SKYPIAX_P_LOG, interface_id);
+                                i = 0;
+                                while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 &amp;&amp; running &amp;&amp; i &lt; 200) {        // 10 seconds! thanks Jeff Lenk
+                                        switch_sleep(50000);
+                                        i++;
+                                }
+                                if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected) {
+                                        NOTICA
+                                                (&quot;Found a running Skype client, connected to its SKYPE API for interface_id=%d, waiting 60 seconds for CURRENTUSERHANDLE==%s\n&quot;,
+                                                 SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user);
+                                } else {
+                                        ERRORA
+                                                (&quot;Failed to connect to a SKYPE API for interface_id=%d, no SKYPE client running, please (re)start Skype client. Skypiax exiting\n&quot;,
+                                                 SKYPIAX_P_LOG, interface_id);
+                                        running = 0;
+                                        switch_mutex_unlock(globals.mutex);
+                                        switch_xml_free(xml);
+                                        return SWITCH_STATUS_FALSE;
+                                }
</ins><span class="cx"> 
</span><del>-        i = 0;
-        while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 &amp;&amp; running &amp;&amp; i &lt; 1200) { // 60 seconds! thanks Jeff Lenk
-          switch_sleep(50000);
-          i++;
-        }
-        if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle) {
-          WARNINGA
-            (&quot;Interface_id=%d is now STARTED, the Skype client to which we are connected gave us the correct CURRENTUSERHANDLE (%s)\n&quot;,
-             SKYPIAX_P_LOG, interface_id,
-             globals.SKYPIAX_INTERFACES[interface_id].skype_user);
</del><ins>+                                i = 0;
+                                while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 &amp;&amp; running &amp;&amp; i &lt; 1200) {        // 60 seconds! thanks Jeff Lenk
+                                        switch_sleep(50000);
+                                        i++;
+                                }
+                                if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle) {
+                                        WARNINGA
+                                                (&quot;Interface_id=%d is now STARTED, the Skype client to which we are connected gave us the correct CURRENTUSERHANDLE (%s)\n&quot;,
+                                                 SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user);
</ins><span class="cx"> 
</span><del>-          skypiax_signaling_write(&amp;globals.SKYPIAX_INTERFACES[interface_id],
-                                  &quot;SET AUTOAWAY OFF&quot;);
-        } else {
-          ERRORA
-            (&quot;The Skype client to which we are connected FAILED to gave us CURRENTUSERHANDLE=%s, interface_id=%d FAILED to start. No Skype client logged in as '%s' has been found. Please (re)launch a Skype client logged in as '%s'. Skypiax exiting now\n&quot;,
-             SKYPIAX_P_LOG, globals.SKYPIAX_INTERFACES[interface_id].skype_user,
-             interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user,
-             globals.SKYPIAX_INTERFACES[interface_id].skype_user);
-          running = 0;
-                  switch_mutex_unlock(globals.mutex);
-                  switch_xml_free(xml);
-          return SWITCH_STATUS_FALSE;
-        }
</del><ins>+                                        skypiax_signaling_write(&amp;globals.SKYPIAX_INTERFACES[interface_id], &quot;SET AUTOAWAY OFF&quot;);
+                                } else {
+                                        ERRORA
+                                                (&quot;The Skype client to which we are connected FAILED to gave us CURRENTUSERHANDLE=%s, interface_id=%d FAILED to start. No Skype client logged in as '%s' has been found. Please (re)launch a Skype client logged in as '%s'. Skypiax exiting now\n&quot;,
+                                                 SKYPIAX_P_LOG, globals.SKYPIAX_INTERFACES[interface_id].skype_user,
+                                                 interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user, globals.SKYPIAX_INTERFACES[interface_id].skype_user);
+                                        running = 0;
+                                        switch_mutex_unlock(globals.mutex);
+                                        switch_xml_free(xml);
+                                        return SWITCH_STATUS_FALSE;
+                                }
</ins><span class="cx"> 
</span><del>-      } else {
-        ERRORA(&quot;interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n&quot;,
-               SKYPIAX_P_LOG, interface_id, SKYPIAX_MAX_INTERFACES);
-        continue;
-      }
</del><ins>+                        } else {
+                                ERRORA(&quot;interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n&quot;, SKYPIAX_P_LOG, interface_id, SKYPIAX_MAX_INTERFACES);
+                                continue;
+                        }
</ins><span class="cx"> 
</span><del>-    }
</del><ins>+                }
</ins><span class="cx"> 
</span><del>-    for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-      if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
-               /* How many real intterfaces */
-               globals.real_interfaces = i + 1;
</del><ins>+                for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                        if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
+                                /* How many real intterfaces */
+                                globals.real_interfaces = i + 1;
</ins><span class="cx"> 
</span><del>-        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
</del><ins>+                                tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
</ins><span class="cx"> 
</span><del>-        DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n&quot;,
-                     SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].interface_id);
-        DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].X11_display=%s\n&quot;,
-                     SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].X11_display);
-        DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].name=%s\n&quot;, SKYPIAX_P_LOG, i, i,
-                     globals.SKYPIAX_INTERFACES[i].name);
-        DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n&quot;, SKYPIAX_P_LOG, i,
-                     i, globals.SKYPIAX_INTERFACES[i].context);
-        DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].dialplan=%s\n&quot;, SKYPIAX_P_LOG,
-                     i, i, globals.SKYPIAX_INTERFACES[i].dialplan);
-        DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].destination=%s\n&quot;,
-                     SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].destination);
-        DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n&quot;, SKYPIAX_P_LOG, i,
-                     i, globals.SKYPIAX_INTERFACES[i].context);
-      }
-    }
-  }
</del><ins>+                                DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].interface_id);
+                                DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].X11_display=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].X11_display);
+                                DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].name=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].name);
+                                DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].context);
+                                DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].dialplan=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].dialplan);
+                                DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].destination=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].destination);
+                                DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].context);
+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  switch_mutex_unlock(globals.mutex);
-  switch_xml_free(xml);
</del><ins>+        switch_mutex_unlock(globals.mutex);
+        switch_xml_free(xml);
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
</span><span class="cx"> {
</span><del>-  switch_api_interface_t *commands_api_interface;
</del><ins>+        switch_api_interface_t *commands_api_interface;
</ins><span class="cx"> 
</span><del>-  skypiax_module_pool = pool;
-  memset(&amp;globals, '\0', sizeof(globals));
</del><ins>+        skypiax_module_pool = pool;
+        memset(&amp;globals, '\0', sizeof(globals));
</ins><span class="cx"> 
</span><del>-  running = 1;
</del><ins>+        running = 1;
</ins><span class="cx"> 
</span><del>-  if (load_config(FULL_RELOAD) != SWITCH_STATUS_SUCCESS) {
-    running = 0;
-    return SWITCH_STATUS_FALSE;
-  }
</del><ins>+        if (load_config(FULL_RELOAD) != SWITCH_STATUS_SUCCESS) {
+                running = 0;
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx"> 
</span><del>-  *module_interface = switch_loadable_module_create_module_interface(pool, modname);
-  skypiax_endpoint_interface =
-    switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
-  skypiax_endpoint_interface-&gt;interface_name = &quot;skypiax&quot;;
-  skypiax_endpoint_interface-&gt;io_routines = &amp;skypiax_io_routines;
-  skypiax_endpoint_interface-&gt;state_handler = &amp;skypiax_state_handlers;
</del><ins>+        *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+        skypiax_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
+        skypiax_endpoint_interface-&gt;interface_name = &quot;skypiax&quot;;
+        skypiax_endpoint_interface-&gt;io_routines = &amp;skypiax_io_routines;
+        skypiax_endpoint_interface-&gt;state_handler = &amp;skypiax_state_handlers;
</ins><span class="cx"> 
</span><del>-  if (running) {
</del><ins>+        if (running) {
</ins><span class="cx"> 
</span><del>-    SWITCH_ADD_API(commands_api_interface, &quot;sk&quot;, &quot;Skypiax console commands&quot;, sk_function,
-                   SK_SYNTAX);
-    SWITCH_ADD_API(commands_api_interface, &quot;skypiax&quot;, &quot;Skypiax interface commands&quot;,
-                   skypiax_function, SKYPIAX_SYNTAX);
</del><ins>+                SWITCH_ADD_API(commands_api_interface, &quot;sk&quot;, &quot;Skypiax console commands&quot;, sk_function, SK_SYNTAX);
+                SWITCH_ADD_API(commands_api_interface, &quot;skypiax&quot;, &quot;Skypiax interface commands&quot;, skypiax_function, SKYPIAX_SYNTAX);
</ins><span class="cx"> 
</span><del>-    /* indicate that the module should continue to be loaded */
-    return SWITCH_STATUS_SUCCESS;
-  } else
-    return SWITCH_STATUS_FALSE;
</del><ins>+                /* indicate that the module should continue to be loaded */
+                return SWITCH_STATUS_SUCCESS;
+        } else
+                return SWITCH_STATUS_FALSE;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown)
</span><span class="cx"> {
</span><del>-  int x = 100;
-  private_t *tech_pvt = NULL;
-  switch_status_t status;
-  unsigned int howmany = 8;
-  int interface_id;
</del><ins>+        int x = 100;
+        private_t *tech_pvt = NULL;
+        switch_status_t status;
+        unsigned int howmany = 8;
+        int interface_id;
</ins><span class="cx"> 
</span><del>-  running = 0;
</del><ins>+        running = 0;
</ins><span class="cx"> 
</span><del>-  for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
-    tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
</del><ins>+        for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
+                tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
</ins><span class="cx"> 
</span><del>-    if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
</del><ins>+                if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
</ins><span class="cx"> #ifdef WIN32
</span><del>-      switch_file_write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, &amp;howmany);   // let's the controldev_thread die
</del><ins>+                        switch_file_write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, &amp;howmany);        // let's the controldev_thread die
</ins><span class="cx"> #else /* WIN32 */
</span><del>-      howmany = write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, howmany);
</del><ins>+                        howmany = write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, howmany);
</ins><span class="cx"> #endif /* WIN32 */
</span><del>-    }
</del><ins>+                }
</ins><span class="cx"> 
</span><del>-    if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
</del><ins>+                if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
</ins><span class="cx"> #ifdef WIN32
</span><del>-      if (SendMessage(tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) {  // let's the skypiax_api_thread_func die
-        DEBUGA_SKYPE
-          (&quot;got FALSE here, thread probably was already dead. GetLastError returned: %d\n&quot;,
-           SKYPIAX_P_LOG, GetLastError());
-        globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
-      }
</del><ins>+                        if (SendMessage(tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) {        // let's the skypiax_api_thread_func die
+                                DEBUGA_SKYPE(&quot;got FALSE here, thread probably was already dead. GetLastError returned: %d\n&quot;, SKYPIAX_P_LOG, GetLastError());
+                                globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
+                        }
</ins><span class="cx"> #else
</span><del>-      XEvent e;
-      Atom atom1 =
-        XInternAtom(tech_pvt-&gt;SkypiaxHandles.disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;,
-                    False);
-      memset(&amp;e, 0, sizeof(e));
-      e.xclient.type = ClientMessage;
-      e.xclient.message_type = atom1;   /*  leading message */
-      e.xclient.display = tech_pvt-&gt;SkypiaxHandles.disp;
-      e.xclient.window = tech_pvt-&gt;SkypiaxHandles.skype_win;
-      e.xclient.format = 8;
</del><ins>+                        XEvent e;
+                        Atom atom1 = XInternAtom(tech_pvt-&gt;SkypiaxHandles.disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;,
+                                                                         False);
+                        memset(&amp;e, 0, sizeof(e));
+                        e.xclient.type = ClientMessage;
+                        e.xclient.message_type = atom1;        /*  leading message */
+                        e.xclient.display = tech_pvt-&gt;SkypiaxHandles.disp;
+                        e.xclient.window = tech_pvt-&gt;SkypiaxHandles.skype_win;
+                        e.xclient.format = 8;
</ins><span class="cx"> 
</span><del>-      XSendEvent(tech_pvt-&gt;SkypiaxHandles.disp, tech_pvt-&gt;SkypiaxHandles.win, False, 0,
-                 &amp;e);
-      XSync(tech_pvt-&gt;SkypiaxHandles.disp, False);
</del><ins>+                        XSendEvent(tech_pvt-&gt;SkypiaxHandles.disp, tech_pvt-&gt;SkypiaxHandles.win, False, 0, &amp;e);
+                        XSync(tech_pvt-&gt;SkypiaxHandles.disp, False);
</ins><span class="cx"> #endif
</span><del>-    }
-    while (x) {                 //FIXME 2 seconds?
-      x--;
-      switch_yield(20000);
-    }
-    if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
-      switch_thread_join(&amp;status,
-                         globals.SKYPIAX_INTERFACES[interface_id].
-                         skypiax_signaling_thread);
-    }
-    if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
-      switch_thread_join(&amp;status,
-                         globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
-    }
-  }
</del><ins>+                }
+                while (x) {                                //FIXME 2 seconds?
+                        x--;
+                        switch_yield(20000);
+                }
+                if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
+                        switch_thread_join(&amp;status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread);
+                }
+                if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
+                        switch_thread_join(&amp;status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  switch_safe_free(globals.dialplan);
-  switch_safe_free(globals.context);
-  switch_safe_free(globals.destination);
-  switch_safe_free(globals.codec_string);
-  switch_safe_free(globals.codec_rates_string);
</del><ins>+        switch_safe_free(globals.dialplan);
+        switch_safe_free(globals.context);
+        switch_safe_free(globals.destination);
+        switch_safe_free(globals.codec_string);
+        switch_safe_free(globals.codec_rates_string);
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, void *obj)
</span><span class="cx"> {
</span><del>-  return skypiax_do_tcp_srv_thread_func(obj);
</del><ins>+        return skypiax_do_tcp_srv_thread_func(obj);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj)
</span><span class="cx"> {
</span><del>-  return skypiax_do_tcp_cli_thread_func(obj);
</del><ins>+        return skypiax_do_tcp_cli_thread_func(obj);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj)
</span><span class="cx"> {
</span><del>-  return skypiax_do_skypeapi_thread_func(obj);
</del><ins>+        return skypiax_do_skypeapi_thread_func(obj);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int dtmf_received(private_t * tech_pvt, char *value)
</span><span class="cx"> {
</span><del>-  switch_core_session_t *session = NULL;
-  switch_channel_t *channel = NULL;
</del><ins>+        switch_core_session_t *session = NULL;
+        switch_channel_t *channel = NULL;
</ins><span class="cx"> 
</span><del>-  session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
-  channel = switch_core_session_get_channel(session);
</del><ins>+        session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
+        channel = switch_core_session_get_channel(session);
</ins><span class="cx"> 
</span><del>-  if (channel) {
</del><ins>+        if (channel) {
</ins><span class="cx"> 
</span><del>-    if (!switch_channel_test_flag(channel, CF_BRIDGED)) {
</del><ins>+                if (!switch_channel_test_flag(channel, CF_BRIDGED)) {
</ins><span class="cx"> 
</span><del>-      switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
-      DEBUGA_SKYPE(&quot;received DTMF %c on channel %s\n&quot;, SKYPIAX_P_LOG, dtmf.digit,
-                   switch_channel_get_name(channel));
-      switch_mutex_lock(tech_pvt-&gt;flag_mutex);
-      //FIXME: why sometimes DTMFs from here do not seems to be get by FS?
-      switch_channel_queue_dtmf(channel, &amp;dtmf);
-      switch_set_flag(tech_pvt, TFLAG_DTMF);
-      switch_mutex_unlock(tech_pvt-&gt;flag_mutex);
-    } else {
-      DEBUGA_SKYPE
-        (&quot;received a DTMF on channel %s, but we're BRIDGED, so let's NOT relay it out of band\n&quot;,
-         SKYPIAX_P_LOG, switch_channel_get_name(channel));
-    }
-  } else {
-    WARNINGA(&quot;received %c DTMF, but no channel?\n&quot;, SKYPIAX_P_LOG, value[0]);
-  }
-  switch_core_session_rwunlock(session);
</del><ins>+                        switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
+                        DEBUGA_SKYPE(&quot;received DTMF %c on channel %s\n&quot;, SKYPIAX_P_LOG, dtmf.digit, switch_channel_get_name(channel));
+                        switch_mutex_lock(tech_pvt-&gt;flag_mutex);
+                        //FIXME: why sometimes DTMFs from here do not seems to be get by FS?
+                        switch_channel_queue_dtmf(channel, &amp;dtmf);
+                        switch_set_flag(tech_pvt, TFLAG_DTMF);
+                        switch_mutex_unlock(tech_pvt-&gt;flag_mutex);
+                } else {
+                        DEBUGA_SKYPE
+                                (&quot;received a DTMF on channel %s, but we're BRIDGED, so let's NOT relay it out of band\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
+                }
+        } else {
+                WARNINGA(&quot;received %c DTMF, but no channel?\n&quot;, SKYPIAX_P_LOG, value[0]);
+        }
+        switch_core_session_rwunlock(session);
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int start_audio_threads(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  switch_threadattr_t *thd_attr = NULL;
</del><ins>+        switch_threadattr_t *thd_attr = NULL;
</ins><span class="cx"> 
</span><del>-  switch_threadattr_create(&amp;thd_attr, skypiax_module_pool);
-  switch_threadattr_detach_set(thd_attr, 1);
-  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-  switch_thread_create(&amp;tech_pvt-&gt;tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread,
-                       tech_pvt, skypiax_module_pool);
-  DEBUGA_SKYPE(&quot;started tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        switch_threadattr_create(&amp;thd_attr, skypiax_module_pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&amp;tech_pvt-&gt;tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread, tech_pvt, skypiax_module_pool);
+        DEBUGA_SKYPE(&quot;started tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  switch_threadattr_create(&amp;thd_attr, skypiax_module_pool);
-  switch_threadattr_detach_set(thd_attr, 1);
-  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-  switch_thread_create(&amp;tech_pvt-&gt;tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread,
-                       tech_pvt, skypiax_module_pool);
-  DEBUGA_SKYPE(&quot;started tcp_cli_thread thread.\n&quot;, SKYPIAX_P_LOG);
-  switch_sleep(100000);
</del><ins>+        switch_threadattr_create(&amp;thd_attr, skypiax_module_pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&amp;tech_pvt-&gt;tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread, tech_pvt, skypiax_module_pool);
+        DEBUGA_SKYPE(&quot;started tcp_cli_thread thread.\n&quot;, SKYPIAX_P_LOG);
+        switch_sleep(100000);
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int new_inbound_channel(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  switch_core_session_t *session = NULL;
-  switch_channel_t *channel = NULL;
</del><ins>+        switch_core_session_t *session = NULL;
+        switch_channel_t *channel = NULL;
</ins><span class="cx"> 
</span><del>-  if ((session =
-       switch_core_session_request(skypiax_endpoint_interface,
-                                   SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
-    switch_core_session_add_stream(session, NULL);
-    channel = switch_core_session_get_channel(session);
-    skypiax_tech_init(tech_pvt, session);
</del><ins>+        if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
+                switch_core_session_add_stream(session, NULL);
+                channel = switch_core_session_get_channel(session);
+                skypiax_tech_init(tech_pvt, session);
</ins><span class="cx"> 
</span><del>-    if ((tech_pvt-&gt;caller_profile =
-         switch_caller_profile_new(switch_core_session_get_pool(session), &quot;skypiax&quot;,
-                                   tech_pvt-&gt;dialplan, tech_pvt-&gt;callid_name,
-                                   tech_pvt-&gt;callid_number, NULL, NULL, NULL, NULL,
-                                   &quot;mod_skypiax&quot;, tech_pvt-&gt;context,
-                                   tech_pvt-&gt;destination)) != 0) {
-      char name[128];
-      //switch_snprintf(name, sizeof(name), &quot;skypiax/%s/%s&quot;, tech_pvt-&gt;name, tech_pvt-&gt;caller_profile-&gt;destination_number);
-      switch_snprintf(name, sizeof(name), &quot;skypiax/%s&quot;, tech_pvt-&gt;name);
-      switch_channel_set_name(channel, name);
-      switch_channel_set_caller_profile(channel, tech_pvt-&gt;caller_profile);
-    }
-    switch_channel_set_state(channel, CS_INIT);
-    if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
-      ERRORA(&quot;Error spawning thread\n&quot;, SKYPIAX_P_LOG);
-      switch_core_session_destroy(&amp;session);
-    }
-  }
-  switch_channel_mark_answered(channel);
</del><ins>+                if ((tech_pvt-&gt;caller_profile =
+                         switch_caller_profile_new(switch_core_session_get_pool(session), &quot;skypiax&quot;,
+                                                                           tech_pvt-&gt;dialplan, tech_pvt-&gt;callid_name,
+                                                                           tech_pvt-&gt;callid_number, NULL, NULL, NULL, NULL, &quot;mod_skypiax&quot;, tech_pvt-&gt;context, tech_pvt-&gt;destination)) != 0) {
+                        char name[128];
+                        //switch_snprintf(name, sizeof(name), &quot;skypiax/%s/%s&quot;, tech_pvt-&gt;name, tech_pvt-&gt;caller_profile-&gt;destination_number);
+                        switch_snprintf(name, sizeof(name), &quot;skypiax/%s&quot;, tech_pvt-&gt;name);
+                        switch_channel_set_name(channel, name);
+                        switch_channel_set_caller_profile(channel, tech_pvt-&gt;caller_profile);
+                }
+                switch_channel_set_state(channel, CS_INIT);
+                if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
+                        ERRORA(&quot;Error spawning thread\n&quot;, SKYPIAX_P_LOG);
+                        switch_core_session_destroy(&amp;session);
+                }
+        }
+        switch_channel_mark_answered(channel);
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;Here\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        DEBUGA_SKYPE(&quot;Here\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int remote_party_is_ringing(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  switch_core_session_t *session = NULL;
-  switch_channel_t *channel = NULL;
</del><ins>+        switch_core_session_t *session = NULL;
+        switch_channel_t *channel = NULL;
</ins><span class="cx"> 
</span><del>-  if (!switch_strlen_zero(tech_pvt-&gt;session_uuid_str)) {
-    session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
-  } else {
-    ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
-    goto done;
-  }
-  if (session) {
-    channel = switch_core_session_get_channel(session);
-  } else {
-    ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
-    goto done;
-  }
-  if (channel) {
-    switch_channel_mark_ring_ready(channel);
-    DEBUGA_SKYPE(&quot;skype_call: REMOTE PARTY RINGING\n&quot;, SKYPIAX_P_LOG);
-  } else {
-    ERRORA(&quot;No channel???\n&quot;, SKYPIAX_P_LOG);
-    goto done;
-  }
</del><ins>+        if (!switch_strlen_zero(tech_pvt-&gt;session_uuid_str)) {
+                session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
+        } else {
+                ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
+                goto done;
+        }
+        if (session) {
+                channel = switch_core_session_get_channel(session);
+        } else {
+                ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
+                goto done;
+        }
+        if (channel) {
+                switch_channel_mark_ring_ready(channel);
+                DEBUGA_SKYPE(&quot;skype_call: REMOTE PARTY RINGING\n&quot;, SKYPIAX_P_LOG);
+        } else {
+                ERRORA(&quot;No channel???\n&quot;, SKYPIAX_P_LOG);
+                goto done;
+        }
</ins><span class="cx"> 
</span><del>-  switch_core_session_rwunlock(session);
</del><ins>+        switch_core_session_rwunlock(session);
</ins><span class="cx"> 
</span><del>-done:
-  return 0;
</del><ins>+  done:
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int remote_party_is_early_media(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  switch_core_session_t *session = NULL;
-  switch_channel_t *channel = NULL;
</del><ins>+        switch_core_session_t *session = NULL;
+        switch_channel_t *channel = NULL;
</ins><span class="cx"> 
</span><del>-  if (!switch_strlen_zero(tech_pvt-&gt;session_uuid_str)) {
-    session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
-  } else {
-    ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
-    goto done;
-  }
-  if (session) {
-    channel = switch_core_session_get_channel(session);
-    switch_core_session_add_stream(session, NULL);
-  } else {
-    ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
-    goto done;
-  }
-  if (channel) {
-    switch_channel_mark_pre_answered(channel);
-    DEBUGA_SKYPE(&quot;skype_call: REMOTE PARTY EARLY MEDIA\n&quot;, SKYPIAX_P_LOG);
-  } else {
-    ERRORA(&quot;No channel???\n&quot;, SKYPIAX_P_LOG);
-    goto done;
-  }
</del><ins>+        if (!switch_strlen_zero(tech_pvt-&gt;session_uuid_str)) {
+                session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
+        } else {
+                ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
+                goto done;
+        }
+        if (session) {
+                channel = switch_core_session_get_channel(session);
+                switch_core_session_add_stream(session, NULL);
+        } else {
+                ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
+                goto done;
+        }
+        if (channel) {
+                switch_channel_mark_pre_answered(channel);
+                DEBUGA_SKYPE(&quot;skype_call: REMOTE PARTY EARLY MEDIA\n&quot;, SKYPIAX_P_LOG);
+        } else {
+                ERRORA(&quot;No channel???\n&quot;, SKYPIAX_P_LOG);
+                goto done;
+        }
</ins><span class="cx"> 
</span><del>-  switch_core_session_rwunlock(session);
</del><ins>+        switch_core_session_rwunlock(session);
</ins><span class="cx"> 
</span><del>-done:
-  return 0;
</del><ins>+  done:
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int outbound_channel_answered(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  switch_core_session_t *session = NULL;
-  switch_channel_t *channel = NULL;
</del><ins>+        switch_core_session_t *session = NULL;
+        switch_channel_t *channel = NULL;
</ins><span class="cx"> 
</span><del>-  if (!switch_strlen_zero(tech_pvt-&gt;session_uuid_str)) {
-    session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
-  } else {
-    ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
-    goto done;
-  }
-  if (session) {
-    channel = switch_core_session_get_channel(session);
-  } else {
-    ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
-    goto done;
-  }
-  if (channel) {
-    switch_channel_mark_answered(channel);
-    //DEBUGA_SKYPE(&quot;skype_call: %s, answered\n&quot;, SKYPIAX_P_LOG, id);
-  } else {
-    ERRORA(&quot;No channel???\n&quot;, SKYPIAX_P_LOG);
-    goto done;
-  }
</del><ins>+        if (!switch_strlen_zero(tech_pvt-&gt;session_uuid_str)) {
+                session = switch_core_session_locate(tech_pvt-&gt;session_uuid_str);
+        } else {
+                ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
+                goto done;
+        }
+        if (session) {
+                channel = switch_core_session_get_channel(session);
+        } else {
+                ERRORA(&quot;No session???\n&quot;, SKYPIAX_P_LOG);
+                goto done;
+        }
+        if (channel) {
+                switch_channel_mark_answered(channel);
+                //DEBUGA_SKYPE(&quot;skype_call: %s, answered\n&quot;, SKYPIAX_P_LOG, id);
+        } else {
+                ERRORA(&quot;No channel???\n&quot;, SKYPIAX_P_LOG);
+                goto done;
+        }
</ins><span class="cx"> 
</span><del>-  switch_core_session_rwunlock(session);
</del><ins>+        switch_core_session_rwunlock(session);
</ins><span class="cx"> 
</span><del>-done:
-  DEBUGA_SKYPE(&quot;HERE!\n&quot;, SKYPIAX_P_LOG);
</del><ins>+  done:
+        DEBUGA_SKYPE(&quot;HERE!\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> private_t *find_available_skypiax_interface(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  private_t *tech_pvt2 = NULL;
-  int found = 0;
-  int i;
</del><ins>+        private_t *tech_pvt2 = NULL;
+        int found = 0;
+        int i;
</ins><span class="cx"> 
</span><del>-  switch_mutex_lock(globals.mutex);
</del><ins>+        switch_mutex_lock(globals.mutex);
</ins><span class="cx"> 
</span><del>-  for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-    if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
-      int skype_state = 0;
</del><ins>+        for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
+                        int skype_state = 0;
</ins><span class="cx"> 
</span><del>-      tech_pvt2 = &amp;globals.SKYPIAX_INTERFACES[i];
-      skype_state = tech_pvt2-&gt;interface_state;
-      DEBUGA_SKYPE(&quot;skype interface: %d, name: %s, state: %d\n&quot;, SKYPIAX_P_LOG, i,
-                   globals.SKYPIAX_INTERFACES[i].name, skype_state);
-      if ((tech_pvt ? strcmp(tech_pvt2-&gt;skype_user, tech_pvt-&gt;skype_user) : 1) &amp;&amp; (SKYPIAX_STATE_DOWN == skype_state || SKYPIAX_STATE_RING == skype_state || 0 == skype_state)) {   //(if we got tech_pvt NOT NULL) if user is NOT the same, and iface is idle
-        found = 1;
-        break;
-      }
-    }
-  }
</del><ins>+                        tech_pvt2 = &amp;globals.SKYPIAX_INTERFACES[i];
+                        skype_state = tech_pvt2-&gt;interface_state;
+                        DEBUGA_SKYPE(&quot;skype interface: %d, name: %s, state: %d\n&quot;, SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name, skype_state);
+                        if ((tech_pvt ? strcmp(tech_pvt2-&gt;skype_user, tech_pvt-&gt;skype_user) : 1) &amp;&amp; (SKYPIAX_STATE_DOWN == skype_state || SKYPIAX_STATE_RING == skype_state || 0 == skype_state)) {        //(if we got tech_pvt NOT NULL) if user is NOT the same, and iface is idle
+                                found = 1;
+                                break;
+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  switch_mutex_unlock(globals.mutex);
-  if (found)
-    return tech_pvt2;
-  else
-    return NULL;
</del><ins>+        switch_mutex_unlock(globals.mutex);
+        if (found)
+                return tech_pvt2;
+        else
+                return NULL;
</ins><span class="cx"> }
</span><del>-   
</del><ins>+
</ins><span class="cx"> private_t *find_available_skypiax_interface_rr(void)
</span><span class="cx"> {
</span><del>-  private_t *tech_pvt = NULL;
-  int i;
-  //int num_interfaces = SKYPIAX_MAX_INTERFACES; 
-  //int num_interfaces = globals.real_interfaces;
</del><ins>+        private_t *tech_pvt = NULL;
+        int i;
+        //int num_interfaces = SKYPIAX_MAX_INTERFACES; 
+        //int num_interfaces = globals.real_interfaces;
</ins><span class="cx"> 
</span><del>-  switch_mutex_lock(globals.mutex);
</del><ins>+        switch_mutex_lock(globals.mutex);
</ins><span class="cx"> 
</span><del>-  /* Fact is the real interface start from 1 */
-  //XXX no, is just a convention, but you can have it start from 0. I do not, for aestetic reasons :-)  
-  //if (globals.next_interface == 0) globals.next_interface = 1;
</del><ins>+        /* Fact is the real interface start from 1 */
+        //XXX no, is just a convention, but you can have it start from 0. I do not, for aestetic reasons :-)  
+        //if (globals.next_interface == 0) globals.next_interface = 1;
</ins><span class="cx"> 
</span><del>-  for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) { 
-    int interface_id;
</del><ins>+        for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                int interface_id;
</ins><span class="cx"> 
</span><del>-    interface_id = globals.next_interface;
-    //interface_id = interface_id &lt; SKYPIAX_MAX_INTERFACES ? interface_id : interface_id - SKYPIAX_MAX_INTERFACES + 1;
-        globals.next_interface = interface_id + 1 &lt; SKYPIAX_MAX_INTERFACES ? interface_id + 1 : 0;
</del><ins>+                interface_id = globals.next_interface;
+                //interface_id = interface_id &lt; SKYPIAX_MAX_INTERFACES ? interface_id : interface_id - SKYPIAX_MAX_INTERFACES + 1;
+                globals.next_interface = interface_id + 1 &lt; SKYPIAX_MAX_INTERFACES ? interface_id + 1 : 0;
</ins><span class="cx"> 
</span><del>-    if (strlen(globals.SKYPIAX_INTERFACES[interface_id].name)) {
-      int skype_state = 0;
</del><ins>+                if (strlen(globals.SKYPIAX_INTERFACES[interface_id].name)) {
+                        int skype_state = 0;
</ins><span class="cx"> 
</span><del>-      tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
-      skype_state = tech_pvt-&gt;interface_state;
-      DEBUGA_SKYPE(&quot;skype interface: %d, name: %s, state: %d\n&quot;, SKYPIAX_P_LOG, interface_id,
-                         globals.SKYPIAX_INTERFACES[interface_id].name, skype_state);
-      if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) {
-        /*set to Dialing state to avoid other thread fint it, don't know if it is safe */
-        //XXX no, it's not safe 
-                  //tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING ;
-        
-        switch_mutex_unlock(globals.mutex);
-        return tech_pvt;
-      }
-    }// else {
-      //DEBUGA_SKYPE(&quot;Skype interface: %d blank!! A hole here means we cannot hunt the last interface.\n&quot;, SKYPIAX_P_LOG, interface_id);
-    //}
-  }
</del><ins>+                        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
+                        skype_state = tech_pvt-&gt;interface_state;
+                        DEBUGA_SKYPE(&quot;skype interface: %d, name: %s, state: %d\n&quot;, SKYPIAX_P_LOG, interface_id,
+                                                 globals.SKYPIAX_INTERFACES[interface_id].name, skype_state);
+                        if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) {
+                                /*set to Dialing state to avoid other thread fint it, don't know if it is safe */
+                                //XXX no, it's not safe 
+                                //tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING ;
</ins><span class="cx"> 
</span><del>-  switch_mutex_unlock(globals.mutex);
-  return NULL;
</del><ins>+                                switch_mutex_unlock(globals.mutex);
+                                return tech_pvt;
+                        }
+                }                                                // else {
+                //DEBUGA_SKYPE(&quot;Skype interface: %d blank!! A hole here means we cannot hunt the last interface.\n&quot;, SKYPIAX_P_LOG, interface_id);
+                //}
+        }
+
+        switch_mutex_unlock(globals.mutex);
+        return NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> SWITCH_STANDARD_API(sk_function)
</span><span class="cx"> {
</span><del>-  char *mycmd = NULL, *argv[10] = { 0 };
-  int argc = 0;
</del><ins>+        char *mycmd = NULL, *argv[10] = { 0 };
+        int argc = 0;
</ins><span class="cx"> 
</span><del>-  if (globals.sk_console)
-    stream-&gt;write_function(stream, &quot;sk console is: |||%s|||\n&quot;, globals.sk_console-&gt;name);
-  else
-    stream-&gt;write_function(stream, &quot;sk console is NOT yet assigned\n&quot;);
</del><ins>+        if (globals.sk_console)
+                stream-&gt;write_function(stream, &quot;sk console is: |||%s|||\n&quot;, globals.sk_console-&gt;name);
+        else
+                stream-&gt;write_function(stream, &quot;sk console is NOT yet assigned\n&quot;);
</ins><span class="cx"> 
</span><del>-  if (!switch_strlen_zero(cmd) &amp;&amp; (mycmd = strdup(cmd))) {
-    argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-  }
</del><ins>+        if (!switch_strlen_zero(cmd) &amp;&amp; (mycmd = strdup(cmd))) {
+                argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+        }
</ins><span class="cx"> 
</span><del>-  if (!argc || !argv[0]) {
-    stream-&gt;write_function(stream, &quot;%s&quot;, SK_SYNTAX);
-    goto end;
-  }
</del><ins>+        if (!argc || !argv[0]) {
+                stream-&gt;write_function(stream, &quot;%s&quot;, SK_SYNTAX);
+                goto end;
+        }
</ins><span class="cx"> 
</span><del>-  if (!strcasecmp(argv[0], &quot;list&quot;)) {
-    int i;             
-       char next_flag_char = ' ';
</del><ins>+        if (!strcasecmp(argv[0], &quot;list&quot;)) {
+                int i;
+                char next_flag_char = ' ';
</ins><span class="cx"> 
</span><del>-    for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-         next_flag_char = i == globals.next_interface ? '*' : ' ';
</del><ins>+                for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                        next_flag_char = i == globals.next_interface ? '*' : ' ';
</ins><span class="cx"> 
</span><del>-      if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
-        if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) {
-          stream-&gt;write_function(stream,
-                                 &quot;%c\t%d\t[%s]\tBUSY, session_uuid_str=|||%s|||\n&quot;,
-                                 next_flag_char,
-                                 i, globals.SKYPIAX_INTERFACES[i].name,
-                                 globals.SKYPIAX_INTERFACES[i].session_uuid_str);
-        } else {
-          stream-&gt;write_function(stream,
-                                 &quot;%c\t%d\t[%s]\tIDLE\n&quot;,
-                                 next_flag_char,
-                                 i, globals.SKYPIAX_INTERFACES[i].name);
-        }
-      } else if(argc &gt; 1 &amp;&amp; !strcasecmp(argv[1], &quot;full&quot;)) {
-        stream-&gt;write_function(stream, &quot;%c\t%d\n&quot;, next_flag_char, i);
-      }                                                                      
</del><ins>+                        if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
+                                if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) {
+                                        stream-&gt;write_function(stream,
+                                                                                   &quot;%c\t%d\t[%s]\tBUSY, session_uuid_str=|||%s|||\n&quot;,
+                                                                                   next_flag_char, i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str);
+                                } else {
+                                        stream-&gt;write_function(stream, &quot;%c\t%d\t[%s]\tIDLE\n&quot;, next_flag_char, i, globals.SKYPIAX_INTERFACES[i].name);
+                                }
+                        } else if (argc &gt; 1 &amp;&amp; !strcasecmp(argv[1], &quot;full&quot;)) {
+                                stream-&gt;write_function(stream, &quot;%c\t%d\n&quot;, next_flag_char, i);
+                        }
</ins><span class="cx"> 
</span><del>-    }
-    stream-&gt;write_function(stream, &quot;\nTotal: %d\n&quot;, globals.real_interfaces - 1 );
</del><ins>+                }
+                stream-&gt;write_function(stream, &quot;\nTotal: %d\n&quot;, globals.real_interfaces - 1);
</ins><span class="cx"> 
</span><del>-  } else if (!strcasecmp(argv[0], &quot;console&quot;)) {
-    int i;
-    int found = 0;
</del><ins>+        } else if (!strcasecmp(argv[0], &quot;console&quot;)) {
+                int i;
+                int found = 0;
</ins><span class="cx"> 
</span><del>-    if (argc == 2) {
-      for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-        /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the &quot;ANY&quot; interface */
-        if (strlen(globals.SKYPIAX_INTERFACES[i].name)
-            &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[1], strlen(argv[1])) ==
-                0)) {
-          globals.sk_console = &amp;globals.SKYPIAX_INTERFACES[i];
-          stream-&gt;write_function(stream,
-                                 &quot;sk console is now: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;,
-                                 i, globals.SKYPIAX_INTERFACES[i].name);
-          stream-&gt;write_function(stream, &quot;sk console is: |||%s|||\n&quot;,
-                                 globals.sk_console-&gt;name);
-          found = 1;
-          break;
-        }
</del><ins>+                if (argc == 2) {
+                        for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                                /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the &quot;ANY&quot; interface */
+                                if (strlen(globals.SKYPIAX_INTERFACES[i].name)
+                                        &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[1], strlen(argv[1])) == 0)) {
+                                        globals.sk_console = &amp;globals.SKYPIAX_INTERFACES[i];
+                                        stream-&gt;write_function(stream,
+                                                                                   &quot;sk console is now: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;, i, globals.SKYPIAX_INTERFACES[i].name);
+                                        stream-&gt;write_function(stream, &quot;sk console is: |||%s|||\n&quot;, globals.sk_console-&gt;name);
+                                        found = 1;
+                                        break;
+                                }
</ins><span class="cx"> 
</span><del>-      }
-      if (!found)
-        stream-&gt;write_function(stream,
-                               &quot;ERROR: A Skypiax interface with name='%s' was not found\n&quot;,
-                               argv[1]);
-    } else {
</del><ins>+                        }
+                        if (!found)
+                                stream-&gt;write_function(stream, &quot;ERROR: A Skypiax interface with name='%s' was not found\n&quot;, argv[1]);
+                } else {
</ins><span class="cx"> 
</span><del>-      stream-&gt;write_function(stream, &quot;-ERR Usage: sk console interface_name\n&quot;);
-      goto end;
-    }
</del><ins>+                        stream-&gt;write_function(stream, &quot;-ERR Usage: sk console interface_name\n&quot;);
+                        goto end;
+                }
</ins><span class="cx"> 
</span><del>-  } else if (!strcasecmp(argv[0], &quot;ciapalino&quot;)) {
</del><ins>+        } else if (!strcasecmp(argv[0], &quot;ciapalino&quot;)) {
</ins><span class="cx"> 
</span><span class="cx"> /* BEGIN: Changes heres */
</span><del>-  } else if (!strcasecmp(argv[0], &quot;reload&quot;)) {
-    if (load_config(SOFT_RELOAD) != SWITCH_STATUS_SUCCESS) {
-      stream-&gt;write_function(stream, &quot;sk reload failed\n&quot;);
-    } else {
-      stream-&gt;write_function(stream, &quot;sk reload success\n&quot;);
-    }
-  } else if (!strcasecmp(argv[0], &quot;remove&quot;)) {
-    if (argc == 2) {
-      if (remove_interface(argv[1]) == SWITCH_STATUS_SUCCESS) {
-        if (interface_exists(argv[1]) == SWITCH_STATUS_SUCCESS) {
-          stream-&gt;write_function(stream, &quot;sk remove '%s' failed\n&quot;, argv[1]);
-        } else {
-          stream-&gt;write_function(stream, &quot;sk remove '%s' success\n&quot;, argv[1]);
-        }
-      }
-    } else {
-      stream-&gt;write_function(stream, &quot;-ERR Usage: sk remove interface_name\n&quot;);
-      goto end;
-    }
</del><ins>+        } else if (!strcasecmp(argv[0], &quot;reload&quot;)) {
+                if (load_config(SOFT_RELOAD) != SWITCH_STATUS_SUCCESS) {
+                        stream-&gt;write_function(stream, &quot;sk reload failed\n&quot;);
+                } else {
+                        stream-&gt;write_function(stream, &quot;sk reload success\n&quot;);
+                }
+        } else if (!strcasecmp(argv[0], &quot;remove&quot;)) {
+                if (argc == 2) {
+                        if (remove_interface(argv[1]) == SWITCH_STATUS_SUCCESS) {
+                                if (interface_exists(argv[1]) == SWITCH_STATUS_SUCCESS) {
+                                        stream-&gt;write_function(stream, &quot;sk remove '%s' failed\n&quot;, argv[1]);
+                                } else {
+                                        stream-&gt;write_function(stream, &quot;sk remove '%s' success\n&quot;, argv[1]);
+                                }
+                        }
+                } else {
+                        stream-&gt;write_function(stream, &quot;-ERR Usage: sk remove interface_name\n&quot;);
+                        goto end;
+                }
</ins><span class="cx"> /* END: Changes heres */
</span><span class="cx"> 
</span><del>-  } else {
-    if (globals.sk_console)
-      skypiax_signaling_write(globals.sk_console, (char *) cmd);
-    else
-      stream-&gt;write_function(stream, &quot;sk console is NOT yet assigned\n&quot;);
-  }
-end:
-  switch_safe_free(mycmd);
</del><ins>+        } else {
+                if (globals.sk_console)
+                        skypiax_signaling_write(globals.sk_console, (char *) cmd);
+                else
+                        stream-&gt;write_function(stream, &quot;sk console is NOT yet assigned\n&quot;);
+        }
+  end:
+        switch_safe_free(mycmd);
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> SWITCH_STANDARD_API(skypiax_function)
</span><span class="cx"> {
</span><del>-  char *mycmd = NULL, *argv[10] = { 0 };
-  int argc = 0;
-  private_t *tech_pvt = NULL;
</del><ins>+        char *mycmd = NULL, *argv[10] = { 0 };
+        int argc = 0;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  if (!switch_strlen_zero(cmd) &amp;&amp; (mycmd = strdup(cmd))) {
-    argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-  }
</del><ins>+        if (!switch_strlen_zero(cmd) &amp;&amp; (mycmd = strdup(cmd))) {
+                argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+        }
</ins><span class="cx"> 
</span><del>-  if (!argc) {
-    stream-&gt;write_function(stream, &quot;ERROR, usage: %s&quot;, SKYPIAX_SYNTAX);
-    goto end;
-  }
</del><ins>+        if (!argc) {
+                stream-&gt;write_function(stream, &quot;ERROR, usage: %s&quot;, SKYPIAX_SYNTAX);
+                goto end;
+        }
</ins><span class="cx"> 
</span><del>-  if (argc &lt; 2) {
-    stream-&gt;write_function(stream, &quot;ERROR, usage: %s&quot;, SKYPIAX_SYNTAX);
-    goto end;
-  }
</del><ins>+        if (argc &lt; 2) {
+                stream-&gt;write_function(stream, &quot;ERROR, usage: %s&quot;, SKYPIAX_SYNTAX);
+                goto end;
+        }
</ins><span class="cx"> 
</span><del>-  if (argv[0]) {
-    int i;
-    int found = 0;
</del><ins>+        if (argv[0]) {
+                int i;
+                int found = 0;
</ins><span class="cx"> 
</span><del>-    for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-      /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the &quot;ANY&quot; interface */
-      if (strlen(globals.SKYPIAX_INTERFACES[i].name)
-          &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
-        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
-        stream-&gt;write_function(stream,
-                               &quot;Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;,
-                               i, globals.SKYPIAX_INTERFACES[i].name);
-        found = 1;
-        break;
-      }
</del><ins>+                for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                        /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the &quot;ANY&quot; interface */
+                        if (strlen(globals.SKYPIAX_INTERFACES[i].name)
+                                &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
+                                tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
+                                stream-&gt;write_function(stream, &quot;Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;, i, globals.SKYPIAX_INTERFACES[i].name);
+                                found = 1;
+                                break;
+                        }
</ins><span class="cx"> 
</span><del>-    }
-    if (!found) {
-      stream-&gt;write_function(stream,
-                             &quot;ERROR: A Skypiax interface with name='%s' was not found\n&quot;,
-                             argv[0]);
-      switch_safe_free(mycmd);
</del><ins>+                }
+                if (!found) {
+                        stream-&gt;write_function(stream, &quot;ERROR: A Skypiax interface with name='%s' was not found\n&quot;, argv[0]);
+                        switch_safe_free(mycmd);
</ins><span class="cx"> 
</span><del>-      return SWITCH_STATUS_SUCCESS;
-    } else {
-      skypiax_signaling_write(tech_pvt, (char *) &amp;cmd[strlen(argv[0]) + 1]);
-    }
-  } else {
-    stream-&gt;write_function(stream, &quot;ERROR, usage: %s&quot;, SKYPIAX_SYNTAX);
-  }
-end:
-  switch_safe_free(mycmd);
</del><ins>+                        return SWITCH_STATUS_SUCCESS;
+                } else {
+                        skypiax_signaling_write(tech_pvt, (char *) &amp;cmd[strlen(argv[0]) + 1]);
+                }
+        } else {
+                stream-&gt;write_function(stream, &quot;ERROR, usage: %s&quot;, SKYPIAX_SYNTAX);
+        }
+  end:
+        switch_safe_free(mycmd);
</ins><span class="cx"> 
</span><del>-  return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_answer(private_t * tech_pvt, char *id, char *value)
</span><span class="cx"> {
</span><del>-  char msg_to_skype[1024];
-  int i;
-  int found = 0;
-  private_t *giovatech;
-  struct timeval timenow;
</del><ins>+        char msg_to_skype[1024];
+        int i;
+        int found = 0;
+        private_t *giovatech;
+        struct timeval timenow;
</ins><span class="cx"> 
</span><del>-  switch_mutex_lock(globals.mutex);
</del><ins>+        switch_mutex_lock(globals.mutex);
</ins><span class="cx"> 
</span><del>-  gettimeofday(&amp;timenow, NULL);
-  for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-    if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</del><ins>+        gettimeofday(&amp;timenow, NULL);
+        for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</ins><span class="cx"> 
</span><del>-      giovatech = &amp;globals.SKYPIAX_INTERFACES[i];
-      //NOTICA(&quot;skype interface: %d, name: %s, state: %d, value=%s, giovatech-&gt;callid_number=%s, giovatech-&gt;skype_user=%s\n&quot;, SKYPIAX_P_LOG, i, giovatech-&gt;name, giovatech-&gt;interface_state, value, giovatech-&gt;callid_number, giovatech-&gt;skype_user);
-      //FIXME check a timestamp here
-      if (strlen(giovatech-&gt;skype_call_id) &amp;&amp; (giovatech-&gt;interface_state != SKYPIAX_STATE_DOWN) &amp;&amp; (!strcmp(giovatech-&gt;skype_user, tech_pvt-&gt;skype_user)) &amp;&amp; (!strcmp(giovatech-&gt;callid_number, value)) &amp;&amp; ((((timenow.tv_sec - giovatech-&gt;answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech-&gt;answer_time.tv_usec)) &lt; 500000)) {   //0.5sec
-        found = 1;
-        DEBUGA_SKYPE
-          (&quot;FOUND  (name=%s, giovatech-&gt;interface_state=%d != SKYPIAX_STATE_DOWN) &amp;&amp; (giovatech-&gt;skype_user=%s == tech_pvt-&gt;skype_user=%s) &amp;&amp; (giovatech-&gt;callid_number=%s == value=%s)\n&quot;,
-           SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state,
-           giovatech-&gt;skype_user, tech_pvt-&gt;skype_user, giovatech-&gt;callid_number, value)
-          break;
-      }
-    }
-  }
</del><ins>+                        giovatech = &amp;globals.SKYPIAX_INTERFACES[i];
+                        //NOTICA(&quot;skype interface: %d, name: %s, state: %d, value=%s, giovatech-&gt;callid_number=%s, giovatech-&gt;skype_user=%s\n&quot;, SKYPIAX_P_LOG, i, giovatech-&gt;name, giovatech-&gt;interface_state, value, giovatech-&gt;callid_number, giovatech-&gt;skype_user);
+                        //FIXME check a timestamp here
+                        if (strlen(giovatech-&gt;skype_call_id) &amp;&amp; (giovatech-&gt;interface_state != SKYPIAX_STATE_DOWN) &amp;&amp; (!strcmp(giovatech-&gt;skype_user, tech_pvt-&gt;skype_user)) &amp;&amp; (!strcmp(giovatech-&gt;callid_number, value)) &amp;&amp; ((((timenow.tv_sec - giovatech-&gt;answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech-&gt;answer_time.tv_usec)) &lt; 500000)) {        //0.5sec
+                                found = 1;
+                                DEBUGA_SKYPE
+                                        (&quot;FOUND  (name=%s, giovatech-&gt;interface_state=%d != SKYPIAX_STATE_DOWN) &amp;&amp; (giovatech-&gt;skype_user=%s == tech_pvt-&gt;skype_user=%s) &amp;&amp; (giovatech-&gt;callid_number=%s == value=%s)\n&quot;,
+                                         SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state,
+                                         giovatech-&gt;skype_user, tech_pvt-&gt;skype_user, giovatech-&gt;callid_number, value)
+                                        break;
+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (found) {
-    //tech_pvt-&gt;callid_number[0]='\0';
-    switch_mutex_unlock(globals.mutex);
-    return 0;
-  }
-  DEBUGA_SKYPE(&quot;NOT FOUND\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        if (found) {
+                //tech_pvt-&gt;callid_number[0]='\0';
+                switch_mutex_unlock(globals.mutex);
+                return 0;
+        }
+        DEBUGA_SKYPE(&quot;NOT FOUND\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  if (tech_pvt &amp;&amp; tech_pvt-&gt;skype_call_id &amp;&amp; !strlen(tech_pvt-&gt;skype_call_id)) {
-    /* we are not inside an active call */
</del><ins>+        if (tech_pvt &amp;&amp; tech_pvt-&gt;skype_call_id &amp;&amp; !strlen(tech_pvt-&gt;skype_call_id)) {
+                /* we are not inside an active call */
</ins><span class="cx"> 
</span><del>-    sprintf(msg_to_skype, &quot;GET CALL %s PARTNER_DISPNAME&quot;, id);
-    skypiax_signaling_write(tech_pvt, msg_to_skype);
-    switch_sleep(10000);
-    sprintf(msg_to_skype, &quot;ALTER CALL %s ANSWER&quot;, id);
-    skypiax_signaling_write(tech_pvt, msg_to_skype);
-    DEBUGA_SKYPE(&quot;We answered a Skype RING on skype_call %s\n&quot;, SKYPIAX_P_LOG, id);
-    //FIXME write a timestamp here
-    gettimeofday(&amp;tech_pvt-&gt;answer_time, NULL);
-    switch_copy_string(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
</del><ins>+                sprintf(msg_to_skype, &quot;GET CALL %s PARTNER_DISPNAME&quot;, id);
+                skypiax_signaling_write(tech_pvt, msg_to_skype);
+                switch_sleep(10000);
+                sprintf(msg_to_skype, &quot;ALTER CALL %s ANSWER&quot;, id);
+                skypiax_signaling_write(tech_pvt, msg_to_skype);
+                DEBUGA_SKYPE(&quot;We answered a Skype RING on skype_call %s\n&quot;, SKYPIAX_P_LOG, id);
+                //FIXME write a timestamp here
+                gettimeofday(&amp;tech_pvt-&gt;answer_time, NULL);
+                switch_copy_string(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
</ins><span class="cx"> 
</span><del>-    switch_copy_string(tech_pvt-&gt;callid_number, value,
-                       sizeof(tech_pvt-&gt;callid_number) - 1);
</del><ins>+                switch_copy_string(tech_pvt-&gt;callid_number, value, sizeof(tech_pvt-&gt;callid_number) - 1);
</ins><span class="cx"> 
</span><del>-    DEBUGA_SKYPE
-      (&quot;NEW!  name: %s, state: %d, value=%s, tech_pvt-&gt;callid_number=%s, tech_pvt-&gt;skype_user=%s\n&quot;,
-       SKYPIAX_P_LOG, tech_pvt-&gt;name, tech_pvt-&gt;interface_state, value,
-       tech_pvt-&gt;callid_number, tech_pvt-&gt;skype_user);
-  } else if (!tech_pvt || !tech_pvt-&gt;skype_call_id) {
-    ERRORA(&quot;No Call ID?\n&quot;, SKYPIAX_P_LOG);
-  } else {
-    ERRORA(&quot;We're in a call now %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id);
-  }
</del><ins>+                DEBUGA_SKYPE
+                        (&quot;NEW!  name: %s, state: %d, value=%s, tech_pvt-&gt;callid_number=%s, tech_pvt-&gt;skype_user=%s\n&quot;,
+                         SKYPIAX_P_LOG, tech_pvt-&gt;name, tech_pvt-&gt;interface_state, value, tech_pvt-&gt;callid_number, tech_pvt-&gt;skype_user);
+        } else if (!tech_pvt || !tech_pvt-&gt;skype_call_id) {
+                ERRORA(&quot;No Call ID?\n&quot;, SKYPIAX_P_LOG);
+        } else {
+                ERRORA(&quot;We're in a call now %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id);
+        }
</ins><span class="cx"> 
</span><del>-  switch_mutex_unlock(globals.mutex);
-  return 0;
</del><ins>+        switch_mutex_unlock(globals.mutex);
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> int skypiax_transfer(private_t * tech_pvt, char *id, char *value)
</span><span class="cx"> {
</span><del>-  char msg_to_skype[1024];
-  int i;
-  int found = 0;
-  private_t *giovatech;
-  struct timeval timenow;
</del><ins>+        char msg_to_skype[1024];
+        int i;
+        int found = 0;
+        private_t *giovatech;
+        struct timeval timenow;
</ins><span class="cx"> 
</span><del>-  switch_mutex_lock(globals.mutex);
</del><ins>+        switch_mutex_lock(globals.mutex);
</ins><span class="cx"> 
</span><del>-  gettimeofday(&amp;timenow, NULL);
-  for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-    if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</del><ins>+        gettimeofday(&amp;timenow, NULL);
+        for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</ins><span class="cx"> 
</span><del>-      giovatech = &amp;globals.SKYPIAX_INTERFACES[i];
-      //NOTICA(&quot;skype interface: %d, name: %s, state: %d, value=%s, giovatech-&gt;callid_number=%s, giovatech-&gt;skype_user=%s\n&quot;, SKYPIAX_P_LOG, i, giovatech-&gt;name, giovatech-&gt;interface_state, value, giovatech-&gt;callid_number, giovatech-&gt;skype_user);
-      //FIXME check a timestamp here
-      if (strlen(giovatech-&gt;skype_call_id) &amp;&amp; (giovatech-&gt;interface_state != SKYPIAX_STATE_DOWN) &amp;&amp; (!strcmp(giovatech-&gt;skype_user, tech_pvt-&gt;skype_user)) &amp;&amp; (!strcmp(giovatech-&gt;callid_number, value)) &amp;&amp; ((((timenow.tv_sec - giovatech-&gt;answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech-&gt;answer_time.tv_usec)) &lt; 500000)) {   //0.5sec
-        found = 1;
-        DEBUGA_SKYPE
-          (&quot;FOUND  (name=%s, giovatech-&gt;interface_state=%d != SKYPIAX_STATE_DOWN) &amp;&amp; (giovatech-&gt;skype_user=%s == tech_pvt-&gt;skype_user=%s) &amp;&amp; (giovatech-&gt;callid_number=%s == value=%s)\n&quot;,
-           SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state,
-           giovatech-&gt;skype_user, tech_pvt-&gt;skype_user, giovatech-&gt;callid_number, value)
-          break;
-      }
-    }
-  }
</del><ins>+                        giovatech = &amp;globals.SKYPIAX_INTERFACES[i];
+                        //NOTICA(&quot;skype interface: %d, name: %s, state: %d, value=%s, giovatech-&gt;callid_number=%s, giovatech-&gt;skype_user=%s\n&quot;, SKYPIAX_P_LOG, i, giovatech-&gt;name, giovatech-&gt;interface_state, value, giovatech-&gt;callid_number, giovatech-&gt;skype_user);
+                        //FIXME check a timestamp here
+                        if (strlen(giovatech-&gt;skype_call_id) &amp;&amp; (giovatech-&gt;interface_state != SKYPIAX_STATE_DOWN) &amp;&amp; (!strcmp(giovatech-&gt;skype_user, tech_pvt-&gt;skype_user)) &amp;&amp; (!strcmp(giovatech-&gt;callid_number, value)) &amp;&amp; ((((timenow.tv_sec - giovatech-&gt;answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech-&gt;answer_time.tv_usec)) &lt; 500000)) {        //0.5sec
+                                found = 1;
+                                DEBUGA_SKYPE
+                                        (&quot;FOUND  (name=%s, giovatech-&gt;interface_state=%d != SKYPIAX_STATE_DOWN) &amp;&amp; (giovatech-&gt;skype_user=%s == tech_pvt-&gt;skype_user=%s) &amp;&amp; (giovatech-&gt;callid_number=%s == value=%s)\n&quot;,
+                                         SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state,
+                                         giovatech-&gt;skype_user, tech_pvt-&gt;skype_user, giovatech-&gt;callid_number, value)
+                                        break;
+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (found) {
-    //tech_pvt-&gt;callid_number[0]='\0';
-    switch_mutex_unlock(globals.mutex);
-    return 0;
-  }
-  DEBUGA_SKYPE(&quot;NOT FOUND\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        if (found) {
+                //tech_pvt-&gt;callid_number[0]='\0';
+                switch_mutex_unlock(globals.mutex);
+                return 0;
+        }
+        DEBUGA_SKYPE(&quot;NOT FOUND\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  if (!tech_pvt || !tech_pvt-&gt;skype_call_id || !strlen(tech_pvt-&gt;skype_call_id)) {
-    /* we are not inside an active call */
-          ERRORA(&quot;We're NO MORE in a call now %s\n&quot;, SKYPIAX_P_LOG, (tech_pvt &amp;&amp; tech_pvt-&gt;skype_call_id) ? tech_pvt-&gt;skype_call_id : &quot;&quot; );
-    switch_mutex_unlock(globals.mutex);
</del><ins>+        if (!tech_pvt || !tech_pvt-&gt;skype_call_id || !strlen(tech_pvt-&gt;skype_call_id)) {
+                /* we are not inside an active call */
+                ERRORA(&quot;We're NO MORE in a call now %s\n&quot;, SKYPIAX_P_LOG, (tech_pvt &amp;&amp; tech_pvt-&gt;skype_call_id) ? tech_pvt-&gt;skype_call_id : &quot;&quot;);
+                switch_mutex_unlock(globals.mutex);
</ins><span class="cx"> 
</span><del>-  } else {
</del><ins>+        } else {
</ins><span class="cx"> 
</span><del>-    /* we're owned, we're in a call, let's try to transfer */
-        /************************** TODO
</del><ins>+                /* we're owned, we're in a call, let's try to transfer */
+                /************************** TODO
</ins><span class="cx">                   Checking here if it is possible to transfer this call to Test2
</span><span class="cx">                   -&gt; GET CALL 288 CAN_TRANSFER Test2
</span><span class="cx">                   &lt;- CALL 288 CAN_TRANSFER test2 TRUE
</span><span class="cx">                  **********************************/
</span><span class="cx"> 
</span><del>-    private_t *available_skypiax_interface = NULL;
</del><ins>+                private_t *available_skypiax_interface = NULL;
</ins><span class="cx"> 
</span><del>-    gettimeofday(&amp;timenow, NULL);
-    for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-      if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</del><ins>+                gettimeofday(&amp;timenow, NULL);
+                for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                        if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</ins><span class="cx"> 
</span><del>-        giovatech = &amp;globals.SKYPIAX_INTERFACES[i];
-        //NOTICA(&quot;skype interface: %d, name: %s, state: %d, value=%s, giovatech-&gt;callid_number=%s, giovatech-&gt;skype_user=%s\n&quot;, SKYPIAX_P_LOG, i, giovatech-&gt;name, giovatech-&gt;interface_state, value, giovatech-&gt;callid_number, giovatech-&gt;skype_user);
-        //FIXME check a timestamp here
-        if (strlen(giovatech-&gt;skype_transfer_call_id) &amp;&amp; (giovatech-&gt;interface_state != SKYPIAX_STATE_DOWN) &amp;&amp; (!strcmp(giovatech-&gt;skype_user, tech_pvt-&gt;skype_user)) &amp;&amp; (!strcmp(giovatech-&gt;transfer_callid_number, value)) &amp;&amp; ((((timenow.tv_sec - giovatech-&gt;transfer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech-&gt;transfer_time.tv_usec)) &lt; 1000000)) {  //1.0 sec
-          found = 1;
-          DEBUGA_SKYPE
-            (&quot;FOUND  (name=%s, giovatech-&gt;interface_state=%d != SKYPIAX_STATE_DOWN) &amp;&amp; (giovatech-&gt;skype_user=%s == tech_pvt-&gt;skype_user=%s) &amp;&amp; (giovatech-&gt;transfer_callid_number=%s == value=%s)\n&quot;,
-             SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state,
-             giovatech-&gt;skype_user, tech_pvt-&gt;skype_user,
-             giovatech-&gt;transfer_callid_number, value)
-            break;
-        }
-      }
-    }
</del><ins>+                                giovatech = &amp;globals.SKYPIAX_INTERFACES[i];
+                                //NOTICA(&quot;skype interface: %d, name: %s, state: %d, value=%s, giovatech-&gt;callid_number=%s, giovatech-&gt;skype_user=%s\n&quot;, SKYPIAX_P_LOG, i, giovatech-&gt;name, giovatech-&gt;interface_state, value, giovatech-&gt;callid_number, giovatech-&gt;skype_user);
+                                //FIXME check a timestamp here
+                                if (strlen(giovatech-&gt;skype_transfer_call_id) &amp;&amp; (giovatech-&gt;interface_state != SKYPIAX_STATE_DOWN) &amp;&amp; (!strcmp(giovatech-&gt;skype_user, tech_pvt-&gt;skype_user)) &amp;&amp; (!strcmp(giovatech-&gt;transfer_callid_number, value)) &amp;&amp; ((((timenow.tv_sec - giovatech-&gt;transfer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech-&gt;transfer_time.tv_usec)) &lt; 1000000)) {        //1.0 sec
+                                        found = 1;
+                                        DEBUGA_SKYPE
+                                                (&quot;FOUND  (name=%s, giovatech-&gt;interface_state=%d != SKYPIAX_STATE_DOWN) &amp;&amp; (giovatech-&gt;skype_user=%s == tech_pvt-&gt;skype_user=%s) &amp;&amp; (giovatech-&gt;transfer_callid_number=%s == value=%s)\n&quot;,
+                                                 SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state,
+                                                 giovatech-&gt;skype_user, tech_pvt-&gt;skype_user, giovatech-&gt;transfer_callid_number, value)
+                                                break;
+                                }
+                        }
+                }
</ins><span class="cx"> 
</span><del>-    if (found) {
-      //tech_pvt-&gt;callid_number[0]='\0';
-      switch_mutex_unlock(globals.mutex);
-      return 0;
-    }
-    DEBUGA_SKYPE(&quot;NOT FOUND\n&quot;, SKYPIAX_P_LOG);
</del><ins>+                if (found) {
+                        //tech_pvt-&gt;callid_number[0]='\0';
+                        switch_mutex_unlock(globals.mutex);
+                        return 0;
+                }
+                DEBUGA_SKYPE(&quot;NOT FOUND\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-    available_skypiax_interface = find_available_skypiax_interface(tech_pvt);
-    if (available_skypiax_interface) {
-      /* there is a skypiax interface idle, let's transfer the call to it */
</del><ins>+                available_skypiax_interface = find_available_skypiax_interface(tech_pvt);
+                if (available_skypiax_interface) {
+                        /* there is a skypiax interface idle, let's transfer the call to it */
</ins><span class="cx"> 
</span><del>-      //FIXME write a timestamp here
-      gettimeofday(&amp;tech_pvt-&gt;transfer_time, NULL);
-      switch_copy_string(tech_pvt-&gt;skype_transfer_call_id, id,
-                         sizeof(tech_pvt-&gt;skype_transfer_call_id) - 1);
</del><ins>+                        //FIXME write a timestamp here
+                        gettimeofday(&amp;tech_pvt-&gt;transfer_time, NULL);
+                        switch_copy_string(tech_pvt-&gt;skype_transfer_call_id, id, sizeof(tech_pvt-&gt;skype_transfer_call_id) - 1);
</ins><span class="cx"> 
</span><del>-      switch_copy_string(tech_pvt-&gt;transfer_callid_number, value,
-                         sizeof(tech_pvt-&gt;transfer_callid_number) - 1);
</del><ins>+                        switch_copy_string(tech_pvt-&gt;transfer_callid_number, value, sizeof(tech_pvt-&gt;transfer_callid_number) - 1);
</ins><span class="cx"> 
</span><del>-      DEBUGA_SKYPE
-        (&quot;Let's transfer the skype_call %s to %s interface (with skype_user: %s), because we are already in a skypiax call(%s)\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id, available_skypiax_interface-&gt;name,
-         available_skypiax_interface-&gt;skype_user, id);
-      sprintf(msg_to_skype, &quot;ALTER CALL %s TRANSFER %s&quot;, id,
-              available_skypiax_interface-&gt;skype_user);
-      skypiax_signaling_write(tech_pvt, msg_to_skype);
-    } else {
-      /* no skypiax interfaces idle, do nothing */
-      DEBUGA_SKYPE
-        (&quot;Not answering the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available OR another interface is answering this call\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id, id);
-      //sprintf(msg_to_skype, &quot;ALTER CALL %s END HANGUP&quot;, id);
-    }
-    switch_sleep(10000);
-    DEBUGA_SKYPE
-      (&quot;We (%s) have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n&quot;,
-       SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id, id);
</del><ins>+                        DEBUGA_SKYPE
+                                (&quot;Let's transfer the skype_call %s to %s interface (with skype_user: %s), because we are already in a skypiax call(%s)\n&quot;,
+                                 SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id, available_skypiax_interface-&gt;name, available_skypiax_interface-&gt;skype_user, id);
+                        sprintf(msg_to_skype, &quot;ALTER CALL %s TRANSFER %s&quot;, id, available_skypiax_interface-&gt;skype_user);
+                        skypiax_signaling_write(tech_pvt, msg_to_skype);
+                } else {
+                        /* no skypiax interfaces idle, do nothing */
+                        DEBUGA_SKYPE
+                                (&quot;Not answering the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available OR another interface is answering this call\n&quot;,
+                                 SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id, id);
+                        //sprintf(msg_to_skype, &quot;ALTER CALL %s END HANGUP&quot;, id);
+                }
+                switch_sleep(10000);
+                DEBUGA_SKYPE
+                        (&quot;We (%s) have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n&quot;,
+                         SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id, id);
</ins><span class="cx"> 
</span><del>-    switch_mutex_unlock(globals.mutex);
-  }
-  return 0;
</del><ins>+                switch_mutex_unlock(globals.mutex);
+        }
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* For Emacs:
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h (14443 => 14444)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-08-01 01:02:02 UTC (rev 14443)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-08-01 02:47:35 UTC (rev 14444)
</span><span class="lines">@@ -58,19 +58,19 @@
</span><span class="cx"> #endif /* SKYPIAX_SVN_VERSION */
</span><span class="cx"> 
</span><span class="cx"> typedef enum {
</span><del>-  TFLAG_IO = (1 &lt;&lt; 0),
-  TFLAG_INBOUND = (1 &lt;&lt; 1),
-  TFLAG_OUTBOUND = (1 &lt;&lt; 2),
-  TFLAG_DTMF = (1 &lt;&lt; 3),
-  TFLAG_VOICE = (1 &lt;&lt; 4),
-  TFLAG_HANGUP = (1 &lt;&lt; 5),
-  TFLAG_LINEAR = (1 &lt;&lt; 6),
-  TFLAG_CODEC = (1 &lt;&lt; 7),
-  TFLAG_BREAK = (1 &lt;&lt; 8)
</del><ins>+        TFLAG_IO = (1 &lt;&lt; 0),
+        TFLAG_INBOUND = (1 &lt;&lt; 1),
+        TFLAG_OUTBOUND = (1 &lt;&lt; 2),
+        TFLAG_DTMF = (1 &lt;&lt; 3),
+        TFLAG_VOICE = (1 &lt;&lt; 4),
+        TFLAG_HANGUP = (1 &lt;&lt; 5),
+        TFLAG_LINEAR = (1 &lt;&lt; 6),
+        TFLAG_CODEC = (1 &lt;&lt; 7),
+        TFLAG_BREAK = (1 &lt;&lt; 8)
</ins><span class="cx"> } TFLAGS;
</span><span class="cx"> 
</span><span class="cx"> typedef enum {
</span><del>-  GFLAG_MY_CODEC_PREFS = (1 &lt;&lt; 0)
</del><ins>+        GFLAG_MY_CODEC_PREFS = (1 &lt;&lt; 0)
</ins><span class="cx"> } GFLAGS;
</span><span class="cx"> 
</span><span class="cx"> #define DEBUGA_SKYPE(...)  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,                 &quot;rev &quot;SKYPIAX_SVN_VERSION &quot;[%p|%-7lx][DEBUG_SKYPE  %-5d][%-10s][%2d,%2d,%2d] &quot; __VA_ARGS__ );
</span><span class="lines">@@ -135,116 +135,116 @@
</span><span class="cx"> 
</span><span class="cx"> #ifndef WIN32
</span><span class="cx"> struct SkypiaxHandles {
</span><del>-  Window skype_win;
-  Display *disp;
-  Window win;
-  int currentuserhandle;
-  int api_connected;
-  int fdesc[2];
</del><ins>+        Window skype_win;
+        Display *disp;
+        Window win;
+        int currentuserhandle;
+        int api_connected;
+        int fdesc[2];
</ins><span class="cx"> };
</span><span class="cx"> #else //WIN32
</span><span class="cx"> 
</span><span class="cx"> struct SkypiaxHandles {
</span><del>-  HWND win32_hInit_MainWindowHandle;
-  HWND win32_hGlobal_SkypeAPIWindowHandle;
-  HINSTANCE win32_hInit_ProcessHandle;
-  char win32_acInit_WindowClassName[128];
-  UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
-  UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
-  int currentuserhandle;
-  int api_connected;
-  switch_file_t *fdesc[2];
</del><ins>+        HWND win32_hInit_MainWindowHandle;
+        HWND win32_hGlobal_SkypeAPIWindowHandle;
+        HINSTANCE win32_hInit_ProcessHandle;
+        char win32_acInit_WindowClassName[128];
+        UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
+        UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
+        int currentuserhandle;
+        int api_connected;
+        switch_file_t *fdesc[2];
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif //WIN32
</span><span class="cx"> 
</span><span class="cx"> struct private_object {
</span><del>-  unsigned int flags;
-  switch_codec_t read_codec;
-  switch_codec_t write_codec;
-  switch_frame_t read_frame;
-  unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
-  char session_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
-  switch_caller_profile_t *caller_profile;
-  switch_mutex_t *mutex;
-  switch_mutex_t *flag_mutex;
</del><ins>+        unsigned int flags;
+        switch_codec_t read_codec;
+        switch_codec_t write_codec;
+        switch_frame_t read_frame;
+        unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+        char session_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+        switch_caller_profile_t *caller_profile;
+        switch_mutex_t *mutex;
+        switch_mutex_t *flag_mutex;
</ins><span class="cx"> 
</span><del>-  char interface_id[80];
-  char name[80];
-  char dialplan[80];
-  char context[80];
-  char dial_regex[256];
-  char fail_dial_regex[256];
-  char hold_music[256];
-  char type[256];
-  char X11_display[256];
</del><ins>+        char interface_id[80];
+        char name[80];
+        char dialplan[80];
+        char context[80];
+        char dial_regex[256];
+        char fail_dial_regex[256];
+        char hold_music[256];
+        char type[256];
+        char X11_display[256];
</ins><span class="cx"> #ifdef WIN32
</span><del>-  unsigned short tcp_cli_port;
-  unsigned short tcp_srv_port;
</del><ins>+        unsigned short tcp_cli_port;
+        unsigned short tcp_srv_port;
</ins><span class="cx"> #else
</span><del>-  int tcp_cli_port;
-  int tcp_srv_port;
</del><ins>+        int tcp_cli_port;
+        int tcp_srv_port;
</ins><span class="cx"> #endif
</span><del>-  struct SkypiaxHandles SkypiaxHandles;
</del><ins>+        struct SkypiaxHandles SkypiaxHandles;
</ins><span class="cx"> 
</span><del>-  int interface_state;          /*!&lt; \brief 'state' of the interface (channel) */
-  char language[80];            /*!&lt; \brief default Asterisk dialplan language for this interface */
-  char exten[80];               /*!&lt; \brief default Asterisk dialplan extension for this interface */
-  int skypiax_sound_rate;       /*!&lt; \brief rate of the sound device, in Hz, eg: 8000 */
-  char callid_name[50];
-  char callid_number[50];
-  double playback_boost;
-  double capture_boost;
-  int stripmsd;
-  char skype_call_id[512];
-  int skype_call_ongoing;
-  char skype_friends[4096];
-  char skype_fullname[512];
-  char skype_displayname[512];
-  int skype_callflow;           /*!&lt; \brief 'callflow' of the skype interface (as opposed to phone interface) */
-  int skype;                    /*!&lt; \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */
-  int control_to_send;
</del><ins>+        int interface_state;                /*!&lt; \brief 'state' of the interface (channel) */
+        char language[80];                        /*!&lt; \brief default Asterisk dialplan language for this interface */
+        char exten[80];                                /*!&lt; \brief default Asterisk dialplan extension for this interface */
+        int skypiax_sound_rate;                /*!&lt; \brief rate of the sound device, in Hz, eg: 8000 */
+        char callid_name[50];
+        char callid_number[50];
+        double playback_boost;
+        double capture_boost;
+        int stripmsd;
+        char skype_call_id[512];
+        int skype_call_ongoing;
+        char skype_friends[4096];
+        char skype_fullname[512];
+        char skype_displayname[512];
+        int skype_callflow;                        /*!&lt; \brief 'callflow' of the skype interface (as opposed to phone interface) */
+        int skype;                                        /*!&lt; \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */
+        int control_to_send;
</ins><span class="cx"> #ifdef WIN32
</span><del>-  switch_file_t *audiopipe[2];
-  switch_file_t *audioskypepipe[2];
-  switch_file_t *skypiax_sound_capt_fd; /*!&lt; \brief file descriptor for sound capture dev */
-#else                           /* WIN32 */
-  int audiopipe[2];
-  int audioskypepipe[2];
-  int skypiax_sound_capt_fd;    /*!&lt; \brief file descriptor for sound capture dev */
-#endif                          /* WIN32 */
-  switch_thread_t *tcp_srv_thread;
-  switch_thread_t *tcp_cli_thread;
-  switch_thread_t *skypiax_signaling_thread;
-  switch_thread_t *skypiax_api_thread;
-  short audiobuf[SAMPLES_PER_FRAME];
-  int audiobuf_is_loaded;
</del><ins>+        switch_file_t *audiopipe[2];
+        switch_file_t *audioskypepipe[2];
+        switch_file_t *skypiax_sound_capt_fd;        /*!&lt; \brief file descriptor for sound capture dev */
+#else                                                        /* WIN32 */
+        int audiopipe[2];
+        int audioskypepipe[2];
+        int skypiax_sound_capt_fd;        /*!&lt; \brief file descriptor for sound capture dev */
+#endif                                                        /* WIN32 */
+        switch_thread_t *tcp_srv_thread;
+        switch_thread_t *tcp_cli_thread;
+        switch_thread_t *skypiax_signaling_thread;
+        switch_thread_t *skypiax_api_thread;
+        short audiobuf[SAMPLES_PER_FRAME];
+        int audiobuf_is_loaded;
</ins><span class="cx"> 
</span><del>-  //int phonebook_listing;
-  //int phonebook_querying;
-  //int phonebook_listing_received_calls;
</del><ins>+        //int phonebook_listing;
+        //int phonebook_querying;
+        //int phonebook_listing_received_calls;
</ins><span class="cx"> 
</span><del>-  //int phonebook_first_entry;
-  //int phonebook_last_entry;
-  //int phonebook_number_lenght;
-  //int phonebook_text_lenght;
-  FILE *phonebook_writing_fp;
-  int skypiax_dir_entry_extension_prefix;
-  char skype_user[256];
-  char skype_password[256];
-  char destination[256];
-  struct timeval answer_time;
</del><ins>+        //int phonebook_first_entry;
+        //int phonebook_last_entry;
+        //int phonebook_number_lenght;
+        //int phonebook_text_lenght;
+        FILE *phonebook_writing_fp;
+        int skypiax_dir_entry_extension_prefix;
+        char skype_user[256];
+        char skype_password[256];
+        char destination[256];
+        struct timeval answer_time;
</ins><span class="cx"> 
</span><del>-  struct timeval transfer_time;
-  char transfer_callid_number[50];
-  char skype_transfer_call_id[512];
-  int running;
</del><ins>+        struct timeval transfer_time;
+        char transfer_callid_number[50];
+        char skype_transfer_call_id[512];
+        int running;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef struct private_object private_t;
</span><span class="cx"> 
</span><span class="cx"> void *SWITCH_THREAD_FUNC skypiax_api_thread_func(switch_thread_t * thread, void *obj);
</span><del>-void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session);
</del><ins>+void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t *session);
</ins><span class="cx"> int skypiax_audio_read(private_t * tech_pvt);
</span><span class="cx"> int skypiax_audio_init(private_t * tech_pvt);
</span><span class="cx"> int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (14443 => 14444)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-08-01 01:02:02 UTC (rev 14443)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-08-01 02:47:35 UTC (rev 14444)
</span><span class="lines">@@ -27,844 +27,791 @@
</span><span class="cx"> /*************************************/
</span><span class="cx"> int skypiax_signaling_read(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  char read_from_pipe[4096];
-  char message[4096];
-  char message_2[4096];
-  char *buf, obj[512] = &quot;&quot;, id[512] = &quot;&quot;, prop[512] = &quot;&quot;, value[512] = &quot;&quot;, *where;
-  char **stringp = NULL;
-  int a;
-  unsigned int howmany;
-  unsigned int i;
</del><ins>+        char read_from_pipe[4096];
+        char message[4096];
+        char message_2[4096];
+        char *buf, obj[512] = &quot;&quot;, id[512] = &quot;&quot;, prop[512] = &quot;&quot;, value[512] = &quot;&quot;, *where;
+        char **stringp = NULL;
+        int a;
+        unsigned int howmany;
+        unsigned int i;
</ins><span class="cx"> 
</span><del>-  memset(read_from_pipe, 0, 4096);
-  memset(message, 0, 4096);
-  memset(message_2, 0, 4096);
</del><ins>+        memset(read_from_pipe, 0, 4096);
+        memset(message, 0, 4096);
+        memset(message_2, 0, 4096);
</ins><span class="cx"> 
</span><del>-  howmany =
-    skypiax_pipe_read(tech_pvt-&gt;SkypiaxHandles.fdesc[0], (short *) read_from_pipe,
-                      sizeof(read_from_pipe));
</del><ins>+        howmany = skypiax_pipe_read(tech_pvt-&gt;SkypiaxHandles.fdesc[0], (short *) read_from_pipe, sizeof(read_from_pipe));
</ins><span class="cx"> 
</span><del>-  a = 0;
-  for (i = 0; i &lt; howmany; i++) {
-    message[a] = read_from_pipe[i];
-    a++;
</del><ins>+        a = 0;
+        for (i = 0; i &lt; howmany; i++) {
+                message[a] = read_from_pipe[i];
+                a++;
</ins><span class="cx"> 
</span><del>-    if (read_from_pipe[i] == '\0') {
</del><ins>+                if (read_from_pipe[i] == '\0') {
</ins><span class="cx"> 
</span><del>-      if (!strstr(message, &quot;DURATION&quot;)) {
-        DEBUGA_SKYPE(&quot;READING: |||%s||| \n&quot;, SKYPIAX_P_LOG, message);
-      }
</del><ins>+                        if (!strstr(message, &quot;DURATION&quot;)) {
+                                DEBUGA_SKYPE(&quot;READING: |||%s||| \n&quot;, SKYPIAX_P_LOG, message);
+                        }
</ins><span class="cx"> 
</span><del>-      if (!strcasecmp(message, &quot;ERROR 68&quot;)) {
-        DEBUGA_SKYPE
-          (&quot;If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n&quot;,
-           SKYPIAX_P_LOG);
-        skypiax_sleep(1000000);
-        skypiax_signaling_write(tech_pvt, &quot;PROTOCOL 7&quot;);
-        skypiax_sleep(10000);
-        return 0;
-      }
-      if (!strncasecmp(message, &quot;ERROR 92 CALL&quot;, 12)) {
-        ERRORA
-          (&quot;Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\n&quot;,
-           SKYPIAX_P_LOG, message);
-        tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
-        DEBUGA_SKYPE(&quot;skype_call now is DOWN\n&quot;, SKYPIAX_P_LOG);
-        tech_pvt-&gt;skype_call_id[0] = '\0';
</del><ins>+                        if (!strcasecmp(message, &quot;ERROR 68&quot;)) {
+                                DEBUGA_SKYPE
+                                        (&quot;If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n&quot;,
+                                         SKYPIAX_P_LOG);
+                                skypiax_sleep(1000000);
+                                skypiax_signaling_write(tech_pvt, &quot;PROTOCOL 7&quot;);
+                                skypiax_sleep(10000);
+                                return 0;
+                        }
+                        if (!strncasecmp(message, &quot;ERROR 92 CALL&quot;, 12)) {
+                                ERRORA(&quot;Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\n&quot;, SKYPIAX_P_LOG, message);
+                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
+                                DEBUGA_SKYPE(&quot;skype_call now is DOWN\n&quot;, SKYPIAX_P_LOG);
+                                tech_pvt-&gt;skype_call_id[0] = '\0';
</ins><span class="cx"> 
</span><del>-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
-          tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-          return CALLFLOW_INCOMING_HANGUP;
-        } else {
-          tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-        }
-      }
-      skypiax_strncpy(message_2, message, sizeof(message) - 1);
-      buf = message;
-      stringp = &amp;buf;
-      where = strsep(stringp, &quot; &quot;);
-      if (!where) {
-        WARNINGA(&quot;Skype MSG without spaces: %s\n&quot;, SKYPIAX_P_LOG, message);
-      }
-      if (!strcasecmp(message, &quot;ERROR&quot;)) {
-        if (!strncasecmp(message, &quot;ERROR 592 ALTER CALL&quot;, 19)) {
-          ERRORA(&quot;Skype got ERROR about TRANSFERRING, no problem: |||%s|||\n&quot;,
-                 SKYPIAX_P_LOG, message);
-        } else {
-          DEBUGA_SKYPE(&quot;Skype got ERROR: |||%s|||\n&quot;, SKYPIAX_P_LOG, message);
-          tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
-          DEBUGA_SKYPE(&quot;skype_call now is DOWN\n&quot;, SKYPIAX_P_LOG);
-          tech_pvt-&gt;skype_call_id[0] = '\0';
</del><ins>+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+                                        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                        return CALLFLOW_INCOMING_HANGUP;
+                                } else {
+                                        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                }
+                        }
+                        skypiax_strncpy(message_2, message, sizeof(message) - 1);
+                        buf = message;
+                        stringp = &amp;buf;
+                        where = strsep(stringp, &quot; &quot;);
+                        if (!where) {
+                                WARNINGA(&quot;Skype MSG without spaces: %s\n&quot;, SKYPIAX_P_LOG, message);
+                        }
+                        if (!strcasecmp(message, &quot;ERROR&quot;)) {
+                                if (!strncasecmp(message, &quot;ERROR 592 ALTER CALL&quot;, 19)) {
+                                        ERRORA(&quot;Skype got ERROR about TRANSFERRING, no problem: |||%s|||\n&quot;, SKYPIAX_P_LOG, message);
+                                } else {
+                                        DEBUGA_SKYPE(&quot;Skype got ERROR: |||%s|||\n&quot;, SKYPIAX_P_LOG, message);
+                                        tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
+                                        DEBUGA_SKYPE(&quot;skype_call now is DOWN\n&quot;, SKYPIAX_P_LOG);
+                                        tech_pvt-&gt;skype_call_id[0] = '\0';
</ins><span class="cx"> 
</span><del>-          if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-            return CALLFLOW_INCOMING_HANGUP;
-          } else {
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-          }
-        }
-      }
-      if (!strcasecmp(message, &quot;CURRENTUSERHANDLE&quot;)) {
-        skypiax_strncpy(obj, where, sizeof(obj) - 1);
-        where = strsep(stringp, &quot; &quot;);
-        skypiax_strncpy(id, where, sizeof(id) - 1);
-        if (!strcasecmp(id, tech_pvt-&gt;skype_user)) {
-          tech_pvt-&gt;SkypiaxHandles.currentuserhandle = 1;
-          DEBUGA_SKYPE
-            (&quot;Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n&quot;,
-             SKYPIAX_P_LOG, message, obj, id, tech_pvt-&gt;skype_user);
-        }
-      }
-      if (!strcasecmp(message, &quot;USER&quot;)) {
-        skypiax_strncpy(obj, where, sizeof(obj) - 1);
-        where = strsep(stringp, &quot; &quot;);
-        skypiax_strncpy(id, where, sizeof(id) - 1);
-        where = strsep(stringp, &quot; &quot;);
-        skypiax_strncpy(prop, where, sizeof(prop) - 1);
-        if (!strcasecmp(prop, &quot;RECEIVEDAUTHREQUEST&quot;)) {
-          char msg_to_skype[256];
-          DEBUGA_SKYPE(&quot;Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n&quot;,
-                       SKYPIAX_P_LOG, message, obj, id, prop);
-          //TODO: allow authorization based on config param
-          sprintf(msg_to_skype, &quot;SET USER %s ISAUTHORIZED TRUE&quot;, id);
-          skypiax_signaling_write(tech_pvt, msg_to_skype);
-        }
-      }
-      if (!strcasecmp(message, &quot;MESSAGE&quot;)) {
-        skypiax_strncpy(obj, where, sizeof(obj) - 1);
-        where = strsep(stringp, &quot; &quot;);
-        skypiax_strncpy(id, where, sizeof(id) - 1);
-        where = strsep(stringp, &quot; &quot;);
-        skypiax_strncpy(prop, where, sizeof(prop) - 1);
-        if (!strcasecmp(prop, &quot;STATUS&quot;)) {
-          where = strsep(stringp, &quot; &quot;);
-          skypiax_strncpy(value, where, sizeof(value) - 1);
-          if (!strcasecmp(value, &quot;RECEIVED&quot;)) {
-            char msg_to_skype[256];
-            DEBUGA_SKYPE(&quot;Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n&quot;,
-                         SKYPIAX_P_LOG, message, obj, id, prop, value);
-            //TODO: authomatically flag messages as read based on config param
-            sprintf(msg_to_skype, &quot;SET MESSAGE %s SEEN&quot;, id);
-            skypiax_signaling_write(tech_pvt, msg_to_skype);
-          }
-        } else if (!strcasecmp(prop, &quot;BODY&quot;)) {
-          char msg_to_skype[256];
-          DEBUGA_SKYPE(&quot;Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n&quot;,
-                       SKYPIAX_P_LOG, message, obj, id, prop);
-          //TODO: authomatically flag messages as read based on config param
-          sprintf(msg_to_skype, &quot;SET MESSAGE %s SEEN&quot;, id);
-          skypiax_signaling_write(tech_pvt, msg_to_skype);
-        }
-      }
-      if (!strcasecmp(message, &quot;CALL&quot;)) {
-        skypiax_strncpy(obj, where, sizeof(obj) - 1);
-        where = strsep(stringp, &quot; &quot;);
-        skypiax_strncpy(id, where, sizeof(id) - 1);
-        where = strsep(stringp, &quot; &quot;);
-        skypiax_strncpy(prop, where, sizeof(prop) - 1);
-        where = strsep(stringp, &quot; &quot;);
-        skypiax_strncpy(value, where, sizeof(value) - 1);
-        where = strsep(stringp, &quot; &quot;);
</del><ins>+                                        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                return CALLFLOW_INCOMING_HANGUP;
+                                        } else {
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                        }
+                                }
+                        }
+                        if (!strcasecmp(message, &quot;CURRENTUSERHANDLE&quot;)) {
+                                skypiax_strncpy(obj, where, sizeof(obj) - 1);
+                                where = strsep(stringp, &quot; &quot;);
+                                skypiax_strncpy(id, where, sizeof(id) - 1);
+                                if (!strcasecmp(id, tech_pvt-&gt;skype_user)) {
+                                        tech_pvt-&gt;SkypiaxHandles.currentuserhandle = 1;
+                                        DEBUGA_SKYPE
+                                                (&quot;Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n&quot;,
+                                                 SKYPIAX_P_LOG, message, obj, id, tech_pvt-&gt;skype_user);
+                                }
+                        }
+                        if (!strcasecmp(message, &quot;USER&quot;)) {
+                                skypiax_strncpy(obj, where, sizeof(obj) - 1);
+                                where = strsep(stringp, &quot; &quot;);
+                                skypiax_strncpy(id, where, sizeof(id) - 1);
+                                where = strsep(stringp, &quot; &quot;);
+                                skypiax_strncpy(prop, where, sizeof(prop) - 1);
+                                if (!strcasecmp(prop, &quot;RECEIVEDAUTHREQUEST&quot;)) {
+                                        char msg_to_skype[256];
+                                        DEBUGA_SKYPE(&quot;Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n&quot;, SKYPIAX_P_LOG, message, obj, id, prop);
+                                        //TODO: allow authorization based on config param
+                                        sprintf(msg_to_skype, &quot;SET USER %s ISAUTHORIZED TRUE&quot;, id);
+                                        skypiax_signaling_write(tech_pvt, msg_to_skype);
+                                }
+                        }
+                        if (!strcasecmp(message, &quot;MESSAGE&quot;)) {
+                                skypiax_strncpy(obj, where, sizeof(obj) - 1);
+                                where = strsep(stringp, &quot; &quot;);
+                                skypiax_strncpy(id, where, sizeof(id) - 1);
+                                where = strsep(stringp, &quot; &quot;);
+                                skypiax_strncpy(prop, where, sizeof(prop) - 1);
+                                if (!strcasecmp(prop, &quot;STATUS&quot;)) {
+                                        where = strsep(stringp, &quot; &quot;);
+                                        skypiax_strncpy(value, where, sizeof(value) - 1);
+                                        if (!strcasecmp(value, &quot;RECEIVED&quot;)) {
+                                                char msg_to_skype[256];
+                                                DEBUGA_SKYPE(&quot;Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n&quot;, SKYPIAX_P_LOG, message, obj, id, prop, value);
+                                                //TODO: authomatically flag messages as read based on config param
+                                                sprintf(msg_to_skype, &quot;SET MESSAGE %s SEEN&quot;, id);
+                                                skypiax_signaling_write(tech_pvt, msg_to_skype);
+                                        }
+                                } else if (!strcasecmp(prop, &quot;BODY&quot;)) {
+                                        char msg_to_skype[256];
+                                        DEBUGA_SKYPE(&quot;Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n&quot;, SKYPIAX_P_LOG, message, obj, id, prop);
+                                        //TODO: authomatically flag messages as read based on config param
+                                        sprintf(msg_to_skype, &quot;SET MESSAGE %s SEEN&quot;, id);
+                                        skypiax_signaling_write(tech_pvt, msg_to_skype);
+                                }
+                        }
+                        if (!strcasecmp(message, &quot;CALL&quot;)) {
+                                skypiax_strncpy(obj, where, sizeof(obj) - 1);
+                                where = strsep(stringp, &quot; &quot;);
+                                skypiax_strncpy(id, where, sizeof(id) - 1);
+                                where = strsep(stringp, &quot; &quot;);
+                                skypiax_strncpy(prop, where, sizeof(prop) - 1);
+                                where = strsep(stringp, &quot; &quot;);
+                                skypiax_strncpy(value, where, sizeof(value) - 1);
+                                where = strsep(stringp, &quot; &quot;);
</ins><span class="cx"> 
</span><del>-        //DEBUGA_SKYPE
-        //(&quot;Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n&quot;,
-        //SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : &quot;NULL&quot;);
</del><ins>+                                //DEBUGA_SKYPE
+                                //(&quot;Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n&quot;,
+                                //SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : &quot;NULL&quot;);
</ins><span class="cx"> 
</span><del>-        if (!strcasecmp(prop, &quot;PARTNER_HANDLE&quot;)) {
-          if (!strlen(tech_pvt-&gt;skype_call_id)) {
-            /* we are NOT inside an active call */
-            DEBUGA_SKYPE(&quot;Call %s TRY ANSWER\n&quot;, SKYPIAX_P_LOG, id);
-            skypiax_answer(tech_pvt, id, value);
-          } else {
-            /* we are inside an active call */
-            if (!strcasecmp(tech_pvt-&gt;skype_call_id, id)) {
-              /* this is the call in which we are calling out */
-              DEBUGA_SKYPE(&quot;Call %s NOTHING\n&quot;, SKYPIAX_P_LOG, id);
-            } else {
-              skypiax_sleep(400000);    //0.4 seconds
-              DEBUGA_SKYPE(&quot;Call %s TRY TRANSFER\n&quot;, SKYPIAX_P_LOG, id);
-              skypiax_transfer(tech_pvt, id, value);
-            }
-          }
-        }
-        if (!strcasecmp(prop, &quot;PARTNER_DISPNAME&quot;)) {
-          snprintf(tech_pvt-&gt;callid_name, sizeof(tech_pvt-&gt;callid_name) - 1, &quot;%s%s%s&quot;,
-                   value, where ? &quot; &quot; : &quot;&quot;, where ? where : &quot;&quot;);
-          //DEBUGA_SKYPE
-          //(&quot;the skype_call %s caller PARTNER_DISPNAME (tech_pvt-&gt;callid_name) is: %s\n&quot;,
-          //SKYPIAX_P_LOG, id, tech_pvt-&gt;callid_name);
-        }
-        if (!strcasecmp(prop, &quot;CONF_ID&quot;) &amp;&amp; !strcasecmp(value, &quot;0&quot;)) {
-          //DEBUGA_SKYPE(&quot;the skype_call %s is NOT a conference call\n&quot;, SKYPIAX_P_LOG, id);
-          if (tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN)
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_PRERING;
-        }
-        if (!strcasecmp(prop, &quot;CONF_ID&quot;) &amp;&amp; strcasecmp(value, &quot;0&quot;)) {
-          DEBUGA_SKYPE(&quot;the skype_call %s is a conference call\n&quot;, SKYPIAX_P_LOG, id);
-          if (tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN)
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_PRERING;
-        }
-        if (!strcasecmp(prop, &quot;DTMF&quot;)) {
-          DEBUGA_SKYPE(&quot;Call %s received a DTMF: %s\n&quot;, SKYPIAX_P_LOG, id, value);
-          dtmf_received(tech_pvt, value);
-        }
-        if (!strcasecmp(prop, &quot;FAILUREREASON&quot;)) {
-          DEBUGA_SKYPE
-            (&quot;Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n&quot;,
-             SKYPIAX_P_LOG, id);
-        }
-        if (!strcasecmp(prop, &quot;DURATION&quot;) &amp;&amp; (!strcasecmp(value, &quot;1&quot;))) {
-          if (strcasecmp(id, tech_pvt-&gt;skype_call_id)) {
-            skypiax_strncpy(tech_pvt-&gt;skype_call_id, id,
-                            sizeof(tech_pvt-&gt;skype_call_id) - 1);
-            DEBUGA_SKYPE
-              (&quot;We called a Skype contact and he answered us on skype_call: %s.\n&quot;,
-               SKYPIAX_P_LOG, id);
-          }
-        }
-        if (!strcasecmp(prop, &quot;STATUS&quot;)) {
</del><ins>+                                if (!strcasecmp(prop, &quot;PARTNER_HANDLE&quot;)) {
+                                        if (!strlen(tech_pvt-&gt;skype_call_id)) {
+                                                /* we are NOT inside an active call */
+                                                DEBUGA_SKYPE(&quot;Call %s TRY ANSWER\n&quot;, SKYPIAX_P_LOG, id);
+                                                skypiax_answer(tech_pvt, id, value);
+                                        } else {
+                                                /* we are inside an active call */
+                                                if (!strcasecmp(tech_pvt-&gt;skype_call_id, id)) {
+                                                        /* this is the call in which we are calling out */
+                                                        DEBUGA_SKYPE(&quot;Call %s NOTHING\n&quot;, SKYPIAX_P_LOG, id);
+                                                } else {
+                                                        skypiax_sleep(400000);        //0.4 seconds
+                                                        DEBUGA_SKYPE(&quot;Call %s TRY TRANSFER\n&quot;, SKYPIAX_P_LOG, id);
+                                                        skypiax_transfer(tech_pvt, id, value);
+                                                }
+                                        }
+                                }
+                                if (!strcasecmp(prop, &quot;PARTNER_DISPNAME&quot;)) {
+                                        snprintf(tech_pvt-&gt;callid_name, sizeof(tech_pvt-&gt;callid_name) - 1, &quot;%s%s%s&quot;, value, where ? &quot; &quot; : &quot;&quot;, where ? where : &quot;&quot;);
+                                        //DEBUGA_SKYPE
+                                        //(&quot;the skype_call %s caller PARTNER_DISPNAME (tech_pvt-&gt;callid_name) is: %s\n&quot;,
+                                        //SKYPIAX_P_LOG, id, tech_pvt-&gt;callid_name);
+                                }
+                                if (!strcasecmp(prop, &quot;CONF_ID&quot;) &amp;&amp; !strcasecmp(value, &quot;0&quot;)) {
+                                        //DEBUGA_SKYPE(&quot;the skype_call %s is NOT a conference call\n&quot;, SKYPIAX_P_LOG, id);
+                                        if (tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN)
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_PRERING;
+                                }
+                                if (!strcasecmp(prop, &quot;CONF_ID&quot;) &amp;&amp; strcasecmp(value, &quot;0&quot;)) {
+                                        DEBUGA_SKYPE(&quot;the skype_call %s is a conference call\n&quot;, SKYPIAX_P_LOG, id);
+                                        if (tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN)
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_PRERING;
+                                }
+                                if (!strcasecmp(prop, &quot;DTMF&quot;)) {
+                                        DEBUGA_SKYPE(&quot;Call %s received a DTMF: %s\n&quot;, SKYPIAX_P_LOG, id, value);
+                                        dtmf_received(tech_pvt, value);
+                                }
+                                if (!strcasecmp(prop, &quot;FAILUREREASON&quot;)) {
+                                        DEBUGA_SKYPE(&quot;Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n&quot;, SKYPIAX_P_LOG, id);
+                                }
+                                if (!strcasecmp(prop, &quot;DURATION&quot;) &amp;&amp; (!strcasecmp(value, &quot;1&quot;))) {
+                                        if (strcasecmp(id, tech_pvt-&gt;skype_call_id)) {
+                                                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
+                                                DEBUGA_SKYPE(&quot;We called a Skype contact and he answered us on skype_call: %s.\n&quot;, SKYPIAX_P_LOG, id);
+                                        }
+                                }
+                                if (!strcasecmp(prop, &quot;STATUS&quot;)) {
</ins><span class="cx"> 
</span><del>-          if (!strcasecmp(value, &quot;RINGING&quot;)) {
-            char msg_to_skype[1024];
-            if (!strlen(tech_pvt-&gt;skype_call_id)) {
-              /* we are NOT inside an active call */
-              sprintf(msg_to_skype, &quot;GET CALL %s PARTNER_HANDLE&quot;, id);
-              skypiax_signaling_write(tech_pvt, msg_to_skype);
-              skypiax_sleep(10000);
-            } else {
-              /* we are inside an active call */
-              if (!strcasecmp(tech_pvt-&gt;skype_call_id, id)) {
-                /* this is the call in which we are calling out */
-                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_RINGING;
-                tech_pvt-&gt;interface_state = SKYPIAX_STATE_RINGING;
-                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id,
-                                sizeof(tech_pvt-&gt;skype_call_id) - 1);
-                DEBUGA_SKYPE(&quot;Our remote party in skype_call %s is RINGING\n&quot;,
-                             SKYPIAX_P_LOG, id);
-                remote_party_is_ringing(tech_pvt);
-              } else {
-                sprintf(msg_to_skype, &quot;GET CALL %s PARTNER_HANDLE&quot;, id);
-                skypiax_signaling_write(tech_pvt, msg_to_skype);
-                skypiax_sleep(10000);
-              }
-            }
-          } else if (!strcasecmp(value, &quot;EARLYMEDIA&quot;)) {
-            char msg_to_skype[1024];
-            tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
-            DEBUGA_SKYPE(&quot;Our remote party in skype_call %s is EARLYMEDIA\n&quot;,
-                         SKYPIAX_P_LOG, id);
-            start_audio_threads(tech_pvt);
-            skypiax_sleep(1000);
-            sprintf(msg_to_skype, &quot;ALTER CALL %s SET_INPUT PORT=\&quot;%d\&quot;&quot;, id,
-                    tech_pvt-&gt;tcp_cli_port);
-            skypiax_signaling_write(tech_pvt, msg_to_skype);
-            sprintf(msg_to_skype, &quot;#output ALTER CALL %s SET_OUTPUT PORT=\&quot;%d\&quot;&quot;, id,
-                    tech_pvt-&gt;tcp_srv_port);
-            skypiax_signaling_write(tech_pvt, msg_to_skype);
</del><ins>+                                        if (!strcasecmp(value, &quot;RINGING&quot;)) {
+                                                char msg_to_skype[1024];
+                                                if (!strlen(tech_pvt-&gt;skype_call_id)) {
+                                                        /* we are NOT inside an active call */
+                                                        sprintf(msg_to_skype, &quot;GET CALL %s PARTNER_HANDLE&quot;, id);
+                                                        skypiax_signaling_write(tech_pvt, msg_to_skype);
+                                                        skypiax_sleep(10000);
+                                                } else {
+                                                        /* we are inside an active call */
+                                                        if (!strcasecmp(tech_pvt-&gt;skype_call_id, id)) {
+                                                                /* this is the call in which we are calling out */
+                                                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_RINGING;
+                                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_RINGING;
+                                                                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
+                                                                DEBUGA_SKYPE(&quot;Our remote party in skype_call %s is RINGING\n&quot;, SKYPIAX_P_LOG, id);
+                                                                remote_party_is_ringing(tech_pvt);
+                                                        } else {
+                                                                sprintf(msg_to_skype, &quot;GET CALL %s PARTNER_HANDLE&quot;, id);
+                                                                skypiax_signaling_write(tech_pvt, msg_to_skype);
+                                                                skypiax_sleep(10000);
+                                                        }
+                                                }
+                                        } else if (!strcasecmp(value, &quot;EARLYMEDIA&quot;)) {
+                                                char msg_to_skype[1024];
+                                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
+                                                DEBUGA_SKYPE(&quot;Our remote party in skype_call %s is EARLYMEDIA\n&quot;, SKYPIAX_P_LOG, id);
+                                                start_audio_threads(tech_pvt);
+                                                skypiax_sleep(1000);
+                                                sprintf(msg_to_skype, &quot;ALTER CALL %s SET_INPUT PORT=\&quot;%d\&quot;&quot;, id, tech_pvt-&gt;tcp_cli_port);
+                                                skypiax_signaling_write(tech_pvt, msg_to_skype);
+                                                sprintf(msg_to_skype, &quot;#output ALTER CALL %s SET_OUTPUT PORT=\&quot;%d\&quot;&quot;, id, tech_pvt-&gt;tcp_srv_port);
+                                                skypiax_signaling_write(tech_pvt, msg_to_skype);
</ins><span class="cx"> 
</span><del>-            remote_party_is_early_media(tech_pvt);
-          } else if (!strcasecmp(value, &quot;MISSED&quot;)) {
-            DEBUGA_SKYPE(&quot;We missed skype_call %s\n&quot;, SKYPIAX_P_LOG, id);
-          } else if (!strcasecmp(value, &quot;FINISHED&quot;)) {
-            //DEBUGA_SKYPE(&quot;skype_call %s now is DOWN\n&quot;, SKYPIAX_P_LOG, id);
-            //usleep(150000);//150msec, let's give the TCP sockets time to timeout
-            if (!strcasecmp(tech_pvt-&gt;skype_call_id, id)) {
-              tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
-              DEBUGA_SKYPE(&quot;skype_call %s is MY call, now I'm going DOWN\n&quot;,
-                           SKYPIAX_P_LOG, id);
-              tech_pvt-&gt;skype_call_id[0] = '\0';
-              if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
-                //tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-                return CALLFLOW_INCOMING_HANGUP;
-              } else {
-                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-              }
-            } else {
-              DEBUGA_SKYPE(&quot;skype_call %s is NOT MY call, ignoring\n&quot;, SKYPIAX_P_LOG, id);
-            }
</del><ins>+                                                remote_party_is_early_media(tech_pvt);
+                                        } else if (!strcasecmp(value, &quot;MISSED&quot;)) {
+                                                DEBUGA_SKYPE(&quot;We missed skype_call %s\n&quot;, SKYPIAX_P_LOG, id);
+                                        } else if (!strcasecmp(value, &quot;FINISHED&quot;)) {
+                                                //DEBUGA_SKYPE(&quot;skype_call %s now is DOWN\n&quot;, SKYPIAX_P_LOG, id);
+                                                //usleep(150000);//150msec, let's give the TCP sockets time to timeout
+                                                if (!strcasecmp(tech_pvt-&gt;skype_call_id, id)) {
+                                                        tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
+                                                        DEBUGA_SKYPE(&quot;skype_call %s is MY call, now I'm going DOWN\n&quot;, SKYPIAX_P_LOG, id);
+                                                        tech_pvt-&gt;skype_call_id[0] = '\0';
+                                                        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+                                                                //tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                                return CALLFLOW_INCOMING_HANGUP;
+                                                        } else {
+                                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                        }
+                                                } else {
+                                                        DEBUGA_SKYPE(&quot;skype_call %s is NOT MY call, ignoring\n&quot;, SKYPIAX_P_LOG, id);
+                                                }
</ins><span class="cx"> 
</span><del>-          } else if (!strcasecmp(value, &quot;CANCELLED&quot;)) {
-            tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_CANCELLED;
-            DEBUGA_SKYPE
-              (&quot;we tried to call Skype on skype_call %s and Skype has now CANCELLED\n&quot;,
-               SKYPIAX_P_LOG, id);
-            tech_pvt-&gt;skype_call_id[0] = '\0';
-            if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
-              tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-              return CALLFLOW_INCOMING_HANGUP;
-            } else {
-              tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-            }
-          } else if (!strcasecmp(value, &quot;FAILED&quot;)) {
-            tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FAILED;
-            DEBUGA_SKYPE
-              (&quot;we tried to call Skype on skype_call %s and Skype has now FAILED\n&quot;,
-               SKYPIAX_P_LOG, id);
-            tech_pvt-&gt;skype_call_id[0] = '\0';
-            skypiax_strncpy(tech_pvt-&gt;skype_call_id, id,
-                            sizeof(tech_pvt-&gt;skype_call_id) - 1);
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-            return CALLFLOW_INCOMING_HANGUP;
-          } else if (!strcasecmp(value, &quot;REFUSED&quot;)) {
-            if (!strcasecmp(id, tech_pvt-&gt;skype_call_id)) {
-              /* this is the id of the call we are in, probably we generated it */
-              tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_REFUSED;
-              DEBUGA_SKYPE
-                (&quot;we tried to call Skype on skype_call %s and Skype has now REFUSED\n&quot;,
-                 SKYPIAX_P_LOG, id);
-              skypiax_strncpy(tech_pvt-&gt;skype_call_id, id,
-                              sizeof(tech_pvt-&gt;skype_call_id) - 1);
-              tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-              tech_pvt-&gt;skype_call_id[0] = '\0';
-              return CALLFLOW_INCOMING_HANGUP;
-            } else {
-              /* we're here because were us that refused an incoming call */
-              DEBUGA_SKYPE(&quot;we REFUSED skype_call %s\n&quot;, SKYPIAX_P_LOG, id);
-            }
-          } else if (!strcasecmp(value, &quot;TRANSFERRING&quot;)) {
-            DEBUGA_SKYPE(&quot;skype_call %s is transferring\n&quot;, SKYPIAX_P_LOG, id);
-          } else if (!strcasecmp(value, &quot;TRANSFERRED&quot;)) {
-            DEBUGA_SKYPE(&quot;skype_call %s has been transferred\n&quot;, SKYPIAX_P_LOG, id);
-          } else if (!strcasecmp(value, &quot;ROUTING&quot;)) {
-            tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_ROUTING;
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
-            skypiax_strncpy(tech_pvt-&gt;skype_call_id, id,
-                            sizeof(tech_pvt-&gt;skype_call_id) - 1);
-            DEBUGA_SKYPE(&quot;skype_call: %s is now ROUTING\n&quot;, SKYPIAX_P_LOG, id);
-          } else if (!strcasecmp(value, &quot;UNPLACED&quot;)) {
-            tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_UNPLACED;
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
-            skypiax_strncpy(tech_pvt-&gt;skype_call_id, id,
-                            sizeof(tech_pvt-&gt;skype_call_id) - 1);
-            DEBUGA_SKYPE(&quot;skype_call: %s is now UNPLACED\n&quot;, SKYPIAX_P_LOG, id);
-          } else if (!strcasecmp(value, &quot;INPROGRESS&quot;)) {
-            char msg_to_skype[1024];
</del><ins>+                                        } else if (!strcasecmp(value, &quot;CANCELLED&quot;)) {
+                                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_CANCELLED;
+                                                DEBUGA_SKYPE(&quot;we tried to call Skype on skype_call %s and Skype has now CANCELLED\n&quot;, SKYPIAX_P_LOG, id);
+                                                tech_pvt-&gt;skype_call_id[0] = '\0';
+                                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+                                                        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                        return CALLFLOW_INCOMING_HANGUP;
+                                                } else {
+                                                        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                }
+                                        } else if (!strcasecmp(value, &quot;FAILED&quot;)) {
+                                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FAILED;
+                                                DEBUGA_SKYPE(&quot;we tried to call Skype on skype_call %s and Skype has now FAILED\n&quot;, SKYPIAX_P_LOG, id);
+                                                tech_pvt-&gt;skype_call_id[0] = '\0';
+                                                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                return CALLFLOW_INCOMING_HANGUP;
+                                        } else if (!strcasecmp(value, &quot;REFUSED&quot;)) {
+                                                if (!strcasecmp(id, tech_pvt-&gt;skype_call_id)) {
+                                                        /* this is the id of the call we are in, probably we generated it */
+                                                        tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_REFUSED;
+                                                        DEBUGA_SKYPE(&quot;we tried to call Skype on skype_call %s and Skype has now REFUSED\n&quot;, SKYPIAX_P_LOG, id);
+                                                        skypiax_strncpy(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
+                                                        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                        tech_pvt-&gt;skype_call_id[0] = '\0';
+                                                        return CALLFLOW_INCOMING_HANGUP;
+                                                } else {
+                                                        /* we're here because were us that refused an incoming call */
+                                                        DEBUGA_SKYPE(&quot;we REFUSED skype_call %s\n&quot;, SKYPIAX_P_LOG, id);
+                                                }
+                                        } else if (!strcasecmp(value, &quot;TRANSFERRING&quot;)) {
+                                                DEBUGA_SKYPE(&quot;skype_call %s is transferring\n&quot;, SKYPIAX_P_LOG, id);
+                                        } else if (!strcasecmp(value, &quot;TRANSFERRED&quot;)) {
+                                                DEBUGA_SKYPE(&quot;skype_call %s has been transferred\n&quot;, SKYPIAX_P_LOG, id);
+                                        } else if (!strcasecmp(value, &quot;ROUTING&quot;)) {
+                                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_ROUTING;
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
+                                                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
+                                                DEBUGA_SKYPE(&quot;skype_call: %s is now ROUTING\n&quot;, SKYPIAX_P_LOG, id);
+                                        } else if (!strcasecmp(value, &quot;UNPLACED&quot;)) {
+                                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_UNPLACED;
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
+                                                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
+                                                DEBUGA_SKYPE(&quot;skype_call: %s is now UNPLACED\n&quot;, SKYPIAX_P_LOG, id);
+                                        } else if (!strcasecmp(value, &quot;INPROGRESS&quot;)) {
+                                                char msg_to_skype[1024];
</ins><span class="cx"> 
</span><del>-            if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
-              if (!strlen(tech_pvt-&gt;session_uuid_str) || !strlen(tech_pvt-&gt;skype_call_id)
-                  || !strcasecmp(tech_pvt-&gt;skype_call_id, id)) {
-                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id,
-                                sizeof(tech_pvt-&gt;skype_call_id) - 1);
-                DEBUGA_SKYPE(&quot;skype_call: %s is now active\n&quot;, SKYPIAX_P_LOG, id);
</del><ins>+                                                if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
+                                                        if (!strlen(tech_pvt-&gt;session_uuid_str) || !strlen(tech_pvt-&gt;skype_call_id)
+                                                                || !strcasecmp(tech_pvt-&gt;skype_call_id, id)) {
+                                                                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
+                                                                DEBUGA_SKYPE(&quot;skype_call: %s is now active\n&quot;, SKYPIAX_P_LOG, id);
</ins><span class="cx"> 
</span><del>-                if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
-                  tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_INPROGRESS;
-                  tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
-                  start_audio_threads(tech_pvt);
-                  skypiax_sleep(1000);  //FIXME
-                  sprintf(msg_to_skype, &quot;ALTER CALL %s SET_INPUT PORT=\&quot;%d\&quot;&quot;, id,
-                          tech_pvt-&gt;tcp_cli_port);
-                  skypiax_signaling_write(tech_pvt, msg_to_skype);
-                  skypiax_sleep(1000);  //FIXME
-                  sprintf(msg_to_skype, &quot;#output ALTER CALL %s SET_OUTPUT PORT=\&quot;%d\&quot;&quot;,
-                          id, tech_pvt-&gt;tcp_srv_port);
-                  skypiax_signaling_write(tech_pvt, msg_to_skype);
-                }
-                tech_pvt-&gt;skype_callflow = SKYPIAX_STATE_UP;
-                if (!strlen(tech_pvt-&gt;session_uuid_str)) {
-                  DEBUGA_SKYPE(&quot;New Inbound Channel!\n&quot;, SKYPIAX_P_LOG);
-                  new_inbound_channel(tech_pvt);
-                } else {
-                  DEBUGA_SKYPE(&quot;Outbound Channel Answered!\n&quot;, SKYPIAX_P_LOG);
-                  outbound_channel_answered(tech_pvt);
-                }
-              } else {
-                DEBUGA_SKYPE(&quot;I'm on %s, skype_call %s is NOT MY call, ignoring\n&quot;,
-                             SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id, id);
-              }
-            } else {
-              tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_INPROGRESS;
-              DEBUGA_SKYPE(&quot;Back from REMOTEHOLD!\n&quot;, SKYPIAX_P_LOG);
-            }
</del><ins>+                                                                if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
+                                                                        tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_INPROGRESS;
+                                                                        tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
+                                                                        start_audio_threads(tech_pvt);
+                                                                        skypiax_sleep(1000);        //FIXME
+                                                                        sprintf(msg_to_skype, &quot;ALTER CALL %s SET_INPUT PORT=\&quot;%d\&quot;&quot;, id, tech_pvt-&gt;tcp_cli_port);
+                                                                        skypiax_signaling_write(tech_pvt, msg_to_skype);
+                                                                        skypiax_sleep(1000);        //FIXME
+                                                                        sprintf(msg_to_skype, &quot;#output ALTER CALL %s SET_OUTPUT PORT=\&quot;%d\&quot;&quot;, id, tech_pvt-&gt;tcp_srv_port);
+                                                                        skypiax_signaling_write(tech_pvt, msg_to_skype);
+                                                                }
+                                                                tech_pvt-&gt;skype_callflow = SKYPIAX_STATE_UP;
+                                                                if (!strlen(tech_pvt-&gt;session_uuid_str)) {
+                                                                        DEBUGA_SKYPE(&quot;New Inbound Channel!\n&quot;, SKYPIAX_P_LOG);
+                                                                        new_inbound_channel(tech_pvt);
+                                                                } else {
+                                                                        DEBUGA_SKYPE(&quot;Outbound Channel Answered!\n&quot;, SKYPIAX_P_LOG);
+                                                                        outbound_channel_answered(tech_pvt);
+                                                                }
+                                                        } else {
+                                                                DEBUGA_SKYPE(&quot;I'm on %s, skype_call %s is NOT MY call, ignoring\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id, id);
+                                                        }
+                                                } else {
+                                                        tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_INPROGRESS;
+                                                        DEBUGA_SKYPE(&quot;Back from REMOTEHOLD!\n&quot;, SKYPIAX_P_LOG);
+                                                }
</ins><span class="cx"> 
</span><del>-          } else if (!strcasecmp(value, &quot;REMOTEHOLD&quot;)) {
-            tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_REMOTEHOLD;
-            DEBUGA_SKYPE(&quot;skype_call: %s is now REMOTEHOLD\n&quot;, SKYPIAX_P_LOG, id);
</del><ins>+                                        } else if (!strcasecmp(value, &quot;REMOTEHOLD&quot;)) {
+                                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_REMOTEHOLD;
+                                                DEBUGA_SKYPE(&quot;skype_call: %s is now REMOTEHOLD\n&quot;, SKYPIAX_P_LOG, id);
</ins><span class="cx"> 
</span><del>-          } else if (!strcasecmp(value, &quot;BUSY&quot;)) {
-            tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FAILED;
-            DEBUGA_SKYPE
-              (&quot;we tried to call Skype on skype_call %s and remote party (destination) was BUSY. Our outbound call has failed\n&quot;,
-               SKYPIAX_P_LOG, id);
-            skypiax_strncpy(tech_pvt-&gt;skype_call_id, id,
-                            sizeof(tech_pvt-&gt;skype_call_id) - 1);
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-            tech_pvt-&gt;skype_call_id[0] = '\0';
-            skypiax_sleep(1000);
-            return CALLFLOW_INCOMING_HANGUP;
-          } else if (!strcasecmp(value, &quot;WAITING_REDIAL_COMMAND&quot;)) {
-            tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FAILED;
-            DEBUGA_SKYPE
-              (&quot;we tried to call Skype on skype_call %s and remote party (destination) has rejected us (WAITING_REDIAL_COMMAND). Our outbound call has failed\n&quot;,
-               SKYPIAX_P_LOG, id);
-            skypiax_strncpy(tech_pvt-&gt;skype_call_id, id,
-                            sizeof(tech_pvt-&gt;skype_call_id) - 1);
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-            tech_pvt-&gt;skype_call_id[0] = '\0';
-            skypiax_sleep(1000);
-            return CALLFLOW_INCOMING_HANGUP;
-          } else {
-            WARNINGA(&quot;skype_call: %s, STATUS: %s is not recognized\n&quot;, SKYPIAX_P_LOG, id,
-                     value);
-          }
-        }                       //STATUS
-      }                         //CALL
-      /* the &quot;numbered&quot; messages that follows are used by the directory application, not yet ported */
-      if (!strcasecmp(message, &quot;#333&quot;)) {
-        /* DEBUGA_SKYPE(&quot;Skype MSG: message_2: %s, message2[11]: %s\n&quot;, SKYPIAX_P_LOG,
-         * message_2, &amp;message_2[11]); */
-        memset(tech_pvt-&gt;skype_friends, 0, 4096);
-        skypiax_strncpy(tech_pvt-&gt;skype_friends, &amp;message_2[11], 4095);
-      }
-      if (!strcasecmp(message, &quot;#222&quot;)) {
-        /* DEBUGA_SKYPE(&quot;Skype MSG: message_2: %s, message2[10]: %s\n&quot;, SKYPIAX_P_LOG,
-         * message_2, &amp;message_2[10]); */
-        memset(tech_pvt-&gt;skype_fullname, 0, 512);
-        skypiax_strncpy(tech_pvt-&gt;skype_fullname, &amp;message_2[10], 511);
-      }
-      if (!strcasecmp(message, &quot;#765&quot;)) {
-        /* DEBUGA_SKYPE(&quot;Skype MSG: message_2: %s, message2[10]: %s\n&quot;, SKYPIAX_P_LOG,
-         * message_2, &amp;message_2[10]); */
-        memset(tech_pvt-&gt;skype_displayname, 0, 512);
-        skypiax_strncpy(tech_pvt-&gt;skype_displayname, &amp;message_2[10], 511);
-      }
-      a = 0;
-    }                           //message end
-  }                             //read_from_pipe
-  return 0;
</del><ins>+                                        } else if (!strcasecmp(value, &quot;BUSY&quot;)) {
+                                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FAILED;
+                                                DEBUGA_SKYPE
+                                                        (&quot;we tried to call Skype on skype_call %s and remote party (destination) was BUSY. Our outbound call has failed\n&quot;,
+                                                         SKYPIAX_P_LOG, id);
+                                                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                tech_pvt-&gt;skype_call_id[0] = '\0';
+                                                skypiax_sleep(1000);
+                                                return CALLFLOW_INCOMING_HANGUP;
+                                        } else if (!strcasecmp(value, &quot;WAITING_REDIAL_COMMAND&quot;)) {
+                                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FAILED;
+                                                DEBUGA_SKYPE
+                                                        (&quot;we tried to call Skype on skype_call %s and remote party (destination) has rejected us (WAITING_REDIAL_COMMAND). Our outbound call has failed\n&quot;,
+                                                         SKYPIAX_P_LOG, id);
+                                                skypiax_strncpy(tech_pvt-&gt;skype_call_id, id, sizeof(tech_pvt-&gt;skype_call_id) - 1);
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                tech_pvt-&gt;skype_call_id[0] = '\0';
+                                                skypiax_sleep(1000);
+                                                return CALLFLOW_INCOMING_HANGUP;
+                                        } else {
+                                                WARNINGA(&quot;skype_call: %s, STATUS: %s is not recognized\n&quot;, SKYPIAX_P_LOG, id, value);
+                                        }
+                                }                                //STATUS
+                        }                                        //CALL
+                        /* the &quot;numbered&quot; messages that follows are used by the directory application, not yet ported */
+                        if (!strcasecmp(message, &quot;#333&quot;)) {
+                                /* DEBUGA_SKYPE(&quot;Skype MSG: message_2: %s, message2[11]: %s\n&quot;, SKYPIAX_P_LOG,
+                                 * message_2, &amp;message_2[11]); */
+                                memset(tech_pvt-&gt;skype_friends, 0, 4096);
+                                skypiax_strncpy(tech_pvt-&gt;skype_friends, &amp;message_2[11], 4095);
+                        }
+                        if (!strcasecmp(message, &quot;#222&quot;)) {
+                                /* DEBUGA_SKYPE(&quot;Skype MSG: message_2: %s, message2[10]: %s\n&quot;, SKYPIAX_P_LOG,
+                                 * message_2, &amp;message_2[10]); */
+                                memset(tech_pvt-&gt;skype_fullname, 0, 512);
+                                skypiax_strncpy(tech_pvt-&gt;skype_fullname, &amp;message_2[10], 511);
+                        }
+                        if (!strcasecmp(message, &quot;#765&quot;)) {
+                                /* DEBUGA_SKYPE(&quot;Skype MSG: message_2: %s, message2[10]: %s\n&quot;, SKYPIAX_P_LOG,
+                                 * message_2, &amp;message_2[10]); */
+                                memset(tech_pvt-&gt;skype_displayname, 0, 512);
+                                skypiax_strncpy(tech_pvt-&gt;skype_displayname, &amp;message_2[10], 511);
+                        }
+                        a = 0;
+                }                                                //message end
+        }                                                        //read_from_pipe
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void *skypiax_do_tcp_srv_thread_func(void *obj)
</span><span class="cx"> {
</span><del>-  private_t *tech_pvt = obj;
-  int s;
-  unsigned int len;
-  unsigned int i;
-  unsigned int a;
</del><ins>+        private_t *tech_pvt = obj;
+        int s;
+        unsigned int len;
+        unsigned int i;
+        unsigned int a;
</ins><span class="cx"> #if defined(WIN32) &amp;&amp; !defined(__CYGWIN__)
</span><del>-  int sin_size;
</del><ins>+        int sin_size;
</ins><span class="cx"> #else /* WIN32 */
</span><del>-  unsigned int sin_size;
</del><ins>+        unsigned int sin_size;
</ins><span class="cx"> #endif /* WIN32 */
</span><del>-  unsigned int fd;
-  short srv_in[SAMPLES_PER_FRAME];
-  short srv_out[SAMPLES_PER_FRAME / 2];
-  struct sockaddr_in my_addr;
-  struct sockaddr_in remote_addr;
-  //int exit = 0;
-  unsigned int kill_cli_size;
-  short kill_cli_buff[SAMPLES_PER_FRAME];
-  short totalbuf[SAMPLES_PER_FRAME];
</del><ins>+        unsigned int fd;
+        short srv_in[SAMPLES_PER_FRAME];
+        short srv_out[SAMPLES_PER_FRAME / 2];
+        struct sockaddr_in my_addr;
+        struct sockaddr_in remote_addr;
+        //int exit = 0;
+        unsigned int kill_cli_size;
+        short kill_cli_buff[SAMPLES_PER_FRAME];
+        short totalbuf[SAMPLES_PER_FRAME];
</ins><span class="cx"> 
</span><del>-  memset(&amp;my_addr, 0, sizeof(my_addr));
-  my_addr.sin_family = AF_INET;
-  my_addr.sin_addr.s_addr = htonl(0x7f000001);  /* use the localhost */
-  my_addr.sin_port = htons(tech_pvt-&gt;tcp_srv_port);
</del><ins>+        memset(&amp;my_addr, 0, sizeof(my_addr));
+        my_addr.sin_family = AF_INET;
+        my_addr.sin_addr.s_addr = htonl(0x7f000001);        /* use the localhost */
+        my_addr.sin_port = htons(tech_pvt-&gt;tcp_srv_port);
</ins><span class="cx"> 
</span><del>-  if ((s = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0) {
-    ERRORA(&quot;socket Error\n&quot;, SKYPIAX_P_LOG);
-    return NULL;
-  }
</del><ins>+        if ((s = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0) {
+                ERRORA(&quot;socket Error\n&quot;, SKYPIAX_P_LOG);
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  if (bind(s, (struct sockaddr *) &amp;my_addr, sizeof(struct sockaddr)) &lt; 0) {
-    ERRORA(&quot;bind Error\n&quot;, SKYPIAX_P_LOG);
-    return NULL;
-  }
-  DEBUGA_SKYPE(&quot;started tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        if (bind(s, (struct sockaddr *) &amp;my_addr, sizeof(struct sockaddr)) &lt; 0) {
+                ERRORA(&quot;bind Error\n&quot;, SKYPIAX_P_LOG);
+                return NULL;
+        }
+        DEBUGA_SKYPE(&quot;started tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  listen(s, 6);
</del><ins>+        listen(s, 6);
</ins><span class="cx"> 
</span><del>-  sin_size = sizeof(remote_addr);
</del><ins>+        sin_size = sizeof(remote_addr);
</ins><span class="cx"> 
</span><span class="cx">   /****************************/
</span><del>-  while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
-         &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
-             || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
-             || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
-             || tech_pvt-&gt;skype_callflow == SKYPIAX_STATE_UP)) {
</del><ins>+        while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
+                   &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
+                           || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
+                           || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt-&gt;skype_callflow == SKYPIAX_STATE_UP)) {
</ins><span class="cx"> 
</span><del>-    unsigned int fdselectgio;
-    int rtgio;
-    fd_set fsgio;
-    struct timeval togio;
</del><ins>+                unsigned int fdselectgio;
+                int rtgio;
+                fd_set fsgio;
+                struct timeval togio;
</ins><span class="cx"> 
</span><del>-    if (!(running &amp;&amp; tech_pvt-&gt;running))
-      break;
-    FD_ZERO(&amp;fsgio);
-    togio.tv_usec = 20000;      //20msec
-    togio.tv_sec = 0;
-    fdselectgio = s;
-    FD_SET(fdselectgio, &amp;fsgio);
</del><ins>+                if (!(running &amp;&amp; tech_pvt-&gt;running))
+                        break;
+                FD_ZERO(&amp;fsgio);
+                togio.tv_usec = 20000;        //20msec
+                togio.tv_sec = 0;
+                fdselectgio = s;
+                FD_SET(fdselectgio, &amp;fsgio);
</ins><span class="cx"> 
</span><del>-    rtgio = select(fdselectgio + 1, &amp;fsgio, NULL, NULL, &amp;togio);
</del><ins>+                rtgio = select(fdselectgio + 1, &amp;fsgio, NULL, NULL, &amp;togio);
</ins><span class="cx"> 
</span><del>-    if (rtgio) {
</del><ins>+                if (rtgio) {
</ins><span class="cx"> 
</span><span class="cx">   /****************************/
</span><span class="cx"> 
</span><del>-      while ((fd = accept(s, (struct sockaddr *) &amp;remote_addr, &amp;sin_size)) &gt; 0) {
-        DEBUGA_SKYPE(&quot;ACCEPTED here I send you %d\n&quot;, SKYPIAX_P_LOG,
-                     tech_pvt-&gt;tcp_srv_port);
-        if (!(running &amp;&amp; tech_pvt-&gt;running))
-          break;
-        while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
-               &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
-                   || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
-                   || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
-                   || tech_pvt-&gt;skype_callflow == SKYPIAX_STATE_UP)) {
</del><ins>+                        while ((fd = accept(s, (struct sockaddr *) &amp;remote_addr, &amp;sin_size)) &gt; 0) {
+                                DEBUGA_SKYPE(&quot;ACCEPTED here I send you %d\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;tcp_srv_port);
+                                if (!(running &amp;&amp; tech_pvt-&gt;running))
+                                        break;
+                                while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
+                                           &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
+                                                   || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
+                                                   || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt-&gt;skype_callflow == SKYPIAX_STATE_UP)) {
</ins><span class="cx"> 
</span><del>-          unsigned int fdselect;
-          int rt;
-          fd_set fs;
-          struct timeval to;
</del><ins>+                                        unsigned int fdselect;
+                                        int rt;
+                                        fd_set fs;
+                                        struct timeval to;
</ins><span class="cx"> 
</span><del>-          if (!(running &amp;&amp; tech_pvt-&gt;running))
-            break;
-          //exit = 1;
</del><ins>+                                        if (!(running &amp;&amp; tech_pvt-&gt;running))
+                                                break;
+                                        //exit = 1;
</ins><span class="cx"> 
</span><del>-          fdselect = fd;
-          FD_ZERO(&amp;fs);
-          FD_SET(fdselect, &amp;fs);
-          //to.tv_usec = 2000000;     //2000 msec
-          to.tv_usec = 60000;   //60 msec
-          to.tv_sec = 0;
</del><ins>+                                        fdselect = fd;
+                                        FD_ZERO(&amp;fs);
+                                        FD_SET(fdselect, &amp;fs);
+                                        //to.tv_usec = 2000000;     //2000 msec
+                                        to.tv_usec = 60000;        //60 msec
+                                        to.tv_sec = 0;
</ins><span class="cx"> 
</span><del>-          rt = select(fdselect + 1, &amp;fs, NULL, NULL, &amp;to);
-          if (rt &gt; 0) {
</del><ins>+                                        rt = select(fdselect + 1, &amp;fs, NULL, NULL, &amp;to);
+                                        if (rt &gt; 0) {
</ins><span class="cx"> 
</span><del>-            if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
-              len = recv(fd, (char *) srv_in, 320, 0);  //seems that Skype only sends 320 bytes at time
-            } else {
-              len = 0;
-            }
</del><ins>+                                                if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
+                                                        len = recv(fd, (char *) srv_in, 320, 0);        //seems that Skype only sends 320 bytes at time
+                                                } else {
+                                                        len = 0;
+                                                }
</ins><span class="cx"> 
</span><del>-            if (len == 320) {
-              unsigned int howmany;
</del><ins>+                                                if (len == 320) {
+                                                        unsigned int howmany;
</ins><span class="cx"> 
</span><del>-              if (samplerate_skypiax == 8000) {
-                /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
-                a = 0;
-                for (i = 0; i &lt; len / sizeof(short); i++) {
-                  srv_out[a] = srv_in[i];
-                  i++;
-                  a++;
-                }
-              } else if (samplerate_skypiax == 16000) {
-                /* we're NOT downsampling, srv_out will contain ALL samples from srv_in */
-                for (i = 0; i &lt; len / sizeof(short); i++) {
-                  srv_out[i] = srv_in[i];
-                }
-              } else {
-                ERRORA(&quot;SAMPLERATE_SKYPIAX can only be 8000 or 16000\n&quot;, SKYPIAX_P_LOG);
-              }
-              /* if not yet done, let's store the half incoming frame */
-              if (!tech_pvt-&gt;audiobuf_is_loaded) {
-                for (i = 0; i &lt; SAMPLES_PER_FRAME / 2; i++) {
-                  tech_pvt-&gt;audiobuf[i] = srv_out[i];
-                }
-                tech_pvt-&gt;audiobuf_is_loaded = 1;
-              } else {
-                /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */
-                for (i = 0; i &lt; SAMPLES_PER_FRAME / 2; i++) {
-                  totalbuf[i] = tech_pvt-&gt;audiobuf[i];
-                }
-                for (a = 0; a &lt; SAMPLES_PER_FRAME / 2; a++) {
-                  totalbuf[i] = srv_out[a];
-                  i++;
-                }
-                /* send the complete frame through the pipe to our code waiting for incoming audio */
-                howmany =
-                  skypiax_pipe_write(tech_pvt-&gt;audiopipe[1], totalbuf,
-                                     SAMPLES_PER_FRAME * sizeof(short));
-                if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
-                  ERRORA(&quot;howmany is %d, but was expected to be %d\n&quot;, SKYPIAX_P_LOG,
-                         howmany, (int) (SAMPLES_PER_FRAME * sizeof(short)));
-                }
-                /* done with the stored half frame */
-                tech_pvt-&gt;audiobuf_is_loaded = 0;
-              }
</del><ins>+                                                        if (samplerate_skypiax == 8000) {
+                                                                /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
+                                                                a = 0;
+                                                                for (i = 0; i &lt; len / sizeof(short); i++) {
+                                                                        srv_out[a] = srv_in[i];
+                                                                        i++;
+                                                                        a++;
+                                                                }
+                                                        } else if (samplerate_skypiax == 16000) {
+                                                                /* we're NOT downsampling, srv_out will contain ALL samples from srv_in */
+                                                                for (i = 0; i &lt; len / sizeof(short); i++) {
+                                                                        srv_out[i] = srv_in[i];
+                                                                }
+                                                        } else {
+                                                                ERRORA(&quot;SAMPLERATE_SKYPIAX can only be 8000 or 16000\n&quot;, SKYPIAX_P_LOG);
+                                                        }
+                                                        /* if not yet done, let's store the half incoming frame */
+                                                        if (!tech_pvt-&gt;audiobuf_is_loaded) {
+                                                                for (i = 0; i &lt; SAMPLES_PER_FRAME / 2; i++) {
+                                                                        tech_pvt-&gt;audiobuf[i] = srv_out[i];
+                                                                }
+                                                                tech_pvt-&gt;audiobuf_is_loaded = 1;
+                                                        } else {
+                                                                /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */
+                                                                for (i = 0; i &lt; SAMPLES_PER_FRAME / 2; i++) {
+                                                                        totalbuf[i] = tech_pvt-&gt;audiobuf[i];
+                                                                }
+                                                                for (a = 0; a &lt; SAMPLES_PER_FRAME / 2; a++) {
+                                                                        totalbuf[i] = srv_out[a];
+                                                                        i++;
+                                                                }
+                                                                /* send the complete frame through the pipe to our code waiting for incoming audio */
+                                                                howmany = skypiax_pipe_write(tech_pvt-&gt;audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short));
+                                                                if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
+                                                                        ERRORA(&quot;howmany is %d, but was expected to be %d\n&quot;, SKYPIAX_P_LOG,
+                                                                                   howmany, (int) (SAMPLES_PER_FRAME * sizeof(short)));
+                                                                }
+                                                                /* done with the stored half frame */
+                                                                tech_pvt-&gt;audiobuf_is_loaded = 0;
+                                                        }
</ins><span class="cx"> 
</span><del>-            } else if (len == 0) {
-              skypiax_sleep(1000);
-            } else {
-              ERRORA(&quot;len=%d, expected 320\n&quot;, SKYPIAX_P_LOG, len);
-            }
</del><ins>+                                                } else if (len == 0) {
+                                                        skypiax_sleep(1000);
+                                                } else {
+                                                        ERRORA(&quot;len=%d, expected 320\n&quot;, SKYPIAX_P_LOG, len);
+                                                }
</ins><span class="cx"> 
</span><del>-          } else {
-            if (rt)
-              ERRORA(&quot;SRV rt=%d\n&quot;, SKYPIAX_P_LOG, rt);
-            skypiax_sleep(10000);
-          }
</del><ins>+                                        } else {
+                                                if (rt)
+                                                        ERRORA(&quot;SRV rt=%d\n&quot;, SKYPIAX_P_LOG, rt);
+                                                skypiax_sleep(10000);
+                                        }
</ins><span class="cx"> 
</span><del>-        }
</del><ins>+                                }
</ins><span class="cx"> 
</span><del>-        /* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */
-        kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-        len = skypiax_pipe_write(tech_pvt-&gt;audiopipe[1], kill_cli_buff, kill_cli_size);
-        kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-        len =
-          skypiax_pipe_write(tech_pvt-&gt;audioskypepipe[1], kill_cli_buff, kill_cli_size);
-        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-        kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-        len = skypiax_pipe_write(tech_pvt-&gt;audiopipe[1], kill_cli_buff, kill_cli_size);
-        kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-        len =
-          skypiax_pipe_write(tech_pvt-&gt;audioskypepipe[1], kill_cli_buff, kill_cli_size);
</del><ins>+                                /* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */
+                                kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+                                len = skypiax_pipe_write(tech_pvt-&gt;audiopipe[1], kill_cli_buff, kill_cli_size);
+                                kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+                                len = skypiax_pipe_write(tech_pvt-&gt;audioskypepipe[1], kill_cli_buff, kill_cli_size);
+                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+                                len = skypiax_pipe_write(tech_pvt-&gt;audiopipe[1], kill_cli_buff, kill_cli_size);
+                                kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+                                len = skypiax_pipe_write(tech_pvt-&gt;audioskypepipe[1], kill_cli_buff, kill_cli_size);
</ins><span class="cx"> 
</span><del>-        DEBUGA_SKYPE(&quot;Skype incoming audio GONE\n&quot;, SKYPIAX_P_LOG);
-        skypiax_close_socket(fd);
-        //if (exit)
-        break;
-      }
-    }
-  }
</del><ins>+                                DEBUGA_SKYPE(&quot;Skype incoming audio GONE\n&quot;, SKYPIAX_P_LOG);
+                                skypiax_close_socket(fd);
+                                //if (exit)
+                                break;
+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;incoming audio server (I am it) EXITING\n&quot;, SKYPIAX_P_LOG);
-  skypiax_close_socket(s);
-  return NULL;
</del><ins>+        DEBUGA_SKYPE(&quot;incoming audio server (I am it) EXITING\n&quot;, SKYPIAX_P_LOG);
+        skypiax_close_socket(s);
+        return NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void *skypiax_do_tcp_cli_thread_func(void *obj)
</span><span class="cx"> {
</span><del>-  private_t *tech_pvt = obj;
-  int s;
-  struct sockaddr_in my_addr;
-  struct sockaddr_in remote_addr;
-  unsigned int got;
-  unsigned int len;
-  unsigned int i;
-  unsigned int a;
-  unsigned int fd;
-  short cli_out[SAMPLES_PER_FRAME * 2];
-  short cli_in[SAMPLES_PER_FRAME];
</del><ins>+        private_t *tech_pvt = obj;
+        int s;
+        struct sockaddr_in my_addr;
+        struct sockaddr_in remote_addr;
+        unsigned int got;
+        unsigned int len;
+        unsigned int i;
+        unsigned int a;
+        unsigned int fd;
+        short cli_out[SAMPLES_PER_FRAME * 2];
+        short cli_in[SAMPLES_PER_FRAME];
</ins><span class="cx"> #ifdef WIN32
</span><del>-  int sin_size;
</del><ins>+        int sin_size;
</ins><span class="cx"> #else
</span><del>-  unsigned int sin_size;
</del><ins>+        unsigned int sin_size;
</ins><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> 
</span><del>-  memset(&amp;my_addr, 0, sizeof(my_addr));
-  my_addr.sin_family = AF_INET;
-  my_addr.sin_addr.s_addr = htonl(0x7f000001);  /* use the localhost */
-  my_addr.sin_port = htons(tech_pvt-&gt;tcp_cli_port);
</del><ins>+        memset(&amp;my_addr, 0, sizeof(my_addr));
+        my_addr.sin_family = AF_INET;
+        my_addr.sin_addr.s_addr = htonl(0x7f000001);        /* use the localhost */
+        my_addr.sin_port = htons(tech_pvt-&gt;tcp_cli_port);
</ins><span class="cx"> 
</span><del>-  if ((s = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0) {
-    ERRORA(&quot;socket Error\n&quot;, SKYPIAX_P_LOG);
-    return NULL;
-  }
</del><ins>+        if ((s = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0) {
+                ERRORA(&quot;socket Error\n&quot;, SKYPIAX_P_LOG);
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  if (bind(s, (struct sockaddr *) &amp;my_addr, sizeof(struct sockaddr)) &lt; 0) {
-    ERRORA(&quot;bind Error\n&quot;, SKYPIAX_P_LOG);
-    skypiax_close_socket(s);
-    return NULL;
-  }
-  DEBUGA_SKYPE(&quot;started tcp_cli_thread thread.\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        if (bind(s, (struct sockaddr *) &amp;my_addr, sizeof(struct sockaddr)) &lt; 0) {
+                ERRORA(&quot;bind Error\n&quot;, SKYPIAX_P_LOG);
+                skypiax_close_socket(s);
+                return NULL;
+        }
+        DEBUGA_SKYPE(&quot;started tcp_cli_thread thread.\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  listen(s, 6);
</del><ins>+        listen(s, 6);
</ins><span class="cx"> 
</span><del>-  sin_size = sizeof(remote_addr);
</del><ins>+        sin_size = sizeof(remote_addr);
</ins><span class="cx"> 
</span><span class="cx">   /****************************/
</span><del>-  while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
-         &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
-             || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
-             || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
-             || tech_pvt-&gt;skype_callflow == SKYPIAX_STATE_UP)) {
</del><ins>+        while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
+                   &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
+                           || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
+                           || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt-&gt;skype_callflow == SKYPIAX_STATE_UP)) {
</ins><span class="cx"> 
</span><del>-    unsigned int fdselectgio;
-    int rtgio;
-    fd_set fsgio;
-    struct timeval togio;
</del><ins>+                unsigned int fdselectgio;
+                int rtgio;
+                fd_set fsgio;
+                struct timeval togio;
</ins><span class="cx"> 
</span><del>-    if (!(running &amp;&amp; tech_pvt-&gt;running))
-      break;
-    FD_ZERO(&amp;fsgio);
-    togio.tv_usec = 20000;      //20msec
-    togio.tv_sec = 0;
-    fdselectgio = s;
-    FD_SET(fdselectgio, &amp;fsgio);
</del><ins>+                if (!(running &amp;&amp; tech_pvt-&gt;running))
+                        break;
+                FD_ZERO(&amp;fsgio);
+                togio.tv_usec = 20000;        //20msec
+                togio.tv_sec = 0;
+                fdselectgio = s;
+                FD_SET(fdselectgio, &amp;fsgio);
</ins><span class="cx"> 
</span><del>-    rtgio = select(fdselectgio + 1, &amp;fsgio, NULL, NULL, &amp;togio);
</del><ins>+                rtgio = select(fdselectgio + 1, &amp;fsgio, NULL, NULL, &amp;togio);
</ins><span class="cx"> 
</span><del>-    if (rtgio) {
</del><ins>+                if (rtgio) {
</ins><span class="cx"> 
</span><span class="cx">   /****************************/
</span><span class="cx"> 
</span><del>-      while ((fd = accept(s, (struct sockaddr *) &amp;remote_addr, &amp;sin_size)) &gt; 0) {
-        DEBUGA_SKYPE(&quot;ACCEPTED here you send me %d\n&quot;, SKYPIAX_P_LOG,
-                     tech_pvt-&gt;tcp_cli_port);
</del><ins>+                        while ((fd = accept(s, (struct sockaddr *) &amp;remote_addr, &amp;sin_size)) &gt; 0) {
+                                DEBUGA_SKYPE(&quot;ACCEPTED here you send me %d\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;tcp_cli_port);
</ins><span class="cx"> #ifndef WIN32
</span><del>-        fcntl(tech_pvt-&gt;audioskypepipe[0], F_SETFL, O_NONBLOCK);
</del><ins>+                                fcntl(tech_pvt-&gt;audioskypepipe[0], F_SETFL, O_NONBLOCK);
+                                fcntl(tech_pvt-&gt;audioskypepipe[1], F_SETFL, O_NONBLOCK);
</ins><span class="cx"> #endif //WIN32
</span><span class="cx"> 
</span><del>-        if (!(running &amp;&amp; tech_pvt-&gt;running))
-          break;
-        while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
-               &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
-                   || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
-                   || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
-                   || tech_pvt-&gt;skype_callflow == SKYPIAX_STATE_UP)) {
-          unsigned int fdselect;
-          int rt;
-          fd_set fs;
-          struct timeval to;
</del><ins>+                                if (!(running &amp;&amp; tech_pvt-&gt;running))
+                                        break;
+                                while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
+                                           &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
+                                                   || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
+                                                   || tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt-&gt;skype_callflow == SKYPIAX_STATE_UP)) {
+                                        unsigned int fdselect;
+                                        int rt;
+                                        fd_set fs;
+                                        struct timeval to;
</ins><span class="cx"> 
</span><del>-          if (!(running &amp;&amp; tech_pvt-&gt;running))
-            break;
-          FD_ZERO(&amp;fs);
-          to.tv_usec = 120000;  //120msec
-          to.tv_sec = 0;
</del><ins>+                                        if (!(running &amp;&amp; tech_pvt-&gt;running))
+                                                break;
+                                        FD_ZERO(&amp;fs);
+                                        to.tv_usec = 120000;        //120msec
+                                        to.tv_sec = 0;
</ins><span class="cx"> #if defined(WIN32) &amp;&amp; !defined(__CYGWIN__)
</span><span class="cx"> /* on win32 we cannot select from the apr &quot;pipe&quot;, so we select on socket writability */
</span><del>-          fdselect = fd;
-          FD_SET(fdselect, &amp;fs);
</del><ins>+                                        fdselect = fd;
+                                        FD_SET(fdselect, &amp;fs);
</ins><span class="cx"> 
</span><del>-          rt = select(fdselect + 1, NULL, &amp;fs, NULL, &amp;to);
</del><ins>+                                        rt = select(fdselect + 1, NULL, &amp;fs, NULL, &amp;to);
</ins><span class="cx"> #else
</span><span class="cx"> /* on *unix and cygwin we select from the real pipe */
</span><del>-          fdselect = tech_pvt-&gt;audioskypepipe[0];
-          FD_SET(fdselect, &amp;fs);
</del><ins>+                                        fdselect = tech_pvt-&gt;audioskypepipe[0];
+                                        FD_SET(fdselect, &amp;fs);
</ins><span class="cx"> 
</span><del>-          rt = select(fdselect + 1, &amp;fs, NULL, NULL, &amp;to);
</del><ins>+                                        rt = select(fdselect + 1, &amp;fs, NULL, NULL, &amp;to);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-          if (rt &gt; 0) {
-            int counter;
</del><ins>+                                        if (rt &gt; 0) {
+                                                int counter;
</ins><span class="cx"> 
</span><del>-            /* until we drained the pipe to empty */
-            for (counter = 0; counter &lt; 10; counter++) {
-              /* read from the pipe the audio frame we are supposed to send out */
-              got =
-                skypiax_pipe_read(tech_pvt-&gt;audioskypepipe[0], cli_in,
-                                  SAMPLES_PER_FRAME * sizeof(short));
-              if (got == -1)
-                break;
</del><ins>+                                                /* until we drained the pipe to empty */
+                                                for (counter = 0; counter &lt; 10; counter++) {
+                                                        /* read from the pipe the audio frame we are supposed to send out */
+                                                        got = skypiax_pipe_read(tech_pvt-&gt;audioskypepipe[0], cli_in, SAMPLES_PER_FRAME * sizeof(short));
+                                                        if (got == -1)
+                                                                break;
</ins><span class="cx"> 
</span><del>-              if (got != SAMPLES_PER_FRAME * sizeof(short)) {
-                WARNINGA(&quot;got is %d, but was expected to be %d\n&quot;, SKYPIAX_P_LOG, got,
-                         (int) (SAMPLES_PER_FRAME * sizeof(short)));
-              }
</del><ins>+                                                        if (got != SAMPLES_PER_FRAME * sizeof(short)) {
+                                                                WARNINGA(&quot;got is %d, but was expected to be %d\n&quot;, SKYPIAX_P_LOG, got, (int) (SAMPLES_PER_FRAME * sizeof(short)));
+                                                        }
</ins><span class="cx"> 
</span><del>-              if (got == SAMPLES_PER_FRAME * sizeof(short)) {
-                if (samplerate_skypiax == 8000) {
</del><ins>+                                                        if (got == SAMPLES_PER_FRAME * sizeof(short)) {
+                                                                if (samplerate_skypiax == 8000) {
</ins><span class="cx"> 
</span><del>-                  /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */
-                  a = 0;
-                  for (i = 0; i &lt; got / sizeof(short); i++) {
-                    cli_out[a] = cli_in[i];
-                    a++;
-                    cli_out[a] = cli_in[i];
-                    a++;
-                  }
-                  got = got * 2;
-                } else if (samplerate_skypiax == 16000) {
-                  /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */
-                  for (i = 0; i &lt; got / sizeof(short); i++) {
-                    cli_out[i] = cli_in[i];
-                  }
-                } else {
-                  ERRORA(&quot;SAMPLERATE_SKYPIAX can only be 8000 or 16000\n&quot;, SKYPIAX_P_LOG);
-                }
</del><ins>+                                                                        /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */
+                                                                        a = 0;
+                                                                        for (i = 0; i &lt; got / sizeof(short); i++) {
+                                                                                cli_out[a] = cli_in[i];
+                                                                                a++;
+                                                                                cli_out[a] = cli_in[i];
+                                                                                a++;
+                                                                        }
+                                                                        got = got * 2;
+                                                                } else if (samplerate_skypiax == 16000) {
+                                                                        /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */
+                                                                        for (i = 0; i &lt; got / sizeof(short); i++) {
+                                                                                cli_out[i] = cli_in[i];
+                                                                        }
+                                                                } else {
+                                                                        ERRORA(&quot;SAMPLERATE_SKYPIAX can only be 8000 or 16000\n&quot;, SKYPIAX_P_LOG);
+                                                                }
</ins><span class="cx"> 
</span><del>-                /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
-                if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
-                  len = send(fd, (char *) cli_out, got, 0);
-                  skypiax_sleep(5000);  //5 msec
</del><ins>+                                                                /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
+                                                                if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
+                                                                        len = send(fd, (char *) cli_out, got, 0);
+                                                                        skypiax_sleep(5000);        //5 msec
</ins><span class="cx"> 
</span><del>-                  if (len == -1) {
-                    break;
-                  } else if (len != got) {
-                    ERRORA(&quot;len=%d\n&quot;, SKYPIAX_P_LOG, len);
-                    skypiax_sleep(1000);
-                    break;
-                  }
-                }
</del><ins>+                                                                        if (len == -1) {
+                                                                                break;
+                                                                        } else if (len != got) {
+                                                                                ERRORA(&quot;len=%d\n&quot;, SKYPIAX_P_LOG, len);
+                                                                                skypiax_sleep(1000);
+                                                                                break;
+                                                                        }
+                                                                }
</ins><span class="cx"> 
</span><del>-              } else {
</del><ins>+                                                        } else {
</ins><span class="cx"> 
</span><del>-                WARNINGA(&quot;got is %d, but was expected to be %d\n&quot;, SKYPIAX_P_LOG, got,
-                         (int) (SAMPLES_PER_FRAME * sizeof(short)));
-              }
-            }
-          } else {
-            if (rt)
-              ERRORA(&quot;CLI rt=%d\n&quot;, SKYPIAX_P_LOG, rt);
-            memset(cli_out, 0, sizeof(cli_out));
-            if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
-              len = send(fd, (char *) cli_out, sizeof(cli_out), 0);
-              len = send(fd, (char *) cli_out, sizeof(cli_out) / 2, 0);
-              //WARNINGA(&quot;sent %d of zeros to keep the Skype client socket busy\n&quot;, SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2);
-            } else {
-              /*
-                 XXX do nothing 
-               */
-              //WARNINGA(&quot;we don't send it\n&quot;, SKYPIAX_P_LOG);
-            }
-            skypiax_sleep(1000);
-          }
</del><ins>+                                                                WARNINGA(&quot;got is %d, but was expected to be %d\n&quot;, SKYPIAX_P_LOG, got, (int) (SAMPLES_PER_FRAME * sizeof(short)));
+                                                        }
+                                                }
+                                        } else {
+                                                if (rt)
+                                                        ERRORA(&quot;CLI rt=%d\n&quot;, SKYPIAX_P_LOG, rt);
+                                                memset(cli_out, 0, sizeof(cli_out));
+                                                if (tech_pvt-&gt;skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
+                                                        len = send(fd, (char *) cli_out, sizeof(cli_out), 0);
+                                                        len = send(fd, (char *) cli_out, sizeof(cli_out) / 2, 0);
+                                                        //WARNINGA(&quot;sent %d of zeros to keep the Skype client socket busy\n&quot;, SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2);
+                                                } else {
+                                                        /*
+                                                           XXX do nothing 
+                                                         */
+                                                        //WARNINGA(&quot;we don't send it\n&quot;, SKYPIAX_P_LOG);
+                                                }
+                                                skypiax_sleep(1000);
+                                        }
</ins><span class="cx"> 
</span><del>-        }
-        DEBUGA_SKYPE(&quot;Skype outbound audio GONE\n&quot;, SKYPIAX_P_LOG);
-        skypiax_close_socket(fd);
-        break;
-      }
-    }
-  }
</del><ins>+                                }
+                                DEBUGA_SKYPE(&quot;Skype outbound audio GONE\n&quot;, SKYPIAX_P_LOG);
+                                skypiax_close_socket(fd);
+                                break;
+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;outbound audio server (I am it) EXITING\n&quot;, SKYPIAX_P_LOG);
-  skypiax_close_socket(s);
-  return NULL;
</del><ins>+        DEBUGA_SKYPE(&quot;outbound audio server (I am it) EXITING\n&quot;, SKYPIAX_P_LOG);
+        skypiax_close_socket(s);
+        return NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_audio_read(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  unsigned int samples;
</del><ins>+        unsigned int samples;
</ins><span class="cx"> 
</span><del>-  samples =
-    skypiax_pipe_read(tech_pvt-&gt;audiopipe[0], tech_pvt-&gt;read_frame.data,
-                      SAMPLES_PER_FRAME * sizeof(short));
</del><ins>+        samples = skypiax_pipe_read(tech_pvt-&gt;audiopipe[0], tech_pvt-&gt;read_frame.data, SAMPLES_PER_FRAME * sizeof(short));
</ins><span class="cx"> 
</span><del>-  if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
-    if (samples)
-      WARNINGA(&quot;read samples=%u expected=%u\n&quot;, SKYPIAX_P_LOG, samples,
-               (int) (SAMPLES_PER_FRAME * sizeof(short)));
-    return 0;
-  } else {
-    /* A real frame */
-    tech_pvt-&gt;read_frame.datalen = samples;
-  }
-  return 1;
</del><ins>+        if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
+                if (samples)
+                        WARNINGA(&quot;read samples=%u expected=%u\n&quot;, SKYPIAX_P_LOG, samples, (int) (SAMPLES_PER_FRAME * sizeof(short)));
+                return 0;
+        } else {
+                /* A real frame */
+                tech_pvt-&gt;read_frame.datalen = samples;
+        }
+        return 1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_senddigit(private_t * tech_pvt, char digit)
</span><span class="cx"> {
</span><del>-  char msg_to_skype[1024];
</del><ins>+        char msg_to_skype[1024];
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;DIGIT received: %c\n&quot;, SKYPIAX_P_LOG, digit);
-  sprintf(msg_to_skype, &quot;SET CALL %s DTMF %c&quot;, tech_pvt-&gt;skype_call_id, digit);
-  skypiax_signaling_write(tech_pvt, msg_to_skype);
</del><ins>+        DEBUGA_SKYPE(&quot;DIGIT received: %c\n&quot;, SKYPIAX_P_LOG, digit);
+        sprintf(msg_to_skype, &quot;SET CALL %s DTMF %c&quot;, tech_pvt-&gt;skype_call_id, digit);
+        skypiax_signaling_write(tech_pvt, msg_to_skype);
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_call(private_t * tech_pvt, char *rdest, int timeout)
</span><span class="cx"> {
</span><del>-  char msg_to_skype[1024];
</del><ins>+        char msg_to_skype[1024];
</ins><span class="cx"> 
</span><del>-  //skypiax_sleep(5000);
-  DEBUGA_SKYPE(&quot;Calling Skype, rdest is: %s\n&quot;, SKYPIAX_P_LOG, rdest);
-  //skypiax_signaling_write(tech_pvt, &quot;SET AGC OFF&quot;);
-  //skypiax_sleep(10000);
-  //skypiax_signaling_write(tech_pvt, &quot;SET AEC OFF&quot;);
-  //skypiax_sleep(10000);
</del><ins>+        //skypiax_sleep(5000);
+        DEBUGA_SKYPE(&quot;Calling Skype, rdest is: %s\n&quot;, SKYPIAX_P_LOG, rdest);
+        //skypiax_signaling_write(tech_pvt, &quot;SET AGC OFF&quot;);
+        //skypiax_sleep(10000);
+        //skypiax_signaling_write(tech_pvt, &quot;SET AEC OFF&quot;);
+        //skypiax_sleep(10000);
</ins><span class="cx"> 
</span><del>-  sprintf(msg_to_skype, &quot;CALL %s&quot;, rdest);
-  if (skypiax_signaling_write(tech_pvt, msg_to_skype) &lt; 0) {
-    ERRORA(&quot;failed to communicate with Skype client, now exit\n&quot;, SKYPIAX_P_LOG);
-    return -1;
-  }
-  return 0;
</del><ins>+        sprintf(msg_to_skype, &quot;CALL %s&quot;, rdest);
+        if (skypiax_signaling_write(tech_pvt, msg_to_skype) &lt; 0) {
+                ERRORA(&quot;failed to communicate with Skype client, now exit\n&quot;, SKYPIAX_P_LOG);
+                return -1;
+        }
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /***************************/
</span><span class="lines">@@ -873,692 +820,649 @@
</span><span class="cx"> #if defined(WIN32) &amp;&amp; !defined(__CYGWIN__)
</span><span class="cx"> int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany)
</span><span class="cx"> {
</span><del>-  switch_size_t quantity;
</del><ins>+        switch_size_t quantity;
</ins><span class="cx"> 
</span><del>-  quantity = howmany;
</del><ins>+        quantity = howmany;
</ins><span class="cx"> 
</span><del>-  switch_file_read(pipe, buf, &amp;quantity);
</del><ins>+        switch_file_read(pipe, buf, &amp;quantity);
</ins><span class="cx"> 
</span><del>-  howmany = quantity;
</del><ins>+        howmany = quantity;
</ins><span class="cx"> 
</span><del>-  return howmany;
</del><ins>+        return howmany;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany)
</span><span class="cx"> {
</span><del>-  switch_size_t quantity;
</del><ins>+        switch_size_t quantity;
</ins><span class="cx"> 
</span><del>-  quantity = howmany;
</del><ins>+        quantity = howmany;
</ins><span class="cx"> 
</span><del>-  switch_file_write(pipe, buf, &amp;quantity);
</del><ins>+        switch_file_write(pipe, buf, &amp;quantity);
</ins><span class="cx"> 
</span><del>-  howmany = quantity;
</del><ins>+        howmany = quantity;
</ins><span class="cx"> 
</span><del>-  return howmany;
</del><ins>+        return howmany;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_close_socket(unsigned int fd)
</span><span class="cx"> {
</span><del>-  int res;
</del><ins>+        int res;
</ins><span class="cx"> 
</span><del>-  res = closesocket(fd);
</del><ins>+        res = closesocket(fd);
</ins><span class="cx"> 
</span><del>-  return res;
</del><ins>+        return res;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_audio_init(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  switch_status_t rv;
-  rv =
-    switch_file_pipe_create(&amp;tech_pvt-&gt;audiopipe[0], &amp;tech_pvt-&gt;audiopipe[1],
-                            skypiax_module_pool);
-  rv =
-    switch_file_pipe_create(&amp;tech_pvt-&gt;audioskypepipe[0], &amp;tech_pvt-&gt;audioskypepipe[1],
-                            skypiax_module_pool);
-  return 0;
</del><ins>+        switch_status_t rv;
+        rv = switch_file_pipe_create(&amp;tech_pvt-&gt;audiopipe[0], &amp;tech_pvt-&gt;audiopipe[1], skypiax_module_pool);
+        rv = switch_file_pipe_create(&amp;tech_pvt-&gt;audioskypepipe[0], &amp;tech_pvt-&gt;audioskypepipe[1], skypiax_module_pool);
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> #else /* WIN32 */
</span><span class="cx"> int skypiax_pipe_read(int pipe, short *buf, int howmany)
</span><span class="cx"> {
</span><del>-  howmany = read(pipe, buf, howmany);
-  return howmany;
</del><ins>+        howmany = read(pipe, buf, howmany);
+        return howmany;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_pipe_write(int pipe, short *buf, int howmany)
</span><span class="cx"> {
</span><del>-  howmany = write(pipe, buf, howmany);
-  return howmany;
</del><ins>+        howmany = write(pipe, buf, howmany);
+        return howmany;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_close_socket(unsigned int fd)
</span><span class="cx"> {
</span><del>-  int res;
</del><ins>+        int res;
</ins><span class="cx"> 
</span><del>-  res = close(fd);
</del><ins>+        res = close(fd);
</ins><span class="cx"> 
</span><del>-  return res;
</del><ins>+        return res;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_audio_init(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  if (pipe(tech_pvt-&gt;audiopipe)) {
-    fcntl(tech_pvt-&gt;audiopipe[0], F_SETFL, O_NONBLOCK);
-    fcntl(tech_pvt-&gt;audiopipe[1], F_SETFL, O_NONBLOCK);
-  }
-  if (pipe(tech_pvt-&gt;audioskypepipe)) {
-    fcntl(tech_pvt-&gt;audioskypepipe[0], F_SETFL, O_NONBLOCK);
-    fcntl(tech_pvt-&gt;audioskypepipe[1], F_SETFL, O_NONBLOCK);
-  }
</del><ins>+        if (pipe(tech_pvt-&gt;audiopipe)) {
+                fcntl(tech_pvt-&gt;audiopipe[0], F_SETFL, O_NONBLOCK);
+                fcntl(tech_pvt-&gt;audiopipe[1], F_SETFL, O_NONBLOCK);
+        }
+        if (pipe(tech_pvt-&gt;audioskypepipe)) {
+                fcntl(tech_pvt-&gt;audioskypepipe[0], F_SETFL, O_NONBLOCK);
+                fcntl(tech_pvt-&gt;audioskypepipe[1], F_SETFL, O_NONBLOCK);
+        }
</ins><span class="cx"> 
</span><span class="cx"> /* this pipe is the audio fd for asterisk to poll on during a call. FS do not use it */
</span><del>-  tech_pvt-&gt;skypiax_sound_capt_fd = tech_pvt-&gt;audiopipe[0];
</del><ins>+        tech_pvt-&gt;skypiax_sound_capt_fd = tech_pvt-&gt;audiopipe[0];
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> 
</span><span class="cx"> #ifdef WIN32
</span><span class="cx"> 
</span><span class="cx"> enum {
</span><del>-  SKYPECONTROLAPI_ATTACH_SUCCESS = 0,   /*  Client is successfully 
-                                           attached and API window handle can be found
-                                           in wParam parameter */
-  SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /*  Skype has acknowledged
-                                                       connection request and is waiting
-                                                       for confirmation from the user. */
-  /*  The client is not yet attached 
-   * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */
-  SKYPECONTROLAPI_ATTACH_REFUSED = 2,   /*  User has explicitly
-                                           denied access to client */
-  SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /*  API is not available
-                                               at the moment.
-                                               For example, this happens when no user
-                                               is currently logged in. */
-  /*  Client should wait for 
-   * SKYPECONTROLAPI_ATTACH_API_AVAILABLE 
-   * broadcast before making any further */
-  /*  connection attempts. */
-  SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
</del><ins>+        SKYPECONTROLAPI_ATTACH_SUCCESS = 0,        /*  Client is successfully 
+                                                                                   attached and API window handle can be found
+                                                                                   in wParam parameter */
+        SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1,        /*  Skype has acknowledged
+                                                                                                                   connection request and is waiting
+                                                                                                                   for confirmation from the user. */
+        /*  The client is not yet attached 
+         * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */
+        SKYPECONTROLAPI_ATTACH_REFUSED = 2,        /*  User has explicitly
+                                                                                   denied access to client */
+        SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3,        /*  API is not available
+                                                                                                   at the moment.
+                                                                                                   For example, this happens when no user
+                                                                                                   is currently logged in. */
+        /*  Client should wait for 
+         * SKYPECONTROLAPI_ATTACH_API_AVAILABLE 
+         * broadcast before making any further */
+        /*  connection attempts. */
+        SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* Visual C do not have strsep? */
</span><span class="cx"> char
</span><del>- *strsep(char **stringp, const char *delim)
</del><ins>+    *strsep(char **stringp, const char *delim)
</ins><span class="cx"> {
</span><del>-  char *res;
</del><ins>+        char *res;
</ins><span class="cx"> 
</span><del>-  if (!stringp || !*stringp || !**stringp)
-    return (char *) 0;
</del><ins>+        if (!stringp || !*stringp || !**stringp)
+                return (char *) 0;
</ins><span class="cx"> 
</span><del>-  res = *stringp;
-  while (**stringp &amp;&amp; !strchr(delim, **stringp))
-    ++(*stringp);
</del><ins>+        res = *stringp;
+        while (**stringp &amp;&amp; !strchr(delim, **stringp))
+                ++(*stringp);
</ins><span class="cx"> 
</span><del>-  if (**stringp) {
-    **stringp = '\0';
-    ++(*stringp);
-  }
</del><ins>+        if (**stringp) {
+                **stringp = '\0';
+                ++(*stringp);
+        }
</ins><span class="cx"> 
</span><del>-  return res;
</del><ins>+        return res;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype)
</span><span class="cx"> {
</span><del>-  static char acInputRow[1024];
-  COPYDATASTRUCT oCopyData;
</del><ins>+        static char acInputRow[1024];
+        COPYDATASTRUCT oCopyData;
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;SENDING: |||%s||||\n&quot;, SKYPIAX_P_LOG, msg_to_skype);
</del><ins>+        DEBUGA_SKYPE(&quot;SENDING: |||%s||||\n&quot;, SKYPIAX_P_LOG, msg_to_skype);
</ins><span class="cx"> 
</span><del>-  sprintf(acInputRow, &quot;%s&quot;, msg_to_skype);
-  DEBUGA_SKYPE(&quot;acInputRow: |||%s||||\n&quot;, SKYPIAX_P_LOG, acInputRow);
-  /*  send command to skype */
-  oCopyData.dwData = 0;
-  oCopyData.lpData = acInputRow;
-  oCopyData.cbData = strlen(acInputRow) + 1;
-  if (oCopyData.cbData != 1) {
-    if (SendMessage
-        (tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA,
-         (WPARAM) tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle,
-         (LPARAM) &amp; oCopyData) == FALSE) {
-      ERRORA
-        (&quot;Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then launch Skypiax and try again.\n&quot;,
-         SKYPIAX_P_LOG);
-      return -1;
-    }
-  }
</del><ins>+        sprintf(acInputRow, &quot;%s&quot;, msg_to_skype);
+        DEBUGA_SKYPE(&quot;acInputRow: |||%s||||\n&quot;, SKYPIAX_P_LOG, acInputRow);
+        /*  send command to skype */
+        oCopyData.dwData = 0;
+        oCopyData.lpData = acInputRow;
+        oCopyData.cbData = strlen(acInputRow) + 1;
+        if (oCopyData.cbData != 1) {
+                if (SendMessage
+                        (tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA,
+                         (WPARAM) tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, (LPARAM) &amp; oCopyData) == FALSE) {
+                        ERRORA(&quot;Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then launch Skypiax and try again.\n&quot;, SKYPIAX_P_LOG);
+                        return -1;
+                }
+        }
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LRESULT APIENTRY skypiax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
-                                 LPARAM ulParam)
</del><ins>+LRESULT APIENTRY skypiax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, LPARAM ulParam)
</ins><span class="cx"> {
</span><del>-  LRESULT lReturnCode;
-  int fIssueDefProc;
-  private_t *tech_pvt = NULL;
</del><ins>+        LRESULT lReturnCode;
+        int fIssueDefProc;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  lReturnCode = 0;
-  fIssueDefProc = 0;
-  tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA);
-  if (!running)
-    return lReturnCode;
-  switch (uiMessage) {
-  case WM_CREATE:
-    tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)-&gt;lpCreateParams;
-    SetWindowLong(hWindow, GWL_USERDATA, (LONG) tech_pvt);
-    DEBUGA_SKYPE(&quot;got CREATE\n&quot;, SKYPIAX_P_LOG);
-    break;
-  case WM_DESTROY:
-    DEBUGA_SKYPE(&quot;got DESTROY\n&quot;, SKYPIAX_P_LOG);
-    tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
-    PostQuitMessage(0);
-    break;
-  case WM_COPYDATA:
-    if (tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
-      unsigned int howmany;
-      char msg_from_skype[2048];
</del><ins>+        lReturnCode = 0;
+        fIssueDefProc = 0;
+        tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA);
+        if (!running)
+                return lReturnCode;
+        switch (uiMessage) {
+        case WM_CREATE:
+                tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)-&gt;lpCreateParams;
+                SetWindowLong(hWindow, GWL_USERDATA, (LONG) tech_pvt);
+                DEBUGA_SKYPE(&quot;got CREATE\n&quot;, SKYPIAX_P_LOG);
+                break;
+        case WM_DESTROY:
+                DEBUGA_SKYPE(&quot;got DESTROY\n&quot;, SKYPIAX_P_LOG);
+                tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
+                PostQuitMessage(0);
+                break;
+        case WM_COPYDATA:
+                if (tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
+                        unsigned int howmany;
+                        char msg_from_skype[2048];
</ins><span class="cx"> 
</span><del>-      PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
</del><ins>+                        PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
</ins><span class="cx"> 
</span><del>-      memset(msg_from_skype, '\0', sizeof(msg_from_skype));
-      skypiax_strncpy(msg_from_skype, (const char *) poCopyData-&gt;lpData,
-                      sizeof(msg_from_skype) - 2);
</del><ins>+                        memset(msg_from_skype, '\0', sizeof(msg_from_skype));
+                        skypiax_strncpy(msg_from_skype, (const char *) poCopyData-&gt;lpData, sizeof(msg_from_skype) - 2);
</ins><span class="cx"> 
</span><del>-      howmany = strlen(msg_from_skype) + 1;
-      howmany =
-        skypiax_pipe_write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], (short *) msg_from_skype,
-                           howmany);
-      //DEBUGA_SKYPE(&quot;From Skype API: %s\n&quot;, SKYPIAX_P_LOG, msg_from_skype);
-      lReturnCode = 1;
-    }
-    break;
-  default:
-    if (tech_pvt &amp;&amp; tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
-      if (uiMessage ==
-          tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
-        switch (ulParam) {
-        case SKYPECONTROLAPI_ATTACH_SUCCESS:
-          if (!tech_pvt-&gt;SkypiaxHandles.currentuserhandle) {
-            //DEBUGA_SKYPE(&quot;\n\n\tConnected to Skype API!\n&quot;, SKYPIAX_P_LOG);
-            tech_pvt-&gt;SkypiaxHandles.api_connected = 1;
-            tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
-            tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle =
-              tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle;
-          }
-          break;
-        case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
-          //DEBUGA_SKYPE (&quot;\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n&quot;, SKYPIAX_P_LOG);
-          skypiax_sleep(5000);
</del><ins>+                        howmany = strlen(msg_from_skype) + 1;
+                        howmany = skypiax_pipe_write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], (short *) msg_from_skype, howmany);
+                        //DEBUGA_SKYPE(&quot;From Skype API: %s\n&quot;, SKYPIAX_P_LOG, msg_from_skype);
+                        lReturnCode = 1;
+                }
+                break;
+        default:
+                if (tech_pvt &amp;&amp; tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+                        if (uiMessage == tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+                                switch (ulParam) {
+                                case SKYPECONTROLAPI_ATTACH_SUCCESS:
+                                        if (!tech_pvt-&gt;SkypiaxHandles.currentuserhandle) {
+                                                //DEBUGA_SKYPE(&quot;\n\n\tConnected to Skype API!\n&quot;, SKYPIAX_P_LOG);
+                                                tech_pvt-&gt;SkypiaxHandles.api_connected = 1;
+                                                tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
+                                                tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = tech_pvt-&gt;SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle;
+                                        }
+                                        break;
+                                case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
+                                        //DEBUGA_SKYPE (&quot;\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n&quot;, SKYPIAX_P_LOG);
+                                        skypiax_sleep(5000);
</ins><span class="cx"> #if 0
</span><del>-          if (!tech_pvt-&gt;SkypiaxHandles.currentuserhandle) {
-            SendMessage(HWND_BROADCAST,
-                        tech_pvt-&gt;SkypiaxHandles.
-                        win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
-                        (WPARAM) tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle,
-                        0);
-          }
</del><ins>+                                        if (!tech_pvt-&gt;SkypiaxHandles.currentuserhandle) {
+                                                SendMessage(HWND_BROADCAST,
+                                                                        tech_pvt-&gt;SkypiaxHandles.
+                                                                        win32_uiGlobal_MsgID_SkypeControlAPIDiscover, (WPARAM) tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, 0);
+                                        }
</ins><span class="cx"> #endif
</span><del>-          break;
-        case SKYPECONTROLAPI_ATTACH_REFUSED:
-          ERRORA(&quot;Skype client refused to be connected by Skypiax!\n&quot;, SKYPIAX_P_LOG);
-          break;
-        case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
-          ERRORA(&quot;Skype API not (yet?) available\n&quot;, SKYPIAX_P_LOG);
-          break;
-        case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
-          DEBUGA_SKYPE(&quot;Skype API available\n&quot;, SKYPIAX_P_LOG);
-          skypiax_sleep(5000);
</del><ins>+                                        break;
+                                case SKYPECONTROLAPI_ATTACH_REFUSED:
+                                        ERRORA(&quot;Skype client refused to be connected by Skypiax!\n&quot;, SKYPIAX_P_LOG);
+                                        break;
+                                case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
+                                        ERRORA(&quot;Skype API not (yet?) available\n&quot;, SKYPIAX_P_LOG);
+                                        break;
+                                case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
+                                        DEBUGA_SKYPE(&quot;Skype API available\n&quot;, SKYPIAX_P_LOG);
+                                        skypiax_sleep(5000);
</ins><span class="cx"> #if 0
</span><del>-          if (!tech_pvt-&gt;SkypiaxHandles.currentuserhandle) {
-            SendMessage(HWND_BROADCAST,
-                        tech_pvt-&gt;SkypiaxHandles.
-                        win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
-                        (WPARAM) tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle,
-                        0);
-          }
</del><ins>+                                        if (!tech_pvt-&gt;SkypiaxHandles.currentuserhandle) {
+                                                SendMessage(HWND_BROADCAST,
+                                                                        tech_pvt-&gt;SkypiaxHandles.
+                                                                        win32_uiGlobal_MsgID_SkypeControlAPIDiscover, (WPARAM) tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, 0);
+                                        }
</ins><span class="cx"> #endif
</span><del>-          break;
-        default:
-          WARNINGA(&quot;GOT AN UNKNOWN SKYPE WINDOWS MSG\n&quot;, SKYPIAX_P_LOG);
-        }
-        lReturnCode = 1;
-        break;
-      }
-    }
-    fIssueDefProc = 1;
-    break;
-  }
-  if (fIssueDefProc)
-    lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam);
-  return (lReturnCode);
</del><ins>+                                        break;
+                                default:
+                                        WARNINGA(&quot;GOT AN UNKNOWN SKYPE WINDOWS MSG\n&quot;, SKYPIAX_P_LOG);
+                                }
+                                lReturnCode = 1;
+                                break;
+                        }
+                }
+                fIssueDefProc = 1;
+                break;
+        }
+        if (fIssueDefProc)
+                lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam);
+        return (lReturnCode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int win32_Initialize_CreateWindowClass(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  unsigned char *paucUUIDString;
-  RPC_STATUS lUUIDResult;
-  int fReturnStatus;
-  UUID oUUID;
</del><ins>+        unsigned char *paucUUIDString;
+        RPC_STATUS lUUIDResult;
+        int fReturnStatus;
+        UUID oUUID;
</ins><span class="cx"> 
</span><del>-  fReturnStatus = 0;
-  lUUIDResult = UuidCreate(&amp;oUUID);
-  tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle =
-    (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
-  if (tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle != NULL
-      &amp;&amp; (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) {
-    if (UuidToString(&amp;oUUID, &amp;paucUUIDString) == RPC_S_OK) {
-      WNDCLASS oWindowClass;
</del><ins>+        fReturnStatus = 0;
+        lUUIDResult = UuidCreate(&amp;oUUID);
+        tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle = (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
+        if (tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle != NULL &amp;&amp; (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) {
+                if (UuidToString(&amp;oUUID, &amp;paucUUIDString) == RPC_S_OK) {
+                        WNDCLASS oWindowClass;
</ins><span class="cx"> 
</span><del>-      strcpy(tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName, &quot;Skype-API-Skypiax-&quot;);
-      strcat(tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName,
-             (char *) paucUUIDString);
</del><ins>+                        strcpy(tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName, &quot;Skype-API-Skypiax-&quot;);
+                        strcat(tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName, (char *) paucUUIDString);
</ins><span class="cx"> 
</span><del>-      oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
-      oWindowClass.lpfnWndProc = (WNDPROC) &amp; skypiax_present;
-      oWindowClass.cbClsExtra = 0;
-      oWindowClass.cbWndExtra = 0;
-      oWindowClass.hInstance = tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle;
-      oWindowClass.hIcon = NULL;
-      oWindowClass.hCursor = NULL;
-      oWindowClass.hbrBackground = NULL;
-      oWindowClass.lpszMenuName = NULL;
-      oWindowClass.lpszClassName = tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName;
</del><ins>+                        oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
+                        oWindowClass.lpfnWndProc = (WNDPROC) &amp; skypiax_present;
+                        oWindowClass.cbClsExtra = 0;
+                        oWindowClass.cbWndExtra = 0;
+                        oWindowClass.hInstance = tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle;
+                        oWindowClass.hIcon = NULL;
+                        oWindowClass.hCursor = NULL;
+                        oWindowClass.hbrBackground = NULL;
+                        oWindowClass.lpszMenuName = NULL;
+                        oWindowClass.lpszClassName = tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName;
</ins><span class="cx"> 
</span><del>-      if (RegisterClass(&amp;oWindowClass) != 0)
-        fReturnStatus = 1;
</del><ins>+                        if (RegisterClass(&amp;oWindowClass) != 0)
+                                fReturnStatus = 1;
</ins><span class="cx"> 
</span><del>-      RpcStringFree(&amp;paucUUIDString);
-    }
-  }
-  if (fReturnStatus == 0)
-    CloseHandle(tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle);
-  tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
-  return (fReturnStatus);
</del><ins>+                        RpcStringFree(&amp;paucUUIDString);
+                }
+        }
+        if (fReturnStatus == 0)
+                CloseHandle(tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle);
+        tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
+        return (fReturnStatus);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  UnregisterClass(tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName,
-                  tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle);
-  CloseHandle(tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle);
-  tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
</del><ins>+        UnregisterClass(tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName, tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle);
+        CloseHandle(tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle);
+        tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int win32_Initialize_CreateMainWindow(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle =
-    CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
-                   tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName, &quot;&quot;,
-                   WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
-                   128, 128, NULL, 0, tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle,
-                   tech_pvt);
-  return (tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0);
</del><ins>+        tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle =
+                CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
+                                           tech_pvt-&gt;SkypiaxHandles.win32_acInit_WindowClassName, &quot;&quot;,
+                                           WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
+                                           128, 128, NULL, 0, tech_pvt-&gt;SkypiaxHandles.win32_hInit_ProcessHandle, tech_pvt);
+        return (tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void win32_DeInitialize_DestroyMainWindow(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  if (tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle != NULL)
-    DestroyWindow(tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle),
-      tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
</del><ins>+        if (tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle != NULL)
+                DestroyWindow(tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle), tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void *skypiax_do_skypeapi_thread_func(void *obj)
</span><span class="cx"> {
</span><del>-  private_t *tech_pvt = obj;
</del><ins>+        private_t *tech_pvt = obj;
</ins><span class="cx"> #if defined(WIN32) &amp;&amp; !defined(__CYGWIN__)
</span><del>-  switch_status_t rv;
</del><ins>+        switch_status_t rv;
</ins><span class="cx"> 
</span><del>-  switch_file_pipe_create(&amp;tech_pvt-&gt;SkypiaxHandles.fdesc[0],
-                          &amp;tech_pvt-&gt;SkypiaxHandles.fdesc[1], skypiax_module_pool);
-  rv =
-    switch_file_pipe_create(&amp;tech_pvt-&gt;SkypiaxHandles.fdesc[0],
-                            &amp;tech_pvt-&gt;SkypiaxHandles.fdesc[1], skypiax_module_pool);
</del><ins>+        switch_file_pipe_create(&amp;tech_pvt-&gt;SkypiaxHandles.fdesc[0], &amp;tech_pvt-&gt;SkypiaxHandles.fdesc[1], skypiax_module_pool);
+        rv = switch_file_pipe_create(&amp;tech_pvt-&gt;SkypiaxHandles.fdesc[0], &amp;tech_pvt-&gt;SkypiaxHandles.fdesc[1], skypiax_module_pool);
</ins><span class="cx"> #else /* WIN32 */
</span><del>-  if (pipe(tech_pvt-&gt;SkypiaxHandles.fdesc)) {
-    fcntl(tech_pvt-&gt;SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
-    fcntl(tech_pvt-&gt;SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
-  }
</del><ins>+        if (pipe(tech_pvt-&gt;SkypiaxHandles.fdesc)) {
+                fcntl(tech_pvt-&gt;SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
+                fcntl(tech_pvt-&gt;SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
+        }
</ins><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> 
</span><del>-  tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach =
-    RegisterWindowMessage(&quot;SkypeControlAPIAttach&quot;);
-  tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
-    RegisterWindowMessage(&quot;SkypeControlAPIDiscover&quot;);
</del><ins>+        tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach = RegisterWindowMessage(&quot;SkypeControlAPIAttach&quot;);
+        tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover = RegisterWindowMessage(&quot;SkypeControlAPIDiscover&quot;);
</ins><span class="cx"> 
</span><del>-  skypiax_sleep(200000);        //0,2 sec
</del><ins>+        skypiax_sleep(200000);                //0,2 sec
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
-      &amp;&amp; tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
-    if (win32_Initialize_CreateWindowClass(tech_pvt)) {
-      if (win32_Initialize_CreateMainWindow(tech_pvt)) {
-        if (SendMessage
-            (HWND_BROADCAST,
-             tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
-             (WPARAM) tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) {
-          tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle =
-            tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle;
-          while (running &amp;&amp; tech_pvt-&gt;running) {
-            MSG oMessage;
-            if (! (running &amp;&amp; tech_pvt-&gt;running))
-              break;
-            while (GetMessage(&amp;oMessage, 0, 0, 0)) {
-              TranslateMessage(&amp;oMessage);
-              DispatchMessage(&amp;oMessage);
-            }
-          }
-        }
-        win32_DeInitialize_DestroyMainWindow(tech_pvt);
-      }
-      win32_DeInitialize_DestroyWindowClass(tech_pvt);
-    }
-  }
</del><ins>+        if (tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
+                &amp;&amp; tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
+                if (win32_Initialize_CreateWindowClass(tech_pvt)) {
+                        if (win32_Initialize_CreateMainWindow(tech_pvt)) {
+                                if (SendMessage
+                                        (HWND_BROADCAST,
+                                         tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+                                         (WPARAM) tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) {
+                                        tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle = tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle;
+                                        while (running &amp;&amp; tech_pvt-&gt;running) {
+                                                MSG oMessage;
+                                                if (!(running &amp;&amp; tech_pvt-&gt;running))
+                                                        break;
+                                                while (GetMessage(&amp;oMessage, 0, 0, 0)) {
+                                                        TranslateMessage(&amp;oMessage);
+                                                        DispatchMessage(&amp;oMessage);
+                                                }
+                                        }
+                                }
+                                win32_DeInitialize_DestroyMainWindow(tech_pvt);
+                        }
+                        win32_DeInitialize_DestroyWindowClass(tech_pvt);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  return NULL;
</del><ins>+        return NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #else /* NOT WIN32 */
</span><span class="cx"> int X11_errors_handler(Display * dpy, XErrorEvent * err)
</span><span class="cx"> {
</span><del>-  (void) dpy;
-  private_t *tech_pvt = NULL;
</del><ins>+        (void) dpy;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  xerror = err-&gt;error_code;
-  ERRORA(&quot;Received error code %d from X Server\n\n&quot;, SKYPIAX_P_LOG, xerror); ///FIXME why crash the entire skypiax? just crash the interface, instead
-  running = 0;
-  return 0;                     /*  ignore the error */
</del><ins>+        xerror = err-&gt;error_code;
+        ERRORA(&quot;Received error code %d from X Server\n\n&quot;, SKYPIAX_P_LOG, xerror);        ///FIXME why crash the entire skypiax? just crash the interface, instead
+        running = 0;
+        return 0;                                        /*  ignore the error */
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void X11_errors_trap(void)
</span><span class="cx"> {
</span><del>-  xerror = 0;
-  old_handler = XSetErrorHandler(X11_errors_handler);
</del><ins>+        xerror = 0;
+        old_handler = XSetErrorHandler(X11_errors_handler);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static int X11_errors_untrap(void)
</span><span class="cx"> {
</span><del>-  XSetErrorHandler(old_handler);
-  return (xerror != BadValue) &amp;&amp; (xerror != BadWindow);
</del><ins>+        XSetErrorHandler(old_handler);
+        return (xerror != BadValue) &amp;&amp; (xerror != BadWindow);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-  Window w_P;
-  Display *disp;
-  Window handle_P;
-  int ok;
-  private_t *tech_pvt = NULL;
</del><ins>+        Window w_P;
+        Display *disp;
+        Window handle_P;
+        int ok;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  w_P = SkypiaxHandles-&gt;skype_win;
-  disp = SkypiaxHandles-&gt;disp;
-  handle_P = SkypiaxHandles-&gt;win;
</del><ins>+        w_P = SkypiaxHandles-&gt;skype_win;
+        disp = SkypiaxHandles-&gt;disp;
+        handle_P = SkypiaxHandles-&gt;win;
</ins><span class="cx"> 
</span><del>-  Atom atom1 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
-  Atom atom2 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE&quot;, False);
-  unsigned int pos = 0;
-  unsigned int len = strlen(message_P);
-  XEvent e;
</del><ins>+        Atom atom1 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
+        Atom atom2 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE&quot;, False);
+        unsigned int pos = 0;
+        unsigned int len = strlen(message_P);
+        XEvent e;
</ins><span class="cx"> 
</span><del>-  memset(&amp;e, 0, sizeof(e));
-  e.xclient.type = ClientMessage;
-  e.xclient.message_type = atom1;   /*  leading message */
-  e.xclient.display = disp;
-  e.xclient.window = handle_P;
-  e.xclient.format = 8;
</del><ins>+        memset(&amp;e, 0, sizeof(e));
+        e.xclient.type = ClientMessage;
+        e.xclient.message_type = atom1;        /*  leading message */
+        e.xclient.display = disp;
+        e.xclient.window = handle_P;
+        e.xclient.format = 8;
</ins><span class="cx"> 
</span><del>-  X11_errors_trap();
-  //XLockDisplay(disp);
-  do {
-    unsigned int i;
-    for (i = 0; i &lt; 20 &amp;&amp; i + pos &lt;= len; ++i)
-      e.xclient.data.b[i] = message_P[i + pos];
-    XSendEvent(disp, w_P, False, 0, &amp;e);
</del><ins>+        X11_errors_trap();
+        //XLockDisplay(disp);
+        do {
+                unsigned int i;
+                for (i = 0; i &lt; 20 &amp;&amp; i + pos &lt;= len; ++i)
+                        e.xclient.data.b[i] = message_P[i + pos];
+                XSendEvent(disp, w_P, False, 0, &amp;e);
</ins><span class="cx"> 
</span><del>-    e.xclient.message_type = atom2; /*  following messages */
-    pos += i;
-  } while (pos &lt;= len);
</del><ins>+                e.xclient.message_type = atom2;        /*  following messages */
+                pos += i;
+        } while (pos &lt;= len);
</ins><span class="cx"> 
</span><del>-  XSync(disp, False);
-  ok = X11_errors_untrap();
</del><ins>+        XSync(disp, False);
+        ok = X11_errors_untrap();
</ins><span class="cx"> 
</span><del>-  if (!ok)
-    ERRORA(&quot;Sending message failed with status %d\n&quot;, SKYPIAX_P_LOG, xerror);
-  //XUnlockDisplay(disp);
</del><ins>+        if (!ok)
+                ERRORA(&quot;Sending message failed with status %d\n&quot;, SKYPIAX_P_LOG, xerror);
+        //XUnlockDisplay(disp);
</ins><span class="cx"> 
</span><del>-  return 1;
</del><ins>+        return 1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype)
</span><span class="cx"> {
</span><del>-  struct SkypiaxHandles *SkypiaxHandles;
</del><ins>+        struct SkypiaxHandles *SkypiaxHandles;
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;SENDING: |||%s||||\n&quot;, SKYPIAX_P_LOG, msg_to_skype);
</del><ins>+        DEBUGA_SKYPE(&quot;SENDING: |||%s||||\n&quot;, SKYPIAX_P_LOG, msg_to_skype);
</ins><span class="cx"> 
</span><del>-  SkypiaxHandles = &amp;tech_pvt-&gt;SkypiaxHandles;
</del><ins>+        SkypiaxHandles = &amp;tech_pvt-&gt;SkypiaxHandles;
</ins><span class="cx"> 
</span><del>-  if (!skypiax_send_message(SkypiaxHandles, msg_to_skype)) {
-    ERRORA
-      (&quot;Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then restart Skype, then launch Skypiax and try again.\n&quot;,
-       SKYPIAX_P_LOG);
-    return -1;
-  }
</del><ins>+        if (!skypiax_send_message(SkypiaxHandles, msg_to_skype)) {
+                ERRORA
+                        (&quot;Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then restart Skype, then launch Skypiax and try again.\n&quot;,
+                         SKYPIAX_P_LOG);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int skypiax_present(struct SkypiaxHandles *SkypiaxHandles)
</span><span class="cx"> {
</span><del>-  Atom skype_inst = XInternAtom(SkypiaxHandles-&gt;disp, &quot;_SKYPE_INSTANCE&quot;, True);
</del><ins>+        Atom skype_inst = XInternAtom(SkypiaxHandles-&gt;disp, &quot;_SKYPE_INSTANCE&quot;, True);
</ins><span class="cx"> 
</span><del>-  Atom type_ret;
-  int format_ret;
-  unsigned long nitems_ret;
-  unsigned long bytes_after_ret;
-  unsigned char *prop;
-  int status;
-  private_t *tech_pvt = NULL;
</del><ins>+        Atom type_ret;
+        int format_ret;
+        unsigned long nitems_ret;
+        unsigned long bytes_after_ret;
+        unsigned char *prop;
+        int status;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  X11_errors_trap();
-  //XLockDisplay(disp);
-  status =
-    XGetWindowProperty(SkypiaxHandles-&gt;disp, DefaultRootWindow(SkypiaxHandles-&gt;disp),
-                       skype_inst, 0, 1, False, XA_WINDOW, &amp;type_ret, &amp;format_ret,
-                       &amp;nitems_ret, &amp;bytes_after_ret, &amp;prop);
-  //XUnlockDisplay(disp);
-  X11_errors_untrap();
</del><ins>+        X11_errors_trap();
+        //XLockDisplay(disp);
+        status =
+                XGetWindowProperty(SkypiaxHandles-&gt;disp, DefaultRootWindow(SkypiaxHandles-&gt;disp),
+                                                   skype_inst, 0, 1, False, XA_WINDOW, &amp;type_ret, &amp;format_ret, &amp;nitems_ret, &amp;bytes_after_ret, &amp;prop);
+        //XUnlockDisplay(disp);
+        X11_errors_untrap();
</ins><span class="cx"> 
</span><del>-  /*  sanity check */
-  if (status != Success || format_ret != 32 || nitems_ret != 1) {
-    SkypiaxHandles-&gt;skype_win = (Window) - 1;
-    DEBUGA_SKYPE(&quot;Skype instance not found\n&quot;, SKYPIAX_P_LOG);
-    running = 0;
-    SkypiaxHandles-&gt;api_connected = 0;
-    return 0;
-  }
</del><ins>+        /*  sanity check */
+        if (status != Success || format_ret != 32 || nitems_ret != 1) {
+                SkypiaxHandles-&gt;skype_win = (Window) - 1;
+                DEBUGA_SKYPE(&quot;Skype instance not found\n&quot;, SKYPIAX_P_LOG);
+                running = 0;
+                SkypiaxHandles-&gt;api_connected = 0;
+                return 0;
+        }
</ins><span class="cx"> 
</span><del>-  SkypiaxHandles-&gt;skype_win = *(const unsigned long *) prop &amp; 0xffffffff;
-  DEBUGA_SKYPE(&quot;Skype instance found with id #%d\n&quot;, SKYPIAX_P_LOG,
-               (unsigned int) SkypiaxHandles-&gt;skype_win);
-  SkypiaxHandles-&gt;api_connected = 1;
-  return 1;
</del><ins>+        SkypiaxHandles-&gt;skype_win = *(const unsigned long *) prop &amp; 0xffffffff;
+        DEBUGA_SKYPE(&quot;Skype instance found with id #%d\n&quot;, SKYPIAX_P_LOG, (unsigned int) SkypiaxHandles-&gt;skype_win);
+        SkypiaxHandles-&gt;api_connected = 1;
+        return 1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void skypiax_clean_disp(void *data)
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-  int *dispptr;
-  int disp;
-  private_t *tech_pvt = NULL;
</del><ins>+        int *dispptr;
+        int disp;
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><del>-  dispptr = data;
-  disp = *dispptr;
</del><ins>+        dispptr = data;
+        disp = *dispptr;
</ins><span class="cx"> 
</span><del>-  if (disp) {
-    DEBUGA_SKYPE(&quot;to be destroyed disp %d\n&quot;, SKYPIAX_P_LOG, disp);
-    close(disp);
-    DEBUGA_SKYPE(&quot;destroyed disp\n&quot;, SKYPIAX_P_LOG);
-  } else {
-    DEBUGA_SKYPE(&quot;NOT destroyed disp\n&quot;, SKYPIAX_P_LOG);
-  }
-  DEBUGA_SKYPE(&quot;OUT destroyed disp\n&quot;, SKYPIAX_P_LOG);
-  skypiax_sleep(1000);
</del><ins>+        if (disp) {
+                DEBUGA_SKYPE(&quot;to be destroyed disp %d\n&quot;, SKYPIAX_P_LOG, disp);
+                close(disp);
+                DEBUGA_SKYPE(&quot;destroyed disp\n&quot;, SKYPIAX_P_LOG);
+        } else {
+                DEBUGA_SKYPE(&quot;NOT destroyed disp\n&quot;, SKYPIAX_P_LOG);
+        }
+        DEBUGA_SKYPE(&quot;OUT destroyed disp\n&quot;, SKYPIAX_P_LOG);
+        skypiax_sleep(1000);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void *skypiax_do_skypeapi_thread_func(void *obj)
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-  private_t *tech_pvt = obj;
-  struct SkypiaxHandles *SkypiaxHandles;
-  char buf[512];
-  Display *disp = NULL;
-  Window root = -1;
-  Window win = -1;
</del><ins>+        private_t *tech_pvt = obj;
+        struct SkypiaxHandles *SkypiaxHandles;
+        char buf[512];
+        Display *disp = NULL;
+        Window root = -1;
+        Window win = -1;
</ins><span class="cx"> 
</span><del>-  if (!strlen(tech_pvt-&gt;X11_display))
-    strcpy(tech_pvt-&gt;X11_display, getenv(&quot;DISPLAY&quot;));
</del><ins>+        if (!strlen(tech_pvt-&gt;X11_display))
+                strcpy(tech_pvt-&gt;X11_display, getenv(&quot;DISPLAY&quot;));
</ins><span class="cx"> 
</span><del>-  if (!tech_pvt-&gt;tcp_srv_port)
-    tech_pvt-&gt;tcp_srv_port = 10160;
</del><ins>+        if (!tech_pvt-&gt;tcp_srv_port)
+                tech_pvt-&gt;tcp_srv_port = 10160;
</ins><span class="cx"> 
</span><del>-  if (!tech_pvt-&gt;tcp_cli_port)
-    tech_pvt-&gt;tcp_cli_port = 10161;
</del><ins>+        if (!tech_pvt-&gt;tcp_cli_port)
+                tech_pvt-&gt;tcp_cli_port = 10161;
</ins><span class="cx"> 
</span><del>-  if (pipe(tech_pvt-&gt;SkypiaxHandles.fdesc)) {
-    fcntl(tech_pvt-&gt;SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
-    fcntl(tech_pvt-&gt;SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
-  }
-  SkypiaxHandles = &amp;tech_pvt-&gt;SkypiaxHandles;
-  disp = XOpenDisplay(tech_pvt-&gt;X11_display);
-  if (!disp) {
-    ERRORA(&quot;Cannot open X Display '%s', exiting skype thread\n&quot;, SKYPIAX_P_LOG,
-           tech_pvt-&gt;X11_display);
-    running = 0;
-    return NULL;
-  } else {
-    DEBUGA_SKYPE(&quot;X Display '%s' opened\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;X11_display);
-  }
</del><ins>+        if (pipe(tech_pvt-&gt;SkypiaxHandles.fdesc)) {
+                fcntl(tech_pvt-&gt;SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
+                fcntl(tech_pvt-&gt;SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
+        }
+        SkypiaxHandles = &amp;tech_pvt-&gt;SkypiaxHandles;
+        disp = XOpenDisplay(tech_pvt-&gt;X11_display);
+        if (!disp) {
+                ERRORA(&quot;Cannot open X Display '%s', exiting skype thread\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;X11_display);
+                running = 0;
+                return NULL;
+        } else {
+                DEBUGA_SKYPE(&quot;X Display '%s' opened\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;X11_display);
+        }
</ins><span class="cx"> 
</span><del>-  int xfd;
-  xfd = XConnectionNumber(disp);
-  fcntl(xfd, F_SETFD, FD_CLOEXEC);
</del><ins>+        int xfd;
+        xfd = XConnectionNumber(disp);
+        fcntl(xfd, F_SETFD, FD_CLOEXEC);
</ins><span class="cx"> 
</span><del>-  SkypiaxHandles-&gt;disp = disp;
</del><ins>+        SkypiaxHandles-&gt;disp = disp;
</ins><span class="cx"> 
</span><del>-  if (skypiax_present(SkypiaxHandles)) {
-    root = DefaultRootWindow(disp);
-    win =
-      XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0,
-                          BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp,
-                                                                            DefaultScreen
-                                                                            (disp)));
</del><ins>+        if (skypiax_present(SkypiaxHandles)) {
+                root = DefaultRootWindow(disp);
+                win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, DefaultScreen(disp)));
</ins><span class="cx"> 
</span><del>-    SkypiaxHandles-&gt;win = win;
</del><ins>+                SkypiaxHandles-&gt;win = win;
</ins><span class="cx"> 
</span><del>-    snprintf(buf, 512, &quot;NAME skypiax&quot;);
</del><ins>+                snprintf(buf, 512, &quot;NAME skypiax&quot;);
</ins><span class="cx"> 
</span><del>-    if (!skypiax_send_message(SkypiaxHandles, buf)) {
-      ERRORA
-        (&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n&quot;,
-         SKYPIAX_P_LOG);
-      running = 0;
-      return NULL;
-    }
</del><ins>+                if (!skypiax_send_message(SkypiaxHandles, buf)) {
+                        ERRORA(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n&quot;, SKYPIAX_P_LOG);
+                        running = 0;
+                        return NULL;
+                }
</ins><span class="cx"> 
</span><del>-    snprintf(buf, 512, &quot;PROTOCOL 7&quot;);
-    if (!skypiax_send_message(SkypiaxHandles, buf)) {
-      ERRORA
-        (&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n&quot;,
-         SKYPIAX_P_LOG);
-      running = 0;
-      return NULL;
-    }
</del><ins>+                snprintf(buf, 512, &quot;PROTOCOL 7&quot;);
+                if (!skypiax_send_message(SkypiaxHandles, buf)) {
+                        ERRORA(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n&quot;, SKYPIAX_P_LOG);
+                        running = 0;
+                        return NULL;
+                }
</ins><span class="cx"> 
</span><del>-    /* perform an events loop */
-    XEvent an_event;
-    char buf[21];               /*  can't be longer */
-    char buffer[17000];
-    char *b;
-    int i;
-    int continue_is_broken = 0;
-    Atom atom_begin = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
-    Atom atom_continue = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE&quot;, False);
</del><ins>+                /* perform an events loop */
+                XEvent an_event;
+                char buf[21];                        /*  can't be longer */
+                char buffer[17000];
+                char *b;
+                int i;
+                int continue_is_broken = 0;
+                Atom atom_begin = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
+                Atom atom_continue = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE&quot;, False);
</ins><span class="cx"> 
</span><del>-    b = buffer;
</del><ins>+                b = buffer;
</ins><span class="cx"> 
</span><del>-    while (1) {
-      XNextEvent(disp, &amp;an_event);
-      if (! (running &amp;&amp; tech_pvt-&gt;running))
-        break;
-      switch (an_event.type) {
-      case ClientMessage:
</del><ins>+                while (1) {
+                        XNextEvent(disp, &amp;an_event);
+                        if (!(running &amp;&amp; tech_pvt-&gt;running))
+                                break;
+                        switch (an_event.type) {
+                        case ClientMessage:
</ins><span class="cx"> 
</span><del>-        if (an_event.xclient.format != 8)
-          break;
</del><ins>+                                if (an_event.xclient.format != 8)
+                                        break;
</ins><span class="cx"> 
</span><del>-        for (i = 0; i &lt; 20 &amp;&amp; an_event.xclient.data.b[i] != '\0'; ++i)
-          buf[i] = an_event.xclient.data.b[i];
</del><ins>+                                for (i = 0; i &lt; 20 &amp;&amp; an_event.xclient.data.b[i] != '\0'; ++i)
+                                        buf[i] = an_event.xclient.data.b[i];
</ins><span class="cx"> 
</span><del>-        buf[i] = '\0';
</del><ins>+                                buf[i] = '\0';
</ins><span class="cx"> 
</span><del>-        //DEBUGA_SKYPE (&quot;BUF=|||%s|||\n&quot;, SKYPIAX_P_LOG, buf);
</del><ins>+                                //DEBUGA_SKYPE (&quot;BUF=|||%s|||\n&quot;, SKYPIAX_P_LOG, buf);
</ins><span class="cx"> 
</span><del>-        if (an_event.xclient.message_type == atom_begin) {
</del><ins>+                                if (an_event.xclient.message_type == atom_begin) {
</ins><span class="cx"> 
</span><del>-          if (strlen(buffer)) {
-            unsigned int howmany;
-            howmany = strlen(b) + 1;
-            howmany = write(SkypiaxHandles-&gt;fdesc[1], b, howmany);
-            DEBUGA_SKYPE(&quot;RECEIVED2=|||%s|||\n&quot;, SKYPIAX_P_LOG, buffer);
-            memset(buffer, '\0', 17000);
-          }
-        }
-        if (an_event.xclient.message_type == atom_continue) {
</del><ins>+                                        if (strlen(buffer)) {
+                                                unsigned int howmany;
+                                                howmany = strlen(b) + 1;
+                                                howmany = write(SkypiaxHandles-&gt;fdesc[1], b, howmany);
+                                                DEBUGA_SKYPE(&quot;RECEIVED2=|||%s|||\n&quot;, SKYPIAX_P_LOG, buffer);
+                                                memset(buffer, '\0', 17000);
+                                        }
+                                }
+                                if (an_event.xclient.message_type == atom_continue) {
</ins><span class="cx"> 
</span><del>-          if (!strlen(buffer)) {
-            DEBUGA_SKYPE
-              (&quot;Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||\n&quot;,
-               SKYPIAX_P_LOG, buf);
-            continue_is_broken = 1;
-            if (!strncmp(buf, &quot;ognised identity&quot;, 15)) {
-              WARNINGA
-                (&quot;Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n&quot;,
-                 SKYPIAX_P_LOG, buf);
-              skypiax_sleep(1000000);   //1 sec
-            }
-            break;
-          }
-        }
</del><ins>+                                        if (!strlen(buffer)) {
+                                                DEBUGA_SKYPE
+                                                        (&quot;Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||\n&quot;, SKYPIAX_P_LOG, buf);
+                                                continue_is_broken = 1;
+                                                if (!strncmp(buf, &quot;ognised identity&quot;, 15)) {
+                                                        WARNINGA
+                                                                (&quot;Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n&quot;,
+                                                                 SKYPIAX_P_LOG, buf);
+                                                        skypiax_sleep(1000000);        //1 sec
+                                                }
+                                                break;
+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-        strcat(buffer, buf);
</del><ins>+                                strcat(buffer, buf);
</ins><span class="cx"> 
</span><del>-        if (i &lt; 20 || continue_is_broken) { /* last fragment */
-          unsigned int howmany;
</del><ins>+                                if (i &lt; 20 || continue_is_broken) {        /* last fragment */
+                                        unsigned int howmany;
</ins><span class="cx"> 
</span><del>-          howmany = strlen(b) + 1;
</del><ins>+                                        howmany = strlen(b) + 1;
</ins><span class="cx"> 
</span><del>-          howmany = write(SkypiaxHandles-&gt;fdesc[1], b, howmany);
-          //DEBUGA_SKYPE (&quot;RECEIVED=|||%s|||\n&quot;, SKYPIAX_P_LOG, buffer);
-          memset(buffer, '\0', 17000);
-          XFlush(disp);
-          continue_is_broken = 0;
-        }
</del><ins>+                                        howmany = write(SkypiaxHandles-&gt;fdesc[1], b, howmany);
+                                        //DEBUGA_SKYPE (&quot;RECEIVED=|||%s|||\n&quot;, SKYPIAX_P_LOG, buffer);
+                                        memset(buffer, '\0', 17000);
+                                        XFlush(disp);
+                                        continue_is_broken = 0;
+                                }
</ins><span class="cx"> 
</span><del>-        break;
-      default:
-        break;
-      }
-    }
-  } else {
-    ERRORA
-      (&quot;Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n&quot;,
-       SKYPIAX_P_LOG);
-    running = 0;
-    return NULL;
-  }
-  //running = 0;
-  return NULL;
</del><ins>+                                break;
+                        default:
+                                break;
+                        }
+                }
+        } else {
+                ERRORA(&quot;Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n&quot;, SKYPIAX_P_LOG);
+                running = 0;
+                return NULL;
+        }
+        //running = 0;
+        return NULL;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> #endif // WIN32
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_ioc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_io.c (14443 => 14444)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_io.c        2009-08-01 01:02:02 UTC (rev 14443)
+++ freeswitch/trunk/src/switch_core_io.c        2009-08-01 02:47:35 UTC (rev 14444)
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx">                                 switch_codec_t *use_codec = read_frame-&gt;codec;
</span><span class="cx">                                 if (do_bugs) {
</span><span class="cx">                                         if (!switch_core_codec_ready(&amp;session-&gt;bug_codec)) {
</span><del>-                                                switch_core_codec_copy(read_frame-&gt;codec, &amp;session-&gt;bug_codec, switch_core_session_get_pool(session));
</del><ins>+                                                switch_core_codec_copy(read_frame-&gt;codec, &amp;session-&gt;bug_codec, NULL);
</ins><span class="cx">                                         }
</span><span class="cx">                                         use_codec = &amp;session-&gt;bug_codec;
</span><span class="cx">                                 }
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>