<!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][16521] </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=16521">16521</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2010-01-27 07:30:07 -0600 (Wed, 27 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>skypiax: added FS timers, allow for better Virtual Machine (xen, ec2) conference behavior, to be polished</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>
</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 (16520 => 16521)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2010-01-27 02:25:22 UTC (rev 16520)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2010-01-27 13:30:07 UTC (rev 16521)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;skypiax.h&quot;
</span><span class="cx"> #define MDL_CHAT_PROTO &quot;skype&quot;
</span><ins>+#define TIMER_WRITE
</ins><span class="cx"> 
</span><span class="cx"> #ifdef WIN32
</span><span class="cx"> /***************/
</span><span class="lines">@@ -193,7 +194,8 @@
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
</span><span class="cx">                                                                                                         switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause);
</ins><span class="cx"> static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
</span><span class="lines">@@ -255,7 +257,26 @@
</span><span class="cx">                 ERRORA(&quot;skypiax_codec FAILED\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        DEBUGA_SKYPE(&quot;skypiax_codec SUCCESS\n&quot;, SKYPIAX_P_LOG);
</del><ins>+
+        if (switch_core_timer_init(&amp;tech_pvt-&gt;timer_read, &quot;soft&quot;, 20, tech_pvt-&gt;read_codec.implementation-&gt;samples_per_packet, skypiax_module_pool) !=
+                SWITCH_STATUS_SUCCESS) {
+                ERRORA(&quot;setup timer failed\n&quot;, SKYPIAX_P_LOG);
+                return SWITCH_STATUS_FALSE;
+        }
+
+        switch_core_timer_sync(&amp;tech_pvt-&gt;timer_read);
+
+#ifdef TIMER_WRITE
+        if (switch_core_timer_init(&amp;tech_pvt-&gt;timer_write, &quot;soft&quot;, 20, tech_pvt-&gt;write_codec.implementation-&gt;samples_per_packet, skypiax_module_pool) !=
+                SWITCH_STATUS_SUCCESS) {
+                ERRORA(&quot;setup timer failed\n&quot;, SKYPIAX_P_LOG);
+                return SWITCH_STATUS_FALSE;
+        }
+
+        switch_core_timer_sync(&amp;tech_pvt-&gt;timer_write);
+#endif// TIMER_WRITE
+
+        DEBUGA_SKYPE(&quot;skypiax_tech_init SUCCESS\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -362,7 +383,7 @@
</span><span class="cx">                         globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
</span><span class="cx">                 }
</span><span class="cx"> #else
</span><del>-                if(tech_pvt-&gt;running &amp;&amp; tech_pvt-&gt;SkypiaxHandles.disp){
</del><ins>+                if (tech_pvt-&gt;running &amp;&amp; tech_pvt-&gt;SkypiaxHandles.disp) {
</ins><span class="cx">                         XEvent e;
</span><span class="cx">                         Atom atom1 = XInternAtom(tech_pvt-&gt;SkypiaxHandles.disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
</span><span class="cx">                         memset(&amp;e, 0, sizeof(e));
</span><span class="lines">@@ -460,6 +481,14 @@
</span><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;write_codec);
</span><span class="cx">                 }
</span><ins>+
+                switch_core_timer_destroy(&amp;tech_pvt-&gt;timer_read);
+#ifdef TIMER_WRITE
+
+                switch_core_timer_destroy(&amp;tech_pvt-&gt;timer_write);
+#endif// TIMER_WRITE
+
+
</ins><span class="cx">                 *tech_pvt-&gt;session_uuid_str = '\0';
</span><span class="cx">                 tech_pvt-&gt;interface_state = SKYPIAX_STATE_IDLE;
</span><span class="cx">                 if (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_FINISHED) {
</span><span class="lines">@@ -582,7 +611,7 @@
</span><span class="cx">                         ERRORA(&quot;FYI %s CHANNEL in CS_NEW state got SWITCH_SIG_KILL\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</span><span class="cx">                         channel_on_hangup(session);
</span><span class="cx">                 }
</span><del>-                if ( switch_channel_get_state(channel) != CS_NEW &amp;&amp; switch_channel_get_state(channel) &lt; CS_EXECUTE) {
</del><ins>+                if (switch_channel_get_state(channel) != CS_NEW &amp;&amp; switch_channel_get_state(channel) &lt; CS_EXECUTE) {
</ins><span class="cx">                         ERRORA(&quot;FYI %s CHANNEL in %d state got SWITCH_SIG_KILL\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel), switch_channel_get_state(channel));
</span><span class="cx">                         channel_on_hangup(session);
</span><span class="cx">                 }
</span><span class="lines">@@ -662,6 +691,8 @@
</span><span class="cx">         tech_pvt-&gt;read_frame.flags = SFF_NONE;
</span><span class="cx">         *frame = NULL;
</span><span class="cx"> 
</span><ins>+        switch_core_timer_next(&amp;tech_pvt-&gt;timer_read);
+
</ins><span class="cx">         if (!skypiax_audio_read(tech_pvt)) {
</span><span class="cx"> 
</span><span class="cx">                 ERRORA(&quot;skypiax_audio_read ERROR\n&quot;, SKYPIAX_P_LOG);
</span><span class="lines">@@ -745,21 +776,20 @@
</span><span class="cx"> #else /* WIN32 */
</span><span class="cx">         //sent = write(tech_pvt-&gt;audiopipe_cli[1], frame-&gt;data, sent);
</span><span class="cx"> #endif /* WIN32 */
</span><del>-                                        //FIXME while(tech_pvt-&gt;flag_audio_cli == 1){
-                                                //FIXME switch_sleep(100); //1 millisec
-                                                //NOTICA(&quot;write now is 1\n&quot;, SKYPIAX_P_LOG);
-                                                //FIXME }
-                                                //WARNINGA(&quot;write is now 0\n&quot;, SKYPIAX_P_LOG);
</del><span class="cx"> 
</span><ins>+        //memcpy(tech_pvt-&gt;audiobuf_cli, frame-&gt;data, frame-&gt;datalen);
+        if (tech_pvt-&gt;flag_audio_cli == 1) {
+                switch_sleep(1000);                //1 millisec
+        }
+        if (tech_pvt-&gt;flag_audio_cli == 0) {
+#ifdef TIMER_WRITE
</ins><span class="cx"> 
</span><del>-        //memcpy(tech_pvt-&gt;audiobuf_cli, frame-&gt;data, frame-&gt;datalen);
-                                                                if(tech_pvt-&gt;flag_audio_cli == 1){
-                                                                        switch_sleep(1000); //1 millisec
-                                                                }
-                                                                if(tech_pvt-&gt;flag_audio_cli == 0){
-        memcpy(tech_pvt-&gt;audiobuf_cli, frame-&gt;data, frame-&gt;datalen);
-        tech_pvt-&gt;flag_audio_cli = 1;
-                                                                }
</del><ins>+                switch_core_timer_next(&amp;tech_pvt-&gt;timer_write);
+#endif// TIMER_WRITE
+
+                memcpy(tech_pvt-&gt;audiobuf_cli, frame-&gt;data, frame-&gt;datalen);
+                tech_pvt-&gt;flag_audio_cli = 1;
+        }
</ins><span class="cx">         //NOTICA(&quot;write \n&quot;, SKYPIAX_P_LOG);
</span><span class="cx"> 
</span><span class="cx">         if (sent != frame-&gt;datalen &amp;&amp; sent != -1) {
</span><span class="lines">@@ -798,29 +828,38 @@
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx"> 
</span><span class="cx">         switch (msg-&gt;message_id) {
</span><del>-                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;
-                case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
</del><ins>+        case SWITCH_MESSAGE_INDICATE_ANSWER:
+                {
+                        DEBUGA_SKYPE(&quot;MSG_ID=%d, TO BE ANSWERED!\n&quot;, SKYPIAX_P_LOG, msg-&gt;message_id);
+        
+                switch_core_timer_sync(&amp;tech_pvt-&gt;timer_read);
+#ifdef TIMER_WRITE
+                switch_core_timer_sync(&amp;tech_pvt-&gt;timer_write);
+#endif// TIMER_WRITE
+                channel_answer_channel(session);
+                }
+                break;
+        case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
</ins><span class="cx"> 
</span><del>-                        DEBUGA_SKYPE(&quot;%s CHANNEL got SWITCH_MESSAGE_INDICATE_AUDIO_SYNC\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</del><ins>+                DEBUGA_SKYPE(&quot;%s CHANNEL got SWITCH_MESSAGE_INDICATE_AUDIO_SYNC\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</ins><span class="cx"> 
</span><del>-                        //for (i=0; i&lt;50; i++) {
-                        //skypiax_audio_read(tech_pvt);
-                        //WARNINGA(&quot;read samples\n&quot;, SKYPIAX_P_LOG);
-                        //}
-                        //switch_core_timer_sync(&amp;tech_pvt-&gt;timer_read);
-                        //switch_core_timer_sync(&amp;tech_pvt-&gt;timer_write);
</del><ins>+                switch_core_timer_sync(&amp;tech_pvt-&gt;timer_read);
+#ifdef TIMER_WRITE
+                switch_core_timer_sync(&amp;tech_pvt-&gt;timer_write);
+#endif// TIMER_WRITE
+                break;
+        default:
+                {
+        
+                switch_core_timer_sync(&amp;tech_pvt-&gt;timer_read);
+#ifdef TIMER_WRITE
</ins><span class="cx"> 
</span><del>-                        break;
-                default:
-                        {
-                                DEBUGA_SKYPE(&quot;MSG_ID=%d\n&quot;, SKYPIAX_P_LOG, msg-&gt;message_id);
-                        }
-                        break;
</del><ins>+                switch_core_timer_sync(&amp;tech_pvt-&gt;timer_write);
+#endif// TIMER_WRITE
+
+                DEBUGA_SKYPE(&quot;MSG_ID=%d\n&quot;, SKYPIAX_P_LOG, msg-&gt;message_id);
+                }
+                break;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -869,7 +908,8 @@
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
</span><span class="cx">                                                                                                         switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">         private_t *tech_pvt = NULL;
</span><span class="cx">         if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
</span><span class="lines">@@ -961,10 +1001,10 @@
</span><span class="cx">                 if (outbound_profile) {
</span><span class="cx">                         char name[128];
</span><span class="cx"> 
</span><del>-                        if (strncmp(&quot;ANY&quot;, outbound_profile-&gt;destination_number, 3 ) == 0) {
-                                snprintf(name, sizeof(name), &quot;skypiax/ANY/%s%s&quot;, tech_pvt-&gt;name, outbound_profile-&gt;destination_number+3);
</del><ins>+                        if (strncmp(&quot;ANY&quot;, outbound_profile-&gt;destination_number, 3) == 0) {
+                                snprintf(name, sizeof(name), &quot;skypiax/ANY/%s%s&quot;, tech_pvt-&gt;name, outbound_profile-&gt;destination_number + 3);
</ins><span class="cx">                         } else if (strncmp(&quot;RR&quot;, outbound_profile-&gt;destination_number, 2) == 0) {
</span><del>-                                snprintf(name, sizeof(name), &quot;skypiax/RR/%s%s&quot;, tech_pvt-&gt;name, outbound_profile-&gt;destination_number+2);
</del><ins>+                                snprintf(name, sizeof(name), &quot;skypiax/RR/%s%s&quot;, tech_pvt-&gt;name, outbound_profile-&gt;destination_number + 2);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 snprintf(name, sizeof(name), &quot;skypiax/%s&quot;, outbound_profile-&gt;destination_number);
</span><span class="cx">                         }
</span><span class="lines">@@ -1261,7 +1301,7 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 DEBUGA_SKYPE(&quot;Initialized XInitThreads!\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                         }
</span><del>-                        switch_sleep(100);
</del><ins>+                        switch_sleep(1000);
</ins><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> 
</span><span class="cx">                         if (interface_id &amp;&amp; interface_id &lt; SKYPIAX_MAX_INTERFACES) {
</span><span class="lines">@@ -1297,10 +1337,10 @@
</span><span class="cx">                                 switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].destination, destination);
</span><span class="cx">                                 switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
</span><span class="cx"> 
</span><del>-                                if(!strcmp(report_incoming_chatmessages, &quot;true&quot;) || !strcmp(report_incoming_chatmessages, &quot;1&quot;)){
</del><ins>+                                if (!strcmp(report_incoming_chatmessages, &quot;true&quot;) || !strcmp(report_incoming_chatmessages, &quot;1&quot;)) {
</ins><span class="cx">                                         globals.SKYPIAX_INTERFACES[interface_id].report_incoming_chatmessages = 1;
</span><del>-                                }else {
-                                        globals.SKYPIAX_INTERFACES[interface_id].report_incoming_chatmessages = 0; //redundant, just in case
</del><ins>+                                } else {
+                                        globals.SKYPIAX_INTERFACES[interface_id].report_incoming_chatmessages = 0;        //redundant, just in case
</ins><span class="cx"> 
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="lines">@@ -1424,7 +1464,8 @@
</span><span class="cx">                                 DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].dialplan=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].dialplan);
</span><span class="cx">                                 DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].destination=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].destination);
</span><span class="cx">                                 DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].context);
</span><del>-                                DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].report_incoming_chatmessages=%d\n&quot;, SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].report_incoming_chatmessages);
</del><ins>+                                DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].report_incoming_chatmessages=%d\n&quot;, SKYPIAX_P_LOG, i, i,
+                                                         globals.SKYPIAX_INTERFACES[i].report_incoming_chatmessages);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -1434,25 +1475,27 @@
</span><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><del>-static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint)
</del><ins>+static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type,
+                                                                 const char *hint)
</ins><span class="cx"> {
</span><span class="cx">         //char *user, *host, *f_user = NULL, *ffrom = NULL, *f_host = NULL, *f_resource = NULL;
</span><del>-        char *user=NULL, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL;
</del><ins>+        char *user = NULL, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL;
</ins><span class="cx">         //mdl_profile_t *profile = NULL;
</span><del>-        private_t * tech_pvt=NULL;
-        int i=0, found=0, tried=0;
</del><ins>+        private_t *tech_pvt = NULL;
+        int i = 0, found = 0, tried = 0;
</ins><span class="cx">         char skype_msg[1024];
</span><span class="cx"> 
</span><span class="cx">         switch_assert(proto != NULL);
</span><span class="cx"> 
</span><del>-        DEBUGA_SKYPE(&quot;chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n&quot;, SKYPIAX_P_LOG, proto, from, to, subject, body, type, hint?hint:&quot;NULL&quot;);
</del><ins>+        DEBUGA_SKYPE(&quot;chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n&quot;, SKYPIAX_P_LOG, proto, from, to, subject, body, type,
+                                 hint ? hint : &quot;NULL&quot;);
</ins><span class="cx"> 
</span><span class="cx">         if (!to || !strlen(to)) {
</span><span class="cx">                 ERRORA(&quot;Missing To: header.\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ((!from &amp;&amp; !hint) || (!strlen(from) &amp;&amp; !strlen(hint)) ) {
</del><ins>+        if ((!from &amp;&amp; !hint) || (!strlen(from) &amp;&amp; !strlen(hint))) {
</ins><span class="cx">                 ERRORA(&quot;Missing From: AND Hint: headers.\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="lines">@@ -1470,70 +1513,71 @@
</span><span class="cx">                 if ((host = strchr(user, '@'))) {
</span><span class="cx">                         *host++ = '\0';
</span><span class="cx">                 }
</span><del>-
</del><span class="cx">                 //if (!strcmp(proto, MDL_CHAT_PROTO)) {
</span><span class="cx"> 
</span><del>-        DEBUGA_SKYPE(&quot;chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n&quot;, SKYPIAX_P_LOG, proto, from, to, subject, body, type, hint?hint:&quot;NULL&quot;);
-                        if (hint &amp;&amp; strlen(hint)) {
-                                //in hint we receive the interface name to use
-                                for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-                                        if (strlen(globals.SKYPIAX_INTERFACES[i].name)
-                                                        &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, hint, strlen(hint)) == 0)) {
-                                                tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
-                                                DEBUGA_SKYPE(&quot;Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;, SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name);
-                                                found = 1;
-                                                break;
-                                        }
</del><ins>+                DEBUGA_SKYPE(&quot;chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n&quot;, SKYPIAX_P_LOG, proto, from, to, subject, body, type,
+                                         hint ? hint : &quot;NULL&quot;);
+                if (hint &amp;&amp; strlen(hint)) {
+                        //in hint we receive the interface name to use
+                        for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                                if (strlen(globals.SKYPIAX_INTERFACES[i].name)
+                                        &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, hint, strlen(hint)) == 0)) {
+                                        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
+                                        DEBUGA_SKYPE(&quot;Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;, SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name);
+                                        found = 1;
+                                        break;
</ins><span class="cx">                                 }
</span><del>-                        } else {
-                                //we have no a predefined interface name to use (hint is NULL), so let's choose an interface from the username (from)
-                                for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
-                                        if (strlen(globals.SKYPIAX_INTERFACES[i].name)
-                                                        &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].skype_user, from, strlen(from)) == 0)) {
-                                                tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
-                                                DEBUGA_SKYPE(&quot;Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;, SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name);
-                                                found = 1;
-                                                break;
-                                        }
</del><ins>+                        }
+                } else {
+                        //we have no a predefined interface name to use (hint is NULL), so let's choose an interface from the username (from)
+                        for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
+                                if (strlen(globals.SKYPIAX_INTERFACES[i].name)
+                                        &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].skype_user, from, strlen(from)) == 0)) {
+                                        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
+                                        DEBUGA_SKYPE(&quot;Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;, SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name);
+                                        found = 1;
+                                        break;
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        if (!found) {
-                                ERRORA(&quot;ERROR: A Skypiax interface with name='%s' or one with skypeuser='%s' was not found\n&quot;, SKYPIAX_P_LOG, hint?hint:&quot;NULL&quot;, from?from:&quot;NULL&quot;);
-                                goto end;
-                        } else {
</del><ins>+                }
+                if (!found) {
+                        ERRORA(&quot;ERROR: A Skypiax interface with name='%s' or one with skypeuser='%s' was not found\n&quot;, SKYPIAX_P_LOG, hint ? hint : &quot;NULL&quot;,
+                                   from ? from : &quot;NULL&quot;);
+                        goto end;
+                } else {
</ins><span class="cx"> 
</span><del>-                                snprintf(skype_msg, sizeof(skype_msg), &quot;CHAT CREATE %s&quot;, to);
-                                skypiax_signaling_write(tech_pvt, skype_msg);
-                                switch_sleep(100);
-                        }
</del><ins>+                        snprintf(skype_msg, sizeof(skype_msg), &quot;CHAT CREATE %s&quot;, to);
+                        skypiax_signaling_write(tech_pvt, skype_msg);
+                        switch_sleep(1000);
+                }
</ins><span class="cx">                 //} else {
</span><del>-                        //FIXME don't know how to do here, let's hope this is correct
-                        //char *p;
-                        //ffrom = switch_mprintf(&quot;%s+%s&quot;, proto, from);
-                        //from = ffrom;
-                        //if ((p = strchr(from, '/'))) {
-                                //*p = '\0';
-                        //}
-        //NOTICA(&quot;chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n&quot;, SKYPIAX_P_LOG, proto, from, to, subject, body, type, hint?hint:&quot;NULL&quot;);
-                        //switch_core_chat_send(proto, proto, from, to, subject, body, type, hint);
-                        //return SWITCH_STATUS_SUCCESS;
</del><ins>+                //FIXME don't know how to do here, let's hope this is correct
+                //char *p;
+                //ffrom = switch_mprintf(&quot;%s+%s&quot;, proto, from);
+                //from = ffrom;
+                //if ((p = strchr(from, '/'))) {
+                //*p = '\0';
</ins><span class="cx">                 //}
</span><ins>+                //NOTICA(&quot;chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n&quot;, SKYPIAX_P_LOG, proto, from, to, subject, body, type, hint?hint:&quot;NULL&quot;);
+                //switch_core_chat_send(proto, proto, from, to, subject, body, type, hint);
+                //return SWITCH_STATUS_SUCCESS;
+                //}
</ins><span class="cx"> 
</span><del>-                found=0;
</del><ins>+                found = 0;
</ins><span class="cx"> 
</span><del>-                while(!found){
-                        for(i=0; i&lt;MAX_CHATS; i++){
-                                if(!strcmp(tech_pvt-&gt;chats[i].dialog_partner, to) ){
</del><ins>+                while (!found) {
+                        for (i = 0; i &lt; MAX_CHATS; i++) {
+                                if (!strcmp(tech_pvt-&gt;chats[i].dialog_partner, to)) {
</ins><span class="cx">                                         snprintf(skype_msg, sizeof(skype_msg), &quot;CHATMESSAGE %s %s&quot;, tech_pvt-&gt;chats[i].chatname, body);
</span><span class="cx">                                         skypiax_signaling_write(tech_pvt, skype_msg);
</span><del>-                                        found=1;
</del><ins>+                                        found = 1;
</ins><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        if(found){
</del><ins>+                        if (found) {
</ins><span class="cx">                                 break;
</span><span class="cx">                         }
</span><del>-                        if(tried &gt; 1000){
</del><ins>+                        if (tried &gt; 1000) {
</ins><span class="cx">                                 ERRORA(&quot;No chat with dialog_partner='%s' was found\n&quot;, SKYPIAX_P_LOG, to);
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="lines">@@ -1541,7 +1585,7 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">         }
</span><del>-end:
</del><ins>+  end:
</ins><span class="cx">         switch_safe_free(user);
</span><span class="cx">         switch_safe_free(f_user);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -1563,10 +1607,10 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (switch_event_reserve_subclass(MY_EVENT_INCOMING_CHATMESSAGE) != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't register subclass!\n&quot;);
-                return SWITCH_STATUS_GENERR;
-        }
</del><ins>+        if (switch_event_reserve_subclass(MY_EVENT_INCOMING_CHATMESSAGE) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't register subclass!\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
</ins><span class="cx"> 
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">         skypiax_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
</span><span class="lines">@@ -1617,10 +1661,10 @@
</span><span class="cx">                                         globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
</span><span class="cx">                                 }
</span><span class="cx"> #else
</span><del>-                                if(tech_pvt-&gt;SkypiaxHandles.disp){
</del><ins>+                                if (tech_pvt-&gt;SkypiaxHandles.disp) {
</ins><span class="cx">                                         XEvent e;
</span><span class="cx">                                         Atom atom1 = XInternAtom(tech_pvt-&gt;SkypiaxHandles.disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;,
</span><del>-                                                        False);
</del><ins>+                                                                                         False);
</ins><span class="cx">                                         memset(&amp;e, 0, sizeof(e));
</span><span class="cx">                                         e.xclient.type = ClientMessage;
</span><span class="cx">                                         e.xclient.message_type = atom1;        /*  leading message */
</span><span class="lines">@@ -1662,7 +1706,7 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">         }
</span><del>-        switch_event_free_subclass(MY_EVENT_INCOMING_CHATMESSAGE);
</del><ins>+        switch_event_free_subclass(MY_EVENT_INCOMING_CHATMESSAGE);
</ins><span class="cx"> 
</span><span class="cx">         switch_safe_free(globals.dialplan);
</span><span class="cx">         switch_safe_free(globals.context);
</span><span class="lines">@@ -1997,7 +2041,7 @@
</span><span class="cx"> 
</span><span class="cx">                 }
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;\nTotal Interfaces: %d  IB Calls(Failed/Total): %ld/%ld  OB Calls(Failed/Total): %ld/%ld\n&quot;,
</span><del>-                       globals.real_interfaces &gt; 0 ? globals.real_interfaces - 1 : 0, ib_failed, ib, ob_failed, ob);
</del><ins>+                                                           globals.real_interfaces &gt; 0 ? globals.real_interfaces - 1 : 0, ib_failed, ib, ob_failed, ob);
</ins><span class="cx"> 
</span><span class="cx">         } else if (!strcasecmp(argv[0], &quot;console&quot;)) {
</span><span class="cx">                 int i;
</span><span class="lines">@@ -2316,7 +2360,7 @@
</span><span class="cx"> 
</span><span class="cx">         DEBUGA_SKYPE(&quot;received CHATMESSAGE on interface %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</span><span class="cx"> 
</span><del>-        if(!tech_pvt-&gt;report_incoming_chatmessages){
</del><ins>+        if (!tech_pvt-&gt;report_incoming_chatmessages) {
</ins><span class="cx">                 DEBUGA_SKYPE(&quot;I will not generate an Event, report_incoming_chatmessages is %d\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;report_incoming_chatmessages);
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><span class="lines">@@ -2333,23 +2377,23 @@
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;chatname&quot;, tech_pvt-&gt;chatmessages[which].chatname);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;id&quot;, tech_pvt-&gt;chatmessages[which].id);
</span><span class="cx">                 switch_event_add_body(event, &quot;%s&quot;, tech_pvt-&gt;chatmessages[which].body);
</span><del>-                if(session){
</del><ins>+                if (session) {
</ins><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;during-call&quot;, &quot;true&quot;);
</span><span class="cx">                         if (switch_core_session_queue_event(session, &amp;event) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;delivery-failure&quot;, &quot;true&quot;);
</span><span class="cx">                                 switch_event_fire(&amp;event);
</span><span class="cx">                         }
</span><del>-                } else { //no session
</del><ins>+                } else {                                //no session
</ins><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;during-call&quot;, &quot;false&quot;);
</span><span class="cx">                         switch_event_fire(&amp;event);
</span><del>-                        event_sent_to_esl=1;
</del><ins>+                        event_sent_to_esl = 1;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><del>-        }else{
</del><ins>+        } else {
</ins><span class="cx">                 ERRORA(&quot;cannot create event on interface %s. WHY?????\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if(!event_sent_to_esl){
</del><ins>+        if (!event_sent_to_esl) {
</ins><span class="cx"> 
</span><span class="cx">                 if (switch_event_create(&amp;event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, MDL_CHAT_PROTO);
</span><span class="lines">@@ -2360,21 +2404,21 @@
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;chatname&quot;, tech_pvt-&gt;chatmessages[which].chatname);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;id&quot;, tech_pvt-&gt;chatmessages[which].id);
</span><span class="cx">                         switch_event_add_body(event, &quot;%s&quot;, tech_pvt-&gt;chatmessages[which].body);
</span><del>-                        if(session){
</del><ins>+                        if (session) {
</ins><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;during-call&quot;, &quot;true&quot;);
</span><del>-                        } else { //no session
</del><ins>+                        } else {                        //no session
</ins><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;during-call&quot;, &quot;false&quot;);
</span><span class="cx">                         }
</span><span class="cx">                         switch_event_fire(&amp;event);
</span><del>-                } else{
</del><ins>+                } else {
</ins><span class="cx">                         ERRORA(&quot;cannot create event on interface %s. WHY?????\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if(session){
</del><ins>+        if (session) {
</ins><span class="cx">                 switch_core_session_rwunlock(session);
</span><span class="cx">         }
</span><del>-        memset(&amp;tech_pvt-&gt;chatmessages[which], '\0', sizeof(&amp;tech_pvt-&gt;chatmessages[which]) );
</del><ins>+        memset(&amp;tech_pvt-&gt;chatmessages[which], '\0', sizeof(&amp;tech_pvt-&gt;chatmessages[which]));
</ins><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2407,7 +2451,7 @@
</span><span class="cx">                 for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
</span><span class="cx">                         /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the &quot;ANY&quot; interface */
</span><span class="cx">                         if (strlen(globals.SKYPIAX_INTERFACES[i].name)
</span><del>-                                        &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
</del><ins>+                                &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
</ins><span class="cx">                                 tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;, i, globals.SKYPIAX_INTERFACES[i].name);
</span><span class="cx">                                 found = 1;
</span><span class="lines">@@ -2424,9 +2468,11 @@
</span><span class="cx">                         //chat_send(p*roto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint);
</span><span class="cx">                         //chat_send(MDL_CHAT_PROTO, tech_pvt-&gt;skype_user, argv[1], &quot;SIMPLE MESSAGE&quot;, switch_str_nil((char *) &amp;cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, hint);
</span><span class="cx"> 
</span><del>-                        NOTICA(&quot;chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n&quot;, SKYPIAX_P_LOG, MDL_CHAT_PROTO, tech_pvt-&gt;skype_user, argv[1], &quot;SIMPLE MESSAGE&quot;, switch_str_nil((char *) &amp;cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt-&gt;name);
</del><ins>+                        NOTICA(&quot;chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n&quot;, SKYPIAX_P_LOG, MDL_CHAT_PROTO, tech_pvt-&gt;skype_user,
+                                   argv[1], &quot;SIMPLE MESSAGE&quot;, switch_str_nil((char *) &amp;cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt-&gt;name);
</ins><span class="cx"> 
</span><del>-                        chat_send(MDL_CHAT_PROTO, tech_pvt-&gt;skype_user, argv[1], &quot;SIMPLE MESSAGE&quot;, switch_str_nil((char *) &amp;cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt-&gt;name);
</del><ins>+                        chat_send(MDL_CHAT_PROTO, tech_pvt-&gt;skype_user, argv[1], &quot;SIMPLE MESSAGE&quot;,
+                                          switch_str_nil((char *) &amp;cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt-&gt;name);
</ins><span class="cx"> 
</span><span class="cx">                         //NOTICA(&quot;TEXT is: %s\n&quot;, SKYPIAX_P_LOG, (char *) &amp;cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1] );
</span><span class="cx">                         //snprintf(skype_msg, sizeof(skype_msg), &quot;CHAT CREATE %s&quot;, argv[1]);
</span><span class="lines">@@ -2440,21 +2486,22 @@
</span><span class="cx"> 
</span><span class="cx"> #ifdef NOTDEF
</span><span class="cx"> 
</span><del>-        found=0;
</del><ins>+        found = 0;
</ins><span class="cx"> 
</span><del>-        while(!found){
-                for(i=0; i&lt;MAX_CHATS; i++){
-                        if(!strcmp(tech_pvt-&gt;chats[i].dialog_partner, argv[1]) ){
-                                snprintf(skype_msg, sizeof(skype_msg), &quot;CHATMESSAGE %s %s&quot;, tech_pvt-&gt;chats[i].chatname, (char *) &amp;cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]);
</del><ins>+        while (!found) {
+                for (i = 0; i &lt; MAX_CHATS; i++) {
+                        if (!strcmp(tech_pvt-&gt;chats[i].dialog_partner, argv[1])) {
+                                snprintf(skype_msg, sizeof(skype_msg), &quot;CHATMESSAGE %s %s&quot;, tech_pvt-&gt;chats[i].chatname,
+                                                 (char *) &amp;cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]);
</ins><span class="cx">                                 skypiax_signaling_write(tech_pvt, skype_msg);
</span><del>-                                found=1;
</del><ins>+                                found = 1;
</ins><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                if(found){
</del><ins>+                if (found) {
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                if(tried &gt; 1000){
</del><ins>+                if (tried &gt; 1000) {
</ins><span class="cx">                         stream-&gt;write_function(stream, &quot;ERROR: no chat with dialog_partner='%s' was found\n&quot;, argv[1]);
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="lines">@@ -2462,7 +2509,7 @@
</span><span class="cx">         }
</span><span class="cx"> #endif //NOTDEF
</span><span class="cx"> 
</span><del>-end:
</del><ins>+  end:
</ins><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h (16520 => 16521)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2010-01-27 02:25:22 UTC (rev 16520)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2010-01-27 13:30:07 UTC (rev 16521)
</span><span class="lines">@@ -277,6 +277,8 @@
</span><span class="cx">         chatmessage_t chatmessages[MAX_CHATMESSAGES];
</span><span class="cx">         chat_t chats[MAX_CHATS];
</span><span class="cx">         uint32_t report_incoming_chatmessages;
</span><ins>+        switch_timer_t timer_read;
+        switch_timer_t timer_write;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef struct private_object private_t;
</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 (16520 => 16521)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2010-01-27 02:25:22 UTC (rev 16520)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2010-01-27 13:30:07 UTC (rev 16521)
</span><span class="lines">@@ -29,16 +29,16 @@
</span><span class="cx"> int skypiax_socket_create_and_bind(private_t * tech_pvt, int *which_port)
</span><span class="cx"> #else
</span><span class="cx"> int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_port)
</span><del>-#endif //WIN32
</del><ins>+#endif                                                        //WIN32
</ins><span class="cx"> {
</span><span class="cx">         int s = -1;
</span><span class="cx">         struct sockaddr_in my_addr;
</span><span class="cx"> #ifndef WIN32
</span><span class="cx">         int start_port = 6001;
</span><span class="cx"> #else
</span><del>-unsigned short start_port = 6001;
</del><ins>+        unsigned short start_port = 6001;
</ins><span class="cx"> #endif //WIN32
</span><del>-        int sockbufsize=0;
</del><ins>+        int sockbufsize = 0;
</ins><span class="cx">         unsigned int size = sizeof(int);
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -78,13 +78,13 @@
</span><span class="cx">         DEBUGA_SKYPE(&quot;SUCCESS! *which_port=%d, tech_pvt-&gt;tcp_cli_port=%d, tech_pvt-&gt;tcp_srv_port=%d\n&quot;, SKYPIAX_P_LOG, *which_port, tech_pvt-&gt;tcp_cli_port,
</span><span class="cx">                                  tech_pvt-&gt;tcp_srv_port);
</span><span class="cx"> 
</span><del>-        sockbufsize=0;
</del><ins>+        sockbufsize = 0;
</ins><span class="cx">         size = sizeof(int);
</span><del>-        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&amp;sockbufsize, &amp;size);
</del><ins>+        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &amp;sockbufsize, &amp;size);
</ins><span class="cx">         DEBUGA_SKYPE(&quot;1 SO_RCVBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
</span><del>-        sockbufsize=0;
</del><ins>+        sockbufsize = 0;
</ins><span class="cx">         size = sizeof(int);
</span><del>-        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&amp;sockbufsize, &amp;size);
</del><ins>+        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &amp;sockbufsize, &amp;size);
</ins><span class="cx">         DEBUGA_SKYPE(&quot;1 SO_SNDBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -94,16 +94,16 @@
</span><span class="cx">  * sockbufsize=SAMPLES_PER_FRAME * 8;
</span><span class="cx">  */
</span><span class="cx"> #ifdef WIN32
</span><del>-        sockbufsize=SAMPLES_PER_FRAME * 8 * 3;
</del><ins>+        sockbufsize = SAMPLES_PER_FRAME * 8 * 3;
</ins><span class="cx"> #else
</span><del>-        sockbufsize=SAMPLES_PER_FRAME * 8;
</del><ins>+        sockbufsize = SAMPLES_PER_FRAME * 8;
</ins><span class="cx"> #endif //WIN32
</span><span class="cx">         size = sizeof(int);
</span><del>-        setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&amp;sockbufsize, size);
</del><ins>+        setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &amp;sockbufsize, size);
</ins><span class="cx"> 
</span><del>-        sockbufsize=0;
</del><ins>+        sockbufsize = 0;
</ins><span class="cx">         size = sizeof(int);
</span><del>-        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&amp;sockbufsize, &amp;size);
</del><ins>+        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &amp;sockbufsize, &amp;size);
</ins><span class="cx">         DEBUGA_SKYPE(&quot;2 SO_RCVBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
</span><span class="cx"> 
</span><span class="cx"> /* for virtual machines, eg: Linux domU-12-31-39-02-68-28 2.6.18-xenU-ec2-v1.0 #2 SMP Tue Feb 19 10:51:53 EST 2008 i686 athlon i386 GNU/Linux
</span><span class="lines">@@ -111,17 +111,17 @@
</span><span class="cx">  * sockbufsize=SAMPLES_PER_FRAME * 8;
</span><span class="cx">  */
</span><span class="cx"> #ifdef WIN32
</span><del>-        sockbufsize=SAMPLES_PER_FRAME * 8 * 3;
</del><ins>+        sockbufsize = SAMPLES_PER_FRAME * 8 * 3;
</ins><span class="cx"> #else
</span><del>-        sockbufsize=SAMPLES_PER_FRAME * 8;
</del><ins>+        sockbufsize = SAMPLES_PER_FRAME * 8;
</ins><span class="cx"> #endif //WIN32
</span><span class="cx">         size = sizeof(int);
</span><del>-        setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&amp;sockbufsize, size);
</del><ins>+        setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &amp;sockbufsize, size);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-        sockbufsize=0;
</del><ins>+        sockbufsize = 0;
</ins><span class="cx">         size = sizeof(int);
</span><del>-        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&amp;sockbufsize, &amp;size);
</del><ins>+        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &amp;sockbufsize, &amp;size);
</ins><span class="cx">         DEBUGA_SKYPE(&quot;2 SO_SNDBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -295,20 +295,21 @@
</span><span class="cx"> 
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;DIALOG_PARTNER&quot;)) {
</span><span class="cx">                                         DEBUGA_SKYPE(&quot;CHAT %s has DIALOG_PARTNER %s\n&quot;, SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i&lt;MAX_CHATS; i++){
-                                                if(strlen(tech_pvt-&gt;chats[i].chatname) == 0 || !strcmp(tech_pvt-&gt;chats[i].chatname, id) ){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i &lt; MAX_CHATS; i++) {
+                                                if (strlen(tech_pvt-&gt;chats[i].chatname) == 0 || !strcmp(tech_pvt-&gt;chats[i].chatname, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt-&gt;chats[i].chatname, id, sizeof(tech_pvt-&gt;chats[i].chatname));
</span><span class="cx">                                                         strncpy(tech_pvt-&gt;chats[i].dialog_partner, value, sizeof(tech_pvt-&gt;chats[i].dialog_partner));
</span><del>-                                                        found=1;
</del><ins>+                                                        found = 1;
</ins><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        if(!found){
</del><ins>+                                        if (!found) {
</ins><span class="cx">                                                 DEBUGA_SKYPE(&quot;why we do not have a chats slot free? we have more than %d chats in parallel?\n&quot;, SKYPIAX_P_LOG, MAX_CHATS);
</span><del>-                                        } 
</del><ins>+                                        }
</ins><span class="cx"> 
</span><del>-                                        DEBUGA_SKYPE(&quot;CHAT %s is in position %d in the chats array, chatname=%s, dialog_partner=%s\n&quot;, SKYPIAX_P_LOG, id, i, tech_pvt-&gt;chats[i].chatname, tech_pvt-&gt;chats[i].dialog_partner);
</del><ins>+                                        DEBUGA_SKYPE(&quot;CHAT %s is in position %d in the chats array, chatname=%s, dialog_partner=%s\n&quot;, SKYPIAX_P_LOG, id, i,
+                                                                 tech_pvt-&gt;chats[i].chatname, tech_pvt-&gt;chats[i].dialog_partner);
</ins><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                         }
</span><span class="lines">@@ -334,28 +335,30 @@
</span><span class="cx"> 
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;TYPE&quot;) &amp;&amp; !strcasecmp(value, &quot;SAID&quot;)) {
</span><span class="cx">                                         DEBUGA_SKYPE(&quot;CHATMESSAGE %s is of type SAID, let's get the other infos\n&quot;, SKYPIAX_P_LOG, id);
</span><del>-                                        found=0;
-                                        for(i=0; i&lt;MAX_CHATMESSAGES; i++){
-                                                if(strlen(tech_pvt-&gt;chatmessages[i].id) == 0){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i &lt; MAX_CHATMESSAGES; i++) {
+                                                if (strlen(tech_pvt-&gt;chatmessages[i].id) == 0) {
</ins><span class="cx">                                                         strncpy(tech_pvt-&gt;chatmessages[i].id, id, sizeof(tech_pvt-&gt;chatmessages[i].id));
</span><span class="cx">                                                         strncpy(tech_pvt-&gt;chatmessages[i].type, value, sizeof(tech_pvt-&gt;chatmessages[i].type));
</span><del>-                                                        found=1;
</del><ins>+                                                        found = 1;
</ins><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        if(!found){
-                                                DEBUGA_SKYPE(&quot;why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n&quot;, SKYPIAX_P_LOG, MAX_CHATMESSAGES);
</del><ins>+                                        if (!found) {
+                                                DEBUGA_SKYPE(&quot;why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n&quot;, SKYPIAX_P_LOG,
+                                                                         MAX_CHATMESSAGES);
</ins><span class="cx">                                         } else {
</span><del>-                                                DEBUGA_SKYPE(&quot;CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n&quot;, SKYPIAX_P_LOG, id, i, tech_pvt-&gt;chatmessages[i].type, tech_pvt-&gt;chatmessages[i].id);
</del><ins>+                                                DEBUGA_SKYPE(&quot;CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n&quot;, SKYPIAX_P_LOG, id, i,
+                                                                         tech_pvt-&gt;chatmessages[i].type, tech_pvt-&gt;chatmessages[i].id);
</ins><span class="cx">                                                 sprintf(msg_to_skype, &quot;GET CHATMESSAGE %s CHATNAME&quot;, id);
</span><span class="cx">                                                 skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><del>-                                                skypiax_sleep(100);
</del><ins>+                                                skypiax_sleep(1000);
</ins><span class="cx">                                                 sprintf(msg_to_skype, &quot;GET CHATMESSAGE %s FROM_HANDLE&quot;, id);
</span><span class="cx">                                                 skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><del>-                                                skypiax_sleep(100);
</del><ins>+                                                skypiax_sleep(1000);
</ins><span class="cx">                                                 sprintf(msg_to_skype, &quot;GET CHATMESSAGE %s FROM_DISPNAME&quot;, id);
</span><span class="cx">                                                 skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><del>-                                                skypiax_sleep(100);
</del><ins>+                                                skypiax_sleep(1000);
</ins><span class="cx">                                                 sprintf(msg_to_skype, &quot;GET CHATMESSAGE %s BODY&quot;, id);
</span><span class="cx">                                                 skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><span class="cx">                                         }
</span><span class="lines">@@ -363,63 +366,66 @@
</span><span class="cx"> 
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;CHATNAME&quot;)) {
</span><span class="cx">                                         DEBUGA_SKYPE(&quot;CHATMESSAGE %s belongs to the CHAT %s\n&quot;, SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i&lt;MAX_CHATMESSAGES; i++){
-                                                if(!strcmp(tech_pvt-&gt;chatmessages[i].id, id)){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i &lt; MAX_CHATMESSAGES; i++) {
+                                                if (!strcmp(tech_pvt-&gt;chatmessages[i].id, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt-&gt;chatmessages[i].chatname, value, sizeof(tech_pvt-&gt;chatmessages[i].chatname));
</span><del>-                                                        found=1;
</del><ins>+                                                        found = 1;
</ins><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        if(!found){
</del><ins>+                                        if (!found) {
</ins><span class="cx">                                                 DEBUGA_SKYPE(&quot;why chatmessage %s was not found in the chatmessages array??\n&quot;, SKYPIAX_P_LOG, id);
</span><del>-                                        } 
</del><ins>+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;FROM_HANDLE&quot;)) {
</span><span class="cx">                                         DEBUGA_SKYPE(&quot;CHATMESSAGE %s was sent by FROM_HANDLE %s\n&quot;, SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i&lt;MAX_CHATMESSAGES; i++){
-                                                if(!strcmp(tech_pvt-&gt;chatmessages[i].id, id)){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i &lt; MAX_CHATMESSAGES; i++) {
+                                                if (!strcmp(tech_pvt-&gt;chatmessages[i].id, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt-&gt;chatmessages[i].from_handle, value, sizeof(tech_pvt-&gt;chatmessages[i].from_handle));
</span><del>-                                                        found=1;
</del><ins>+                                                        found = 1;
</ins><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        if(!found){
</del><ins>+                                        if (!found) {
</ins><span class="cx">                                                 DEBUGA_SKYPE(&quot;why chatmessage %s was not found in the chatmessages array??\n&quot;, SKYPIAX_P_LOG, id);
</span><del>-                                        } 
</del><ins>+                                        }
</ins><span class="cx"> 
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;FROM_DISPNAME&quot;)) {
</span><span class="cx">                                         DEBUGA_SKYPE(&quot;CHATMESSAGE %s was sent by FROM_DISPNAME %s\n&quot;, SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i&lt;MAX_CHATMESSAGES; i++){
-                                                if(!strcmp(tech_pvt-&gt;chatmessages[i].id, id)){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i &lt; MAX_CHATMESSAGES; i++) {
+                                                if (!strcmp(tech_pvt-&gt;chatmessages[i].id, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt-&gt;chatmessages[i].from_dispname, value, sizeof(tech_pvt-&gt;chatmessages[i].from_dispname));
</span><del>-                                                        found=1;
</del><ins>+                                                        found = 1;
</ins><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        if(!found){
</del><ins>+                                        if (!found) {
</ins><span class="cx">                                                 DEBUGA_SKYPE(&quot;why chatmessage %s was not found in the chatmessages array??\n&quot;, SKYPIAX_P_LOG, id);
</span><del>-                                        } 
</del><ins>+                                        }
</ins><span class="cx"> 
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;BODY&quot;)) {
</span><span class="cx">                                         DEBUGA_SKYPE(&quot;CHATMESSAGE %s has BODY %s\n&quot;, SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i&lt;MAX_CHATMESSAGES; i++){
-                                                if(!strcmp(tech_pvt-&gt;chatmessages[i].id, id)){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i &lt; MAX_CHATMESSAGES; i++) {
+                                                if (!strcmp(tech_pvt-&gt;chatmessages[i].id, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt-&gt;chatmessages[i].body, value, sizeof(tech_pvt-&gt;chatmessages[i].body));
</span><del>-                                                        found=1;
</del><ins>+                                                        found = 1;
</ins><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        if(!found){
</del><ins>+                                        if (!found) {
</ins><span class="cx">                                                 DEBUGA_SKYPE(&quot;why chatmessage %s was not found in the chatmessages array??\n&quot;, SKYPIAX_P_LOG, id);
</span><del>-                                        }else {
-                                                DEBUGA_SKYPE(&quot;CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s, chatname=%s, from_handle=%s, from_dispname=%s, body=%s\n&quot;, SKYPIAX_P_LOG, id, i, tech_pvt-&gt;chatmessages[i].type, tech_pvt-&gt;chatmessages[i].id, tech_pvt-&gt;chatmessages[i].chatname, tech_pvt-&gt;chatmessages[i].from_handle, tech_pvt-&gt;chatmessages[i].from_dispname, tech_pvt-&gt;chatmessages[i].body);
-                                                if(strcmp(tech_pvt-&gt;chatmessages[i].from_handle, tech_pvt-&gt;skype_user)){ //if the message was not sent by myself
</del><ins>+                                        } else {
+                                                DEBUGA_SKYPE
+                                                        (&quot;CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s, chatname=%s, from_handle=%s, from_dispname=%s, body=%s\n&quot;,
+                                                         SKYPIAX_P_LOG, id, i, tech_pvt-&gt;chatmessages[i].type, tech_pvt-&gt;chatmessages[i].id, tech_pvt-&gt;chatmessages[i].chatname,
+                                                         tech_pvt-&gt;chatmessages[i].from_handle, tech_pvt-&gt;chatmessages[i].from_dispname, tech_pvt-&gt;chatmessages[i].body);
+                                                if (strcmp(tech_pvt-&gt;chatmessages[i].from_handle, tech_pvt-&gt;skype_user)) {        //if the message was not sent by myself
</ins><span class="cx">                                                         incoming_chatmessage(tech_pvt, i);
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="lines">@@ -535,7 +541,7 @@
</span><span class="cx">                                                 tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
</span><span class="cx">                                                 tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
</span><span class="cx">                                                 DEBUGA_SKYPE(&quot;Our remote party in skype_call %s is EARLYMEDIA\n&quot;, SKYPIAX_P_LOG, id);
</span><del>-                                                if(tech_pvt-&gt;tcp_cli_thread == NULL){
</del><ins>+                                                if (tech_pvt-&gt;tcp_cli_thread == NULL) {
</ins><span class="cx">                                                         DEBUGA_SKYPE(&quot;START start_audio_threads\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                                                         if (start_audio_threads(tech_pvt)) {
</span><span class="cx">                                                                 ERRORA(&quot;start_audio_threads FAILED\n&quot;, SKYPIAX_P_LOG);
</span><span class="lines">@@ -627,7 +633,7 @@
</span><span class="cx">                                                                         tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_INPROGRESS;
</span><span class="cx">                                                                         tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
</span><span class="cx"> 
</span><del>-                                                                        if(tech_pvt-&gt;tcp_cli_thread == NULL){
</del><ins>+                                                                        if (tech_pvt-&gt;tcp_cli_thread == NULL) {
</ins><span class="cx">                                                                                 DEBUGA_SKYPE(&quot;START start_audio_threads\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                                                                                 if (start_audio_threads(tech_pvt)) {
</span><span class="cx">                                                                                         ERRORA(&quot;start_audio_threads FAILED\n&quot;, SKYPIAX_P_LOG);
</span><span class="lines">@@ -733,7 +739,7 @@
</span><span class="cx">         unsigned int kill_cli_size;
</span><span class="cx">         short kill_cli_buff[SAMPLES_PER_FRAME];
</span><span class="cx">         short totalbuf[SAMPLES_PER_FRAME];
</span><del>-        int sockbufsize=0;
</del><ins>+        int sockbufsize = 0;
</ins><span class="cx">         unsigned int size = sizeof(int);
</span><span class="cx"> 
</span><span class="cx">         s = skypiax_socket_create_and_bind(tech_pvt, &amp;tech_pvt-&gt;tcp_srv_port);
</span><span class="lines">@@ -775,14 +781,14 @@
</span><span class="cx">                         while (s &gt; 0 &amp;&amp; (fd = accept(s, (struct sockaddr *) &amp;remote_addr, &amp;sin_size)) &gt; 0) {
</span><span class="cx">                                 DEBUGA_SKYPE(&quot;ACCEPTED here I send you %d\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;tcp_srv_port);
</span><span class="cx"> 
</span><del>-        sockbufsize=0;
-        size = sizeof(int);
-        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&amp;sockbufsize, &amp;size);
-        DEBUGA_SKYPE(&quot;3 SO_RCVBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
-        sockbufsize=0;
-        size = sizeof(int);
-        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&amp;sockbufsize, &amp;size);
-        DEBUGA_SKYPE(&quot;3 SO_SNDBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
</del><ins>+                                sockbufsize = 0;
+                                size = sizeof(int);
+                                getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &amp;sockbufsize, &amp;size);
+                                DEBUGA_SKYPE(&quot;3 SO_RCVBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
+                                sockbufsize = 0;
+                                size = sizeof(int);
+                                getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &amp;sockbufsize, &amp;size);
+                                DEBUGA_SKYPE(&quot;3 SO_SNDBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">                                 if (!(running &amp;&amp; tech_pvt-&gt;running))
</span><span class="lines">@@ -853,20 +859,20 @@
</span><span class="cx">                                                                 }
</span><span class="cx">                                                                 /* send the complete frame through the pipe to our code waiting for incoming audio */
</span><span class="cx">                                                                 //howmany = skypiax_pipe_write(tech_pvt-&gt;audiopipe_srv[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short));
</span><del>-                                        //FIXME while(tech_pvt-&gt;flag_audio_srv == 1){
-                                                //FIXME switch_sleep(100); //1 millisec
-                                                //NOTICA(&quot;read now is 1\n&quot;, SKYPIAX_P_LOG);
-                                                //FIXME }
-                                                //WARNINGA(&quot;read is now 0\n&quot;, SKYPIAX_P_LOG);
</del><ins>+                                                                //FIXME while(tech_pvt-&gt;flag_audio_srv == 1){
+                                                                //FIXME switch_sleep(100); //1 millisec
+                                                                //NOTICA(&quot;read now is 1\n&quot;, SKYPIAX_P_LOG);
+                                                                //FIXME }
+                                                                //WARNINGA(&quot;read is now 0\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">                                                                 howmany = SAMPLES_PER_FRAME * sizeof(short);
</span><del>-                                                                if(tech_pvt-&gt;flag_audio_srv == 1){
-                                                                        switch_sleep(1000); //1 millisec
</del><ins>+                                                                if (tech_pvt-&gt;flag_audio_srv == 1) {
+                                                                        switch_sleep(1000);        //1 millisec
</ins><span class="cx">                                                                 }
</span><del>-                                                                if(tech_pvt-&gt;flag_audio_srv == 0){
-                                                                memcpy(tech_pvt-&gt;audiobuf_srv, totalbuf, SAMPLES_PER_FRAME * sizeof(short));
-                                                                tech_pvt-&gt;flag_audio_srv = 1;
</del><ins>+                                                                if (tech_pvt-&gt;flag_audio_srv == 0) {
+                                                                        memcpy(tech_pvt-&gt;audiobuf_srv, totalbuf, SAMPLES_PER_FRAME * sizeof(short));
+                                                                        tech_pvt-&gt;flag_audio_srv = 1;
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                                 //NOTICA(&quot;read \n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                                                                 if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
</span><span class="lines">@@ -902,14 +908,14 @@
</span><span class="cx">                                 kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
</span><span class="cx">                                 len = skypiax_pipe_write(tech_pvt-&gt;audiopipe_cli[1], kill_cli_buff, kill_cli_size);
</span><span class="cx"> 
</span><del>-                                tech_pvt-&gt;flag_audio_cli = 1; //let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die
</del><ins>+                                tech_pvt-&gt;flag_audio_cli = 1;        //let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die
</ins><span class="cx">                                 skypiax_sleep(200);
</span><del>-                                tech_pvt-&gt;flag_audio_srv = 1; //let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die
</del><ins>+                                tech_pvt-&gt;flag_audio_srv = 1;        //let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die
</ins><span class="cx">                                 skypiax_sleep(200);
</span><span class="cx">                                 tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
</span><del>-                                tech_pvt-&gt;flag_audio_cli = 1; //let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die
</del><ins>+                                tech_pvt-&gt;flag_audio_cli = 1;        //let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die
</ins><span class="cx">                                 skypiax_sleep(200);
</span><del>-                                tech_pvt-&gt;flag_audio_srv = 1; //let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die
</del><ins>+                                tech_pvt-&gt;flag_audio_srv = 1;        //let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die
</ins><span class="cx">                                 skypiax_sleep(200);
</span><span class="cx">                                 DEBUGA_SKYPE(&quot;Skype incoming audio GONE\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                                 skypiax_close_socket(fd);
</span><span class="lines">@@ -919,7 +925,7 @@
</span><span class="cx"> 
</span><span class="cx">         DEBUGA_SKYPE(&quot;incoming audio server (I am it) EXITING\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">         skypiax_close_socket(s);
</span><del>-        s=-1;
</del><ins>+        s = -1;
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -941,7 +947,7 @@
</span><span class="cx"> #else
</span><span class="cx">         unsigned int sin_size;
</span><span class="cx"> #endif /* WIN32 */
</span><del>-        int sockbufsize=0;
</del><ins>+        int sockbufsize = 0;
</ins><span class="cx">         unsigned int size = sizeof(int);
</span><span class="cx"> 
</span><span class="cx">         s = skypiax_socket_create_and_bind(tech_pvt, &amp;tech_pvt-&gt;tcp_cli_port);
</span><span class="lines">@@ -986,14 +992,14 @@
</span><span class="cx">                         while (s &gt; 0 &amp;&amp; (fd = accept(s, (struct sockaddr *) &amp;remote_addr, &amp;sin_size)) &gt; 0) {
</span><span class="cx">                                 DEBUGA_SKYPE(&quot;ACCEPTED here you send me %d\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;tcp_cli_port);
</span><span class="cx"> 
</span><del>-        sockbufsize=0;
-        size = sizeof(int);
-        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&amp;sockbufsize, &amp;size);
-        DEBUGA_SKYPE(&quot;4 SO_RCVBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
-        sockbufsize=0;
-        size = sizeof(int);
-        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&amp;sockbufsize, &amp;size);
-        DEBUGA_SKYPE(&quot;4 SO_SNDBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
</del><ins>+                                sockbufsize = 0;
+                                size = sizeof(int);
+                                getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &amp;sockbufsize, &amp;size);
+                                DEBUGA_SKYPE(&quot;4 SO_RCVBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
+                                sockbufsize = 0;
+                                size = sizeof(int);
+                                getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &amp;sockbufsize, &amp;size);
+                                DEBUGA_SKYPE(&quot;4 SO_SNDBUF is %d, size is %d\n&quot;, SKYPIAX_P_LOG, sockbufsize, size);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1035,15 +1041,15 @@
</span><span class="cx">                                         FD_SET(fdselect, &amp;fs);
</span><span class="cx"> 
</span><span class="cx">                                         //FIXME rt = select(fdselect + 1, NULL, &amp;fs, NULL, &amp;to);
</span><del>-                                        while(tech_pvt-&gt;flag_audio_cli == 0){
</del><ins>+                                        while (tech_pvt-&gt;flag_audio_cli == 0) {
</ins><span class="cx"> #ifdef WIN32
</span><del>-                                                skypiax_sleep(100); //0.1 millisec
</del><ins>+                                                skypiax_sleep(100);        //0.1 millisec
</ins><span class="cx"> #else
</span><del>-                                                skypiax_sleep(1000); //1 millisec
</del><ins>+                                                skypiax_sleep(1000);        //1 millisec
</ins><span class="cx"> #endif //WIN32
</span><span class="cx">                                                 //WARNINGA(&quot;write now is 0\n&quot;, SKYPIAX_P_LOG);
</span><del>-                                                 }
-                                                //ERRORA(&quot;write is now 1\n&quot;, SKYPIAX_P_LOG);
</del><ins>+                                        }
+                                        //ERRORA(&quot;write is now 1\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><span class="cx">                                         rt = 1;
</span><span class="cx"> 
</span><span class="lines">@@ -1137,7 +1143,7 @@
</span><span class="cx"> 
</span><span class="cx">         DEBUGA_SKYPE(&quot;outbound audio server (I am it) EXITING\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">         skypiax_close_socket(s);
</span><del>-        s=-1;
</del><ins>+        s = -1;
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1145,16 +1151,16 @@
</span><span class="cx"> {
</span><span class="cx">         unsigned int samples;
</span><span class="cx"> 
</span><del>-        while(tech_pvt-&gt;flag_audio_srv == 0){
</del><ins>+        while (tech_pvt-&gt;flag_audio_srv == 0) {
</ins><span class="cx"> #ifdef WIN32
</span><del>-                skypiax_sleep(100); //0.1 millisec
</del><ins>+                skypiax_sleep(100);                //0.1 millisec
</ins><span class="cx"> #else
</span><del>-                skypiax_sleep(1000); //1 millisec
</del><ins>+                skypiax_sleep(1000);        //1 millisec
</ins><span class="cx"> #endif //WIN32
</span><span class="cx"> 
</span><span class="cx">                 //WARNINGA(&quot;read now is 0\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">         }
</span><del>-                //ERRORA(&quot;read is now 1\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        //ERRORA(&quot;read is now 1\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx">         //samples = skypiax_pipe_read(tech_pvt-&gt;audiopipe_srv[0], tech_pvt-&gt;read_frame.data, SAMPLES_PER_FRAME * sizeof(short));
</span><span class="cx">         samples = SAMPLES_PER_FRAME * sizeof(short);
</span><span class="cx">         memcpy(tech_pvt-&gt;read_frame.data, tech_pvt-&gt;audiobuf_srv, SAMPLES_PER_FRAME * sizeof(short));
</span><span class="lines">@@ -1256,7 +1262,7 @@
</span><span class="cx"> 
</span><span class="cx"> int skypiax_pipe_write(int pipe, short *buf, int howmany)
</span><span class="cx"> {
</span><del>-        if(buf){
</del><ins>+        if (buf) {
</ins><span class="cx">                 howmany = write(pipe, buf, howmany);
</span><span class="cx">                 return howmany;
</span><span class="cx">         } else {
</span><span class="lines">@@ -1628,7 +1634,7 @@
</span><span class="cx">         XSync(disp, False);
</span><span class="cx">         ok = X11_errors_untrap();
</span><span class="cx"> 
</span><del>-        if (!ok){
</del><ins>+        if (!ok) {
</ins><span class="cx">                 ERRORA(&quot;Sending message failed with status %d\n&quot;, SKYPIAX_P_LOG, xerror);
</span><span class="cx">                 tech_pvt-&gt;running = 0;
</span><span class="cx">                 return 0;
</span><span class="lines">@@ -1754,7 +1760,7 @@
</span><span class="cx">                 root = DefaultRootWindow(disp);
</span><span class="cx">                 win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, DefaultScreen(disp)));
</span><span class="cx"> 
</span><del>-                SkypiaxHandles-&gt;win = win;        
</del><ins>+                SkypiaxHandles-&gt;win = win;
</ins><span class="cx"> 
</span><span class="cx">                 snprintf(buf, 512, &quot;NAME skypiax&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -1762,7 +1768,7 @@
</span><span class="cx">                         ERRORA(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                         running = 0;
</span><span class="cx">                         //if(disp)
</span><del>-                                //XCloseDisplay(disp);
</del><ins>+                        //XCloseDisplay(disp);
</ins><span class="cx">                         return NULL;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -1771,14 +1777,14 @@
</span><span class="cx">                         ERRORA(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                         running = 0;
</span><span class="cx">                         //if(disp)
</span><del>-                                //XCloseDisplay(disp);
</del><ins>+                        //XCloseDisplay(disp);
</ins><span class="cx">                         return NULL;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 {
</span><span class="cx">                         /* perform an events loop */
</span><span class="cx">                         XEvent an_event;
</span><del>-                        char buf[21];                        /*  can't be longer */
</del><ins>+                        char buf[21];                /*  can't be longer */
</ins><span class="cx">                         char buffer[17000];
</span><span class="cx">                         char continuebuffer[17000];
</span><span class="cx">                         char *b;
</span><span class="lines">@@ -1799,8 +1805,8 @@
</span><span class="cx">                                 switch (an_event.type) {
</span><span class="cx">                                 case ClientMessage:
</span><span class="cx"> 
</span><del>-                                        if (an_event.xclient.format != 8){
-                                                skypiax_sleep(100);        //0.1 msec
</del><ins>+                                        if (an_event.xclient.format != 8) {
+                                                skypiax_sleep(1000);        //0.1 msec
</ins><span class="cx">                                                 break;
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><span class="lines">@@ -1818,11 +1824,13 @@
</span><span class="cx">                                                         unsigned int howmany;
</span><span class="cx">                                                         howmany = strlen(b) + 1;
</span><span class="cx">                                                         howmany = write(SkypiaxHandles-&gt;fdesc[1], b, howmany);
</span><del>-                                                        WARNINGA(&quot;A begin atom while the previous message is not closed???? value of previous message (between vertical bars) is=|||%s|||, will be lost\n&quot;, SKYPIAX_P_LOG, buffer);
</del><ins>+                                                        WARNINGA
+                                                                (&quot;A begin atom while the previous message is not closed???? value of previous message (between vertical bars) is=|||%s|||, will be lost\n&quot;,
+                                                                 SKYPIAX_P_LOG, buffer);
</ins><span class="cx">                                                         memset(buffer, '\0', 17000);
</span><span class="cx">                                                 }
</span><del>-                                                if(continue_is_broken){
-                                                        continue_is_broken=0;
</del><ins>+                                                if (continue_is_broken) {
+                                                        continue_is_broken = 0;
</ins><span class="cx">                                                         there_were_continues = 1;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="lines">@@ -1831,7 +1839,8 @@
</span><span class="cx"> 
</span><span class="cx">                                                 if (!strlen(buffer)) {
</span><span class="cx">                                                         DEBUGA_SKYPE
</span><del>-                                                                (&quot;Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||, let's store it and hope next 'begin' will be the good one\n&quot;, SKYPIAX_P_LOG, buf);
</del><ins>+                                                                (&quot;Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||, let's store it and hope next 'begin' will be the good one\n&quot;,
+                                                                 SKYPIAX_P_LOG, buf);
</ins><span class="cx">                                                         strcat(continuebuffer, buf);
</span><span class="cx">                                                         continue_is_broken = 1;
</span><span class="cx">                                                         if (!strncmp(buf, &quot;ognised identity&quot;, 15)) {
</span><span class="lines">@@ -1840,16 +1849,15 @@
</span><span class="cx">                                                                          SKYPIAX_P_LOG, buf);
</span><span class="cx">                                                                 skypiax_sleep(1000000);        //1 sec
</span><span class="cx">                                                         }
</span><del>-                                                        skypiax_sleep(100);        //0.1 msec
</del><ins>+                                                        skypiax_sleep(1000);        //0.1 msec
</ins><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        if(continue_is_broken){
</del><ins>+                                        if (continue_is_broken) {
</ins><span class="cx">                                                 XFlush(disp);
</span><del>-                                                skypiax_sleep(100);        //0.1 msec
</del><ins>+                                                skypiax_sleep(1000);        //0.1 msec
</ins><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><del>-
</del><span class="cx">                                         //DEBUGA_SKYPE (&quot;i=%d, buffer=|||%s|||\n&quot;, SKYPIAX_P_LOG, i, buffer);
</span><span class="cx">                                         strcat(buffer, buf);
</span><span class="cx">                                         //DEBUGA_SKYPE (&quot;i=%d, buffer=|||%s|||\n&quot;, SKYPIAX_P_LOG, i, buffer);
</span><span class="lines">@@ -1869,10 +1877,10 @@
</span><span class="cx">                                                 there_were_continues = 0;
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><del>-                                        skypiax_sleep(100);        //0.1 msec
</del><ins>+                                        skypiax_sleep(1000);        //0.1 msec
</ins><span class="cx">                                         break;
</span><span class="cx">                                 default:
</span><del>-                                        skypiax_sleep(100);        //0.1 msec
</del><ins>+                                        skypiax_sleep(1000);        //0.1 msec
</ins><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -1881,12 +1889,12 @@
</span><span class="cx">                 ERRORA(&quot;Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                 running = 0;
</span><span class="cx">                 //if(disp)
</span><del>-                        //XCloseDisplay(disp);
</del><ins>+                //XCloseDisplay(disp);
</ins><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx">         //running = 0;
</span><span class="cx">         //if(disp)
</span><del>-                //XCloseDisplay(disp);
</del><ins>+        //XCloseDisplay(disp);
</ins><span class="cx">         return NULL;
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>