<!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][14340] </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=14340">14340</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2009-07-24 08:36:43 -0500 (Fri, 24 Jul 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>skypiax: lot of changes to allow for the usage of multiple instances of the same skype username, eg: 10 instances of skypename 'Bob' and 10 instances of skypename 'alice'. Horrible hacks for deciding which instance answer an incoming call, which busy instance will transfer to another and when, etc... ;-) Let's hope it does not breaks havoc...</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 (14339 => 14340)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-07-24 13:34:03 UTC (rev 14339)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-07-24 13:36:43 UTC (rev 14340)
</span><span class="lines">@@ -185,7 +185,7 @@
</span><span class="cx">
</span><span class="cx"> static switch_status_t channel_on_destroy(switch_core_session_t * session)
</span><span class="cx"> {
</span><del>-        //switch_channel_t *channel = NULL;
</del><ins>+ //switch_channel_t *channel = NULL;
</ins><span class="cx"> private_t *tech_pvt = NULL;
</span><span class="cx">
</span><span class="cx"> //channel = switch_core_session_get_channel(session);
</span><span class="lines">@@ -194,19 +194,18 @@
</span><span class="cx"> tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">
</span><span class="cx"> if (tech_pvt) {
</span><del>-         if (switch_core_codec_ready(&tech_pvt->read_codec)) {
-                 switch_core_codec_destroy(&tech_pvt->read_codec);
-         }
-        
-         if (switch_core_codec_ready(&tech_pvt->write_codec)) {
-                 switch_core_codec_destroy(&tech_pvt->write_codec);
-         }
</del><ins>+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ }
+
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
+ switch_core_codec_destroy(&tech_pvt->write_codec);
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
</del><span class="cx"> static switch_status_t channel_on_hangup(switch_core_session_t * session)
</span><span class="cx"> {
</span><span class="cx"> switch_channel_t *channel = NULL;
</span><span class="lines">@@ -230,7 +229,6 @@
</span><span class="cx"> skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
</del><span class="cx"> memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str));
</span><span class="cx"> DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
</span><span class="cx"> switch_mutex_lock(globals.mutex);
</span><span class="lines">@@ -509,12 +507,12 @@
</span><span class="cx"> /*.on_hangup */ channel_on_hangup,
</span><span class="cx"> /*.on_exchange_media */ channel_on_exchange_media,
</span><span class="cx"> /*.on_soft_execute */ channel_on_soft_execute,
</span><del>- /*.on_consume_media*/ NULL,
- /*.on_hibernate*/ NULL,
- /*.on_reset*/ NULL,
- /*.on_park*/ NULL,
- /*.on_reporting*/ NULL,
- /*.on_destroy*/ channel_on_destroy
</del><ins>+ /*.on_consume_media */ NULL,
+ /*.on_hibernate */ NULL,
+ /*.on_reset */ NULL,
+ /*.on_park */ NULL,
+ /*.on_reporting */ NULL,
+ /*.on_destroy */ channel_on_destroy
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> switch_io_routines_t skypiax_io_routines = {
</span><span class="lines">@@ -561,7 +559,7 @@
</span><span class="cx"> if (strncmp("ANY", interface_name, strlen(interface_name)) == 0) {
</span><span class="cx"> /* we've been asked for the "ANY" interface, let's find the first idle interface */
</span><span class="cx"> DEBUGA_SKYPE("Finding one available skype interface\n", SKYPIAX_P_LOG);
</span><del>- tech_pvt = find_available_skypiax_interface();
</del><ins>+ tech_pvt = find_available_skypiax_interface(NULL);
</ins><span class="cx"> if (tech_pvt)
</span><span class="cx"> found = 1;
</span><span class="cx"> }
</span><span class="lines">@@ -1002,6 +1000,9 @@
</span><span class="cx"> ("Interface_id=%d is now STARTED, the Skype client to which we are connected gave us the correct CURRENTUSERHANDLE (%s)\n",
</span><span class="cx"> SKYPIAX_P_LOG, interface_id,
</span><span class="cx"> globals.SKYPIAX_INTERFACES[interface_id].skype_user);
</span><ins>+
+ skypiax_signaling_write(&globals.SKYPIAX_INTERFACES[interface_id],
+ "SET AUTOAWAY OFF");
</ins><span class="cx"> } else {
</span><span class="cx"> ERRORA
</span><span class="cx"> ("The Skype client to which we are connected FAILED to gave us CURRENTUSERHANDLE=%s, interface_id=%d FAILED to start. No Skype client logged in as '%s' has been found. Please (re)launch a Skype client logged in as '%s'. Skypiax exiting now\n",
</span><span class="lines">@@ -1175,19 +1176,21 @@
</span><span class="cx">
</span><span class="cx"> if (channel) {
</span><span class="cx">
</span><del>-         if (! switch_channel_test_flag(channel, CF_BRIDGED)) {
</del><ins>+ if (!switch_channel_test_flag(channel, CF_BRIDGED)) {
</ins><span class="cx">
</span><del>-                 switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
-                 DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit,
-                                 switch_channel_get_name(channel));
-                 switch_mutex_lock(tech_pvt->flag_mutex);
-                 //FIXME: why sometimes DTMFs from here do not seems to be get by FS?
-                 switch_channel_queue_dtmf(channel, &dtmf);
-                 switch_set_flag(tech_pvt, TFLAG_DTMF);
-                 switch_mutex_unlock(tech_pvt->flag_mutex);
-         } else {
-                 DEBUGA_SKYPE("received a DTMF on channel %s, but we're BRIDGED, so let's NOT relay it out of band\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
-         }
</del><ins>+ switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
+ DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit,
+ switch_channel_get_name(channel));
+ switch_mutex_lock(tech_pvt->flag_mutex);
+ //FIXME: why sometimes DTMFs from here do not seems to be get by FS?
+ switch_channel_queue_dtmf(channel, &dtmf);
+ switch_set_flag(tech_pvt, TFLAG_DTMF);
+ switch_mutex_unlock(tech_pvt->flag_mutex);
+ } else {
+ DEBUGA_SKYPE
+ ("received a DTMF on channel %s, but we're BRIDGED, so let's NOT relay it out of band\n",
+ SKYPIAX_P_LOG, switch_channel_get_name(channel));
+ }
</ins><span class="cx"> } else {
</span><span class="cx"> WARNINGA("received %c DTMF, but no channel?\n", SKYPIAX_P_LOG, value[0]);
</span><span class="cx"> }
</span><span class="lines">@@ -1351,29 +1354,32 @@
</span><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-private_t *find_available_skypiax_interface(void)
</del><ins>+private_t *find_available_skypiax_interface(private_t * tech_pvt)
</ins><span class="cx"> {
</span><del>- private_t *tech_pvt = NULL;
</del><ins>+ private_t *tech_pvt2 = NULL;
</ins><span class="cx"> int found = 0;
</span><span class="cx"> int i;
</span><span class="cx">
</span><ins>+ switch_mutex_lock(globals.mutex);
+
</ins><span class="cx"> for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
</span><span class="cx"> if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</span><span class="cx"> int skype_state = 0;
</span><span class="cx">
</span><del>- tech_pvt = &globals.SKYPIAX_INTERFACES[i];
- skype_state = tech_pvt->interface_state;
</del><ins>+ tech_pvt2 = &globals.SKYPIAX_INTERFACES[i];
+ skype_state = tech_pvt2->interface_state;
</ins><span class="cx"> DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n", SKYPIAX_P_LOG, i,
</span><span class="cx"> globals.SKYPIAX_INTERFACES[i].name, skype_state);
</span><del>- if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) {
</del><ins>+ if ((tech_pvt ? strcmp(tech_pvt2->skype_user, tech_pvt->skype_user) : 1) && (SKYPIAX_STATE_DOWN == skype_state || SKYPIAX_STATE_RING == skype_state || 0 == skype_state)) { //(if we got tech_pvt NOT NULL) if user is NOT the same, and iface is idle
</ins><span class="cx"> found = 1;
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ switch_mutex_unlock(globals.mutex);
</ins><span class="cx"> if (found)
</span><del>- return tech_pvt;
</del><ins>+ return tech_pvt2;
</ins><span class="cx"> else
</span><span class="cx"> return NULL;
</span><span class="cx"> }
</span><span class="lines">@@ -1514,6 +1520,182 @@
</span><span class="cx"> return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+int skypiax_answer(private_t * tech_pvt, char *id, char *value)
+{
+ char msg_to_skype[1024];
+ int i;
+ int found = 0;
+ private_t *giovatech;
+ struct timeval timenow;
+
+ switch_mutex_lock(globals.mutex);
+
+ gettimeofday(&timenow, NULL);
+ for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
+ if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
+
+ giovatech = &globals.SKYPIAX_INTERFACES[i];
+ //NOTICA("skype interface: %d, name: %s, state: %d, value=%s, giovatech->callid_number=%s, giovatech->skype_user=%s\n", SKYPIAX_P_LOG, i, giovatech->name, giovatech->interface_state, value, giovatech->callid_number, giovatech->skype_user);
+ //FIXME check a timestamp here
+ if (strlen(giovatech->skype_call_id) && (giovatech->interface_state != SKYPIAX_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->callid_number, value)) && ((((timenow.tv_sec - giovatech->answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->answer_time.tv_usec)) < 500000)) { //0.5sec
+ found = 1;
+ DEBUGA_SKYPE
+ ("FOUND (name=%s, giovatech->interface_state=%d != SKYPIAX_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
+ SKYPIAX_P_LOG, giovatech->name, giovatech->interface_state,
+ giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value)
+ break;
+ }
+ }
+ }
+
+ if (found) {
+ //tech_pvt->callid_number[0]='\0';
+ switch_mutex_unlock(globals.mutex);
+ return 0;
+ }
+ DEBUGA_SKYPE("NOT FOUND\n", SKYPIAX_P_LOG);
+
+ if (!strlen(tech_pvt->skype_call_id)) {
+ /* we are not inside an active call */
+
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
+ skypiax_signaling_write(tech_pvt, msg_to_skype);
+ switch_sleep(10000);
+ sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
+ skypiax_signaling_write(tech_pvt, msg_to_skype);
+ DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, id);
+ //FIXME write a timestamp here
+ gettimeofday(&tech_pvt->answer_time, NULL);
+ switch_copy_string(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+
+ switch_copy_string(tech_pvt->callid_number, value,
+ sizeof(tech_pvt->callid_number) - 1);
+
+ DEBUGA_SKYPE
+ ("NEW! name: %s, state: %d, value=%s, tech_pvt->callid_number=%s, tech_pvt->skype_user=%s\n",
+ SKYPIAX_P_LOG, tech_pvt->name, tech_pvt->interface_state, value,
+ tech_pvt->callid_number, tech_pvt->skype_user);
+ switch_mutex_unlock(globals.mutex);
+ } else {
+
+ ERRORA("We're in a call now %s\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id);
+ switch_mutex_unlock(globals.mutex);
+ }
+ return 0;
+}
+int skypiax_transfer(private_t * tech_pvt, char *id, char *value)
+{
+ char msg_to_skype[1024];
+ int i;
+ int found = 0;
+ private_t *giovatech;
+ struct timeval timenow;
+
+ switch_mutex_lock(globals.mutex);
+
+ gettimeofday(&timenow, NULL);
+ for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
+ if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
+
+ giovatech = &globals.SKYPIAX_INTERFACES[i];
+ //NOTICA("skype interface: %d, name: %s, state: %d, value=%s, giovatech->callid_number=%s, giovatech->skype_user=%s\n", SKYPIAX_P_LOG, i, giovatech->name, giovatech->interface_state, value, giovatech->callid_number, giovatech->skype_user);
+ //FIXME check a timestamp here
+ if (strlen(giovatech->skype_call_id) && (giovatech->interface_state != SKYPIAX_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->callid_number, value)) && ((((timenow.tv_sec - giovatech->answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->answer_time.tv_usec)) < 500000)) { //0.5sec
+ found = 1;
+ DEBUGA_SKYPE
+ ("FOUND (name=%s, giovatech->interface_state=%d != SKYPIAX_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
+ SKYPIAX_P_LOG, giovatech->name, giovatech->interface_state,
+ giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value)
+ break;
+ }
+ }
+ }
+
+ if (found) {
+ //tech_pvt->callid_number[0]='\0';
+ switch_mutex_unlock(globals.mutex);
+ return 0;
+ }
+ DEBUGA_SKYPE("NOT FOUND\n", SKYPIAX_P_LOG);
+
+ if (!strlen(tech_pvt->skype_call_id)) {
+ /* we are not inside an active call */
+ ERRORA("We're NO MORE in a call now %s\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id);
+ switch_mutex_unlock(globals.mutex);
+
+ } else {
+
+ /* we're owned, we're in a call, let's try to transfer */
+ /************************** TODO
+                 Checking here if it is possible to transfer this call to Test2
+                 -> GET CALL 288 CAN_TRANSFER Test2
+                 <- CALL 288 CAN_TRANSFER test2 TRUE
+                 **********************************/
+
+ private_t *available_skypiax_interface = NULL;
+
+ gettimeofday(&timenow, NULL);
+ for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
+ if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
+
+ giovatech = &globals.SKYPIAX_INTERFACES[i];
+ //NOTICA("skype interface: %d, name: %s, state: %d, value=%s, giovatech->callid_number=%s, giovatech->skype_user=%s\n", SKYPIAX_P_LOG, i, giovatech->name, giovatech->interface_state, value, giovatech->callid_number, giovatech->skype_user);
+ //FIXME check a timestamp here
+ if (strlen(giovatech->skype_transfer_call_id) && (giovatech->interface_state != SKYPIAX_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->transfer_callid_number, value)) && ((((timenow.tv_sec - giovatech->transfer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->transfer_time.tv_usec)) < 1000000)) { //1.0 sec
+ found = 1;
+ DEBUGA_SKYPE
+ ("FOUND (name=%s, giovatech->interface_state=%d != SKYPIAX_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->transfer_callid_number=%s == value=%s)\n",
+ SKYPIAX_P_LOG, giovatech->name, giovatech->interface_state,
+ giovatech->skype_user, tech_pvt->skype_user,
+ giovatech->transfer_callid_number, value)
+ break;
+ }
+ }
+ }
+
+ if (found) {
+ //tech_pvt->callid_number[0]='\0';
+ switch_mutex_unlock(globals.mutex);
+ return 0;
+ }
+ DEBUGA_SKYPE("NOT FOUND\n", SKYPIAX_P_LOG);
+
+ available_skypiax_interface = find_available_skypiax_interface(tech_pvt);
+ if (available_skypiax_interface) {
+ /* there is a skypiax interface idle, let's transfer the call to it */
+
+ //FIXME write a timestamp here
+ gettimeofday(&tech_pvt->transfer_time, NULL);
+ switch_copy_string(tech_pvt->skype_transfer_call_id, id,
+ sizeof(tech_pvt->skype_transfer_call_id) - 1);
+
+ switch_copy_string(tech_pvt->transfer_callid_number, value,
+ sizeof(tech_pvt->transfer_callid_number) - 1);
+
+ DEBUGA_SKYPE
+ ("Let's transfer the skype_call %s to %s interface (with skype_user: %s), because we are already in a skypiax call(%s)\n",
+ SKYPIAX_P_LOG, tech_pvt->skype_call_id, available_skypiax_interface->name,
+ available_skypiax_interface->skype_user, id);
+ sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id,
+ available_skypiax_interface->skype_user);
+ skypiax_signaling_write(tech_pvt, msg_to_skype);
+ } else {
+ /* no skypiax interfaces idle, do nothing */
+ DEBUGA_SKYPE
+ ("Not answering the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available OR another interface is answering this call\n",
+ SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
+ //sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
+ }
+ switch_sleep(10000);
+ DEBUGA_SKYPE
+ ("We (%s) have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
+ SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
+
+ switch_mutex_unlock(globals.mutex);
+ }
+ return 0;
+}
+
</ins><span class="cx"> /* For Emacs:
</span><span class="cx"> * Local Variables:
</span><span class="cx"> * mode:c
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h (14339 => 14340)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-07-24 13:34:03 UTC (rev 14339)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-07-24 13:36:43 UTC (rev 14340)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx">
</span><span class="cx"> #include <switch.h>
</span><span class="cx"> #include <switch_version.h>
</span><ins>+#include <sys/time.h>
</ins><span class="cx">
</span><span class="cx"> #ifndef WIN32
</span><span class="cx"> #include <X11/Xlib.h>
</span><span class="lines">@@ -232,7 +233,11 @@
</span><span class="cx"> char skype_user[256];
</span><span class="cx"> char skype_password[256];
</span><span class="cx"> char destination[256];
</span><ins>+ struct timeval answer_time;
</ins><span class="cx">
</span><ins>+ struct timeval transfer_time;
+ char transfer_callid_number[50];
+ char skype_transfer_call_id[512];
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> typedef struct private_object private_t;
</span><span class="lines">@@ -270,6 +275,8 @@
</span><span class="cx"> int skypiax_pipe_write(int pipe, short *buf, int howmany);
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> int skypiax_close_socket(unsigned int fd);
</span><del>-private_t *find_available_skypiax_interface(void);
</del><ins>+private_t *find_available_skypiax_interface(private_t * tech_pvt);
</ins><span class="cx"> int remote_party_is_ringing(private_t * tech_pvt);
</span><span class="cx"> int remote_party_is_early_media(private_t * tech_pvt);
</span><ins>+int skypiax_answer(private_t * tech_pvt, char *id, char *value);
+int skypiax_transfer(private_t * tech_pvt, char *id, char *value);
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (14339 => 14340)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-07-24 13:34:03 UTC (rev 14339)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-07-24 13:36:43 UTC (rev 14340)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx"> int xerror = 0;
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> /*************************************/
</span><del>-
</del><span class="cx"> int skypiax_signaling_read(private_t * tech_pvt)
</span><span class="cx"> {
</span><span class="cx"> char read_from_pipe[4096];
</span><span class="lines">@@ -52,7 +51,9 @@
</span><span class="cx">
</span><span class="cx"> if (read_from_pipe[i] == '\0') {
</span><span class="cx">
</span><del>- DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
</del><ins>+ if (!strstr(message, "DURATION")) {
+ DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
+ }
</ins><span class="cx">
</span><span class="cx"> if (!strcasecmp(message, "ERROR 68")) {
</span><span class="cx"> DEBUGA_SKYPE
</span><span class="lines">@@ -86,16 +87,21 @@
</span><span class="cx"> WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message);
</span><span class="cx"> }
</span><span class="cx"> if (!strcasecmp(message, "ERROR")) {
</span><del>- DEBUGA_SKYPE("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
- tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
- tech_pvt->skype_call_id[0] = '\0';
</del><ins>+ if (!strncasecmp(message, "ERROR 592 ALTER CALL", 19)) {
+ ERRORA("Skype got ERROR about TRANSFERRING, no problem: |||%s|||\n",
+ SKYPIAX_P_LOG, message);
+ } else {
+ DEBUGA_SKYPE("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ tech_pvt->skype_call_id[0] = '\0';
</ins><span class="cx">
</span><del>- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
</del><ins>+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> if (!strcasecmp(message, "CURRENTUSERHANDLE")) {
</span><span class="lines">@@ -160,27 +166,36 @@
</span><span class="cx"> skypiax_strncpy(value, where, sizeof(value) - 1);
</span><span class="cx"> where = strsep(stringp, " ");
</span><span class="cx">
</span><del>- DEBUGA_SKYPE
- ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL");
</del><ins>+ //DEBUGA_SKYPE
+ //("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
+ //SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL");
</ins><span class="cx">
</span><span class="cx"> if (!strcasecmp(prop, "PARTNER_HANDLE")) {
</span><del>- skypiax_strncpy(tech_pvt->callid_number, value,
- sizeof(tech_pvt->callid_number) - 1);
- DEBUGA_SKYPE
- ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n",
- SKYPIAX_P_LOG, id, tech_pvt->callid_number);
- return CALLFLOW_INCOMING_RING;
</del><ins>+ if (!strlen(tech_pvt->skype_call_id)) {
+ /* we are NOT inside an active call */
+ DEBUGA_SKYPE("Call %s TRY ANSWER\n", SKYPIAX_P_LOG, id);
+ skypiax_answer(tech_pvt, id, value);
+ } else {
+ /* we are inside an active call */
+ if (!strcasecmp(tech_pvt->skype_call_id, id)) {
+ /* this is the call in which we are calling out */
+ DEBUGA_SKYPE("Call %s NOTHING\n", SKYPIAX_P_LOG, id);
+ } else {
+ usleep(400000); //0.4 seconds
+ DEBUGA_SKYPE("Call %s TRY TRANSFER\n", SKYPIAX_P_LOG, id);
+ skypiax_transfer(tech_pvt, id, value);
+ }
+ }
</ins><span class="cx"> }
</span><span class="cx"> if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
</span><span class="cx"> snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s",
</span><span class="cx"> value, where ? " " : "", where ? where : "");
</span><del>- DEBUGA_SKYPE
- ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
- SKYPIAX_P_LOG, id, tech_pvt->callid_name);
</del><ins>+ //DEBUGA_SKYPE
+ //("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
+ //SKYPIAX_P_LOG, id, tech_pvt->callid_name);
</ins><span class="cx"> }
</span><span class="cx"> if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
</span><del>- DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG, id);
</del><ins>+ //DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG, id);
</ins><span class="cx"> if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
</span><span class="cx"> tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
</span><span class="cx"> }
</span><span class="lines">@@ -211,71 +226,27 @@
</span><span class="cx">
</span><span class="cx"> if (!strcasecmp(value, "RINGING")) {
</span><span class="cx"> char msg_to_skype[1024];
</span><del>- if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) {
- /* we are not calling out */
- if (!strlen(tech_pvt->skype_call_id)) {
- /* we are not inside an active call */
</del><ins>+ if (!strlen(tech_pvt->skype_call_id)) {
+ /* we are NOT inside an active call */
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
+ skypiax_signaling_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
+ } else {
+ /* we are inside an active call */
+ if (!strcasecmp(tech_pvt->skype_call_id, id)) {
+ /* this is the call in which we are calling out */
</ins><span class="cx"> tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
</span><del>- tech_pvt->interface_state = SKYPIAX_STATE_RING;
- /* no owner, no active call, let's answer */
- skypiax_signaling_write(tech_pvt, "SET AGC OFF");
- skypiax_sleep(10000);
- skypiax_signaling_write(tech_pvt, "SET AEC OFF");
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
- skypiax_signaling_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
- skypiax_signaling_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
- skypiax_signaling_write(tech_pvt, msg_to_skype);
- DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
- id);
</del><ins>+ tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
</ins><span class="cx"> skypiax_strncpy(tech_pvt->skype_call_id, id,
</span><span class="cx"> sizeof(tech_pvt->skype_call_id) - 1);
</span><ins>+ DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
+ SKYPIAX_P_LOG, id);
+ remote_party_is_ringing(tech_pvt);
</ins><span class="cx"> } else {
</span><del>- /* we're owned, we're in a call, let's try to transfer */
- /************************** TODO
-                 Checking here if it is possible to transfer this call to Test2
-                 -> GET CALL 288 CAN_TRANSFER Test2
-                 <- CALL 288 CAN_TRANSFER test2 TRUE
-                **********************************/
-
- private_t *available_skypiax_interface;
-
- available_skypiax_interface = find_available_skypiax_interface();
- if (available_skypiax_interface) {
- /* there is a skypiax interface idle, let's transfer the call to it */
- DEBUGA_SKYPE
- ("Let's transfer the skype_call %s to %s interface (with skype_user: %s), because we are already in a skypiax call(%s)\n",
- SKYPIAX_P_LOG, tech_pvt->skype_call_id,
- available_skypiax_interface->name,
- available_skypiax_interface->skype_user, id);
- sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id,
- available_skypiax_interface->skype_user);
- } else {
- /* no skypiax interfaces idle, let's refuse the call */
- DEBUGA_SKYPE
- ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n",
- SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
- sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
- }
</del><ins>+ sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
</ins><span class="cx"> skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><span class="cx"> skypiax_sleep(10000);
</span><del>- DEBUGA_SKYPE
- ("We (%s) have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
- SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
</del><span class="cx"> }
</span><del>- } else {
- /* we are calling out */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
- tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
- skypiax_strncpy(tech_pvt->skype_call_id, id,
- sizeof(tech_pvt->skype_call_id) - 1);
- DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
- SKYPIAX_P_LOG, id);
- remote_party_is_ringing(tech_pvt);
</del><span class="cx"> }
</span><span class="cx"> } else if (!strcasecmp(value, "EARLYMEDIA")) {
</span><span class="cx"> char msg_to_skype[1024];
</span><span class="lines">@@ -296,8 +267,10 @@
</span><span class="cx"> } else if (!strcasecmp(value, "MISSED")) {
</span><span class="cx"> DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
</span><span class="cx"> } else if (!strcasecmp(value, "FINISHED")) {
</span><del>- DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
</del><ins>+ //DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
+ //usleep(150000);//150msec, let's give the TCP sockets time to timeout
</ins><span class="cx"> if (!strcasecmp(tech_pvt->skype_call_id, id)) {
</span><ins>+ tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
</ins><span class="cx"> DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n",
</span><span class="cx"> SKYPIAX_P_LOG, id);
</span><span class="cx"> tech_pvt->skype_call_id[0] = '\0';
</span><span class="lines">@@ -365,50 +338,50 @@
</span><span class="cx"> skypiax_strncpy(tech_pvt->skype_call_id, id,
</span><span class="cx"> sizeof(tech_pvt->skype_call_id) - 1);
</span><span class="cx"> DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
</span><del>-         } else if (!strcasecmp(value, "INPROGRESS")) {
-                 char msg_to_skype[1024];
</del><ins>+ } else if (!strcasecmp(value, "INPROGRESS")) {
+ char msg_to_skype[1024];
</ins><span class="cx">
</span><del>-                 if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
-                         if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id)
-                                         || !strcasecmp(tech_pvt->skype_call_id, id)) {
-                                 skypiax_strncpy(tech_pvt->skype_call_id, id,
-                                                 sizeof(tech_pvt->skype_call_id) - 1);
-                                 DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
</del><ins>+ if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
+ if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id)
+ || !strcasecmp(tech_pvt->skype_call_id, id)) {
+ skypiax_strncpy(tech_pvt->skype_call_id, id,
+ sizeof(tech_pvt->skype_call_id) - 1);
+ DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
</ins><span class="cx">
</span><del>-                                 if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
-                                         tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
-                                         tech_pvt->interface_state = SKYPIAX_STATE_UP;
-                                         start_audio_threads(tech_pvt);
-                                         skypiax_sleep(1000); //FIXME
-                                         sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
-                                                         tech_pvt->tcp_cli_port);
-                                         skypiax_signaling_write(tech_pvt, msg_to_skype);
-                                         skypiax_sleep(1000); //FIXME
-                                         sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
-                                                         tech_pvt->tcp_srv_port);
-                                         skypiax_signaling_write(tech_pvt, msg_to_skype);
-                                 }
-                                 tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
-                                 if (!strlen(tech_pvt->session_uuid_str)) {
-                                         DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
-                                         new_inbound_channel(tech_pvt);
-                                 } else {
-                                         DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
-                                         outbound_channel_answered(tech_pvt);
-                                 }
-                         } else {
-                                 DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n",
-                                                 SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
-                         }
-                 } else {
-                         tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
-                         WARNINGA("Back from REMOTEHOLD!\n", SKYPIAX_P_LOG);
-                 }
</del><ins>+ if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
+ tech_pvt->interface_state = SKYPIAX_STATE_UP;
+ start_audio_threads(tech_pvt);
+ skypiax_sleep(1000); //FIXME
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
+ tech_pvt->tcp_cli_port);
+ skypiax_signaling_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(1000); //FIXME
+ sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"",
+ id, tech_pvt->tcp_srv_port);
+ skypiax_signaling_write(tech_pvt, msg_to_skype);
+ }
+ tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
+ if (!strlen(tech_pvt->session_uuid_str)) {
+ DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
+ new_inbound_channel(tech_pvt);
+ } else {
+ DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
+ outbound_channel_answered(tech_pvt);
+ }
+ } else {
+ DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n",
+ SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
+ }
+ } else {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
+ WARNINGA("Back from REMOTEHOLD!\n", SKYPIAX_P_LOG);
+ }
</ins><span class="cx">
</span><del>-         } else if (!strcasecmp(value, "REMOTEHOLD")) {
-                 tech_pvt->skype_callflow = CALLFLOW_STATUS_REMOTEHOLD;
-                 WARNINGA("skype_call: %s is now REMOTEHOLD\n", SKYPIAX_P_LOG, id);
-         } else {
</del><ins>+ } else if (!strcasecmp(value, "REMOTEHOLD")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_REMOTEHOLD;
+ WARNINGA("skype_call: %s is now REMOTEHOLD\n", SKYPIAX_P_LOG, id);
+ } else {
</ins><span class="cx"> WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id,
</span><span class="cx"> value);
</span><span class="cx"> }
</span><span class="lines">@@ -456,7 +429,7 @@
</span><span class="cx"> short srv_out[SAMPLES_PER_FRAME / 2];
</span><span class="cx"> struct sockaddr_in my_addr;
</span><span class="cx"> struct sockaddr_in remote_addr;
</span><del>- int exit = 0;
</del><ins>+ //int exit = 0;
</ins><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><span class="lines">@@ -480,115 +453,148 @@
</span><span class="cx"> listen(s, 6);
</span><span class="cx">
</span><span class="cx"> sin_size = sizeof(remote_addr);
</span><del>- while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
- DEBUGA_SKYPE("ACCEPTED here I send you %d\n", SKYPIAX_P_LOG, tech_pvt->tcp_srv_port);
</del><ins>+
+ /****************************/
+ while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
+ && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
+ || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
+
+ unsigned int fdselectgio;
+ int rtgio;
+ fd_set fsgio;
+ struct timeval togio;
+
</ins><span class="cx"> if (!running)
</span><span class="cx"> break;
</span><del>- while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
- && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
- || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
- || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
- || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
</del><ins>+ FD_ZERO(&fsgio);
+ togio.tv_usec = 20000; //20msec
+ togio.tv_sec = 0;
+ fdselectgio = s;
+ FD_SET(fdselectgio, &fsgio);
</ins><span class="cx">
</span><del>- unsigned int fdselect;
- int rt;
- fd_set fs;
- struct timeval to;
</del><ins>+ rtgio = select(fdselectgio + 1, &fsgio, NULL, NULL, &togio);
</ins><span class="cx">
</span><del>- if (!running)
- break;
- exit = 1;
</del><ins>+ if (rtgio) {
</ins><span class="cx">
</span><del>- fdselect = fd;
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //2000 msec
- to.tv_sec = 0;
</del><ins>+ /****************************/
</ins><span class="cx">
</span><del>- rt = select(fdselect + 1, &fs, NULL, NULL, &to);
- if (rt > 0) {
</del><ins>+ while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
+ DEBUGA_SKYPE("ACCEPTED here I send you %d\n", SKYPIAX_P_LOG,
+ tech_pvt->tcp_srv_port);
+ if (!running)
+ break;
+ while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
+ && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
+ || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
</ins><span class="cx">
</span><del>-         if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
-                 len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
-         } else {
-                 len = 0;
-         }
</del><ins>+ unsigned int fdselect;
+ int rt;
+ fd_set fs;
+ struct timeval to;
</ins><span class="cx">
</span><del>-         if (len == 320) {
-                 unsigned int howmany;
</del><ins>+ if (!running)
+ break;
+ //exit = 1;
</ins><span class="cx">
</span><del>-                 if (samplerate_skypiax == 8000) {
-                         /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
-                         a = 0;
-                         for (i = 0; i < len / sizeof(short); i++) {
-                                 srv_out[a] = srv_in[i];
-                                 i++;
-                                 a++;
-                         }
-                 } else if (samplerate_skypiax == 16000) {
-                         /* we're NOT downsampling, srv_out will contain ALL samples from srv_in */
-                         for (i = 0; i < len / sizeof(short); i++) {
-                                 srv_out[i] = srv_in[i];
-                         }
-                 } else {
-                         ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
-                 }
-                 /* if not yet done, let's store the half incoming frame */
-                 if (!tech_pvt->audiobuf_is_loaded) {
-                         for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
-                                 tech_pvt->audiobuf[i] = srv_out[i];
-                         }
-                         tech_pvt->audiobuf_is_loaded = 1;
-                 } else {
-                         /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */
-                         for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
-                                 totalbuf[i] = tech_pvt->audiobuf[i];
-                         }
-                         for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) {
-                                 totalbuf[i] = srv_out[a];
-                                 i++;
-                         }
-                         /* send the complete frame through the pipe to our code waiting for incoming audio */
-                         howmany =
-                                 skypiax_pipe_write(tech_pvt->audiopipe[1], totalbuf,
-                                                 SAMPLES_PER_FRAME * sizeof(short));
-                         if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
-                                 ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany,
-                                                 (int) (SAMPLES_PER_FRAME * sizeof(short)));
-                         }
-                         /* done with the stored half frame */
-                         tech_pvt->audiobuf_is_loaded = 0;
-                 }
</del><ins>+ fdselect = fd;
+ FD_ZERO(&fs);
+ FD_SET(fdselect, &fs);
+ //to.tv_usec = 2000000; //2000 msec
+ to.tv_usec = 60000; //60 msec
+ to.tv_sec = 0;
</ins><span class="cx">
</span><del>-         } else if (len == 0) {
-                 skypiax_sleep(1000);
-         } else {
-                 ERRORA("len=%d, expected 320\n", SKYPIAX_P_LOG, len);
-         }
</del><ins>+ rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+ if (rt > 0) {
</ins><span class="cx">
</span><del>- } else {
- if (rt)
- ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
- skypiax_sleep(10000);
- }
</del><ins>+ if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
+ len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
+ } else {
+ len = 0;
+ }
</ins><span class="cx">
</span><del>- }
</del><ins>+ if (len == 320) {
+ unsigned int howmany;
</ins><span class="cx">
</span><del>- /* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */
- kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
- len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
- kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
- len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
- len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
- kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
- len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
</del><ins>+ if (samplerate_skypiax == 8000) {
+ /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
+ a = 0;
+ for (i = 0; i < len / sizeof(short); i++) {
+ srv_out[a] = srv_in[i];
+ i++;
+ a++;
+ }
+ } else if (samplerate_skypiax == 16000) {
+ /* we're NOT downsampling, srv_out will contain ALL samples from srv_in */
+ for (i = 0; i < len / sizeof(short); i++) {
+ srv_out[i] = srv_in[i];
+ }
+ } else {
+ ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
+ }
+ /* if not yet done, let's store the half incoming frame */
+ if (!tech_pvt->audiobuf_is_loaded) {
+ for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
+ tech_pvt->audiobuf[i] = srv_out[i];
+ }
+ tech_pvt->audiobuf_is_loaded = 1;
+ } else {
+ /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */
+ for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
+ totalbuf[i] = tech_pvt->audiobuf[i];
+ }
+ for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) {
+ totalbuf[i] = srv_out[a];
+ i++;
+ }
+ /* send the complete frame through the pipe to our code waiting for incoming audio */
+ howmany =
+ skypiax_pipe_write(tech_pvt->audiopipe[1], totalbuf,
+ SAMPLES_PER_FRAME * sizeof(short));
+ if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
+ ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG,
+ howmany, (int) (SAMPLES_PER_FRAME * sizeof(short)));
+ }
+ /* done with the stored half frame */
+ tech_pvt->audiobuf_is_loaded = 0;
+ }
</ins><span class="cx">
</span><del>- DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
- skypiax_close_socket(fd);
- if (exit)
- break;
</del><ins>+ } else if (len == 0) {
+ skypiax_sleep(1000);
+ } else {
+ ERRORA("len=%d, expected 320\n", SKYPIAX_P_LOG, len);
+ }
+
+ } else {
+ if (rt)
+ ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
+ skypiax_sleep(10000);
+ }
+
+ }
+
+ /* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+ len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+ len =
+ skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+ len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+ len =
+ skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
+
+ DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
+ skypiax_close_socket(fd);
+ //if (exit)
+ break;
+ }
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> DEBUGA_SKYPE("incoming audio server (I am it) EXITING\n", SKYPIAX_P_LOG);
</span><span class="lines">@@ -635,110 +641,140 @@
</span><span class="cx"> listen(s, 6);
</span><span class="cx">
</span><span class="cx"> sin_size = sizeof(remote_addr);
</span><del>- while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
- DEBUGA_SKYPE("ACCEPTED here you send me %d\n", SKYPIAX_P_LOG, tech_pvt->tcp_cli_port);
</del><ins>+
+ /****************************/
+ while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
+ && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
+ || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
+
+ unsigned int fdselectgio;
+ int rtgio;
+ fd_set fsgio;
+ struct timeval togio;
+
</ins><span class="cx"> if (!running)
</span><span class="cx"> break;
</span><del>- while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
- && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
- || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
- || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
- || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
- unsigned int fdselect;
- int rt;
- fd_set fs;
- struct timeval to;
</del><ins>+ FD_ZERO(&fsgio);
+ togio.tv_usec = 20000; //20msec
+ togio.tv_sec = 0;
+ fdselectgio = s;
+ FD_SET(fdselectgio, &fsgio);
</ins><span class="cx">
</span><del>- if (!running)
- break;
- FD_ZERO(&fs);
- to.tv_usec = 60000; //60msec
- to.tv_sec = 0;
</del><ins>+ rtgio = select(fdselectgio + 1, &fsgio, NULL, NULL, &togio);
+
+ if (rtgio) {
+
+ /****************************/
+
+ while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
+ DEBUGA_SKYPE("ACCEPTED here you send me %d\n", SKYPIAX_P_LOG,
+ tech_pvt->tcp_cli_port);
+ if (!running)
+ break;
+ while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
+ && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
+ || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
+ || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
+ unsigned int fdselect;
+ int rt;
+ fd_set fs;
+ struct timeval to;
+
+ if (!running)
+ break;
+ FD_ZERO(&fs);
+ to.tv_usec = 60000; //60msec
+ to.tv_sec = 0;
</ins><span class="cx"> #if defined(WIN32) && !defined(__CYGWIN__)
</span><span class="cx"> /* on win32 we cannot select from the apr "pipe", so we select on socket writability */
</span><del>- fdselect = fd;
- FD_SET(fdselect, &fs);
</del><ins>+ fdselect = fd;
+ FD_SET(fdselect, &fs);
</ins><span class="cx">
</span><del>- rt = select(fdselect + 1, NULL, &fs, NULL, &to);
</del><ins>+ rt = select(fdselect + 1, NULL, &fs, NULL, &to);
</ins><span class="cx"> #else
</span><span class="cx"> /* on *unix and cygwin we select from the real pipe */
</span><del>- fdselect = tech_pvt->audioskypepipe[0];
- FD_SET(fdselect, &fs);
</del><ins>+ fdselect = tech_pvt->audioskypepipe[0];
+ FD_SET(fdselect, &fs);
</ins><span class="cx">
</span><del>- rt = select(fdselect + 1, &fs, NULL, NULL, &to);
</del><ins>+ rt = select(fdselect + 1, &fs, NULL, NULL, &to);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- if (rt > 0) {
- /* read from the pipe the audio frame we are supposed to send out */
- got =
- skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in,
- SAMPLES_PER_FRAME * sizeof(short));
- if (got != SAMPLES_PER_FRAME * sizeof(short)) {
- WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
- (int) (SAMPLES_PER_FRAME * sizeof(short)));
- }
</del><ins>+ if (rt > 0) {
+ /* read from the pipe the audio frame we are supposed to send out */
+ got =
+ skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in,
+ SAMPLES_PER_FRAME * sizeof(short));
+ if (got != SAMPLES_PER_FRAME * sizeof(short)) {
+ WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
+ (int) (SAMPLES_PER_FRAME * sizeof(short)));
+ }
</ins><span class="cx">
</span><del>- if (got == SAMPLES_PER_FRAME * sizeof(short)) {
- if (samplerate_skypiax == 8000) {
</del><ins>+ if (got == SAMPLES_PER_FRAME * sizeof(short)) {
+ if (samplerate_skypiax == 8000) {
</ins><span class="cx">
</span><del>- /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */
- a = 0;
- for (i = 0; i < got / sizeof(short); i++) {
- cli_out[a] = cli_in[i];
- a++;
- cli_out[a] = cli_in[i];
- a++;
</del><ins>+ /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */
+ a = 0;
+ for (i = 0; i < got / sizeof(short); i++) {
+ cli_out[a] = cli_in[i];
+ a++;
+ cli_out[a] = cli_in[i];
+ a++;
+ }
+ got = got * 2;
+ } else if (samplerate_skypiax == 16000) {
+ /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */
+ for (i = 0; i < got / sizeof(short); i++) {
+ cli_out[i] = cli_in[i];
+ }
+ } else {
+ ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
+ }
+
+ /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
+ if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
+ len = send(fd, (char *) cli_out, got, 0);
+ skypiax_sleep(5000); //5 msec
+
+ if (len == -1) {
+ break;
+ } else if (len != got) {
+ ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+ skypiax_sleep(1000);
+ break;
+ }
+ }
+
+ } else {
+
+ WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
+ (int) (SAMPLES_PER_FRAME * sizeof(short)));
</ins><span class="cx"> }
</span><del>- got = got * 2;
- } else if (samplerate_skypiax == 16000) {
- /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */
- for (i = 0; i < got / sizeof(short); i++) {
- cli_out[i] = cli_in[i];
</del><ins>+ } else {
+ if (rt)
+ ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
+ memset(cli_out, 0, sizeof(cli_out));
+ if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
+ len = send(fd, (char *) cli_out, sizeof(cli_out), 0);
+ len = send(fd, (char *) cli_out, sizeof(cli_out) / 2, 0);
+ //WARNINGA("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2);
+ } else {
+ /*
+ XXX do nothing
+ */
+ //WARNINGA("we don't send it\n", SKYPIAX_P_LOG);
</ins><span class="cx"> }
</span><del>- } else {
- ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
</del><ins>+ skypiax_sleep(1000);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
-         if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
-                 len = send(fd, (char *) cli_out, got, 0);
-                 skypiax_sleep(5000); //5 msec
-
-                 if (len == -1) {
-                         break;
-                 } else if (len != got) {
-                         ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
-                         skypiax_sleep(1000);
-                         break;
-                 }
-         }
-
- } else {
-
- WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
- (int) (SAMPLES_PER_FRAME * sizeof(short)));
</del><span class="cx"> }
</span><del>- } else {
- if (rt)
- ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
- memset(cli_out, 0, sizeof(cli_out));
-        if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
-                len = send(fd, (char *) cli_out, sizeof(cli_out), 0);
-                len = send(fd, (char *) cli_out, sizeof(cli_out) / 2, 0);
-                //WARNINGA("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2);
-        } else {
-                /*
-                 XXX do nothing
-                 */
-                //WARNINGA("we don't send it\n", SKYPIAX_P_LOG);
-        }
- skypiax_sleep(1000);
</del><ins>+ DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
+ skypiax_close_socket(fd);
+ break;
</ins><span class="cx"> }
</span><del>-
</del><span class="cx"> }
</span><del>- DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
- skypiax_close_socket(fd);
- break;
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> DEBUGA_SKYPE("outbound audio server (I am it) EXITING\n", SKYPIAX_P_LOG);
</span><span class="lines">@@ -783,10 +819,10 @@
</span><span class="cx">
</span><span class="cx"> skypiax_sleep(5000);
</span><span class="cx"> DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
</span><del>- skypiax_signaling_write(tech_pvt, "SET AGC OFF");
- skypiax_sleep(10000);
- skypiax_signaling_write(tech_pvt, "SET AEC OFF");
- skypiax_sleep(10000);
</del><ins>+ //skypiax_signaling_write(tech_pvt, "SET AGC OFF");
+ //skypiax_sleep(10000);
+ //skypiax_signaling_write(tech_pvt, "SET AEC OFF");
+ //skypiax_sleep(10000);
</ins><span class="cx">
</span><span class="cx"> sprintf(msg_to_skype, "CALL %s", rdest);
</span><span class="cx"> if (skypiax_signaling_write(tech_pvt, msg_to_skype) < 0) {
</span><span class="lines">@@ -1022,8 +1058,8 @@
</span><span class="cx"> #if 0
</span><span class="cx"> if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
</span><span class="cx"> SendMessage(HWND_BROADCAST,
</span><del>- tech_pvt->
- SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
</del><ins>+ tech_pvt->SkypiaxHandles.
+ win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
</ins><span class="cx"> (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
</span><span class="cx"> 0);
</span><span class="cx"> }
</span><span class="lines">@@ -1041,8 +1077,8 @@
</span><span class="cx"> #if 0
</span><span class="cx"> if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
</span><span class="cx"> SendMessage(HWND_BROADCAST,
</span><del>- tech_pvt->
- SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
</del><ins>+ tech_pvt->SkypiaxHandles.
+ win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
</ins><span class="cx"> (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
</span><span class="cx"> 0);
</span><span class="cx"> }
</span><span class="lines">@@ -1155,7 +1191,7 @@
</span><span class="cx"> tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
</span><span class="cx"> RegisterWindowMessage("SkypeControlAPIDiscover");
</span><span class="cx">
</span><del>- skypiax_sleep(200000); //0,2 sec
</del><ins>+ skypiax_sleep(200000); //0,2 sec
</ins><span class="cx">
</span><span class="cx"> if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
</span><span class="cx"> && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
</span><span class="lines">@@ -1410,7 +1446,7 @@
</span><span class="cx"> char buffer[17000];
</span><span class="cx"> char *b;
</span><span class="cx"> int i;
</span><del>- int continue_is_broken=0;
</del><ins>+ int continue_is_broken = 0;
</ins><span class="cx"> Atom atom_begin = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
</span><span class="cx"> Atom atom_continue = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
</span><span class="cx">
</span><span class="lines">@@ -1431,43 +1467,47 @@
</span><span class="cx">
</span><span class="cx"> buf[i] = '\0';
</span><span class="cx">
</span><del>- DEBUGA_SKYPE ("BUF=|||%s|||\n", SKYPIAX_P_LOG, buf);
</del><ins>+ //DEBUGA_SKYPE ("BUF=|||%s|||\n", SKYPIAX_P_LOG, buf);
</ins><span class="cx">
</span><del>-        if(an_event.xclient.message_type == atom_begin){
</del><ins>+ if (an_event.xclient.message_type == atom_begin) {
</ins><span class="cx">
</span><del>-                if(strlen(buffer)){
-                        unsigned int howmany;
-                        howmany = strlen(b) + 1;
-                        howmany = write(SkypiaxHandles->fdesc[1], b, howmany);
-                        DEBUGA_SKYPE ("RECEIVED2=|||%s|||\n", SKYPIAX_P_LOG, buffer);
-                        memset(buffer, '\0', 17000);
-                }
-        }
-        if(an_event.xclient.message_type == atom_continue){
</del><ins>+ if (strlen(buffer)) {
+ unsigned int howmany;
+ howmany = strlen(b) + 1;
+ howmany = write(SkypiaxHandles->fdesc[1], b, howmany);
+ DEBUGA_SKYPE("RECEIVED2=|||%s|||\n", SKYPIAX_P_LOG, buffer);
+ memset(buffer, '\0', 17000);
+ }
+ }
+ if (an_event.xclient.message_type == atom_continue) {
</ins><span class="cx">
</span><del>-                if(!strlen(buffer)){
-                        DEBUGA_SKYPE("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||\n", SKYPIAX_P_LOG, buf);
-                        continue_is_broken=1;
-                        if(!strncmp(buf, "ognised identity", 15)) {
-                                WARNINGA("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n", SKYPIAX_P_LOG, buf);
-                                skypiax_sleep(1000000); //1 sec
-                        }
-                        break;
-                }
-        }
-
</del><ins>+ if (!strlen(buffer)) {
+ DEBUGA_SKYPE
+ ("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||\n",
+ SKYPIAX_P_LOG, buf);
+ continue_is_broken = 1;
+ if (!strncmp(buf, "ognised identity", 15)) {
+ WARNINGA
+ ("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n",
+ SKYPIAX_P_LOG, buf);
+ skypiax_sleep(1000000); //1 sec
+ }
+ break;
+ }
+ }
+
</ins><span class="cx"> strcat(buffer, buf);
</span><span class="cx">
</span><del>- if (i < 20 || continue_is_broken) { /* last fragment */
</del><ins>+ if (i < 20 || continue_is_broken) { /* last fragment */
</ins><span class="cx"> unsigned int howmany;
</span><span class="cx">
</span><span class="cx"> howmany = strlen(b) + 1;
</span><span class="cx">
</span><span class="cx"> howmany = write(SkypiaxHandles->fdesc[1], b, howmany);
</span><del>- DEBUGA_SKYPE ("RECEIVED=|||%s|||\n", SKYPIAX_P_LOG, buffer);
</del><ins>+ //DEBUGA_SKYPE ("RECEIVED=|||%s|||\n", SKYPIAX_P_LOG, buffer);
</ins><span class="cx"> memset(buffer, '\0', 17000);
</span><span class="cx"> XFlush(disp);
</span><del>- continue_is_broken=0;
</del><ins>+ continue_is_broken = 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> break;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>