<!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][14709] </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=14709">14709</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2009-09-01 04:43:29 -0500 (Tue, 01 Sep 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>celliax: begin cleaning</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchbranchesgmaruzzmod_celliaxcelliax_protocolc">freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c</a></li>
<li><a href="#freeswitchbranchesgmaruzzmod_celliaxmod_celliaxc">freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchbranchesgmaruzzmod_celliaxcelliax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c (14708 => 14709)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c        2009-09-01 09:36:52 UTC (rev 14708)
+++ freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c        2009-09-01 09:43:29 UTC (rev 14709)
</span><span class="lines">@@ -19,1356 +19,8 @@
</span><span class="cx">
</span><span class="cx"> int option_debug = 100;
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-/*************************************/
-/* suspicious globals FIXME */
-#ifdef WIN32
-DWORD win32_dwThreadId;
-#else
-XErrorHandler old_handler = 0;
-int xerror = 0;
-#endif /* WIN32 */
-/*************************************/
</del><span class="cx">
</span><del>-int celliax_socket_create_and_bind(private_t * tech_pvt, int *which_port)
-{
-        int s = -1;
-        struct sockaddr_in my_addr;
-        int start_port = 6001;
</del><span class="cx">
</span><del>-        memset(&my_addr, 0, sizeof(my_addr));
-        my_addr.sin_family = AF_INET;
-        my_addr.sin_addr.s_addr = htonl(0x7f000001);        /* use the localhost */
-
-        if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-                ERRORA("socket Error\n", SKYPIAX_P_LOG);
-                return -1;
-        }
-
-        if (*which_port != 0)
-                start_port = *which_port;
-
-        my_addr.sin_port = htons(start_port);
-        //tech_pvt->tcp_cli_port = start_port;
-        *which_port = start_port;
-        while (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
-                DEBUGA_SKYPE("*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,
-                                         tech_pvt->tcp_srv_port);
-                DEBUGA_SKYPE("bind errno=%d, error: %s\n", SKYPIAX_P_LOG, errno, strerror(errno));
-                start_port++;
-                my_addr.sin_port = htons(start_port);
-                *which_port = start_port;
-                DEBUGA_SKYPE("*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,
-                                         tech_pvt->tcp_srv_port);
-
-                if (start_port > 65000) {
-                        ERRORA("NO MORE PORTS! *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, tech_pvt->tcp_srv_port);
-                        return -1;
-                }
-        }
-
-        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,
-                                 tech_pvt->tcp_srv_port);
-        return s;
-}
-
-#ifdef NOTDEF
-int celliax_signaling_read(private_t * tech_pvt)
-{
-        char read_from_pipe[4096];
-        char message[4096];
-        char message_2[4096];
-        char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
-        char **stringp = NULL;
-        int a;
-        unsigned int howmany;
-        unsigned int i;
-
-        memset(read_from_pipe, 0, 4096);
-        memset(message, 0, 4096);
-        memset(message_2, 0, 4096);
-
-        howmany = celliax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe, sizeof(read_from_pipe));
-
-        a = 0;
-        for (i = 0; i < howmany; i++) {
-                message[a] = read_from_pipe[i];
-                a++;
-
-                if (read_from_pipe[i] == '\0') {
-
-                        //if (!strstr(message, "DURATION")) {
-                        DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
-                        //}
-
-                        if (!strcasecmp(message, "ERROR 68")) {
-                                DEBUGA_SKYPE
-                                        ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
-                                         SKYPIAX_P_LOG);
-                                celliax_sleep(1000000);
-                                celliax_signaling_write(tech_pvt, "PROTOCOL 7");
-                                celliax_sleep(10000);
-                                return 0;
-                        }
-                        if (!strncasecmp(message, "ERROR 92 CALL", 12)) {
-                                ERRORA("Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\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';
-
-                                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;
-                                }
-                        }
-
-                        if (!strncasecmp(message, "ERROR", 4)) {
-                                if (!strncasecmp(message, "ERROR 96 CALL", 12)) {
-                                        DEBUGA_SKYPE
-                                                ("Skype got ERROR: |||%s|||, we are trying to use this interface to make or receive a call, but another call is half-active on this interface. Let's the previous one to continue.\n",
-                                                 SKYPIAX_P_LOG, message);
-                                } else if (!strncasecmp(message, "ERROR 99 CALL", 12)) {
-                                        ERRORA("Skype got ERROR: |||%s|||, another call is active on this interface\n\n\n", SKYPIAX_P_LOG, message);
-                                        tech_pvt->interface_state = SKYPIAX_STATE_ERROR_DOUBLE_CALL;
-                                } else if (!strncasecmp(message, "ERROR 592 ALTER CALL", 19)) {
-                                        ERRORA("Skype got ERROR about TRANSFERRING, no problem: |||%s|||\n", SKYPIAX_P_LOG, message);
-                                } else if (!strncasecmp(message, "ERROR 559 CALL", 13)) {
-                                        DEBUGA_SKYPE("Skype got ERROR about a failed action (probably TRYING to HANGUP A CALL), no problem: |||%s|||\n", SKYPIAX_P_LOG, message);
-                                } else {
-                                        ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
-                                        tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
-                                        ERRORA("skype_call now is DOWN\n", SKYPIAX_P_LOG);
-                                        tech_pvt->skype_call_id[0] = '\0';
-
-                                        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;
-                                        }
-                                }
-                        }
-
-
-
-
-                        celliax_strncpy(message_2, message, sizeof(message) - 1);
-                        buf = message;
-                        stringp = &buf;
-                        where = strsep(stringp, " ");
-                        if (!where) {
-                                WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message);
-                        }
-
-
-
-
-
-
-
-
-                        if (!strcasecmp(message, "CURRENTUSERHANDLE")) {
-                                celliax_strncpy(obj, where, sizeof(obj) - 1);
-                                where = strsep(stringp, " ");
-                                celliax_strncpy(id, where, sizeof(id) - 1);
-                                if (!strcasecmp(id, tech_pvt->skype_user)) {
-                                        tech_pvt->SkypiaxHandles.currentuserhandle = 1;
-                                        DEBUGA_SKYPE
-                                                ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user);
-                                }
-                        }
-                        if (!strcasecmp(message, "USER")) {
-                                celliax_strncpy(obj, where, sizeof(obj) - 1);
-                                where = strsep(stringp, " ");
-                                celliax_strncpy(id, where, sizeof(id) - 1);
-                                where = strsep(stringp, " ");
-                                celliax_strncpy(prop, where, sizeof(prop) - 1);
-                                if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
-                                        char msg_to_skype[256];
-                                        DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", SKYPIAX_P_LOG, message, obj, id, prop);
-                                        //TODO: allow authorization based on config param
-                                        sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
-                                        celliax_signaling_write(tech_pvt, msg_to_skype);
-                                }
-                        }
-                        if (!strcasecmp(message, "MESSAGE")) {
-                                celliax_strncpy(obj, where, sizeof(obj) - 1);
-                                where = strsep(stringp, " ");
-                                celliax_strncpy(id, where, sizeof(id) - 1);
-                                where = strsep(stringp, " ");
-                                celliax_strncpy(prop, where, sizeof(prop) - 1);
-                                if (!strcasecmp(prop, "STATUS")) {
-                                        where = strsep(stringp, " ");
-                                        celliax_strncpy(value, where, sizeof(value) - 1);
-                                        if (!strcasecmp(value, "RECEIVED")) {
-                                                char msg_to_skype[256];
-                                                DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n", SKYPIAX_P_LOG, message, obj, id, prop, value);
-                                                //TODO: authomatically flag messages as read based on config param
-                                                sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
-                                                celliax_signaling_write(tech_pvt, msg_to_skype);
-                                        }
-                                } else if (!strcasecmp(prop, "BODY")) {
-                                        char msg_to_skype[256];
-                                        DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", SKYPIAX_P_LOG, message, obj, id, prop);
-                                        //TODO: authomatically flag messages as read based on config param
-                                        sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
-                                        celliax_signaling_write(tech_pvt, msg_to_skype);
-                                }
-                        }
-                        if (!strcasecmp(message, "CALL")) {
-                                celliax_strncpy(obj, where, sizeof(obj) - 1);
-                                where = strsep(stringp, " ");
-                                celliax_strncpy(id, where, sizeof(id) - 1);
-                                where = strsep(stringp, " ");
-                                celliax_strncpy(prop, where, sizeof(prop) - 1);
-                                where = strsep(stringp, " ");
-                                celliax_strncpy(value, where, sizeof(value) - 1);
-                                where = strsep(stringp, " ");
-
-                                //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");
-
-                                if (!strcasecmp(prop, "PARTNER_HANDLE")) {
-                                        if (tech_pvt->interface_state != SKYPIAX_STATE_SELECTED && (!strlen(tech_pvt->skype_call_id) || !strlen(tech_pvt->session_uuid_str))) {
-                                                //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);
-                                                celliax_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 DO NOTHING\n", SKYPIAX_P_LOG, id);
-                                                } else {
-                                                        celliax_sleep(400000);        //0.4 seconds
-                                                        DEBUGA_SKYPE("Call %s TRY TRANSFER\n", SKYPIAX_P_LOG, id);
-                                                        celliax_transfer(tech_pvt, id, value);
-                                                }
-                                        }
-                                }
-                                if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
-                                        snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s", value, where ? " " : "", where ? where : "");
-                                        //DEBUGA_SKYPE
-                                        //("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
-                                        //SKYPIAX_P_LOG, id, tech_pvt->callid_name);
-                                }
-                                if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
-                                        //DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG, id);
-                                        //if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
-                                        //tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
-                                }
-                                if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
-                                        DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
-                                        //if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
-                                        //tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
-                                }
-                                if (!strcasecmp(prop, "DTMF")) {
-                                        DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
-                                        dtmf_received(tech_pvt, value);
-                                }
-                                if (!strcasecmp(prop, "FAILUREREASON")) {
-                                        DEBUGA_SKYPE("Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n", SKYPIAX_P_LOG, id);
-                                }
-                                if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
-                                        if (strcasecmp(id, tech_pvt->skype_call_id)) {
-                                                celliax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
-                                                DEBUGA_SKYPE("We called a Skype contact and he answered us on skype_call: %s.\n", SKYPIAX_P_LOG, id);
-                                        }
-                                }
-
-                                if (!strcasecmp(prop, "DURATION") && (tech_pvt->interface_state == SKYPIAX_STATE_ERROR_DOUBLE_CALL)) {
-                                        char msg_to_skype[1024];
-                                        celliax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
-                                        ERRORA("We are in a double call situation, trying to get out hanging up call id: %s.\n", SKYPIAX_P_LOG, id);
-                                        sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id);
-                                        celliax_signaling_write(tech_pvt, msg_to_skype);
-                                        celliax_sleep(10000);
-                                        //return CALLFLOW_INCOMING_HANGUP;
-                                }
-
-                                if (!strcasecmp(prop, "STATUS")) {
-
-                                        if (!strcasecmp(value, "RINGING")) {
-                                                char msg_to_skype[1024];
-                                                if ((tech_pvt->interface_state != SKYPIAX_STATE_SELECTED && tech_pvt->interface_state != SKYPIAX_STATE_DIALING)
-                                                        && (!strlen(tech_pvt->skype_call_id) || !strlen(tech_pvt->session_uuid_str))) {
-                                                        /* we are NOT inside an active call */
-
-                                                        DEBUGA_SKYPE("NO ACTIVE calls in this moment, skype_call %s is RINGING, to ask PARTNER_HANDLE\n", SKYPIAX_P_LOG, id);
-                                                        sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
-                                                        celliax_signaling_write(tech_pvt, msg_to_skype);
-                                                        celliax_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 */
-                                                                tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
-                                                                tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
-                                                                celliax_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);
-                                                        } else {
-                                                                DEBUGA_SKYPE
-                                                                        ("We are in another call, but skype_call %s is RINGING on us, let's ask PARTNER_HANDLE, so maybe we'll TRANSFER\n",
-                                                                         SKYPIAX_P_LOG, id);
-                                                                sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
-                                                                celliax_signaling_write(tech_pvt, msg_to_skype);
-                                                                celliax_sleep(10000);
-                                                        }
-                                                }
-                                        } else if (!strcasecmp(value, "EARLYMEDIA")) {
-                                                char msg_to_skype[1024];
-                                                tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
-                                                tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
-                                                DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG, id);
-                                                if (start_audio_threads(tech_pvt)) {
-                                                        ERRORA("start_audio_threads FAILED\n", SKYPIAX_P_LOG);
-                                                        return CALLFLOW_INCOMING_HANGUP;
-                                                }
-                                                celliax_sleep(1000);
-                                                sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, tech_pvt->tcp_cli_port);
-                                                celliax_signaling_write(tech_pvt, msg_to_skype);
-                                                sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, tech_pvt->tcp_srv_port);
-                                                celliax_signaling_write(tech_pvt, msg_to_skype);
-
-                                                remote_party_is_early_media(tech_pvt);
-                                        } else if (!strcasecmp(value, "MISSED")) {
-                                                DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
-                                        } else if (!strcasecmp(value, "FINISHED")) {
-                                                //DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
-                                                if (!strcasecmp(tech_pvt->skype_call_id, id)) {
-                                                        //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
-                                                        DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n", SKYPIAX_P_LOG, id);
-                                                        //tech_pvt->skype_call_id[0] = '\0';
-                                                        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;
-                                                        }
-                                                } else {
-                                                        DEBUGA_SKYPE("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id);
-                                                }
-
-                                        } else if (!strcasecmp(value, "CANCELLED")) {
-                                                tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
-                                                DEBUGA_SKYPE("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", SKYPIAX_P_LOG, id);
-                                                tech_pvt->skype_call_id[0] = '\0';
-                                                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;
-                                                }
-                                        } else if (!strcasecmp(value, "FAILED")) {
-                                                tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
-                                                DEBUGA_SKYPE("we tried to call Skype on skype_call %s and Skype has now FAILED\n", SKYPIAX_P_LOG, id);
-                                                tech_pvt->skype_call_id[0] = '\0';
-                                                celliax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
-                                                tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-                                                return CALLFLOW_INCOMING_HANGUP;
-                                        } else if (!strcasecmp(value, "REFUSED")) {
-                                                if (!strcasecmp(id, tech_pvt->skype_call_id)) {
-                                                        /* this is the id of the call we are in, probably we generated it */
-                                                        tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
-                                                        DEBUGA_SKYPE("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", SKYPIAX_P_LOG, id);
-                                                        celliax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
-                                                        tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-                                                        tech_pvt->skype_call_id[0] = '\0';
-                                                        return CALLFLOW_INCOMING_HANGUP;
-                                                } else {
-                                                        /* we're here because were us that refused an incoming call */
-                                                        DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
-                                                }
-                                        } else if (!strcasecmp(value, "TRANSFERRING")) {
-                                                DEBUGA_SKYPE("skype_call %s is transferring\n", SKYPIAX_P_LOG, id);
-                                        } else if (!strcasecmp(value, "TRANSFERRED")) {
-                                                DEBUGA_SKYPE("skype_call %s has been transferred\n", SKYPIAX_P_LOG, id);
-                                        } else if (!strcasecmp(value, "ROUTING")) {
-                                                tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
-                                                tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
-                                                celliax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
-                                                DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id);
-                                        } else if (!strcasecmp(value, "UNPLACED")) {
-                                                tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED;
-                                                tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
-                                                celliax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
-                                                DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
-                                        } else if (!strcasecmp(value, "INPROGRESS")) {
-                                                char msg_to_skype[1024];
-
-                                                if (!strlen(tech_pvt->session_uuid_str)) {
-                                                        DEBUGA_SKYPE("no tech_pvt->session_uuid_str\n", SKYPIAX_P_LOG);
-                                                }
-                                                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)) {
-                                                                celliax_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);
-
-                                                                if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
-                                                                        tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
-                                                                        tech_pvt->interface_state = SKYPIAX_STATE_UP;
-
-                                                                        if (start_audio_threads(tech_pvt)) {
-                                                                                ERRORA("start_audio_threads FAILED\n", SKYPIAX_P_LOG);
-                                                                                return CALLFLOW_INCOMING_HANGUP;
-                                                                        }
-                                                                        celliax_sleep(1000);        //FIXME
-                                                                        sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, tech_pvt->tcp_cli_port);
-                                                                        celliax_signaling_write(tech_pvt, msg_to_skype);
-                                                                        celliax_sleep(1000);        //FIXME
-                                                                        sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, tech_pvt->tcp_srv_port);
-                                                                        celliax_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\n\n\n", SKYPIAX_P_LOG);
-                                                                        celliax_answer(tech_pvt);
-                                                                } else {
-                                                                        DEBUGA_SKYPE("Outbound Channel Answered! session_uuid_str=%s\n", SKYPIAX_P_LOG, tech_pvt->session_uuid_str);
-                                                                        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;
-                                                        DEBUGA_SKYPE("Back from REMOTEHOLD!\n", SKYPIAX_P_LOG);
-                                                }
-
-                                        } else if (!strcasecmp(value, "REMOTEHOLD")) {
-                                                tech_pvt->skype_callflow = CALLFLOW_STATUS_REMOTEHOLD;
-                                                DEBUGA_SKYPE("skype_call: %s is now REMOTEHOLD\n", SKYPIAX_P_LOG, id);
-
-                                        } else if (!strcasecmp(value, "BUSY")) {
-                                                tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
-                                                DEBUGA_SKYPE
-                                                        ("we tried to call Skype on skype_call %s and remote party (destination) was BUSY. Our outbound call has failed\n",
-                                                         SKYPIAX_P_LOG, id);
-                                                celliax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
-                                                tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-                                                tech_pvt->skype_call_id[0] = '\0';
-                                                celliax_sleep(1000);
-                                                return CALLFLOW_INCOMING_HANGUP;
-                                        } else if (!strcasecmp(value, "WAITING_REDIAL_COMMAND")) {
-                                                tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
-                                                DEBUGA_SKYPE
-                                                        ("we tried to call Skype on skype_call %s and remote party (destination) has rejected us (WAITING_REDIAL_COMMAND). Our outbound call has failed\n",
-                                                         SKYPIAX_P_LOG, id);
-                                                celliax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
-                                                tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-                                                tech_pvt->skype_call_id[0] = '\0';
-                                                celliax_sleep(1000);
-                                                return CALLFLOW_INCOMING_HANGUP;
-                                        } else {
-                                                WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id, value);
-                                        }
-                                }                                //STATUS
-                        }                                        //CALL
-                        /* the "numbered" messages that follows are used by the directory application, not yet ported */
-                        if (!strcasecmp(message, "#333")) {
-                                /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
-                                 * message_2, &message_2[11]); */
-                                memset(tech_pvt->skype_friends, 0, 4096);
-                                celliax_strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
-                        }
-                        if (!strcasecmp(message, "#222")) {
-                                /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
-                                 * message_2, &message_2[10]); */
-                                memset(tech_pvt->skype_fullname, 0, 512);
-                                celliax_strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
-                        }
-                        if (!strcasecmp(message, "#765")) {
-                                /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
-                                 * message_2, &message_2[10]); */
-                                memset(tech_pvt->skype_displayname, 0, 512);
-                                celliax_strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
-                        }
-                        a = 0;
-                }                                                //message end
-        }                                                        //read_from_pipe
-        return 0;
-}
-#endif // NOTDEF
-
-void *celliax_do_tcp_srv_thread_func(void *obj)
-{
-        private_t *tech_pvt = obj;
-        int s;
-        unsigned int len;
-        unsigned int i;
-        unsigned int a;
-#if defined(WIN32) && !defined(__CYGWIN__)
-        int sin_size;
-#else /* WIN32 */
-        unsigned int sin_size;
-#endif /* WIN32 */
-        unsigned int fd;
-        short srv_in[SAMPLES_PER_FRAME];
-        short srv_out[SAMPLES_PER_FRAME / 2];
-        //struct sockaddr_in my_addr;
-        struct sockaddr_in remote_addr;
-        //int exit = 0;
-        unsigned int kill_cli_size;
-        short kill_cli_buff[SAMPLES_PER_FRAME];
-        short totalbuf[SAMPLES_PER_FRAME];
-
-        s = celliax_socket_create_and_bind(tech_pvt, &tech_pvt->tcp_srv_port);
-        if (s < 0) {
-                ERRORA("celliax_socket_create_and_bind error!\n", SKYPIAX_P_LOG);
-                return NULL;
-        }
-        DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-
-        listen(s, 6);
-
-        sin_size = sizeof(remote_addr);
-
- /****************************/
-        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;
-
-                if (!(running && tech_pvt->running))
-                        break;
-                FD_ZERO(&fsgio);
-                togio.tv_usec = 20000;        //20msec
-                togio.tv_sec = 0;
-                fdselectgio = s;
-                FD_SET(fdselectgio, &fsgio);
-
-                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 I send you %d\n", SKYPIAX_P_LOG, tech_pvt->tcp_srv_port);
-                                if (!(running && tech_pvt->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 && tech_pvt->running))
-                                                break;
-                                        //exit = 1;
-
-                                        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;
-
-                                        rt = select(fdselect + 1, &fs, NULL, NULL, &to);
-                                        if (rt > 0) {
-
-                                                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;
-                                                }
-
-                                                if (len == 320) {
-                                                        unsigned int howmany;
-
-                                                        if (samplerate_celliax == 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_celliax == 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 = celliax_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;
-                                                        }
-
-                                                } else if (len == 0) {
-                                                        celliax_sleep(1000);
-                                                } else {
-                                                        DEBUGA_SKYPE("len=%d, expected 320\n", SKYPIAX_P_LOG, len);
-                                                }
-
-                                        } else {
-                                                if (rt)
-                                                        ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
-                                                celliax_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 = celliax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
-                                kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-                                len = celliax_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 = celliax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
-                                kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-                                len = celliax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
-
-                                DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
-                                celliax_close_socket(fd);
-                                //if (exit)
-                                break;
-                        }
-                }
-        }
-
-        DEBUGA_SKYPE("incoming audio server (I am it) EXITING\n", SKYPIAX_P_LOG);
-        celliax_close_socket(s);
-        tech_pvt->tcp_srv_thread = NULL;
-        return NULL;
-}
-
-void *celliax_do_tcp_cli_thread_func(void *obj)
-{
-        private_t *tech_pvt = obj;
-        int s;
-        //struct sockaddr_in my_addr;
-        struct sockaddr_in remote_addr;
-        unsigned int got;
-        unsigned int len;
-        unsigned int i;
-        unsigned int a;
-        unsigned int fd;
-        short cli_out[SAMPLES_PER_FRAME * 2];
-        short cli_in[SAMPLES_PER_FRAME];
-#ifdef WIN32
-        int sin_size;
-#else
-        unsigned int sin_size;
-#endif /* WIN32 */
-
-        s = celliax_socket_create_and_bind(tech_pvt, &tech_pvt->tcp_cli_port);
-        if (s < 0) {
-                ERRORA("celliax_socket_create_and_bind error!\n", SKYPIAX_P_LOG);
-                return NULL;
-        }
-
-
-
-        DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-
-        listen(s, 6);
-
-        sin_size = sizeof(remote_addr);
-
- /****************************/
-        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;
-
-                if (!(running && tech_pvt->running))
-                        break;
-                FD_ZERO(&fsgio);
-                togio.tv_usec = 20000;        //20msec
-                togio.tv_sec = 0;
-                fdselectgio = s;
-                FD_SET(fdselectgio, &fsgio);
-
-                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);
-#ifndef WIN32
-                                fcntl(tech_pvt->audioskypepipe[0], F_SETFL, O_NONBLOCK);
-                                fcntl(tech_pvt->audioskypepipe[1], F_SETFL, O_NONBLOCK);
-#endif //WIN32
-
-                                if (!(running && tech_pvt->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 && tech_pvt->running))
-                                                break;
-                                        FD_ZERO(&fs);
-                                        to.tv_usec = 120000;        //120msec
-                                        to.tv_sec = 0;
-#if defined(WIN32) && !defined(__CYGWIN__)
-/* on win32 we cannot select from the apr "pipe", so we select on socket writability */
-                                        fdselect = fd;
-                                        FD_SET(fdselect, &fs);
-
-                                        rt = select(fdselect + 1, NULL, &fs, NULL, &to);
-#else
-/* on *unix and cygwin we select from the real pipe */
-                                        fdselect = tech_pvt->audioskypepipe[0];
-                                        FD_SET(fdselect, &fs);
-
-                                        rt = select(fdselect + 1, &fs, NULL, NULL, &to);
-#endif
-
-                                        if (rt > 0) {
-                                                int counter;
-
-                                                /* until we drained the pipe to empty */
-                                                for (counter = 0; counter < 10; counter++) {
-                                                        /* read from the pipe the audio frame we are supposed to send out */
-                                                        got = celliax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, SAMPLES_PER_FRAME * sizeof(short));
-                                                        if (got == -1)
-                                                                break;
-
-                                                        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)));
-                                                        }
-
-                                                        if (got == SAMPLES_PER_FRAME * sizeof(short)) {
-                                                                if (samplerate_celliax == 8000) {
-
-                                                                        /* 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_celliax == 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);
-                                                                        celliax_sleep(5000);        //5 msec
-
-                                                                        if (len == -1) {
-                                                                                break;
-                                                                        } else if (len != got) {
-                                                                                ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
-                                                                                celliax_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)));
-                                                        }
-                                                }
-                                        } 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);
-                                                }
-                                                celliax_sleep(1000);
-                                        }
-
-                                }
-                                DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
-                                celliax_close_socket(fd);
-                                break;
-                        }
-                }
-        }
-
-        DEBUGA_SKYPE("outbound audio server (I am it) EXITING\n", SKYPIAX_P_LOG);
-        celliax_close_socket(s);
-        tech_pvt->tcp_cli_thread = NULL;
-        return NULL;
-}
-
-int celliax_audio_read(private_t * tech_pvt)
-{
-        unsigned int samples;
-
-        samples = celliax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short));
-
-        if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
-                if (samples)
-                        WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, (int) (SAMPLES_PER_FRAME * sizeof(short)));
-                return 0;
-        } else {
-                /* A real frame */
-                tech_pvt->read_frame.datalen = samples;
-        }
-        return 1;
-}
-
-/***************************/
-/* PLATFORM SPECIFIC */
-/***************************/
-#if defined(WIN32) && !defined(__CYGWIN__)
-int celliax_pipe_read(switch_file_t *pipe, short *buf, int howmany)
-{
-        switch_size_t quantity;
-
-        quantity = howmany;
-
-        switch_file_read(pipe, buf, &quantity);
-
-        howmany = quantity;
-
-        return howmany;
-}
-
-int celliax_pipe_write(switch_file_t *pipe, short *buf, int howmany)
-{
-        switch_size_t quantity;
-
-        quantity = howmany;
-
-        switch_file_write(pipe, buf, &quantity);
-
-        howmany = quantity;
-
-        return howmany;
-}
-
-int celliax_close_socket(unsigned int fd)
-{
-        int res;
-
-        res = closesocket(fd);
-
-        return res;
-}
-
-int celliax_audio_init(private_t * tech_pvt)
-{
-        switch_status_t rv;
-        rv = switch_file_pipe_create(&tech_pvt->audiopipe[0], &tech_pvt->audiopipe[1], celliax_module_pool);
-        rv = switch_file_pipe_create(&tech_pvt->audioskypepipe[0], &tech_pvt->audioskypepipe[1], celliax_module_pool);
-        return 0;
-}
-#else /* WIN32 */
-int celliax_pipe_read(int pipe, short *buf, int howmany)
-{
-        howmany = read(pipe, buf, howmany);
-        return howmany;
-}
-
-int celliax_pipe_write(int pipe, short *buf, int howmany)
-{
-        howmany = write(pipe, buf, howmany);
-        return howmany;
-}
-
-int celliax_close_socket(unsigned int fd)
-{
-        int res;
-
-        res = close(fd);
-
-        return res;
-}
-
-int celliax_audio_init(private_t * tech_pvt)
-{
-        if (pipe(tech_pvt->audiopipe)) {
-                fcntl(tech_pvt->audiopipe[0], F_SETFL, O_NONBLOCK);
-                fcntl(tech_pvt->audiopipe[1], F_SETFL, O_NONBLOCK);
-        }
-        if (pipe(tech_pvt->audioskypepipe)) {
-                fcntl(tech_pvt->audioskypepipe[0], F_SETFL, O_NONBLOCK);
-                fcntl(tech_pvt->audioskypepipe[1], F_SETFL, O_NONBLOCK);
-        }
-
-/* this pipe is the audio fd for asterisk to poll on during a call. FS do not use it */
-        tech_pvt->celliax_sound_capt_fd = tech_pvt->audiopipe[0];
-
-        return 0;
-}
-#endif /* WIN32 */
-
-#ifdef WIN32
-
-enum {
-        SKYPECONTROLAPI_ATTACH_SUCCESS = 0,        /* Client is successfully
-                                                                                 attached and API window handle can be found
-                                                                                 in wParam parameter */
-        SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1,        /* Skype has acknowledged
-                                                                                                                 connection request and is waiting
-                                                                                                                 for confirmation from the user. */
-        /* The client is not yet attached
-         * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */
-        SKYPECONTROLAPI_ATTACH_REFUSED = 2,        /* User has explicitly
-                                                                                 denied access to client */
-        SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3,        /* API is not available
-                                                                                                 at the moment.
-                                                                                                 For example, this happens when no user
-                                                                                                 is currently logged in. */
-        /* Client should wait for
-         * SKYPECONTROLAPI_ATTACH_API_AVAILABLE
-         * broadcast before making any further */
-        /* connection attempts. */
-        SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
-};
-
-/* Visual C do not have strsep? */
-char
- *strsep(char **stringp, const char *delim)
-{
-        char *res;
-
-        if (!stringp || !*stringp || !**stringp)
-                return (char *) 0;
-
-        res = *stringp;
-        while (**stringp && !strchr(delim, **stringp))
-                ++(*stringp);
-
-        if (**stringp) {
-                **stringp = '\0';
-                ++(*stringp);
-        }
-
-        return res;
-}
-
-int celliax_signaling_write(private_t * tech_pvt, char *msg_to_skype)
-{
-        static char acInputRow[1024];
-        COPYDATASTRUCT oCopyData;
-
-        DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
-
-        sprintf(acInputRow, "%s", msg_to_skype);
-        DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow);
-        /* send command to skype */
-        oCopyData.dwData = 0;
-        oCopyData.lpData = acInputRow;
-        oCopyData.cbData = strlen(acInputRow) + 1;
-        if (oCopyData.cbData != 1) {
-                if (SendMessage
-                        (tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA,
-                         (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, (LPARAM) & oCopyData) == FALSE) {
-                        ERRORA("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then launch Skypiax and try again.\n", SKYPIAX_P_LOG);
-                        return -1;
-                }
-        }
-
-        return 0;
-
-}
-
-LRESULT APIENTRY celliax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, LPARAM ulParam)
-{
-        LRESULT lReturnCode;
-        int fIssueDefProc;
-        private_t *tech_pvt = NULL;
-
-        lReturnCode = 0;
-        fIssueDefProc = 0;
-        tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA);
-        if (!running)
-                return lReturnCode;
-        switch (uiMessage) {
-        case WM_CREATE:
-                tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams;
-                SetWindowLong(hWindow, GWL_USERDATA, (LONG) tech_pvt);
-                DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG);
-                break;
-        case WM_DESTROY:
-                DEBUGA_SKYPE("got DESTROY\n", SKYPIAX_P_LOG);
-                tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
-                PostQuitMessage(0);
-                break;
-        case WM_COPYDATA:
-                if (tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
-                        unsigned int howmany;
-                        char msg_from_skype[2048];
-
-                        PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
-
-                        memset(msg_from_skype, '\0', sizeof(msg_from_skype));
-                        celliax_strncpy(msg_from_skype, (const char *) poCopyData->lpData, sizeof(msg_from_skype) - 2);
-
-                        howmany = strlen(msg_from_skype) + 1;
-                        howmany = celliax_pipe_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype, howmany);
-                        //DEBUGA_SKYPE("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype);
-                        lReturnCode = 1;
-                }
-                break;
-        default:
-                if (tech_pvt && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
-                        if (uiMessage == tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
-                                switch (ulParam) {
-                                case SKYPECONTROLAPI_ATTACH_SUCCESS:
-                                        if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
-                                                //DEBUGA_SKYPE("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
-                                                tech_pvt->SkypiaxHandles.api_connected = 1;
-                                                tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
-                                                tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle;
-                                        }
-                                        break;
-                                case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
-                                        //DEBUGA_SKYPE ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n", SKYPIAX_P_LOG);
-                                        celliax_sleep(5000);
-                                        break;
-                                case SKYPECONTROLAPI_ATTACH_REFUSED:
-                                        ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG);
-                                        break;
-                                case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
-                                        ERRORA("Skype API not (yet?) available\n", SKYPIAX_P_LOG);
-                                        break;
-                                case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
-                                        DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
-                                        celliax_sleep(5000);
-                                        break;
-                                default:
-                                        WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG);
-                                }
-                                lReturnCode = 1;
-                                break;
-                        }
-                }
-                fIssueDefProc = 1;
-                break;
-        }
-        if (fIssueDefProc)
-                lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam);
-        return (lReturnCode);
-}
-
-int win32_Initialize_CreateWindowClass(private_t * tech_pvt)
-{
-        unsigned char *paucUUIDString;
-        RPC_STATUS lUUIDResult;
-        int fReturnStatus;
-        UUID oUUID;
-
-        fReturnStatus = 0;
-        lUUIDResult = UuidCreate(&oUUID);
-        tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
-        if (tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle != NULL && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) {
-                if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) {
-                        WNDCLASS oWindowClass;
-
-                        strcpy(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "Skype-API-Skypiax-");
-                        strcat(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, (char *) paucUUIDString);
-
-                        oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
-                        oWindowClass.lpfnWndProc = (WNDPROC) & celliax_present;
-                        oWindowClass.cbClsExtra = 0;
-                        oWindowClass.cbWndExtra = 0;
-                        oWindowClass.hInstance = tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle;
-                        oWindowClass.hIcon = NULL;
-                        oWindowClass.hCursor = NULL;
-                        oWindowClass.hbrBackground = NULL;
-                        oWindowClass.lpszMenuName = NULL;
-                        oWindowClass.lpszClassName = tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName;
-
-                        if (RegisterClass(&oWindowClass) != 0)
-                                fReturnStatus = 1;
-
-                        RpcStringFree(&paucUUIDString);
-                }
-        }
-        if (fReturnStatus == 0)
-                CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle);
-        tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
-        return (fReturnStatus);
-}
-
-void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt)
-{
-        UnregisterClass(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle);
-        CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle);
-        tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
-}
-
-int win32_Initialize_CreateMainWindow(private_t * tech_pvt)
-{
-        tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle =
-                CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
-                                         tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "",
-                                         WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
-                                         128, 128, NULL, 0, tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle, tech_pvt);
-        return (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0);
-}
-
-void win32_DeInitialize_DestroyMainWindow(private_t * tech_pvt)
-{
-        if (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL)
-                DestroyWindow(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle), tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
-}
-
-void *celliax_do_skypeapi_thread_func(void *obj)
-{
-        private_t *tech_pvt = obj;
-#if defined(WIN32) && !defined(__CYGWIN__)
-        switch_status_t rv;
-
-        switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], &tech_pvt->SkypiaxHandles.fdesc[1], celliax_module_pool);
-        rv = switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], &tech_pvt->SkypiaxHandles.fdesc[1], celliax_module_pool);
-#else /* WIN32 */
-        if (pipe(tech_pvt->SkypiaxHandles.fdesc)) {
-                fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
-                fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
-        }
-#endif /* WIN32 */
-
-        tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach = RegisterWindowMessage("SkypeControlAPIAttach");
-        tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover = RegisterWindowMessage("SkypeControlAPIDiscover");
-
-        celliax_sleep(200000);                //0,2 sec
-
-        if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0 && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
-                if (win32_Initialize_CreateWindowClass(tech_pvt)) {
-                        if (win32_Initialize_CreateMainWindow(tech_pvt)) {
-                                if (SendMessage
-                                        (HWND_BROADCAST,
-                                         tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
-                                         (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) {
-                                        tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle;
-                                        while (running && tech_pvt->running) {
-                                                MSG oMessage;
-                                                if (!(running && tech_pvt->running))
-                                                        break;
-                                                while (GetMessage(&oMessage, 0, 0, 0)) {
-                                                        TranslateMessage(&oMessage);
-                                                        DispatchMessage(&oMessage);
-                                                }
-                                        }
-                                }
-                                win32_DeInitialize_DestroyMainWindow(tech_pvt);
-                        }
-                        win32_DeInitialize_DestroyWindowClass(tech_pvt);
-                }
-        }
-
-        return NULL;
-}
-
-#else /* NOT WIN32 */
-int X11_errors_handler(Display * dpy, XErrorEvent * err)
-{
-        (void) dpy;
-        private_t *tech_pvt = NULL;
-
-        xerror = err->error_code;
-        ERRORA("Received error code %d from X Server\n\n", SKYPIAX_P_LOG, xerror);        ///FIXME why crash the entire celliax? just crash the interface, instead
-        running = 0;
-        return 0;                                        /* ignore the error */
-}
-
-static void X11_errors_trap(void)
-{
-        xerror = 0;
-        old_handler = XSetErrorHandler(X11_errors_handler);
-}
-
-static int X11_errors_untrap(void)
-{
-        XSetErrorHandler(old_handler);
-        return (xerror != BadValue) && (xerror != BadWindow);
-}
-
-int celliax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
-{
-
-        Window w_P;
-        Display *disp;
-        Window handle_P;
-        int ok;
-        private_t *tech_pvt = NULL;
-
-        w_P = SkypiaxHandles->skype_win;
-        disp = SkypiaxHandles->disp;
-        handle_P = SkypiaxHandles->win;
-
-        Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
-        Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
-        unsigned int pos = 0;
-        unsigned int len = strlen(message_P);
-        XEvent e;
-
-        memset(&e, 0, sizeof(e));
-        e.xclient.type = ClientMessage;
-        e.xclient.message_type = atom1;        /* leading message */
-        e.xclient.display = disp;
-        e.xclient.window = handle_P;
-        e.xclient.format = 8;
-
-        X11_errors_trap();
-        //XLockDisplay(disp);
-        do {
-                unsigned int i;
-                for (i = 0; i < 20 && i + pos <= len; ++i)
-                        e.xclient.data.b[i] = message_P[i + pos];
-                XSendEvent(disp, w_P, False, 0, &e);
-
-                e.xclient.message_type = atom2;        /* following messages */
-                pos += i;
-        } while (pos <= len);
-
-        XSync(disp, False);
-        ok = X11_errors_untrap();
-
-        if (!ok)
-                ERRORA("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror);
-        //XUnlockDisplay(disp);
-
-        return 1;
-}
-
-int celliax_signaling_write(private_t * tech_pvt, char *msg_to_skype)
-{
-        struct SkypiaxHandles *SkypiaxHandles;
-
-        DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
-
-        SkypiaxHandles = &tech_pvt->SkypiaxHandles;
-
-        if (!celliax_send_message(SkypiaxHandles, msg_to_skype)) {
-                ERRORA
-                        ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then restart Skype, then launch Skypiax and try again.\n",
-                         SKYPIAX_P_LOG);
-                return -1;
-        }
-
-        return 0;
-
-}
-
-int celliax_present(struct SkypiaxHandles *SkypiaxHandles)
-{
-        Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True);
-
-        Atom type_ret;
-        int format_ret;
-        unsigned long nitems_ret;
-        unsigned long bytes_after_ret;
-        unsigned char *prop;
-        int status;
-        private_t *tech_pvt = NULL;
-
-        X11_errors_trap();
-        //XLockDisplay(disp);
-        status =
-                XGetWindowProperty(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->disp),
-                                                 skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop);
-        //XUnlockDisplay(disp);
-        X11_errors_untrap();
-
-        /* sanity check */
-        if (status != Success || format_ret != 32 || nitems_ret != 1) {
-                SkypiaxHandles->skype_win = (Window) - 1;
-                DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG);
-                running = 0;
-                SkypiaxHandles->api_connected = 0;
-                return 0;
-        }
-
-        SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff;
-        DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG, (unsigned int) SkypiaxHandles->skype_win);
-        SkypiaxHandles->api_connected = 1;
-        return 1;
-}
-
-void celliax_clean_disp(void *data)
-{
-
-        int *dispptr;
-        int disp;
-        private_t *tech_pvt = NULL;
-
-        dispptr = data;
-        disp = *dispptr;
-
-        if (disp) {
-                DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPIAX_P_LOG, disp);
-                close(disp);
-                DEBUGA_SKYPE("destroyed disp\n", SKYPIAX_P_LOG);
-        } else {
-                DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG);
-        }
-        DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG);
-        celliax_sleep(1000);
-}
-#endif // WIN32
-
-
-#endif //NOTDEF
-
-
-
-
-
-
</del><span class="cx"> int celliax_serial_init(private_t * tech_pvt, speed_t controldevice_speed)
</span><span class="cx"> {
</span><span class="cx">         int fd;
</span><span class="lines">@@ -3298,31 +1950,7 @@
</span><span class="cx">
</span><span class="cx">         DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG);
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-        /* shutdown the serial monitoring thread */
-        if (tech_pvt->controldev_thread && (tech_pvt->controldev_thread != SKYPIAX_PTHREADT_NULL)
-                && (tech_pvt->controldev_thread != SKYPIAX_PTHREADT_STOP)) {
-                if (pthread_cancel(tech_pvt->controldev_thread)) {
-                        ERRORA("controldev_thread pthread_cancel failed, maybe he killed himself?\n", SKYPIAX_P_LOG);
-                }
-                /* push it, maybe is stuck in a select or so */
-                if (pthread_kill(tech_pvt->controldev_thread, SIGURG)) {
-                        DEBUGA_SKYPE("controldev_thread pthread_kill failed, no problem\n", SKYPIAX_P_LOG);
-                }
-#ifndef __CYGWIN__                                /* under cygwin, this seems to be not reliable, get stuck at times */
-                /* wait for it to die */
-                if (pthread_join(tech_pvt->controldev_thread, NULL)) {
-                        ERRORA("controldev_thread pthread_join failed, BAD\n", SKYPIAX_P_LOG);
-                }
-#else /* __CYGWIN__ */
-/* allow the serial thread to die */
-                usleep(300000);                        //300msecs
-#endif /* __CYGWIN__ */
-        }
-        tech_pvt->controldev_thread = SKYPIAX_PTHREADT_NULL;
-#endif // NOTDEF
</del><span class="cx">
</span><del>-
</del><span class="cx">         if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL) {
</span><span class="cx">                 if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
</span><span class="cx">                         /* actually hangup through the serial port */
</span><span class="lines">@@ -3354,74 +1982,6 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_set_flag(tech_pvt, TFLAG_HANGUP);
</span><del>-#ifdef NOTDEF
-        /* if there is a dsp struct alloced, free it */
-        if (tech_pvt->dsp) {
-                ast_dsp_free(tech_pvt->dsp);
-                tech_pvt->dsp = NULL;
-        }
-#ifndef __CYGWIN__
-#ifdef CELLIAX_ALSA
-/* restart alsa */
-        snd_pcm_drop(tech_pvt->alsap);
-        snd_pcm_prepare(tech_pvt->alsap);
-
-        snd_pcm_prepare(tech_pvt->alsac);
-        snd_pcm_start(tech_pvt->alsac);
-#endif /* CELLIAX_ALSA */
-
-#endif /* __CYGWIN__ */
-#ifdef CELLIAX_PORTAUDIO
-        speex_echo_state_reset(tech_pvt->stream->echo_state);
-#endif // CELLIAX_PORTAUDIO
-
-        /* re-init the serial port, be paranoid */
-        if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL) {
-                tech_pvt->controldevfd = celliax_serial_init(p, tech_pvt->controldevice_speed);
-                if (tech_pvt->controldevfd < 1) {
-                        ERRORA("bad, bad, bad\n", SKYPIAX_P_LOG);
-                        if (option_debug) {
-                                DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-                        }
-                        return -1;
-                }
-        }
-#ifndef ASTERISK_VERSION_1_4
-        /* subtract one to the usage count of Celliax-type channels */
-        LOKKA(celliax_usecnt_lock);
-        celliax_usecnt--;
-        if (celliax_usecnt < 0)
-                ERRORA("Usecnt < 0???\n", SKYPIAX_P_LOG);
-        UNLOCKA(celliax_usecnt_lock);
-        ast_update_use_count();
-#else /* ASTERISK_VERSION_1_4 */
-        ast_module_unref(ast_module_info->self);
-#endif /* ASTERISK_VERSION_1_4 */
-
-        /* our celliax pvt interface is no more part of a channel */
-        tech_pvt->owner = NULL;
-        /* our channel has no more this celliax pvt interface to manage */
-        c->tech_pvt = NULL;
-        /* set the channel state to DOWN, eg. available, not in active use */
-        if (ast_setstate(c, SKYPIAX_STATE_DOWN)) {
-                ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG);
-                if (option_debug) {
-                        DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-                }
-                return -1;
-        }
-
-        if (option_debug)
-                DEBUGA_PBX("Hanged Up\n", SKYPIAX_P_LOG);
-        /* restart the monitor thread, so it can recheck which interfaces it have to watch during its loop (the interfaces that are not owned by channels) */
-        if (celliax_restart_monitor()) {
-                ERRORA("celliax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG);
-                if (option_debug) {
-                        DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-                }
-                return -1;
-        }
-#endif // NOTDEF
</del><span class="cx">         if (option_debug) {
</span><span class="cx">                 DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
</span><span class="cx">         }
</span><span class="lines">@@ -3429,216 +1989,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-int celliax_serial_call_AT(private_t * tech_pvt, char *dstr)
-{
-        int res;
-        char at_command[256];
</del><span class="cx">
</span><del>-        if (option_debug)
-                DEBUGA_PBX("Dialing %s\n", SKYPIAX_P_LOG, dstr);
-        memset(at_command, 0, sizeof(at_command));
-        tech_pvt->phone_callflow = CALLFLOW_CALL_DIALING;
-        tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
-        ast_uri_decode(dstr);
-        size_t fixdstr = strspn(dstr, SKYPIAX_DIGIT_ANYDIG);
-        if (fixdstr == 0) {
-                ERRORA("dial command failed because of invalid dial number. dial string was: %s\n", SKYPIAX_P_LOG, dstr);
-                return -1;
-        }
-        dstr[fixdstr] = '\0';
-        sprintf(at_command, "%s%s%s", tech_pvt->at_dial_pre_number, dstr, tech_pvt->at_dial_post_number);
-        res = celliax_serial_write_AT_expect(tech_pvt, at_command, tech_pvt->at_dial_expect);
-        if (res) {
-                ERRORA("dial command failed, dial string was: %s\n", SKYPIAX_P_LOG, at_command);
-                return -1;
-        }
-        // jet - early audio
-        if (tech_pvt->at_early_audio) {
-                ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_ANSWER);
-        }
-
-        return 0;
-}
-
-int celliax_console_at(int fd, int argc, char *argv[])
-{
-        private_t *tech_pvt = celliax_console_find_desc(celliax_console_active);
-        char at_cmd[1024];
-        int i, a, c;
-
-        if (argc == 1)
-                return RESULT_SHOWUSAGE;
-        if (!tech_pvt) {
-                ast_cli(fd, "No \"current\" console for celliax_at, please enter 'help celliax_console'\n");
-                return RESULT_SUCCESS;
-        }
-        if (tech_pvt->controldevprotocol != PROTOCOL_AT) {
-                ast_cli(fd, "The \"current\" console is not connected to an 'AT modem' (cellphone)\n");
-                return RESULT_SUCCESS;
-        }
-
-        memset(at_cmd, 0, sizeof(at_cmd));
-        c = 0;
-        for (i = 1; i < argc; i++) {
-                for (a = 0; a < strlen(argv[i]); a++) {
-                        at_cmd[c] = argv[i][a];
-                        c++;
-                        if (c == 1022)
-                                break;
-                }
-                if (i != argc - 1) {
-                        at_cmd[c] = ' ';
-                        c++;
-                }
-                if (c == 1023)
-                        break;
-        }
-        celliax_serial_write_AT_noack(tech_pvt, at_cmd);
-        return RESULT_SUCCESS;
-}
-
-int celliax_serial_getstatus_AT(private_t * tech_pvt)
-{
-        int res;
-
-        if (tech_pvt->owner) {
-                if (tech_pvt->owner->state != SKYPIAX_STATE_UP && tech_pvt->owner->state != SKYPIAX_STATE_DOWN) {
-                        DEBUGA_SKYPE("No getstatus, we're neither UP nor DOWN\n", SKYPIAX_P_LOG);
-                        return 0;
-                }
-        }
-
-        PUSHA_UNLOCKA(tech_pvt->controldev_lock);
-        LOKKA(tech_pvt->controldev_lock);
-        res = celliax_serial_write_AT_ack(tech_pvt, "AT");
-        if (res) {
-                ERRORA("AT was not acknowledged, continuing but maybe there is a problem\n", SKYPIAX_P_LOG);
-        }
-        usleep(1000);
-
-        if (strlen(tech_pvt->at_query_battchg)) {
-                res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_query_battchg, tech_pvt->at_query_battchg_expect);
-                if (res) {
-                        WARNINGA("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_query_battchg, tech_pvt->at_query_battchg_expect);
-                }
-                usleep(1000);
-        }
-
-        if (strlen(tech_pvt->at_query_signal)) {
-                res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_query_signal, tech_pvt->at_query_signal_expect);
-                if (res) {
-                        WARNINGA("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_query_signal, tech_pvt->at_query_signal_expect);
-                }
-                usleep(1000);
-        }
-        //FIXME all the following commands in config!
-
-        if (tech_pvt->sms_cnmi_not_supported) {
-                res = celliax_serial_write_AT_ack(tech_pvt, "AT+MMGL=\"HEADER ONLY\"");
-                if (res) {
-                        WARNINGA
-                                ("%s does not get %s from the modem, maybe a long msg is incoming. If this cellmodem is not a Motorola, you are arriving here because your cellmodem do not supports CNMI kind of incoming SMS alert; please let it know to the developers of Celliax. If this cellmodem is a Motorola and this message keeps repeating, and you cannot correctly receive SMSs from this interface, please manually clean all messages from the cellmodem/SIM. Continuing.\n",
-                                 SKYPIAX_P_LOG, "AT+MMGL=\"HEADER ONLY\"", "OK");
-                } else {
-                        usleep(1000);
-                        if (tech_pvt->unread_sms_msg_id) {
-                                char at_command[256];
-
-                                if (tech_pvt->no_ucs2 == 0) {
-                                        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
-                                        if (res) {
-                                                ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) do not got OK from the phone\n", SKYPIAX_P_LOG);
-                                                memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
-                                        }
-                                }
-
-                                memset(at_command, 0, sizeof(at_command));
-                                sprintf(at_command, "AT+CMGR=%d", tech_pvt->unread_sms_msg_id);
-                                memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
-
-                                tech_pvt->reading_sms_msg = 1;
-                                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
-                                tech_pvt->reading_sms_msg = 0;
-                                if (res) {
-                                        ERRORA("AT+CMGR (read SMS) do not got OK from the phone, message sent was:|||%s|||\n", SKYPIAX_P_LOG, at_command);
-                                }
-                                res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"GSM\"");
-                                if (res) {
-                                        ERRORA("AT+CSCS=\"GSM\" (set TE messages to GSM) do not got OK from the phone\n", SKYPIAX_P_LOG);
-                                }
-                                memset(at_command, 0, sizeof(at_command));
-                                sprintf(at_command, "AT+CMGD=%d", tech_pvt->unread_sms_msg_id);        /* delete the message */
-                                tech_pvt->unread_sms_msg_id = 0;
-                                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
-                                if (res) {
-                                        ERRORA("AT+CMGD (Delete SMS) do not got OK from the phone, message sent was:|||%s|||\n", SKYPIAX_P_LOG, at_command);
-                                }
-
-                                if (strlen(tech_pvt->sms_message)) {
-
-                                        manager_event(EVENT_FLAG_SYSTEM, "CELLIAXincomingsms", "Interface: %s\r\nSMS_Message: %s\r\n", tech_pvt->name, tech_pvt->sms_message);
-
-                                        if (strlen(tech_pvt->sms_receiving_program)) {
-                                                int fd1[2];
-                                                pid_t pid1;
-                                                char *arg1[] = { tech_pvt->sms_receiving_program, (char *) NULL };
-                                                int i;
-
-                                                NOTICA("incoming SMS message:>>>%s<<<\n", SKYPIAX_P_LOG, tech_pvt->sms_message);
-                                                pipe(fd1);
-                                                pid1 = fork();
-
-                                                if (pid1 == 0) {        //child
-                                                        int err;
-
-                                                        dup2(fd1[0], 0);        // Connect stdin to pipe output
-                                                        close(fd1[1]);        // close input pipe side
-                                                        setsid();        //session id
-                                                        err = execvp(arg1[0], arg1);        //exec our program, with stdin connected to pipe output
-                                                        if (err) {
-                                                                ERRORA
-                                                                        ("'sms_receiving_program' is set in config file to '%s', and it gave us back this error: %d, (%s). SMS received was:---%s---\n",
-                                                                         SKYPIAX_P_LOG, tech_pvt->sms_receiving_program, err, strerror(errno), tech_pvt->sms_message);
-                                                        }
-                                                        close(fd1[0]);        // close output pipe side
-                                                }                //starting here continue the parent
-                                                close(fd1[0]);        // close output pipe side
-                                                // write the msg on the pipe input
-                                                for (i = 0; i < strlen(tech_pvt->sms_message); i++) {
-                                                        write(fd1[1], &tech_pvt->sms_message[i], 1);
-                                                }
-                                                close(fd1[1]);        // close pipe input, let our program know we've finished
-                                        } else {
-                                                ERRORA
-                                                        ("got SMS incoming message, but 'sms_receiving_program' is not set in config file. SMS received was:---%s---\n",
-                                                         SKYPIAX_P_LOG, tech_pvt->sms_message);
-                                        }
-                                }
-#if 1                                                        //is this one needed? maybe it can interrupt an incoming call that is just to announce itself
-                                if (tech_pvt->phone_callflow == CALLFLOW_CALL_IDLE && tech_pvt->interface_state == SKYPIAX_STATE_DOWN && tech_pvt->owner == NULL) {
-                                        /* we're not in a call, neither calling */
-                                        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CKPD=\"EEE\"");
-                                        if (res) {
-                                                ERRORA("AT+CKPD=\"EEE\" (cellphone screen back to user) do not got OK from the phone\n", SKYPIAX_P_LOG);
-                                        }
-                                }
-#endif
-                        }
-                }
-        }
-
-        UNLOCKA(tech_pvt->controldev_lock);
-        POPPA_UNLOCKA(tech_pvt->controldev_lock);
-        return 0;
-}
-
-
-
-
-#endif // NOTDEF
-
-
</del><span class="cx"> #define SKYPIAX_ALSA
</span><span class="cx"> #ifdef SKYPIAX_ALSA
</span><span class="cx"> /*! \brief ALSA pcm format, according to endianess */
</span><span class="lines">@@ -3833,36 +2184,6 @@
</span><span class="cx">         tech_pvt->alsa_play_is_mono = 1;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if 0
-        unsigned int buffer_time = 0;
-        unsigned int period_time = 0;
-        snd_pcm_uframes_t period_frames = 0;
-        snd_pcm_uframes_t buffer_frames = 0;
-
-        if (buffer_time == 0 && buffer_frames == 0) {
-                err = snd_pcm_hw_params_get_buffer_time_max(params, &buffer_time, 0);
-                assert(err >= 0);
-                if (buffer_time > 500000)
-                        buffer_time = 500000;
-        }
-        if (period_time == 0 && period_frames == 0) {
-                if (buffer_time > 0)
-                        period_time = buffer_time / 4;
-                else
-                        period_frames = buffer_frames / 4;
-        }
-        if (period_time > 0)
-                err = snd_pcm_hw_params_set_period_time_near(handle, params, &period_time, 0);
-        else
-                err = snd_pcm_hw_params_set_period_size_near(handle, params, &period_frames, 0);
-        assert(err >= 0);
-        if (buffer_time > 0) {
-                err = snd_pcm_hw_params_set_buffer_time_near(handle, params, &buffer_time, 0);
-        } else {
-                err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &buffer_frames);
-        }
-#endif
-
</del><span class="cx"> #if 1
</span><span class="cx">         rate = tech_pvt->celliax_sound_rate;
</span><span class="cx">         err = snd_pcm_hw_params_set_rate_near(handle, params, &rate, 0);
</span><span class="lines">@@ -3910,29 +2231,6 @@
</span><span class="cx">
</span><span class="cx">         snd_pcm_sw_params_current(handle, swparams);
</span><span class="cx">
</span><del>-#if 0
-        err = snd_pcm_sw_params_get_xfer_align(swparams, &xfer_align);
-        if (err < 0) {
-                ERRORA("Unable to obtain xfer align: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
-        }
-        NOTICA("xfer_align: %d\n", SKYPIAX_P_LOG, xfer_align);
-        /* for some reason, on some platforms, xfer_align here is zero, that gives a floating point exception later. So, let's try to force it to 160, the frame size used by celliax */
-        xfer_align = tech_pvt->alsa_period_size;
-        NOTICA("xfer_align: %d\n", SKYPIAX_P_LOG, xfer_align);
-
-        err = snd_pcm_sw_params_set_xfer_align(handle, swparams, xfer_align);
-        if (err < 0) {
-                ERRORA("Error setting xfer_align: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
-        }
-        NOTICA("xfer_align: %d\n", SKYPIAX_P_LOG, xfer_align);
-
-        err = snd_pcm_sw_params_get_xfer_align(swparams, &xfer_align);
-        if (err < 0) {
-                ERRORA("Unable to obtain xfer align: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
-        }
-        NOTICA("xfer_align: %d\n", SKYPIAX_P_LOG, xfer_align);
-#endif
-
</del><span class="cx">         /*
</span><span class="cx">          if (sleep_min)
</span><span class="cx">          xfer_align = 1;
</span><span class="lines">@@ -3948,14 +2246,6 @@
</span><span class="cx">         if (err < 0) {
</span><span class="cx">                 ERRORA("Error setting avail_min: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
</span><span class="cx">         }
</span><del>-#if 0
-        /* round up to closest transfer boundary */
-        if (xfer_align == 0) {                //so to avoid floating point exception ????
-                xfer_align = 160;
-        }
-        //original n = (buffer_size / xfer_align) * xfer_align;
-        n = (chunk_size / xfer_align) * xfer_align;
-#endif
</del><span class="cx">         if (stream == SND_PCM_STREAM_CAPTURE) {
</span><span class="cx">                 start_delay = 1;
</span><span class="cx">         }
</span><span class="lines">@@ -3987,14 +2277,7 @@
</span><span class="cx">         if (err < 0) {
</span><span class="cx">                 ERRORA("Error setting stop_threshold: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
</span><span class="cx">         }
</span><del>-#if 0
-        err = snd_pcm_sw_params_set_xfer_align(handle, swparams, xfer_align);
</del><span class="cx">
</span><del>-        if (err < 0) {
-                ERRORA("Error setting xfer_align: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
-        }
-#endif
-
</del><span class="cx">         if (snd_pcm_sw_params(handle, swparams) < 0) {
</span><span class="cx">                 ERRORA("Error installing software parameters: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
</span><span class="cx">         }
</span><span class="lines">@@ -4055,349 +2338,7 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-/*! \brief Read audio frames from interface */
-
-struct ast_frame *alsa_read(private_t * tech_pvt)
-{
-        static struct ast_frame f;
-        static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
-        static short __buf2[(SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2];
-        short *buf;
-        short *buf2;
-        static int readpos = 0;
-        static int left = SKYPIAX_FRAME_SIZE;
-        snd_pcm_state_t state;
-        int r = 0;
-        int off = 0;
-        int error = 0;
-        //time_t now_timestamp;
-
-        //memset(&f, 0, sizeof(struct ast_frame)); //giova
-
-        f.frametype = AST_FRAME_NULL;
-        f.subclass = 0;
-        f.samples = 0;
-        f.datalen = 0;
-        f.data = NULL;
-        f.offset = 0;
-        f.src = celliax_type;
-        f.mallocd = 0;
-        f.delivery.tv_sec = 0;
-        f.delivery.tv_usec = 0;
-
-        state = snd_pcm_state(tech_pvt->alsac);
-        if (state != SND_PCM_STATE_RUNNING) {
-                DEBUGA_SKYPE("ALSA read state is not SND_PCM_STATE_RUNNING\n", SKYPIAX_P_LOG);
-
-                if (state != SND_PCM_STATE_PREPARED) {
-                        error = snd_pcm_prepare(tech_pvt->alsac);
-                        if (error) {
-                                ERRORA("snd_pcm_prepare failed, %s\n", SKYPIAX_P_LOG, snd_strerror(error));
-                                return &f;
-                        }
-                        DEBUGA_SKYPE("prepared!\n", SKYPIAX_P_LOG);
-                }
-                usleep(1000);
-                error = snd_pcm_start(tech_pvt->alsac);
-                if (error) {
-                        ERRORA("snd_pcm_start failed, %s\n", SKYPIAX_P_LOG, snd_strerror(error));
-                        return &f;
-                }
-                DEBUGA_SKYPE("started!\n", SKYPIAX_P_LOG);
-                usleep(1000);
-        }
-
-        buf = __buf + AST_FRIENDLY_OFFSET / 2;
-        buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
-
-        if (tech_pvt->alsa_capture_is_mono) {
-                r = snd_pcm_readi(tech_pvt->alsac, buf + readpos, left);
-        } else {
-                r = snd_pcm_readi(tech_pvt->alsac, buf2 + (readpos * 2), left);
-
-                int a = 0;
-                int i = 0;
-                for (i = 0; i < (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
-                        __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;        //comment out this line to use only left
-                        //__buf[a] = __buf2[i]; // enable this line to use only left
-                        a++;
-                        i++;
-                        i++;
-                }
-        }
-
-        if (r == -EPIPE) {
-                ERRORA("XRUN read\n\n\n\n\n", SKYPIAX_P_LOG);
-                return &f;
-        } else if (r == -ESTRPIPE) {
-                ERRORA("-ESTRPIPE\n", SKYPIAX_P_LOG);
-                return &f;
-
-        } else if (r == -EAGAIN) {
-                DEBUGA_SKYPE("ALSA read -EAGAIN, the soundcard is not ready to be read by celliax\n", SKYPIAX_P_LOG);
-                while (r == -EAGAIN) {
-                        usleep(1000);
-
-                        if (tech_pvt->alsa_capture_is_mono) {
-                                r = snd_pcm_readi(tech_pvt->alsac, buf + readpos, left);
-                        } else {
-                                r = snd_pcm_readi(tech_pvt->alsac, buf2 + (readpos * 2), left);
-
-                                int a = 0;
-                                int i = 0;
-                                for (i = 0; i < (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
-                                        __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;
-                                        a++;
-                                        i++;
-                                        i++;
-                                }
-                        }
-
-                }
-        } else if (r < 0) {
-                WARNINGA("ALSA Read error: %s\n", SKYPIAX_P_LOG, snd_strerror(r));
-        } else if (r >= 0) {
-                //DEBUGA_SKYPE("read: r=%d, readpos=%d, left=%d, off=%d\n", SKYPIAX_P_LOG, r, readpos, left, off);
-                off -= r;                                //what is the meaning of this? a leftover, probably
-        }
-        /* Update positions */
-        readpos += r;
-        left -= r;
-
-        if (readpos >= SKYPIAX_FRAME_SIZE) {
-                /* A real frame */
-                readpos = 0;
-                left = SKYPIAX_FRAME_SIZE;
-
-                f.frametype = AST_FRAME_VOICE;
-                f.subclass = AST_FORMAT_SLINEAR;
-                f.samples = SKYPIAX_FRAME_SIZE;
-                f.datalen = SKYPIAX_FRAME_SIZE * 2;
-                f.data = buf;
-                f.offset = AST_FRIENDLY_OFFSET;
-                f.src = celliax_type;
-                f.mallocd = 0;
-#ifdef ALSA_MONITOR
-                alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
-#endif
-
-        }
-        return &f;
-}
-
</del><span class="cx"> /*! \brief Write audio frames to interface */
</span><del>-int alsa_write(private_t * tech_pvt, struct ast_frame *f)
-{
-        static char sizbuf[8000];
-        static char sizbuf2[16000];
-        static char silencebuf[8000];
-        static int sizpos = 0;
-        int len = sizpos;
-        int pos;
-        int res = 0;
-        time_t now_timestamp;
-        /* size_t frames = 0; */
-        snd_pcm_state_t state;
-        snd_pcm_sframes_t delayp1;
-        snd_pcm_sframes_t delayp2;
-
-        /* We have to digest the frame in 160-byte portions */
-        if (f->datalen > sizeof(sizbuf) - sizpos) {
-                ERRORA("Frame too large\n", SKYPIAX_P_LOG);
-                res = -1;
-        } else {
-                memcpy(sizbuf + sizpos, f->data, f->datalen);
-                len += f->datalen;
-                pos = 0;
-#ifdef ALSA_MONITOR
-                alsa_monitor_write(sizbuf, len);
-#endif
-                state = snd_pcm_state(tech_pvt->alsap);
-                if (state == SND_PCM_STATE_XRUN) {
-                        int i;
-
-                        DEBUGA_SKYPE
-                                ("You've got an ALSA write XRUN in the past (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file\n",
-                                 SKYPIAX_P_LOG, tech_pvt->alsa_periods_in_buffer);
-                        res = snd_pcm_prepare(tech_pvt->alsap);
-                        if (res) {
-                                ERRORA("audio play prepare failed: %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                        } else {
-                                res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
-                                if (res < 0) {
-                                        DEBUGA_SKYPE("Silence error %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                                        res = -1;
-                                }
-                                for (i = 0; i < (tech_pvt->alsa_periods_in_buffer - 1); i++) {
-                                        res = snd_pcm_writei(tech_pvt->alsap, silencebuf, len / 2);
-                                        if (res != len / 2) {
-                                                DEBUGA_SKYPE("Write returned a different quantity: %d\n", SKYPIAX_P_LOG, res);
-                                                res = -1;
-                                        } else if (res < 0) {
-                                                DEBUGA_SKYPE("Write error %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                                                res = -1;
-                                        }
-                                }
-                        }
-
-                }
-
-                res = snd_pcm_delay(tech_pvt->alsap, &delayp1);
-                if (res < 0) {
-                        DEBUGA_SKYPE("Error %d on snd_pcm_delay: \"%s\"\n", SKYPIAX_P_LOG, res, snd_strerror(res));
-                        res = snd_pcm_prepare(tech_pvt->alsap);
-                        if (res) {
-                                DEBUGA_SKYPE("snd_pcm_prepare failed: '%s'\n", SKYPIAX_P_LOG, snd_strerror(res));
-                        }
-                        res = snd_pcm_delay(tech_pvt->alsap, &delayp1);
-                }
-
-                delayp2 = snd_pcm_avail_update(tech_pvt->alsap);
-                if (delayp2 < 0) {
-                        DEBUGA_SKYPE("Error %d on snd_pcm_avail_update: \"%s\"\n", SKYPIAX_P_LOG, (int) delayp2, snd_strerror(delayp2));
-
-                        res = snd_pcm_prepare(tech_pvt->alsap);
-                        if (res) {
-                                DEBUGA_SKYPE("snd_pcm_prepare failed: '%s'\n", SKYPIAX_P_LOG, snd_strerror(res));
-                        }
-                        delayp2 = snd_pcm_avail_update(tech_pvt->alsap);
-                }
-
-                if (                                        /* delayp1 != 0 && delayp1 != 160 */
-                         delayp1 < 160 || delayp2 > tech_pvt->alsa_buffer_size) {
-
-                        res = snd_pcm_prepare(tech_pvt->alsap);
-                        if (res) {
-                                DEBUGA_SKYPE
-                                        ("snd_pcm_prepare failed while trying to prevent an ALSA write XRUN: %s, delayp1=%d, delayp2=%d\n",
-                                         SKYPIAX_P_LOG, snd_strerror(res), (int) delayp1, (int) delayp2);
-                        } else {
-
-                                int i;
-                                for (i = 0; i < (tech_pvt->alsa_periods_in_buffer - 1); i++) {
-                                        res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
-                                        if (res < 0) {
-                                                DEBUGA_SKYPE("Silence error %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                                                res = -1;
-                                        }
-                                        res = snd_pcm_writei(tech_pvt->alsap, silencebuf, len / 2);
-                                        if (res < 0) {
-                                                DEBUGA_SKYPE("Write error %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                                                res = -1;
-                                        } else if (res != len / 2) {
-                                                DEBUGA_SKYPE("Write returned a different quantity: %d\n", SKYPIAX_P_LOG, res);
-                                                res = -1;
-                                        }
-                                }
-
-                                DEBUGA_SKYPE
-                                        ("PREVENTING an ALSA write XRUN (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n",
-                                         SKYPIAX_P_LOG, tech_pvt->alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
-                        }
-
-                }
-
-                memset(sizbuf2, 0, sizeof(sizbuf2));
-                if (tech_pvt->alsa_play_is_mono) {
-                        ERRORA("data=%p, datalen=%d, sizbuf=%p, len/2=%d\n", SKYPIAX_P_LOG, (void *) data, datalen, (void *) sizbuf, len / 2);
-                        res = snd_pcm_writei(tech_pvt->alsap, sizbuf, len / 2);
-                } else {
-                        int a = 0;
-                        int i = 0;
-                        for (i = 0; i < 8000;) {
-                                sizbuf2[a] = sizbuf[i];
-                                a++;
-                                i++;
-                                sizbuf2[a] = sizbuf[i];
-                                a++;
-                                i--;
-                                sizbuf2[a] = sizbuf[i];        // comment out this line to use only left
-                                a++;
-                                i++;
-                                sizbuf2[a] = sizbuf[i];        // comment out this line to use only left
-                                a++;
-                                i++;
-                        }
-                        res = snd_pcm_writei(tech_pvt->alsap, sizbuf2, len);
-                }
-                if (res == -EPIPE) {
-                        DEBUGA_SKYPE
-                                ("ALSA write EPIPE (XRUN) (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n",
-                                 SKYPIAX_P_LOG, tech_pvt->alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
-                        res = snd_pcm_prepare(tech_pvt->alsap);
-                        if (res) {
-                                ERRORA("audio play prepare failed: %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                        } else {
-
-                                if (tech_pvt->alsa_play_is_mono) {
-                                        res = snd_pcm_writei(tech_pvt->alsap, sizbuf, len / 2);
-                                } else {
-                                        int a = 0;
-                                        int i = 0;
-                                        for (i = 0; i < 8000;) {
-                                                sizbuf2[a] = sizbuf[i];
-                                                a++;
-                                                i++;
-                                                sizbuf2[a] = sizbuf[i];
-                                                a++;
-                                                i--;
-                                                sizbuf2[a] = sizbuf[i];
-                                                a++;
-                                                i++;
-                                                sizbuf2[a] = sizbuf[i];
-                                                a++;
-                                                i++;
-                                        }
-                                        res = snd_pcm_writei(tech_pvt->alsap, sizbuf2, len);
-                                }
-
-                        }
-
-                } else {
-                        if (res == -ESTRPIPE) {
-                                ERRORA("You've got some big problems\n", SKYPIAX_P_LOG);
-                        } else if (res == -EAGAIN) {
-                                res = 0;
-                        } else if (res < 0) {
-                                ERRORA("Error %d on audio write: \"%s\"\n", SKYPIAX_P_LOG, res, snd_strerror(res));
-                        }
-                }
-        }
-
-        if (tech_pvt->audio_play_reset_period) {
-                time(&now_timestamp);
-                if ((now_timestamp - tech_pvt->audio_play_reset_timestamp) > tech_pvt->audio_play_reset_period) {
-                        if (option_debug)
-                                DEBUGA_SKYPE("reset audio play\n", SKYPIAX_P_LOG);
-                        res = snd_pcm_wait(tech_pvt->alsap, 1000);
-                        if (res < 0) {
-                                ERRORA("audio play wait failed: %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                        }
-                        res = snd_pcm_drop(tech_pvt->alsap);
-                        if (res) {
-                                ERRORA("audio play drop failed: %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                        }
-                        res = snd_pcm_prepare(tech_pvt->alsap);
-                        if (res) {
-                                ERRORA("audio play prepare failed: %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                        }
-                        res = snd_pcm_wait(tech_pvt->alsap, 1000);
-                        if (res < 0) {
-                                ERRORA("audio play wait failed: %s\n", SKYPIAX_P_LOG, snd_strerror(res));
-                        }
-                        time(&tech_pvt->audio_play_reset_timestamp);
-                }
-        }
-        res = 0;
-        if (res > 0)
-                res = 0;
-        return res;
-}
-
-#endif //NOTDEF
-
-/*! \brief Write audio frames to interface */
</del><span class="cx"> #endif /* SKYPIAX_ALSA */
</span><span class="cx">
</span><span class="cx"> int celliax_call(private_t * tech_pvt, char *rdest, int timeout)
</span><span class="lines">@@ -4670,80 +2611,12 @@
</span><span class="cx">         //DEBUGA_SKYPE("buf=%p, datalen=%d, left=%d\n", SKYPIAX_P_LOG, (void *)buf, datalen, left);
</span><span class="cx">         //memset(&f, 0, sizeof(struct ast_frame)); //giova
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-        f.frametype = AST_FRAME_NULL;
-        f.subclass = 0;
-        f.samples = 0;
-        f.datalen = 0;
-        f.data = NULL;
-        f.offset = 0;
-        f.src = celliax_type;
-        f.mallocd = 0;
-        f.delivery.tv_sec = 0;
-        f.delivery.tv_usec = 0;
-#endif // NOTDEF
</del><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx">         left = datalen;
</span><span class="cx">
</span><del>-#if 0
-        struct timeval to;
-        fd_set rfds;
-        int result;
</del><span class="cx">
</span><del>-
-
-        FD_ZERO(&rfds);
-        FD_SET(tech_pvt->celliax_sound_capt_fd, &rfds);
-
-        /* Wait for something to happen */
-        to.tv_sec = 0;
-        //to.tv_usec = 500000;                /* we select with this timeout because under cygwin we avoid the signal usage, so there is no way to end the thread if it is stuck waiting for select */
-        to.tv_usec = 20000;                /* we select with this timeout because under cygwin we avoid the signal usage, so there is no way to end the thread if it is stuck waiting for select */
-        result = select(tech_pvt->celliax_sound_capt_fd + 1, &rfds, NULL, NULL, &to);
-
-
-
-        /* If there are errors... */
-        if (result < 0) {
-                if (errno == EINTR) {        /* EINTR is just the select
-                                                                 being interrupted by a SIGURG, or so */
-                        ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, result, strerror(errno));
-                        usleep(1000);
-                        //continue;
-                } else {
-                        ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, result, strerror(errno));
-//FIXME what to do here? is the interface that failed signaled? which interface we have to disable?
-                        //return NULL;
-                }
-        }
-        /* If there are no file descriptors changed, just continue */
-
-        if (result == 0) {
-                DEBUGA_SKYPE("select returned %d: no file descriptor ready to be read, read would return -EAGAIN\n", SKYPIAX_P_LOG, result);
-                usleep(500);                        //let's breath
-        }
-
-#endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
</del><span class="cx">         state = snd_pcm_state(tech_pvt->alsac);
</span><span class="cx">         if (state != SND_PCM_STATE_RUNNING) {
</span><span class="cx">                 DEBUGA_SKYPE("ALSA read state is not SND_PCM_STATE_RUNNING\n", SKYPIAX_P_LOG);
</span><span class="lines">@@ -4832,20 +2705,6 @@
</span><span class="cx">                 for (i = 0; i < r; i++)
</span><span class="cx">                         data[i] = buf[i];
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-                f.frametype = AST_FRAME_VOICE;
-                f.subclass = AST_FORMAT_SLINEAR;
-                f.samples = SKYPIAX_FRAME_SIZE;
-                f.datalen = SKYPIAX_FRAME_SIZE * 2;
-                f.data = buf;
-                f.offset = AST_FRIENDLY_OFFSET;
-                f.src = celliax_type;
-                f.mallocd = 0;
-#ifdef ALSA_MONITOR
-                alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
-#endif
-#endif //NOTDEF
-
</del><span class="cx">         }
</span><span class="cx">         return r;
</span><span class="cx"> }
</span><span class="lines">@@ -4874,65 +2733,6 @@
</span><span class="cx"> *
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#if 0
- stringp = rdest;
- //device = strsep(&stringp, "/");
- dest = strsep(&stringp, "|");
- text = strsep(&stringp, "|");
-
- if (!device) {
- ERRORA(
- "CelliaxSendsms app do not recognize '%s'. Requires a destination with slashes (interfacename/destinationnumber, TEXT)\n", SKYPIAX_P_LOG,
- idest);
- return -1;
- }
-
- if (!dest) {
- ERRORA(
- "CelliaxSendsms app do not recognize '%s'. Requires a destination with slashes (interfacename/destinationnumber, TEXT)\n", SKYPIAX_P_LOG,
- idest);
- return -1;
- }
-
- if (!text) {
- ERRORA(
- "CelliaxSendsms app do not recognize '%s'. Requires a destination with slashes (interfacename/destinationnumber, TEXT)\n", SKYPIAX_P_LOG,
- idest);
- return -1;
- }
-
- DEBUGA_SKYPE("interfacename:%s, destinationnumber:%s, text:%s\n", SKYPIAX_P_LOG, device, dest,
- text);
- /* lock the interfaces' list */
- LOKKA(&celliax_iflock);
- /* make a pointer to the first interface in the interfaces list */
- p = celliax_iflist;
- /* Search for the requested interface and verify if is unowned */
- //TODO implement groups a la chan_zap
- while (tech_pvt) {
- size_t length = strlen(tech_pvt->name);
- /* is this the requested interface? */
- if (strncmp(device, tech_pvt->name, length) == 0) {
- /* this is the requested interface! */
- if (option_debug)
- DEBUGA_SKYPE("FOUND! interfacename:%s, destinationnumber:%s, text:%s, tech_pvt->name=%s\n",
- SKYPIAX_P_LOG, device, dest, text, tech_pvt->name);
- found = 1;
- break;
-
- }
- /* not yet found, next please */
- p = tech_pvt->next;
- }
- /* unlock the interfaces' list */
- UNLOCKA(&celliax_iflock);
-
- if (!found) {
- ERRORA( "Interface '%s' requested by CelliaxSendsms NOT FOUND\n", device);
- return RESULT_FAILURE;
- }
-
-#endif
</del><span class="cx"> if (tech_pvt->controldevprotocol != PROTOCOL_AT) {
</span><span class="cx"> ERRORA(", SKYPIAX_P_LOGCelliaxSendsms supports only AT command cellphones at the moment :-( !\n",
</span><span class="cx"> SKYPIAX_P_LOG);
</span></span></pre></div>
<a id="freeswitchbranchesgmaruzzmod_celliaxmod_celliaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c (14708 => 14709)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c        2009-09-01 09:36:52 UTC (rev 14708)
+++ freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c        2009-09-01 09:43:29 UTC (rev 14709)
</span><span class="lines">@@ -743,17 +743,6 @@
</span><span class="cx">                         tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-#ifdef NOTDEF
-
-        if (!celliax_audio_read(tech_pvt)) {
-
-                ERRORA("celliax_audio_read ERROR\n", SKYPIAX_P_LOG);
-
-        } else {
-                switch_set_flag(tech_pvt, TFLAG_VOICE);
-        }
-#endif //NOTDEF
-
</del><span class="cx">         while (switch_test_flag(tech_pvt, TFLAG_IO)) {
</span><span class="cx">                 if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
</span><span class="cx">                         switch_clear_flag(tech_pvt, TFLAG_BREAK);
</span><span class="lines">@@ -835,13 +824,6 @@
</span><span class="cx">         sent = alsa_write(tech_pvt, frame->data, (int) (frame->datalen));
</span><span class="cx"> //DEBUGA_SKYPE("sent=%d \n", SKYPIAX_P_LOG, sent);
</span><span class="cx">
</span><del>-#ifdef NOTDEF                                        //FIXME
-#ifdef WIN32
-        switch_file_write(tech_pvt->audioskypepipe[1], frame->data, &sent);
-#else /* WIN32 */
-        sent = write(tech_pvt->audioskypepipe[1], frame->data, sent);
-#endif /* WIN32 */
-#endif //NOTDEF
</del><span class="cx">         if (sent && sent != frame->datalen / 2 && sent != -1) {
</span><span class="cx">                 DEBUGA_SKYPE("sent %d\n", SKYPIAX_P_LOG, sent);
</span><span class="cx">         }
</span><span class="lines">@@ -1083,69 +1065,6 @@
</span><span class="cx"> * \brief This thread runs during a call, and monitor the interface for signaling, like hangup, caller id, etc most of signaling is handled inside the celliax_signaling_read function
</span><span class="cx"> *
</span><span class="cx"> */
</span><del>-#ifdef NOTDEF
-static void *SWITCH_THREAD_FUNC celliax_signaling_thread_func(switch_thread_t *thread, void *obj)
-{
-        private_t *tech_pvt = obj;
-        int res;
-        int forever = 1;
-
-        if (!tech_pvt)
-                return NULL;
-
-        DEBUGA_SKYPE("In celliax_signaling_thread_func: started, p=%p\n", SKYPIAX_P_LOG, (void *) tech_pvt);
-
-        while (forever) {
-                if (!(running && tech_pvt->running))
-                        break;
-                res = celliax_signaling_read(tech_pvt);
-                if (res == CALLFLOW_INCOMING_HANGUP) {
-                        switch_core_session_t *session = NULL;
-                        switch_channel_t *channel = NULL;
-                        //private_t *tech_pvt = NULL;
-                        DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
-
-                        if (tech_pvt) {
-                                session = switch_core_session_locate(tech_pvt->session_uuid_str);
-                                if (session) {
-                                        channel = switch_core_session_get_channel(session);
-                                        if (channel) {
-                                                switch_channel_state_t state = switch_channel_get_state(channel);
-                                                if (state < CS_EXECUTE) {
-                                                        switch_sleep(10000);        //10 msec, let the state evolve from CS_NEW
-                                                }
-                                                switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-                                        } else {
-                                                ERRORA("no channel?\n", SKYPIAX_P_LOG);
-                                        }
-                                        switch_core_session_rwunlock(session);
-                                } else {
-                                        DEBUGA_SKYPE("no session\n", SKYPIAX_P_LOG);
-                                }
-                                switch_mutex_lock(globals.mutex);
-                                tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-                                *tech_pvt->session_uuid_str = '\0';
-                                *tech_pvt->skype_call_id = '\0';
-                                switch_mutex_unlock(globals.mutex);
-
-                                //ERRORA("LET'S WAIT\n", SKYPIAX_P_LOG);
-                                switch_sleep(300000);        //0.3 sec
-                                //ERRORA("WAIT'S OVER\n", SKYPIAX_P_LOG);
-                                //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
-                                //usleep(30000); //0.03 sec
-                                switch_mutex_lock(globals.mutex);
-                                tech_pvt->skype_callflow = CALLFLOW_CALL_IDLE;
-                                tech_pvt->interface_state = SKYPIAX_STATE_IDLE;
-                                switch_mutex_unlock(globals.mutex);
-                        } else {
-                                ERRORA("no tech_pvt?\n", SKYPIAX_P_LOG);
-                        }
-                }
-        }
-        return NULL;
-}
-#endif // NOTDEF
-
</del><span class="cx"> /* BEGIN: Changes heres */
</span><span class="cx"> static switch_status_t load_config(int reload_type)
</span><span class="cx"> /* END: Changes heres */
</span><span class="lines">@@ -1330,17 +1249,6 @@
</span><span class="cx">                         if (name) {
</span><span class="cx">                                 DEBUGA_SKYPE("name=%s\n", SKYPIAX_P_LOG, name);
</span><span class="cx">                         }
</span><del>-#ifdef NOTDEF
-#ifndef WIN32
-                        if (!XInitThreads()) {
-                                ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
-                        } else {
-                                DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG);
-                        }
-                        switch_sleep(100);
-#endif /* WIN32 */
-
-#endif // NOTDEF
</del><span class="cx">                         if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) {
</span><span class="cx">                                 private_t newconf;
</span><span class="cx">                                 switch_threadattr_t *celliax_api_thread_attr = NULL;
</span><span class="lines">@@ -1380,40 +1288,6 @@
</span><span class="cx">
</span><span class="cx">                                 switch_mutex_init(&globals.SKYPIAX_INTERFACES[interface_id].controldev_lock, SWITCH_MUTEX_NESTED, celliax_module_pool);
</span><span class="cx"> /*********************/
</span><del>-#ifdef NOTDEF
-                                .interface_state = SKYPIAX_STATE_DOWN;
-                                .phone_callflow = CALLFLOW_CALL_IDLE;
-                                .dsp_silence_threshold = 512;
-                                .context = "default";
-                                .language = "en";
-                                .exten = "s";
-                                .controldevice_name = "none";
-                                .controldevfd = 0;
-                                .next = NULL;
-                                .owner = NULL;
-                                .dsp = NULL;
-                                .fbus2_outgoing_list = NULL;
-                                .seqnumfbus = FBUS2_SEQNUM_MAX;
-                                .controldev_thread = AST_PTHREADT_NULL;
-                                .arraycounter = 0;
-#ifndef GIOVA48
-                                .celliax_sound_rate = 8000;
-#else // GIOVA48
-                                .celliax_sound_rate = 48000;
-#endif // GIOVA48
-                                .celliax_sound_capt_fd = -1;
-                                .need_acoustic_ring = 0;
-                                .celliax_serial_synced_timestamp = 0;
-                                .celliax_serial_sync_period = 300;
-                                .audio_play_reset_timestamp = 0;
-                                .audio_capture_reset_timestamp = 0;
-                                .controldevice_speed = B38400;
-                                .capture_boost = 0;
-                                .playback_boost = 0;
-                                .stripmsd = 0;
-                                .controldev_dead = 0;
-                                .dtmf_inited = 0;
-#endif // NOTDEF
</del><span class="cx">                                 //at_dial_pre_number = "AT+CKPD=\"";
</span><span class="cx">                                 switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_pre_number, "ATD");
</span><span class="cx">                                 //.at_dial_post_number = "S\"";
</span><span class="lines">@@ -1554,70 +1428,6 @@
</span><span class="cx">
</span><span class="cx">                                 switch_sleep(100000);
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-                                res = alsa_init(&globals.SKYPIAX_INTERFACES[interface_id]);
-                                if (res == -1) {
-                                        ERRORA("Failed initializing sound device\n", SKYPIAX_P_LOG);
-                                        /* we failed, free the PVT */
-                                        //if (tmp)
-                                        //free(tmp);
-                                        //return NULL;
-                                }
-
-                                switch_threadattr_create(&celliax_signaling_thread_attr, celliax_module_pool);
-                                switch_threadattr_stacksize_set(celliax_signaling_thread_attr, SWITCH_THREAD_STACKSIZE);
-                                switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].celliax_signaling_thread, celliax_signaling_thread_attr,
-                                                                         celliax_signaling_thread_func, &globals.SKYPIAX_INTERFACES[interface_id], celliax_module_pool);
-
-                                switch_sleep(100000);
-
-                                celliax_audio_init(&globals.SKYPIAX_INTERFACES[interface_id]);
-
-                                NOTICA
-                                        ("WAITING roughly 10 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d\n",
-                                         SKYPIAX_P_LOG, interface_id);
-                                i = 0;
-                                while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 200) {        // 10 seconds! thanks Jeff Lenk
-                                        switch_sleep(50000);
-                                        i++;
-                                }
-                                if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected) {
-                                        NOTICA
-                                                ("Found a running Skype client, connected to its SKYPE API for interface_id=%d, waiting 60 seconds for CURRENTUSERHANDLE==%s\n",
-                                                 SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user);
-                                } else {
-                                        ERRORA
-                                                ("Failed to connect to a SKYPE API for interface_id=%d, no SKYPE client running, please (re)start Skype client. Skypiax exiting\n",
-                                                 SKYPIAX_P_LOG, interface_id);
-                                        running = 0;
-                                        switch_mutex_unlock(globals.mutex);
-                                        switch_xml_free(xml);
-                                        return SWITCH_STATUS_FALSE;
-                                }
-
-                                i = 0;
-                                while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 && running && i < 1200) {        // 60 seconds! thanks Jeff Lenk
-                                        switch_sleep(50000);
-                                        i++;
-                                }
-                                if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle) {
-                                        WARNINGA
-                                                ("Interface_id=%d is now STARTED, the Skype client to which we are connected gave us the correct CURRENTUSERHANDLE (%s)\n",
-                                                 SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user);
-
-                                        celliax_signaling_write(&globals.SKYPIAX_INTERFACES[interface_id], "SET AUTOAWAY OFF");
-                                } else {
-                                        ERRORA
-                                                ("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",
-                                                 SKYPIAX_P_LOG, globals.SKYPIAX_INTERFACES[interface_id].skype_user,
-                                                 interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user, globals.SKYPIAX_INTERFACES[interface_id].skype_user);
-                                        running = 0;
-                                        switch_mutex_unlock(globals.mutex);
-                                        switch_xml_free(xml);
-                                        return SWITCH_STATUS_FALSE;
-                                }
-#endif // NOTDEF
-
</del><span class="cx">                         } else {
</span><span class="cx">                                 ERRORA("interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n", SKYPIAX_P_LOG, interface_id, SKYPIAX_MAX_INTERFACES);
</span><span class="cx">                                 continue;
</span><span class="lines">@@ -1706,29 +1516,6 @@
</span><span class="cx">                                 howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", howmany);
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx">                         }
</span><del>-#ifdef NOTDEF
-                        if (globals.SKYPIAX_INTERFACES[interface_id].celliax_api_thread) {
-#ifdef WIN32
-                                if (SendMessage(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) {        // let's the celliax_api_thread_func die
-                                        DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPIAX_P_LOG, GetLastError());
-                                        globals.SKYPIAX_INTERFACES[interface_id].celliax_api_thread = NULL;
-                                }
-#else
-                                XEvent e;
-                                Atom atom1 = XInternAtom(tech_pvt->SkypiaxHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN",
-                                                                                 False);
-                                memset(&e, 0, sizeof(e));
-                                e.xclient.type = ClientMessage;
-                                e.xclient.message_type = atom1;        /* leading message */
-                                e.xclient.display = tech_pvt->SkypiaxHandles.disp;
-                                e.xclient.window = tech_pvt->SkypiaxHandles.skype_win;
-                                e.xclient.format = 8;
-
-                                XSendEvent(tech_pvt->SkypiaxHandles.disp, tech_pvt->SkypiaxHandles.win, False, 0, &e);
-                                XSync(tech_pvt->SkypiaxHandles.disp, False);
-#endif
-                        }
-#endif // NOTDEF
</del><span class="cx">                         x = 10;
</span><span class="cx">                         while (x) {                        //FIXME 0.5 seconds?
</span><span class="cx">                                 x--;
</span><span class="lines">@@ -1767,18 +1554,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-void *SWITCH_THREAD_FUNC celliax_do_tcp_srv_thread(switch_thread_t *thread, void *obj)
-{
-        return celliax_do_tcp_srv_thread_func(obj);
-}
</del><span class="cx">
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_tcp_cli_thread(switch_thread_t *thread, void *obj)
-{
-        return celliax_do_tcp_cli_thread_func(obj);
-}
-#endif // NOTDEF
-
</del><span class="cx"> void *SWITCH_THREAD_FUNC celliax_do_skypeapi_thread(switch_thread_t *thread, void *obj)
</span><span class="cx"> {
</span><span class="cx">         return celliax_do_skypeapi_thread_func(obj);
</span><span class="lines">@@ -1815,41 +1591,7 @@
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-int start_audio_threads(private_t * tech_pvt)
-{
-        switch_threadattr_t *thd_attr = NULL;
</del><span class="cx">
</span><del>-        switch_threadattr_create(&thd_attr, celliax_module_pool);
-        switch_threadattr_detach_set(thd_attr, 1);
-        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-        if (switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr, celliax_do_tcp_srv_thread, tech_pvt, celliax_module_pool) == SWITCH_STATUS_SUCCESS) {
-                DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-        } else {
-                ERRORA("failed to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-                return -1;
-        }
-
-        switch_threadattr_create(&thd_attr, celliax_module_pool);
-        switch_threadattr_detach_set(thd_attr, 1);
-        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-        if (switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr, celliax_do_tcp_cli_thread, tech_pvt, celliax_module_pool) == SWITCH_STATUS_SUCCESS) {
-                DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-        } else {
-                ERRORA("failed to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-                return -1;
-        }
-        switch_sleep(100000);
-
-        if (tech_pvt->tcp_cli_thread == NULL || tech_pvt->tcp_srv_thread == NULL) {
-                ERRORA("tcp_cli_thread or tcp_srv_thread exited\n", SKYPIAX_P_LOG);
-                return -1;
-        }
-
-        return 0;
-}
-#endif // NOTDEF
-
</del><span class="cx"> int new_inbound_channel(private_t * tech_pvt)
</span><span class="cx"> {
</span><span class="cx">         switch_core_session_t *session = NULL;
</span><span class="lines">@@ -2140,12 +1882,6 @@
</span><span class="cx"> /* END: Changes heres */
</span><span class="cx">
</span><span class="cx">         } else {
</span><del>-#ifdef NOTDEF
-                if (globals.sk_console)
-                        celliax_signaling_write(globals.sk_console, (char *) cmd);
-                else
-                        stream->write_function(stream, "sk console is NOT yet assigned\n");
-#endif //NOTDEF
</del><span class="cx">         }
</span><span class="cx"> end:
</span><span class="cx">         switch_safe_free(mycmd);
</span><span class="lines">@@ -2257,83 +1993,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-#ifdef NOTDEF
-int celliax_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)
-                                        if (tech_pvt->interface_state == SKYPIAX_STATE_PRERING) {
-                                        tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-                                } else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
-                                        WARNINGA("Why an interface_state %d HERE?\n", SKYPIAX_P_LOG, tech_pvt->interface_state);
-                                        tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-                                }
-
-                                break;
-                        }
-                }
-        }
-
-        if (found) {
-                //tech_pvt->callid_number[0]='\0';
-                //sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
-                //celliax_signaling_write(tech_pvt, msg_to_skype);
-                switch_mutex_unlock(globals.mutex);
-                return 0;
-        }
-        DEBUGA_SKYPE("NOT FOUND\n", SKYPIAX_P_LOG);
-
-        if (tech_pvt && tech_pvt->skype_call_id && !strlen(tech_pvt->skype_call_id)) {
-                /* we are not inside an active call */
-
-                tech_pvt->ib_calls++;
-
-                sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
-                celliax_signaling_write(tech_pvt, msg_to_skype);
-                switch_sleep(10000);
-                tech_pvt->interface_state = SKYPIAX_STATE_PREANSWER;
-                sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
-                celliax_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);
-        } else if (!tech_pvt || !tech_pvt->skype_call_id) {
-                ERRORA("No Call ID?\n", SKYPIAX_P_LOG);
-        } else {
-                DEBUGA_SKYPE("We're in a call now (%s), let's refuse this one (%s)\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
-                sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
-                celliax_signaling_write(tech_pvt, msg_to_skype);
-        }
-
-        switch_mutex_unlock(globals.mutex);
-        return 0;
-}
-#endif // NOTDEF
</del><span class="cx"> int celliax_transfer(private_t * tech_pvt, char *id, char *value)
</span><span class="cx"> {
</span><span class="cx">         char msg_to_skype[1024];
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>