<!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 "skypiax.h"
</span><span class="cx"> #define MDL_CHAT_PROTO "skype"
</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("skypiax_codec FAILED\n", SKYPIAX_P_LOG);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        DEBUGA_SKYPE("skypiax_codec SUCCESS\n", SKYPIAX_P_LOG);
</del><ins>+
+        if (switch_core_timer_init(&tech_pvt->timer_read, "soft", 20, tech_pvt->read_codec.implementation->samples_per_packet, skypiax_module_pool) !=
+                SWITCH_STATUS_SUCCESS) {
+                ERRORA("setup timer failed\n", SKYPIAX_P_LOG);
+                return SWITCH_STATUS_FALSE;
+        }
+
+        switch_core_timer_sync(&tech_pvt->timer_read);
+
+#ifdef TIMER_WRITE
+        if (switch_core_timer_init(&tech_pvt->timer_write, "soft", 20, tech_pvt->write_codec.implementation->samples_per_packet, skypiax_module_pool) !=
+                SWITCH_STATUS_SUCCESS) {
+                ERRORA("setup timer failed\n", SKYPIAX_P_LOG);
+                return SWITCH_STATUS_FALSE;
+        }
+
+        switch_core_timer_sync(&tech_pvt->timer_write);
+#endif// TIMER_WRITE
+
+        DEBUGA_SKYPE("skypiax_tech_init SUCCESS\n", 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->running && tech_pvt->SkypiaxHandles.disp){
</del><ins>+                if (tech_pvt->running && tech_pvt->SkypiaxHandles.disp) {
</ins><span class="cx">                         XEvent e;
</span><span class="cx">                         Atom atom1 = XInternAtom(tech_pvt->SkypiaxHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
</span><span class="cx">                         memset(&e, 0, sizeof(e));
</span><span class="lines">@@ -460,6 +481,14 @@
</span><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->write_codec);
</span><span class="cx">                 }
</span><ins>+
+                switch_core_timer_destroy(&tech_pvt->timer_read);
+#ifdef TIMER_WRITE
+
+                switch_core_timer_destroy(&tech_pvt->timer_write);
+#endif// TIMER_WRITE
+
+
</ins><span class="cx">                 *tech_pvt->session_uuid_str = '\0';
</span><span class="cx">                 tech_pvt->interface_state = SKYPIAX_STATE_IDLE;
</span><span class="cx">                 if (tech_pvt->skype_callflow == CALLFLOW_STATUS_FINISHED) {
</span><span class="lines">@@ -582,7 +611,7 @@
</span><span class="cx">                         ERRORA("FYI %s CHANNEL in CS_NEW state got SWITCH_SIG_KILL\n", 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 && switch_channel_get_state(channel) < CS_EXECUTE) {
</del><ins>+                if (switch_channel_get_state(channel) != CS_NEW && switch_channel_get_state(channel) < CS_EXECUTE) {
</ins><span class="cx">                         ERRORA("FYI %s CHANNEL in %d state got SWITCH_SIG_KILL\n", 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->read_frame.flags = SFF_NONE;
</span><span class="cx">         *frame = NULL;
</span><span class="cx">
</span><ins>+        switch_core_timer_next(&tech_pvt->timer_read);
+
</ins><span class="cx">         if (!skypiax_audio_read(tech_pvt)) {
</span><span class="cx">
</span><span class="cx">                 ERRORA("skypiax_audio_read ERROR\n", 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->audiopipe_cli[1], frame->data, sent);
</span><span class="cx"> #endif /* WIN32 */
</span><del>-                                        //FIXME while(tech_pvt->flag_audio_cli == 1){
-                                                //FIXME switch_sleep(100); //1 millisec
-                                                //NOTICA("write now is 1\n", SKYPIAX_P_LOG);
-                                                //FIXME }
-                                                //WARNINGA("write is now 0\n", SKYPIAX_P_LOG);
</del><span class="cx">
</span><ins>+        //memcpy(tech_pvt->audiobuf_cli, frame->data, frame->datalen);
+        if (tech_pvt->flag_audio_cli == 1) {
+                switch_sleep(1000);                //1 millisec
+        }
+        if (tech_pvt->flag_audio_cli == 0) {
+#ifdef TIMER_WRITE
</ins><span class="cx">
</span><del>-        //memcpy(tech_pvt->audiobuf_cli, frame->data, frame->datalen);
-                                                                if(tech_pvt->flag_audio_cli == 1){
-                                                                        switch_sleep(1000); //1 millisec
-                                                                }
-                                                                if(tech_pvt->flag_audio_cli == 0){
-        memcpy(tech_pvt->audiobuf_cli, frame->data, frame->datalen);
-        tech_pvt->flag_audio_cli = 1;
-                                                                }
</del><ins>+                switch_core_timer_next(&tech_pvt->timer_write);
+#endif// TIMER_WRITE
+
+                memcpy(tech_pvt->audiobuf_cli, frame->data, frame->datalen);
+                tech_pvt->flag_audio_cli = 1;
+        }
</ins><span class="cx">         //NOTICA("write \n", SKYPIAX_P_LOG);
</span><span class="cx">
</span><span class="cx">         if (sent != frame->datalen && 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->message_id) {
</span><del>-                case SWITCH_MESSAGE_INDICATE_ANSWER:
-                        {
-                                DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id);
-                                channel_answer_channel(session);
-                        }
-                        break;
-                case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
</del><ins>+        case SWITCH_MESSAGE_INDICATE_ANSWER:
+                {
+                        DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id);
+        
+                switch_core_timer_sync(&tech_pvt->timer_read);
+#ifdef TIMER_WRITE
+                switch_core_timer_sync(&tech_pvt->timer_write);
+#endif// TIMER_WRITE
+                channel_answer_channel(session);
+                }
+                break;
+        case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
</ins><span class="cx">
</span><del>-                        DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_AUDIO_SYNC\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
</del><ins>+                DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_AUDIO_SYNC\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
</ins><span class="cx">
</span><del>-                        //for (i=0; i<50; i++) {
-                        //skypiax_audio_read(tech_pvt);
-                        //WARNINGA("read samples\n", SKYPIAX_P_LOG);
-                        //}
-                        //switch_core_timer_sync(&tech_pvt->timer_read);
-                        //switch_core_timer_sync(&tech_pvt->timer_write);
</del><ins>+                switch_core_timer_sync(&tech_pvt->timer_read);
+#ifdef TIMER_WRITE
+                switch_core_timer_sync(&tech_pvt->timer_write);
+#endif// TIMER_WRITE
+                break;
+        default:
+                {
+        
+                switch_core_timer_sync(&tech_pvt->timer_read);
+#ifdef TIMER_WRITE
</ins><span class="cx">
</span><del>-                        break;
-                default:
-                        {
-                                DEBUGA_SKYPE("MSG_ID=%d\n", SKYPIAX_P_LOG, msg->message_id);
-                        }
-                        break;
</del><ins>+                switch_core_timer_sync(&tech_pvt->timer_write);
+#endif// TIMER_WRITE
+
+                DEBUGA_SKYPE("MSG_ID=%d\n", SKYPIAX_P_LOG, msg->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("ANY", outbound_profile->destination_number, 3 ) == 0) {
-                                snprintf(name, sizeof(name), "skypiax/ANY/%s%s", tech_pvt->name, outbound_profile->destination_number+3);
</del><ins>+                        if (strncmp("ANY", outbound_profile->destination_number, 3) == 0) {
+                                snprintf(name, sizeof(name), "skypiax/ANY/%s%s", tech_pvt->name, outbound_profile->destination_number + 3);
</ins><span class="cx">                         } else if (strncmp("RR", outbound_profile->destination_number, 2) == 0) {
</span><del>-                                snprintf(name, sizeof(name), "skypiax/RR/%s%s", tech_pvt->name, outbound_profile->destination_number+2);
</del><ins>+                                snprintf(name, sizeof(name), "skypiax/RR/%s%s", tech_pvt->name, outbound_profile->destination_number + 2);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->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("Initialized XInitThreads!\n", 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 && interface_id < 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, "true") || !strcmp(report_incoming_chatmessages, "1")){
</del><ins>+                                if (!strcmp(report_incoming_chatmessages, "true") || !strcmp(report_incoming_chatmessages, "1")) {
</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("i=%d globals.SKYPIAX_INTERFACES[%d].dialplan=%s\n", SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].dialplan);
</span><span class="cx">                                 DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].destination=%s\n", SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].destination);
</span><span class="cx">                                 DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n", SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].context);
</span><del>-                                DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].report_incoming_chatmessages=%d\n", SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].report_incoming_chatmessages);
</del><ins>+                                DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].report_incoming_chatmessages=%d\n", 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("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPIAX_P_LOG, proto, from, to, subject, body, type, hint?hint:"NULL");
</del><ins>+        DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPIAX_P_LOG, proto, from, to, subject, body, type,
+                                 hint ? hint : "NULL");
</ins><span class="cx">
</span><span class="cx">         if (!to || !strlen(to)) {
</span><span class="cx">                 ERRORA("Missing To: header.\n", SKYPIAX_P_LOG);
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ((!from && !hint) || (!strlen(from) && !strlen(hint)) ) {
</del><ins>+        if ((!from && !hint) || (!strlen(from) && !strlen(hint))) {
</ins><span class="cx">                 ERRORA("Missing From: AND Hint: headers.\n", 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("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPIAX_P_LOG, proto, from, to, subject, body, type, hint?hint:"NULL");
-                        if (hint && strlen(hint)) {
-                                //in hint we receive the interface name to use
-                                for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
-                                        if (strlen(globals.SKYPIAX_INTERFACES[i].name)
-                                                        && (strncmp(globals.SKYPIAX_INTERFACES[i].name, hint, strlen(hint)) == 0)) {
-                                                tech_pvt = &globals.SKYPIAX_INTERFACES[i];
-                                                DEBUGA_SKYPE("Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name);
-                                                found = 1;
-                                                break;
-                                        }
</del><ins>+                DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPIAX_P_LOG, proto, from, to, subject, body, type,
+                                         hint ? hint : "NULL");
+                if (hint && strlen(hint)) {
+                        //in hint we receive the interface name to use
+                        for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
+                                if (strlen(globals.SKYPIAX_INTERFACES[i].name)
+                                        && (strncmp(globals.SKYPIAX_INTERFACES[i].name, hint, strlen(hint)) == 0)) {
+                                        tech_pvt = &globals.SKYPIAX_INTERFACES[i];
+                                        DEBUGA_SKYPE("Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", 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 && i < SKYPIAX_MAX_INTERFACES; i++) {
-                                        if (strlen(globals.SKYPIAX_INTERFACES[i].name)
-                                                        && (strncmp(globals.SKYPIAX_INTERFACES[i].skype_user, from, strlen(from)) == 0)) {
-                                                tech_pvt = &globals.SKYPIAX_INTERFACES[i];
-                                                DEBUGA_SKYPE("Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", 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 && i < SKYPIAX_MAX_INTERFACES; i++) {
+                                if (strlen(globals.SKYPIAX_INTERFACES[i].name)
+                                        && (strncmp(globals.SKYPIAX_INTERFACES[i].skype_user, from, strlen(from)) == 0)) {
+                                        tech_pvt = &globals.SKYPIAX_INTERFACES[i];
+                                        DEBUGA_SKYPE("Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", 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("ERROR: A Skypiax interface with name='%s' or one with skypeuser='%s' was not found\n", SKYPIAX_P_LOG, hint?hint:"NULL", from?from:"NULL");
-                                goto end;
-                        } else {
</del><ins>+                }
+                if (!found) {
+                        ERRORA("ERROR: A Skypiax interface with name='%s' or one with skypeuser='%s' was not found\n", SKYPIAX_P_LOG, hint ? hint : "NULL",
+                                 from ? from : "NULL");
+                        goto end;
+                } else {
</ins><span class="cx">
</span><del>-                                snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", to);
-                                skypiax_signaling_write(tech_pvt, skype_msg);
-                                switch_sleep(100);
-                        }
</del><ins>+                        snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", 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("%s+%s", proto, from);
-                        //from = ffrom;
-                        //if ((p = strchr(from, '/'))) {
-                                //*p = '\0';
-                        //}
-        //NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPIAX_P_LOG, proto, from, to, subject, body, type, hint?hint:"NULL");
-                        //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("%s+%s", proto, from);
+                //from = ffrom;
+                //if ((p = strchr(from, '/'))) {
+                //*p = '\0';
</ins><span class="cx">                 //}
</span><ins>+                //NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPIAX_P_LOG, proto, from, to, subject, body, type, hint?hint:"NULL");
+                //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<MAX_CHATS; i++){
-                                if(!strcmp(tech_pvt->chats[i].dialog_partner, to) ){
</del><ins>+                while (!found) {
+                        for (i = 0; i < MAX_CHATS; i++) {
+                                if (!strcmp(tech_pvt->chats[i].dialog_partner, to)) {
</ins><span class="cx">                                         snprintf(skype_msg, sizeof(skype_msg), "CHATMESSAGE %s %s", tech_pvt->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 > 1000){
</del><ins>+                        if (tried > 1000) {
</ins><span class="cx">                                 ERRORA("No chat with dialog_partner='%s' was found\n", 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, "Couldn't register subclass!\n");
- 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, "Couldn't register subclass!\n");
+                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->SkypiaxHandles.disp){
</del><ins>+                                if (tech_pvt->SkypiaxHandles.disp) {
</ins><span class="cx">                                         XEvent e;
</span><span class="cx">                                         Atom atom1 = XInternAtom(tech_pvt->SkypiaxHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN",
</span><del>-                                                        False);
</del><ins>+                                                                                         False);
</ins><span class="cx">                                         memset(&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->write_function(stream, "\nTotal Interfaces: %d IB Calls(Failed/Total): %ld/%ld OB Calls(Failed/Total): %ld/%ld\n",
</span><del>-                 globals.real_interfaces > 0 ? globals.real_interfaces - 1 : 0, ib_failed, ib, ob_failed, ob);
</del><ins>+                                                         globals.real_interfaces > 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], "console")) {
</span><span class="cx">                 int i;
</span><span class="lines">@@ -2316,7 +2360,7 @@
</span><span class="cx">
</span><span class="cx">         DEBUGA_SKYPE("received CHATMESSAGE on interface %s\n", SKYPIAX_P_LOG, tech_pvt->name);
</span><span class="cx">
</span><del>-        if(!tech_pvt->report_incoming_chatmessages){
</del><ins>+        if (!tech_pvt->report_incoming_chatmessages) {
</ins><span class="cx">                 DEBUGA_SKYPE("I will not generate an Event, report_incoming_chatmessages is %d\n", SKYPIAX_P_LOG, tech_pvt->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, "chatname", tech_pvt->chatmessages[which].chatname);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id);
</span><span class="cx">                 switch_event_add_body(event, "%s", tech_pvt->chatmessages[which].body);
</span><del>-                if(session){
</del><ins>+                if (session) {
</ins><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true");
</span><span class="cx">                         if (switch_core_session_queue_event(session, &event) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
</span><span class="cx">                                 switch_event_fire(&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, "during-call", "false");
</span><span class="cx">                         switch_event_fire(&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("cannot create event on interface %s. WHY?????\n", SKYPIAX_P_LOG, tech_pvt->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(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
</span><span class="lines">@@ -2360,21 +2404,21 @@
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id);
</span><span class="cx">                         switch_event_add_body(event, "%s", tech_pvt->chatmessages[which].body);
</span><del>-                        if(session){
</del><ins>+                        if (session) {
</ins><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true");
</span><del>-                        } else { //no session
</del><ins>+                        } else {                        //no session
</ins><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "false");
</span><span class="cx">                         }
</span><span class="cx">                         switch_event_fire(&event);
</span><del>-                } else{
</del><ins>+                } else {
</ins><span class="cx">                         ERRORA("cannot create event on interface %s. WHY?????\n", SKYPIAX_P_LOG, tech_pvt->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(&tech_pvt->chatmessages[which], '\0', sizeof(&tech_pvt->chatmessages[which]) );
</del><ins>+        memset(&tech_pvt->chatmessages[which], '\0', sizeof(&tech_pvt->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 && i < 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 "ANY" interface */
</span><span class="cx">                         if (strlen(globals.SKYPIAX_INTERFACES[i].name)
</span><del>-                                        && (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
</del><ins>+                                && (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
</ins><span class="cx">                                 tech_pvt = &globals.SKYPIAX_INTERFACES[i];
</span><span class="cx">                                 stream->write_function(stream, "Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", 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->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, hint);
</span><span class="cx">
</span><del>-                        NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", SKYPIAX_P_LOG, MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt->name);
</del><ins>+                        NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", SKYPIAX_P_LOG, MDL_CHAT_PROTO, tech_pvt->skype_user,
+                                 argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt->name);
</ins><span class="cx">
</span><del>-                        chat_send(MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt->name);
</del><ins>+                        chat_send(MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE",
+                                         switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt->name);
</ins><span class="cx">
</span><span class="cx">                         //NOTICA("TEXT is: %s\n", SKYPIAX_P_LOG, (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1] );
</span><span class="cx">                         //snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", 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<MAX_CHATS; i++){
-                        if(!strcmp(tech_pvt->chats[i].dialog_partner, argv[1]) ){
-                                snprintf(skype_msg, sizeof(skype_msg), "CHATMESSAGE %s %s", tech_pvt->chats[i].chatname, (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]);
</del><ins>+        while (!found) {
+                for (i = 0; i < MAX_CHATS; i++) {
+                        if (!strcmp(tech_pvt->chats[i].dialog_partner, argv[1])) {
+                                snprintf(skype_msg, sizeof(skype_msg), "CHATMESSAGE %s %s", tech_pvt->chats[i].chatname,
+                                                 (char *) &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 > 1000){
</del><ins>+                if (tried > 1000) {
</ins><span class="cx">                         stream->write_function(stream, "ERROR: no chat with dialog_partner='%s' was found\n", 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("SUCCESS! *which_port=%d, tech_pvt->tcp_cli_port=%d, tech_pvt->tcp_srv_port=%d\n", SKYPIAX_P_LOG, *which_port, tech_pvt->tcp_cli_port,
</span><span class="cx">                                  tech_pvt->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 *)&sockbufsize, &size);
</del><ins>+        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, &size);
</ins><span class="cx">         DEBUGA_SKYPE("1 SO_RCVBUF is %d, size is %d\n", 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 *)&sockbufsize, &size);
</del><ins>+        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size);
</ins><span class="cx">         DEBUGA_SKYPE("1 SO_SNDBUF is %d, size is %d\n", 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 *)&sockbufsize, size);
</del><ins>+        setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &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 *)&sockbufsize, &size);
</del><ins>+        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, &size);
</ins><span class="cx">         DEBUGA_SKYPE("2 SO_RCVBUF is %d, size is %d\n", 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 *)&sockbufsize, size);
</del><ins>+        setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &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 *)&sockbufsize, &size);
</del><ins>+        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size);
</ins><span class="cx">         DEBUGA_SKYPE("2 SO_SNDBUF is %d, size is %d\n", 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, "DIALOG_PARTNER")) {
</span><span class="cx">                                         DEBUGA_SKYPE("CHAT %s has DIALOG_PARTNER %s\n", SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i<MAX_CHATS; i++){
-                                                if(strlen(tech_pvt->chats[i].chatname) == 0 || !strcmp(tech_pvt->chats[i].chatname, id) ){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i < MAX_CHATS; i++) {
+                                                if (strlen(tech_pvt->chats[i].chatname) == 0 || !strcmp(tech_pvt->chats[i].chatname, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt->chats[i].chatname, id, sizeof(tech_pvt->chats[i].chatname));
</span><span class="cx">                                                         strncpy(tech_pvt->chats[i].dialog_partner, value, sizeof(tech_pvt->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("why we do not have a chats slot free? we have more than %d chats in parallel?\n", SKYPIAX_P_LOG, MAX_CHATS);
</span><del>-                                        }
</del><ins>+                                        }
</ins><span class="cx">
</span><del>-                                        DEBUGA_SKYPE("CHAT %s is in position %d in the chats array, chatname=%s, dialog_partner=%s\n", SKYPIAX_P_LOG, id, i, tech_pvt->chats[i].chatname, tech_pvt->chats[i].dialog_partner);
</del><ins>+                                        DEBUGA_SKYPE("CHAT %s is in position %d in the chats array, chatname=%s, dialog_partner=%s\n", SKYPIAX_P_LOG, id, i,
+                                                                 tech_pvt->chats[i].chatname, tech_pvt->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, "TYPE") && !strcasecmp(value, "SAID")) {
</span><span class="cx">                                         DEBUGA_SKYPE("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPIAX_P_LOG, id);
</span><del>-                                        found=0;
-                                        for(i=0; i<MAX_CHATMESSAGES; i++){
-                                                if(strlen(tech_pvt->chatmessages[i].id) == 0){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                if (strlen(tech_pvt->chatmessages[i].id) == 0) {
</ins><span class="cx">                                                         strncpy(tech_pvt->chatmessages[i].id, id, sizeof(tech_pvt->chatmessages[i].id));
</span><span class="cx">                                                         strncpy(tech_pvt->chatmessages[i].type, value, sizeof(tech_pvt->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("why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n", SKYPIAX_P_LOG, MAX_CHATMESSAGES);
</del><ins>+                                        if (!found) {
+                                                DEBUGA_SKYPE("why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n", SKYPIAX_P_LOG,
+                                                                         MAX_CHATMESSAGES);
</ins><span class="cx">                                         } else {
</span><del>-                                                DEBUGA_SKYPE("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPIAX_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id);
</del><ins>+                                                DEBUGA_SKYPE("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPIAX_P_LOG, id, i,
+                                                                         tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id);
</ins><span class="cx">                                                 sprintf(msg_to_skype, "GET CHATMESSAGE %s CHATNAME", 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, "GET CHATMESSAGE %s FROM_HANDLE", 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, "GET CHATMESSAGE %s FROM_DISPNAME", 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, "GET CHATMESSAGE %s BODY", 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, "CHATNAME")) {
</span><span class="cx">                                         DEBUGA_SKYPE("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i<MAX_CHATMESSAGES; i++){
-                                                if(!strcmp(tech_pvt->chatmessages[i].id, id)){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt->chatmessages[i].chatname, value, sizeof(tech_pvt->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("why chatmessage %s was not found in the chatmessages array??\n", SKYPIAX_P_LOG, id);
</span><del>-                                        }
</del><ins>+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, "FROM_HANDLE")) {
</span><span class="cx">                                         DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i<MAX_CHATMESSAGES; i++){
-                                                if(!strcmp(tech_pvt->chatmessages[i].id, id)){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt->chatmessages[i].from_handle, value, sizeof(tech_pvt->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("why chatmessage %s was not found in the chatmessages array??\n", SKYPIAX_P_LOG, id);
</span><del>-                                        }
</del><ins>+                                        }
</ins><span class="cx">
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, "FROM_DISPNAME")) {
</span><span class="cx">                                         DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i<MAX_CHATMESSAGES; i++){
-                                                if(!strcmp(tech_pvt->chatmessages[i].id, id)){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt->chatmessages[i].from_dispname, value, sizeof(tech_pvt->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("why chatmessage %s was not found in the chatmessages array??\n", SKYPIAX_P_LOG, id);
</span><del>-                                        }
</del><ins>+                                        }
</ins><span class="cx">
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, "BODY")) {
</span><span class="cx">                                         DEBUGA_SKYPE("CHATMESSAGE %s has BODY %s\n", SKYPIAX_P_LOG, id, value);
</span><del>-                                        found=0;
-                                        for(i=0; i<MAX_CHATMESSAGES; i++){
-                                                if(!strcmp(tech_pvt->chatmessages[i].id, id)){
</del><ins>+                                        found = 0;
+                                        for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
</ins><span class="cx">                                                         strncpy(tech_pvt->chatmessages[i].body, value, sizeof(tech_pvt->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("why chatmessage %s was not found in the chatmessages array??\n", SKYPIAX_P_LOG, id);
</span><del>-                                        }else {
-                                                DEBUGA_SKYPE("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", SKYPIAX_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id, tech_pvt->chatmessages[i].chatname, tech_pvt->chatmessages[i].from_handle, tech_pvt->chatmessages[i].from_dispname, tech_pvt->chatmessages[i].body);
-                                                if(strcmp(tech_pvt->chatmessages[i].from_handle, tech_pvt->skype_user)){ //if the message was not sent by myself
</del><ins>+                                        } else {
+                                                DEBUGA_SKYPE
+                                                        ("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",
+                                                         SKYPIAX_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id, tech_pvt->chatmessages[i].chatname,
+                                                         tech_pvt->chatmessages[i].from_handle, tech_pvt->chatmessages[i].from_dispname, tech_pvt->chatmessages[i].body);
+                                                if (strcmp(tech_pvt->chatmessages[i].from_handle, tech_pvt->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->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
</span><span class="cx">                                                 tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
</span><span class="cx">                                                 DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG, id);
</span><del>-                                                if(tech_pvt->tcp_cli_thread == NULL){
</del><ins>+                                                if (tech_pvt->tcp_cli_thread == NULL) {
</ins><span class="cx">                                                         DEBUGA_SKYPE("START start_audio_threads\n", SKYPIAX_P_LOG);
</span><span class="cx">                                                         if (start_audio_threads(tech_pvt)) {
</span><span class="cx">                                                                 ERRORA("start_audio_threads FAILED\n", SKYPIAX_P_LOG);
</span><span class="lines">@@ -627,7 +633,7 @@
</span><span class="cx">                                                                         tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
</span><span class="cx">                                                                         tech_pvt->interface_state = SKYPIAX_STATE_UP;
</span><span class="cx">
</span><del>-                                                                        if(tech_pvt->tcp_cli_thread == NULL){
</del><ins>+                                                                        if (tech_pvt->tcp_cli_thread == NULL) {
</ins><span class="cx">                                                                                 DEBUGA_SKYPE("START start_audio_threads\n", SKYPIAX_P_LOG);
</span><span class="cx">                                                                                 if (start_audio_threads(tech_pvt)) {
</span><span class="cx">                                                                                         ERRORA("start_audio_threads FAILED\n", 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, &tech_pvt->tcp_srv_port);
</span><span class="lines">@@ -775,14 +781,14 @@
</span><span class="cx">                         while (s > 0 && (fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
</span><span class="cx">                                 DEBUGA_SKYPE("ACCEPTED here I send you %d\n", SKYPIAX_P_LOG, tech_pvt->tcp_srv_port);
</span><span class="cx">
</span><del>-        sockbufsize=0;
-        size = sizeof(int);
-        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&sockbufsize, &size);
-        DEBUGA_SKYPE("3 SO_RCVBUF is %d, size is %d\n", SKYPIAX_P_LOG, sockbufsize, size);
-        sockbufsize=0;
-        size = sizeof(int);
-        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&sockbufsize, &size);
-        DEBUGA_SKYPE("3 SO_SNDBUF is %d, size is %d\n", SKYPIAX_P_LOG, sockbufsize, size);
</del><ins>+                                sockbufsize = 0;
+                                size = sizeof(int);
+                                getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, &size);
+                                DEBUGA_SKYPE("3 SO_RCVBUF is %d, size is %d\n", SKYPIAX_P_LOG, sockbufsize, size);
+                                sockbufsize = 0;
+                                size = sizeof(int);
+                                getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size);
+                                DEBUGA_SKYPE("3 SO_SNDBUF is %d, size is %d\n", SKYPIAX_P_LOG, sockbufsize, size);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">                                 if (!(running && tech_pvt->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->audiopipe_srv[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short));
</span><del>-                                        //FIXME while(tech_pvt->flag_audio_srv == 1){
-                                                //FIXME switch_sleep(100); //1 millisec
-                                                //NOTICA("read now is 1\n", SKYPIAX_P_LOG);
-                                                //FIXME }
-                                                //WARNINGA("read is now 0\n", SKYPIAX_P_LOG);
</del><ins>+                                                                //FIXME while(tech_pvt->flag_audio_srv == 1){
+                                                                //FIXME switch_sleep(100); //1 millisec
+                                                                //NOTICA("read now is 1\n", SKYPIAX_P_LOG);
+                                                                //FIXME }
+                                                                //WARNINGA("read is now 0\n", 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->flag_audio_srv == 1){
-                                                                        switch_sleep(1000); //1 millisec
</del><ins>+                                                                if (tech_pvt->flag_audio_srv == 1) {
+                                                                        switch_sleep(1000);        //1 millisec
</ins><span class="cx">                                                                 }
</span><del>-                                                                if(tech_pvt->flag_audio_srv == 0){
-                                                                memcpy(tech_pvt->audiobuf_srv, totalbuf, SAMPLES_PER_FRAME * sizeof(short));
-                                                                tech_pvt->flag_audio_srv = 1;
</del><ins>+                                                                if (tech_pvt->flag_audio_srv == 0) {
+                                                                        memcpy(tech_pvt->audiobuf_srv, totalbuf, SAMPLES_PER_FRAME * sizeof(short));
+                                                                        tech_pvt->flag_audio_srv = 1;
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                                 //NOTICA("read \n", 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->audiopipe_cli[1], kill_cli_buff, kill_cli_size);
</span><span class="cx">
</span><del>-                                tech_pvt->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->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->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->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->interface_state = SKYPIAX_STATE_DOWN;
</span><del>-                                tech_pvt->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->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->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->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("Skype incoming audio GONE\n", 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("incoming audio server (I am it) EXITING\n", 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, &tech_pvt->tcp_cli_port);
</span><span class="lines">@@ -986,14 +992,14 @@
</span><span class="cx">                         while (s > 0 && (fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
</span><span class="cx">                                 DEBUGA_SKYPE("ACCEPTED here you send me %d\n", SKYPIAX_P_LOG, tech_pvt->tcp_cli_port);
</span><span class="cx">
</span><del>-        sockbufsize=0;
-        size = sizeof(int);
-        getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&sockbufsize, &size);
-        DEBUGA_SKYPE("4 SO_RCVBUF is %d, size is %d\n", SKYPIAX_P_LOG, sockbufsize, size);
-        sockbufsize=0;
-        size = sizeof(int);
-        getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&sockbufsize, &size);
-        DEBUGA_SKYPE("4 SO_SNDBUF is %d, size is %d\n", SKYPIAX_P_LOG, sockbufsize, size);
</del><ins>+                                sockbufsize = 0;
+                                size = sizeof(int);
+                                getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, &size);
+                                DEBUGA_SKYPE("4 SO_RCVBUF is %d, size is %d\n", SKYPIAX_P_LOG, sockbufsize, size);
+                                sockbufsize = 0;
+                                size = sizeof(int);
+                                getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size);
+                                DEBUGA_SKYPE("4 SO_SNDBUF is %d, size is %d\n", 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, &fs);
</span><span class="cx">
</span><span class="cx">                                         //FIXME rt = select(fdselect + 1, NULL, &fs, NULL, &to);
</span><del>-                                        while(tech_pvt->flag_audio_cli == 0){
</del><ins>+                                        while (tech_pvt->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("write now is 0\n", SKYPIAX_P_LOG);
</span><del>-                                                 }
-                                                //ERRORA("write is now 1\n", SKYPIAX_P_LOG);
</del><ins>+                                        }
+                                        //ERRORA("write is now 1\n", 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("outbound audio server (I am it) EXITING\n", 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->flag_audio_srv == 0){
</del><ins>+        while (tech_pvt->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("read now is 0\n", SKYPIAX_P_LOG);
</span><span class="cx">         }
</span><del>-                //ERRORA("read is now 1\n", SKYPIAX_P_LOG);
</del><ins>+        //ERRORA("read is now 1\n", SKYPIAX_P_LOG);
</ins><span class="cx">         //samples = skypiax_pipe_read(tech_pvt->audiopipe_srv[0], tech_pvt->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->read_frame.data, tech_pvt->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("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror);
</span><span class="cx">                 tech_pvt->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->win = win;        
</del><ins>+                SkypiaxHandles->win = win;
</ins><span class="cx">
</span><span class="cx">                 snprintf(buf, 512, "NAME skypiax");
</span><span class="cx">
</span><span class="lines">@@ -1762,7 +1768,7 @@
</span><span class="cx">                         ERRORA("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", 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("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", 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->fdesc[1], b, howmany);
</span><del>-                                                        WARNINGA("A begin atom while the previous message is not closed???? value of previous message (between vertical bars) is=|||%s|||, will be lost\n", SKYPIAX_P_LOG, buffer);
</del><ins>+                                                        WARNINGA
+                                                                ("A begin atom while the previous message is not closed???? value of previous message (between vertical bars) is=|||%s|||, will be lost\n",
+                                                                 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>-                                                                ("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", SKYPIAX_P_LOG, buf);
</del><ins>+                                                                ("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",
+                                                                 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, "ognised identity", 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 ("i=%d, buffer=|||%s|||\n", SKYPIAX_P_LOG, i, buffer);
</span><span class="cx">                                         strcat(buffer, buf);
</span><span class="cx">                                         //DEBUGA_SKYPE ("i=%d, buffer=|||%s|||\n", 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("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n", 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>