<!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][14676] </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=14676">14676</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2009-08-29 08:24:59 -0500 (Sat, 29 Aug 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>celliax: indented</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchbranchesgmaruzzmod_celliaxcelliaxh">freeswitch/branches/gmaruzz/mod_celliax/celliax.h</a></li>
<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_celliaxcelliaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/celliax.h (14675 => 14676)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/celliax.h        2009-08-29 13:15:21 UTC (rev 14675)
+++ freeswitch/branches/gmaruzz/mod_celliax/celliax.h        2009-08-29 13:24:59 UTC (rev 14676)
</span><span class="lines">@@ -85,9 +85,9 @@
</span><span class="cx">
</span><span class="cx"> #define                AT_BUFSIZ 8192
</span><span class="cx"> //FIXME FIXME FIXME #define AT_MESG_MAX_LENGTH 2048 /* much more than 10 SMSs */
</span><del>-#define AT_MESG_MAX_LENGTH 2048 /* much more than 10 SMSs */
</del><ins>+#define AT_MESG_MAX_LENGTH 2048        /* much more than 10 SMSs */
</ins><span class="cx"> //FIXME FIXME FIXME #define AT_MESG_MAX_LINES 256 /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */
</span><del>-#define AT_MESG_MAX_LINES 20 /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */
</del><ins>+#define AT_MESG_MAX_LINES 20        /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */
</ins><span class="cx">
</span><span class="cx"> //#define SAMPLERATE_SKYPIAX 16000
</span><span class="cx"> //#define SAMPLES_PER_FRAME SAMPLERATE_SKYPIAX/50
</span><span class="lines">@@ -213,13 +213,13 @@
</span><span class="cx"> * \brief structure for storing the results of AT commands, in an array of AT_MESG_MAX_LINES * AT_MESG_MAX_LENGTH chars
</span><span class="cx"> */
</span><span class="cx"> struct s_result {
</span><del>- int elemcount;
- char result[AT_MESG_MAX_LINES][AT_MESG_MAX_LENGTH];
</del><ins>+        int elemcount;
+        char result[AT_MESG_MAX_LINES][AT_MESG_MAX_LENGTH];
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct ciapa_struct {
</span><del>-int state;
-int hangupcause;
</del><ins>+        int state;
+        int hangupcause;
</ins><span class="cx"> };
</span><span class="cx"> typedef struct ciapa_struct ciapa_t;
</span><span class="cx">
</span><span class="lines">@@ -309,138 +309,138 @@
</span><span class="cx">         unsigned long ob_failed_calls;
</span><span class="cx">
</span><span class="cx">
</span><del>- char controldevice_name[50]; /*!< \brief name of the serial device controlling the interface, possibly none */
- int controldevprotocol; /*!< \brief which protocol is used for serial control of this interface */
- char controldevprotocolname[50]; /*!< \brief name of the serial device controlling protocol, one of "at" "fbus2" "no_serial" "alsa_voicemodem" */
- int controldevfd; /*!< \brief serial controlling file descriptor for this interface */
- //pthread_t controldev_thread; /*!< \brief serial control thread for this interface, running during the call */
- speed_t controldevice_speed;
- int controldev_dead;
-
- char at_dial_pre_number[64];
- char at_dial_post_number[64];
- char at_dial_expect[64];
- unsigned int at_early_audio;
- char at_hangup[64];
- char at_hangup_expect[64];
- char at_answer[64];
- char at_answer_expect[64];
- unsigned int at_initial_pause;
- char at_preinit_1[64];
- char at_preinit_1_expect[64];
- char at_preinit_2[64];
- char at_preinit_2_expect[64];
- char at_preinit_3[64];
- char at_preinit_3_expect[64];
- char at_preinit_4[64];
- char at_preinit_4_expect[64];
- char at_preinit_5[64];
- char at_preinit_5_expect[64];
- unsigned int at_after_preinit_pause;
</del><ins>+        char controldevice_name[50];        /*!< \brief name of the serial device controlling the interface, possibly none */
+        int controldevprotocol;                /*!< \brief which protocol is used for serial control of this interface */
+        char controldevprotocolname[50];        /*!< \brief name of the serial device controlling protocol, one of "at" "fbus2" "no_serial" "alsa_voicemodem" */
+        int controldevfd;                        /*!< \brief serial controlling file descriptor for this interface */
+        //pthread_t controldev_thread; /*!< \brief serial control thread for this interface, running during the call */
+        speed_t controldevice_speed;
+        int controldev_dead;
</ins><span class="cx">
</span><del>- char at_postinit_1[64];
- char at_postinit_1_expect[64];
- char at_postinit_2[64];
- char at_postinit_2_expect[64];
- char at_postinit_3[64];
- char at_postinit_3_expect[64];
- char at_postinit_4[64];
- char at_postinit_4_expect[64];
- char at_postinit_5[64];
- char at_postinit_5_expect[64];
</del><ins>+        char at_dial_pre_number[64];
+        char at_dial_post_number[64];
+        char at_dial_expect[64];
+        unsigned int at_early_audio;
+        char at_hangup[64];
+        char at_hangup_expect[64];
+        char at_answer[64];
+        char at_answer_expect[64];
+        unsigned int at_initial_pause;
+        char at_preinit_1[64];
+        char at_preinit_1_expect[64];
+        char at_preinit_2[64];
+        char at_preinit_2_expect[64];
+        char at_preinit_3[64];
+        char at_preinit_3_expect[64];
+        char at_preinit_4[64];
+        char at_preinit_4_expect[64];
+        char at_preinit_5[64];
+        char at_preinit_5_expect[64];
+        unsigned int at_after_preinit_pause;
</ins><span class="cx">
</span><del>- char at_send_dtmf[64];
</del><ins>+        char at_postinit_1[64];
+        char at_postinit_1_expect[64];
+        char at_postinit_2[64];
+        char at_postinit_2_expect[64];
+        char at_postinit_3[64];
+        char at_postinit_3_expect[64];
+        char at_postinit_4[64];
+        char at_postinit_4_expect[64];
+        char at_postinit_5[64];
+        char at_postinit_5_expect[64];
</ins><span class="cx">
</span><del>- char at_query_battchg[64];
- char at_query_battchg_expect[64];
- char at_query_signal[64];
- char at_query_signal_expect[64];
- char at_call_idle[64];
- char at_call_incoming[64];
- char at_call_active[64];
- char at_call_failed[64];
- char at_call_calling[64];
</del><ins>+        char at_send_dtmf[64];
</ins><span class="cx">
</span><ins>+        char at_query_battchg[64];
+        char at_query_battchg_expect[64];
+        char at_query_signal[64];
+        char at_query_signal_expect[64];
+        char at_call_idle[64];
+        char at_call_incoming[64];
+        char at_call_active[64];
+        char at_call_failed[64];
+        char at_call_calling[64];
+
</ins><span class="cx"> #define CIEV_STRING_SIZE 64
</span><del>- char at_indicator_noservice_string[64];
- char at_indicator_nosignal_string[64];
- char at_indicator_lowsignal_string[64];
- char at_indicator_lowbattchg_string[64];
- char at_indicator_nobattchg_string[64];
- char at_indicator_callactive_string[64];
- char at_indicator_nocallactive_string[64];
- char at_indicator_nocallsetup_string[64];
- char at_indicator_callsetupincoming_string[64];
- char at_indicator_callsetupoutgoing_string[64];
- char at_indicator_callsetupremoteringing_string[64];
</del><ins>+        char at_indicator_noservice_string[64];
+        char at_indicator_nosignal_string[64];
+        char at_indicator_lowsignal_string[64];
+        char at_indicator_lowbattchg_string[64];
+        char at_indicator_nobattchg_string[64];
+        char at_indicator_callactive_string[64];
+        char at_indicator_nocallactive_string[64];
+        char at_indicator_nocallsetup_string[64];
+        char at_indicator_callsetupincoming_string[64];
+        char at_indicator_callsetupoutgoing_string[64];
+        char at_indicator_callsetupremoteringing_string[64];
</ins><span class="cx">
</span><del>- int at_indicator_callp;
- int at_indicator_callsetupp;
- int at_indicator_roamp;
- int at_indicator_battchgp;
- int at_indicator_servicep;
- int at_indicator_signalp;
</del><ins>+        int at_indicator_callp;
+        int at_indicator_callsetupp;
+        int at_indicator_roamp;
+        int at_indicator_battchgp;
+        int at_indicator_servicep;
+        int at_indicator_signalp;
</ins><span class="cx">
</span><del>- int at_has_clcc;
- int at_has_ecam;
</del><ins>+        int at_has_clcc;
+        int at_has_ecam;
</ins><span class="cx">
</span><del>- char at_cmgw[16];
- int no_ucs2;
- time_t celliax_serial_sync_period;
</del><ins>+        char at_cmgw[16];
+        int no_ucs2;
+        time_t celliax_serial_sync_period;
</ins><span class="cx">
</span><del>- time_t celliax_serial_synced_timestamp;
- struct s_result line_array;
</del><ins>+        time_t celliax_serial_synced_timestamp;
+        struct s_result line_array;
</ins><span class="cx">
</span><span class="cx">
</span><del>- int unread_sms_msg_id;
- int reading_sms_msg;
- char sms_message[4800];
- int sms_cnmi_not_supported;
- char sms_receiving_program[256];
</del><ins>+        int unread_sms_msg_id;
+        int reading_sms_msg;
+        char sms_message[4800];
+        int sms_cnmi_not_supported;
+        char sms_receiving_program[256];
</ins><span class="cx">
</span><span class="cx">
</span><del>- struct timeval call_incoming_time;
- int phone_callflow; /*!< \brief 'callflow' of the phone interface (as opposed to skype interface) */
- switch_mutex_t *controldev_lock;
</del><ins>+        struct timeval call_incoming_time;
+        int phone_callflow;                        /*!< \brief 'callflow' of the phone interface (as opposed to skype interface) */
+        switch_mutex_t *controldev_lock;
</ins><span class="cx">
</span><del>- int phonebook_listing;
- int phonebook_querying;
- int phonebook_listing_received_calls;
</del><ins>+        int phonebook_listing;
+        int phonebook_querying;
+        int phonebook_listing_received_calls;
</ins><span class="cx">
</span><del>- int phonebook_first_entry;
- int phonebook_last_entry;
- int phonebook_number_lenght;
- int phonebook_text_lenght;
- FILE *phonebook_writing_fp;
</del><ins>+        int phonebook_first_entry;
+        int phonebook_last_entry;
+        int phonebook_number_lenght;
+        int phonebook_text_lenght;
+        FILE *phonebook_writing_fp;
</ins><span class="cx">
</span><del>- struct timeval ringtime;
- ciapa_t *owner;
</del><ins>+        struct timeval ringtime;
+        ciapa_t *owner;
</ins><span class="cx"> #ifdef CELLIAX_ALSA
</span><del>- snd_pcm_t *alsac; /*!< \brief handle of the ALSA capture audio device */
- snd_pcm_t *alsap; /*!< \brief handle of the ALSA playback audio device */
- char alsacname[50]; /*!< \brief name of the ALSA capture audio device */
- char alsapname[50]; /*!< \brief name of the ALSA playback audio device */
- int alsa_period_size; /*!< \brief ALSA period_size, in byte */
- int alsa_periods_in_buffer; /*!< \brief how many periods in ALSA buffer, to calculate buffer_size */
- unsigned long int alsa_buffer_size; /*!< \brief ALSA buffer_size, in byte */
- int alsawrite_filled;
- int alsa_capture_is_mono;
- int alsa_play_is_mono;
- struct pollfd pfd;
-#endif// CELLIAX_ALSA
</del><ins>+        snd_pcm_t *alsac;                        /*!< \brief handle of the ALSA capture audio device */
+        snd_pcm_t *alsap;                        /*!< \brief handle of the ALSA playback audio device */
+        char alsacname[50];                        /*!< \brief name of the ALSA capture audio device */
+        char alsapname[50];                        /*!< \brief name of the ALSA playback audio device */
+        int alsa_period_size;                /*!< \brief ALSA period_size, in byte */
+        int alsa_periods_in_buffer;        /*!< \brief how many periods in ALSA buffer, to calculate buffer_size */
+        unsigned long int alsa_buffer_size;        /*!< \brief ALSA buffer_size, in byte */
+        int alsawrite_filled;
+        int alsa_capture_is_mono;
+        int alsa_play_is_mono;
+        struct pollfd pfd;
+#endif                                                        // CELLIAX_ALSA
</ins><span class="cx">
</span><del>- time_t audio_play_reset_timestamp;
- int audio_play_reset_period;
</del><ins>+        time_t audio_play_reset_timestamp;
+        int audio_play_reset_period;
</ins><span class="cx">
</span><del>-switch_timer_t timer;
- teletone_dtmf_detect_state_t dtmf_detect;
- switch_time_t old_dtmf_timestamp;
</del><ins>+        switch_timer_t timer;
+        teletone_dtmf_detect_state_t dtmf_detect;
+        switch_time_t old_dtmf_timestamp;
</ins><span class="cx">
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> typedef struct private_object private_t;
</span><span class="cx">
</span><del>-void *SWITCH_THREAD_FUNC celliax_api_thread_func(switch_thread_t * thread, void *obj);
</del><ins>+void *SWITCH_THREAD_FUNC celliax_api_thread_func(switch_thread_t *thread, void *obj);
</ins><span class="cx"> int celliax_audio_read(private_t * tech_pvt);
</span><span class="cx"> int celliax_audio_init(private_t * tech_pvt);
</span><span class="cx"> int celliax_signaling_read(private_t * tech_pvt);
</span><span class="lines">@@ -449,21 +449,21 @@
</span><span class="cx"> int celliax_senddigit(private_t * tech_pvt, char digit);
</span><span class="cx">
</span><span class="cx"> void *celliax_do_tcp_srv_thread_func(void *obj);
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_tcp_srv_thread(switch_thread_t * thread, void *obj);
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_tcp_srv_thread(switch_thread_t *thread, void *obj);
</ins><span class="cx">
</span><span class="cx"> void *celliax_do_tcp_cli_thread_func(void *obj);
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_tcp_cli_thread(switch_thread_t * thread, void *obj);
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_tcp_cli_thread(switch_thread_t *thread, void *obj);
</ins><span class="cx">
</span><span class="cx"> void *celliax_do_skypeapi_thread_func(void *obj);
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_skypeapi_thread(switch_thread_t * thread, void *obj);
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_skypeapi_thread(switch_thread_t *thread, void *obj);
</ins><span class="cx"> int dtmf_received(private_t * tech_pvt, char *value);
</span><span class="cx"> int start_audio_threads(private_t * tech_pvt);
</span><span class="cx"> int new_inbound_channel(private_t * tech_pvt);
</span><span class="cx"> int outbound_channel_answered(private_t * tech_pvt);
</span><span class="cx"> //int celliax_signaling_write(private_t * tech_pvt, char *msg_to_skype);
</span><span class="cx"> #if defined(WIN32) && !defined(__CYGWIN__)
</span><del>-int celliax_pipe_read(switch_file_t * pipe, short *buf, int howmany);
-int celliax_pipe_write(switch_file_t * pipe, short *buf, int howmany);
</del><ins>+int celliax_pipe_read(switch_file_t *pipe, short *buf, int howmany);
+int celliax_pipe_write(switch_file_t *pipe, short *buf, int howmany);
</ins><span class="cx"> /* Visual C do not have strsep ? */
</span><span class="cx"> char *strsep(char **stringp, const char *delim);
</span><span class="cx"> #else
</span><span class="lines">@@ -501,13 +501,9 @@
</span><span class="cx"> int celliax_serial_write_AT_ack(private_t * tech_pvt, const char *data);
</span><span class="cx"> int celliax_serial_write_AT_ack_nocr_longtime(private_t * tech_pvt, const char *data);
</span><span class="cx"> int celliax_serial_write_AT_noack(private_t * tech_pvt, const char *data);
</span><del>-int celliax_serial_write_AT_expect1(private_t * tech_pvt, const char *data,
- const char *expected_string, int expect_crlf,
- int seconds);
-int celliax_serial_AT_expect(private_t * tech_pvt, const char *expected_string,
- int expect_crlf, int seconds);
-int celliax_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_usec,
- int timeout_sec, const char *expected_string, int expect_crlf);
</del><ins>+int celliax_serial_write_AT_expect1(private_t * tech_pvt, const char *data, const char *expected_string, int expect_crlf, int seconds);
+int celliax_serial_AT_expect(private_t * tech_pvt, const char *expected_string, int expect_crlf, int seconds);
+int celliax_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_usec, int timeout_sec, const char *expected_string, int expect_crlf);
</ins><span class="cx"> int celliax_serial_read(private_t * tech_pvt);
</span><span class="cx"> #ifdef NOTDEF
</span><span class="cx"> int celliax_serial_getstatus(private_t * tech_pvt);
</span><span class="lines">@@ -517,13 +513,11 @@
</span><span class="cx"> int celliax_serial_hangup_AT(private_t * tech_pvt);
</span><span class="cx"> int celliax_serial_call_AT(private_t * tech_pvt, char *dstr);
</span><span class="cx"> int celliax_serial_getstatus_AT(private_t * tech_pvt);
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx"> #define RESULT_FAILURE 0
</span><span class="cx"> #define RESULT_SUCCESS 1
</span><del>-int utf_to_ucs2(private_t * tech_pvt, char *utf_in, size_t inbytesleft, char *ucs2_out,
- size_t outbytesleft);
-int ucs2_to_utf8(private_t * tech_pvt, char *ucs2_in, char *utf8_out,
- size_t outbytesleft);
</del><ins>+int utf_to_ucs2(private_t * tech_pvt, char *utf_in, size_t inbytesleft, char *ucs2_out, size_t outbytesleft);
+int ucs2_to_utf8(private_t * tech_pvt, char *ucs2_in, char *utf8_out, size_t outbytesleft);
</ins><span class="cx"> //#define PUSHA_UNLOCKA(x) pthread_cleanup_push(celliax_unlocka_log, (void *) x);
</span><span class="cx"> //#define POPPA_UNLOCKA(x) pthread_cleanup_pop(0);
</span><span class="cx">
</span><span class="lines">@@ -531,7 +525,7 @@
</span><span class="cx"> #define POPPA_UNLOCKA(x) if(option_debug > 100) ERRORA("POPPA_UNLOCKA: %p\n", SKYPIAX_P_LOG, (void *)x);
</span><span class="cx"> //#define LOKKA(x) if(option_debug > 100) ERRORA("LOKKA: %p\n", SKYPIAX_P_LOG, (void *)x);
</span><span class="cx"> #define LOKKA(x) switch_mutex_lock(x);
</span><del>-#define UNLOCKA(x) switch_mutex_unlock(x);
</del><ins>+#define UNLOCKA(x) switch_mutex_unlock(x);
</ins><span class="cx"> //#define UNLOCKA(x) if(option_debug > 100) ERRORA("UNLOCKA: %p\n", SKYPIAX_P_LOG, (void *)x);
</span><span class="cx">
</span><span class="cx"> #define celliax_queue_control(x, y) ERRORA("celliax_queue_control: %p, %d\n", SKYPIAX_P_LOG, (void *)x, y);
</span><span class="lines">@@ -552,7 +546,7 @@
</span><span class="cx"> int alsa_init(private_t * tech_pvt);
</span><span class="cx"> int alsa_shutdown(private_t * tech_pvt);
</span><span class="cx"> snd_pcm_t *alsa_open_dev(private_t * tech_pvt, snd_pcm_stream_t stream);
</span><del>-int alsa_write(private_t * tech_pvt, short * data, int datalen);
-int alsa_read(private_t * tech_pvt, short * data, int datalen);
</del><ins>+int alsa_write(private_t * tech_pvt, short *data, int datalen);
+int alsa_read(private_t * tech_pvt, short *data, int datalen);
</ins><span class="cx">
</span><span class="cx"> #endif /* CELLIAX_ALSA */
</span></span></pre></div>
<a id="freeswitchbranchesgmaruzzmod_celliaxcelliax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c (14675 => 14676)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c        2009-08-29 13:15:21 UTC (rev 14675)
+++ freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c        2009-08-29 13:24:59 UTC (rev 14676)
</span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx"> extern int running;
</span><span class="cx"> int celliax_dir_entry_extension = 1;
</span><span class="cx">
</span><del>-int option_debug=100;
</del><ins>+int option_debug = 100;
</ins><span class="cx">
</span><span class="cx"> #ifdef NOTDEF
</span><span class="cx"> /*************************************/
</span><span class="lines">@@ -136,8 +136,7 @@
</span><span class="cx">                                 } else if (!strncasecmp(message, "ERROR 592 ALTER CALL", 19)) {
</span><span class="cx">                                         ERRORA("Skype got ERROR about TRANSFERRING, no problem: |||%s|||\n", SKYPIAX_P_LOG, message);
</span><span class="cx">                                 } else if (!strncasecmp(message, "ERROR 559 CALL", 13)) {
</span><del>-                                        DEBUGA_SKYPE("Skype got ERROR about a failed action (probably TRYING to HANGUP A CALL), no problem: |||%s|||\n", SKYPIAX_P_LOG,
-                                                                 message);
</del><ins>+                                        DEBUGA_SKYPE("Skype got ERROR about a failed action (probably TRYING to HANGUP A CALL), no problem: |||%s|||\n", SKYPIAX_P_LOG, message);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
</span><span class="cx">                                         tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
</span><span class="lines">@@ -178,8 +177,7 @@
</span><span class="cx">                                 if (!strcasecmp(id, tech_pvt->skype_user)) {
</span><span class="cx">                                         tech_pvt->SkypiaxHandles.currentuserhandle = 1;
</span><span class="cx">                                         DEBUGA_SKYPE
</span><del>-                                                ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
-                                                 SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user);
</del><ins>+                                                ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         if (!strcasecmp(message, "USER")) {
</span><span class="lines">@@ -496,7 +494,7 @@
</span><span class="cx">         }                                                        //read_from_pipe
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx">
</span><span class="cx"> void *celliax_do_tcp_srv_thread_func(void *obj)
</span><span class="cx"> {
</span><span class="lines">@@ -627,8 +625,7 @@
</span><span class="cx">                                                                 /* send the complete frame through the pipe to our code waiting for incoming audio */
</span><span class="cx">                                                                 howmany = celliax_pipe_write(tech_pvt->audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short));
</span><span class="cx">                                                                 if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
</span><del>-                                                                        ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG,
-                                                                                 howmany, (int) (SAMPLES_PER_FRAME * sizeof(short)));
</del><ins>+                                                                        ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, (int) (SAMPLES_PER_FRAME * sizeof(short)));
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                                 /* done with the stored half frame */
</span><span class="cx">                                                                 tech_pvt->audiobuf_is_loaded = 0;
</span><span class="lines">@@ -874,7 +871,7 @@
</span><span class="cx"> /* PLATFORM SPECIFIC */
</span><span class="cx"> /***************************/
</span><span class="cx"> #if defined(WIN32) && !defined(__CYGWIN__)
</span><del>-int celliax_pipe_read(switch_file_t * pipe, short *buf, int howmany)
</del><ins>+int celliax_pipe_read(switch_file_t *pipe, short *buf, int howmany)
</ins><span class="cx"> {
</span><span class="cx">         switch_size_t quantity;
</span><span class="cx">
</span><span class="lines">@@ -887,7 +884,7 @@
</span><span class="cx">         return howmany;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-int celliax_pipe_write(switch_file_t * pipe, short *buf, int howmany)
</del><ins>+int celliax_pipe_write(switch_file_t *pipe, short *buf, int howmany)
</ins><span class="cx"> {
</span><span class="cx">         switch_size_t quantity;
</span><span class="cx">
</span><span class="lines">@@ -1189,8 +1186,7 @@
</span><span class="cx">
</span><span class="cx">         celliax_sleep(200000);                //0,2 sec
</span><span class="cx">
</span><del>-        if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
-                && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
</del><ins>+        if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0 && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
</ins><span class="cx">                 if (win32_Initialize_CreateWindowClass(tech_pvt)) {
</span><span class="cx">                         if (win32_Initialize_CreateMainWindow(tech_pvt)) {
</span><span class="cx">                                 if (SendMessage
</span><span class="lines">@@ -1373,1898 +1369,1746 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-int celliax_serial_init(private_t *tech_pvt, speed_t controldevice_speed)
</del><ins>+int celliax_serial_init(private_t * tech_pvt, speed_t controldevice_speed)
</ins><span class="cx"> {
</span><del>- int fd;
- int rt;
- struct termios tp;
</del><ins>+        int fd;
+        int rt;
+        struct termios tp;
</ins><span class="cx">
</span><span class="cx"> /* if there is a file descriptor, close it. But it is probably just an old value, so don't check for close success*/
</span><del>- fd = tech_pvt->controldevfd;
- if (fd) {
- close(fd);
- }
</del><ins>+        fd = tech_pvt->controldevfd;
+        if (fd) {
+                close(fd);
+        }
</ins><span class="cx"> /* open the serial port */
</span><span class="cx"> #ifdef __CYGWIN__
</span><del>- fd = open(tech_pvt->controldevice_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
- sleep(1);
- close(fd);
</del><ins>+        fd = open(tech_pvt->controldevice_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
+        sleep(1);
+        close(fd);
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>- fd = open(tech_pvt->controldevice_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
- if (fd == -1) {
- DEBUGA_SKYPE("serial error: %s\n", SKYPIAX_P_LOG, strerror(errno));
- tech_pvt->controldevfd = fd;
- return -1;
- }
</del><ins>+        fd = open(tech_pvt->controldevice_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
+        if (fd == -1) {
+                DEBUGA_SKYPE("serial error: %s\n", SKYPIAX_P_LOG, strerror(errno));
+                tech_pvt->controldevfd = fd;
+                return -1;
+        }
</ins><span class="cx"> /* flush it */
</span><del>- rt = tcflush(fd, TCIFLUSH);
- if (rt == -1) {
- ERRORA("serial error: %s", SKYPIAX_P_LOG, strerror(errno));
- }
</del><ins>+        rt = tcflush(fd, TCIFLUSH);
+        if (rt == -1) {
+                ERRORA("serial error: %s", SKYPIAX_P_LOG, strerror(errno));
+        }
</ins><span class="cx"> /* attributes */
</span><del>- tp.c_cflag = B0 | CS8 | CLOCAL | CREAD | HUPCL;
- tp.c_iflag = IGNPAR;
- tp.c_cflag &= ~CRTSCTS;
- tp.c_oflag = 0;
- tp.c_lflag = 0;
- tp.c_cc[VMIN] = 1;
- tp.c_cc[VTIME] = 0;
</del><ins>+        tp.c_cflag = B0 | CS8 | CLOCAL | CREAD | HUPCL;
+        tp.c_iflag = IGNPAR;
+        tp.c_cflag &= ~CRTSCTS;
+        tp.c_oflag = 0;
+        tp.c_lflag = 0;
+        tp.c_cc[VMIN] = 1;
+        tp.c_cc[VTIME] = 0;
</ins><span class="cx"> /* set controldevice_speed */
</span><del>- rt = cfsetispeed(&tp, tech_pvt->controldevice_speed);
- if (rt == -1) {
- ERRORA("serial error: %s, speed was: %d", SKYPIAX_P_LOG, strerror(errno), tech_pvt->controldevice_speed);
- }
- rt = cfsetospeed(&tp, tech_pvt->controldevice_speed);
- if (rt == -1) {
- ERRORA("serial error: %s", SKYPIAX_P_LOG, strerror(errno));
- }
</del><ins>+        rt = cfsetispeed(&tp, tech_pvt->controldevice_speed);
+        if (rt == -1) {
+                ERRORA("serial error: %s, speed was: %d", SKYPIAX_P_LOG, strerror(errno), tech_pvt->controldevice_speed);
+        }
+        rt = cfsetospeed(&tp, tech_pvt->controldevice_speed);
+        if (rt == -1) {
+                ERRORA("serial error: %s", SKYPIAX_P_LOG, strerror(errno));
+        }
</ins><span class="cx"> /* set port attributes */
</span><del>- if (tcsetattr(fd, TCSADRAIN, &tp) == -1) {
- ERRORA("serial error: %s", SKYPIAX_P_LOG, strerror(errno));
- }
- rt = tcsetattr(fd, TCSANOW, &tp);
- if (rt == -1) {
- ERRORA("serial error: %s", SKYPIAX_P_LOG, strerror(errno));
- }
- unsigned int status = 0;
</del><ins>+        if (tcsetattr(fd, TCSADRAIN, &tp) == -1) {
+                ERRORA("serial error: %s", SKYPIAX_P_LOG, strerror(errno));
+        }
+        rt = tcsetattr(fd, TCSANOW, &tp);
+        if (rt == -1) {
+                ERRORA("serial error: %s", SKYPIAX_P_LOG, strerror(errno));
+        }
+        unsigned int status = 0;
</ins><span class="cx"> #ifndef __CYGWIN__
</span><del>- ioctl(fd, TIOCMGET, &status);
- status |= TIOCM_DTR; /* Set DTR high */
- status &= ~TIOCM_RTS; /* Set RTS low */
- ioctl(fd, TIOCMSET, &status);
- ioctl(fd, TIOCMGET, &status);
- unsigned int flags = TIOCM_DTR;
- ioctl(fd, TIOCMBIS, &flags);
- flags = TIOCM_RTS;
- ioctl(fd, TIOCMBIC, &flags);
- ioctl(fd, TIOCMGET, &status);
</del><ins>+        ioctl(fd, TIOCMGET, &status);
+        status |= TIOCM_DTR;                /* Set DTR high */
+        status &= ~TIOCM_RTS;                /* Set RTS low */
+        ioctl(fd, TIOCMSET, &status);
+        ioctl(fd, TIOCMGET, &status);
+        unsigned int flags = TIOCM_DTR;
+        ioctl(fd, TIOCMBIS, &flags);
+        flags = TIOCM_RTS;
+        ioctl(fd, TIOCMBIC, &flags);
+        ioctl(fd, TIOCMGET, &status);
</ins><span class="cx"> #else /* __CYGWIN__ */
</span><del>- ioctl(fd, TIOCMGET, &status);
- status |= TIOCM_DTR; /* Set DTR high */
- status &= ~TIOCM_RTS; /* Set RTS low */
- ioctl(fd, TIOCMSET, &status);
</del><ins>+        ioctl(fd, TIOCMGET, &status);
+        status |= TIOCM_DTR;                /* Set DTR high */
+        status &= ~TIOCM_RTS;                /* Set RTS low */
+        ioctl(fd, TIOCMSET, &status);
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>- tech_pvt->controldevfd = fd;
- DEBUGA_SKYPE("Syncing Serial\n", SKYPIAX_P_LOG);
- rt = celliax_serial_sync(tech_pvt);
- if (rt == -1) {
- ERRORA("Serial init error\n", SKYPIAX_P_LOG);
- return -1;
- }
- return (fd);
</del><ins>+        tech_pvt->controldevfd = fd;
+        DEBUGA_SKYPE("Syncing Serial\n", SKYPIAX_P_LOG);
+        rt = celliax_serial_sync(tech_pvt);
+        if (rt == -1) {
+                ERRORA("Serial init error\n", SKYPIAX_P_LOG);
+                return -1;
+        }
+        return (fd);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_read(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_AT)
- return celliax_serial_read_AT(tech_pvt, 0, 100000, 0, NULL, 1); // a 10th of a second timeout
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_read_AT(tech_pvt, 0, 100000, 0, NULL, 1);        // a 10th of a second timeout
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
- return celliax_serial_read_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_read_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
- return celliax_serial_read_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_read_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>- return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> int celliax_serial_sync(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_AT)
- return celliax_serial_sync_AT(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_sync_AT(tech_pvt);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
- return celliax_serial_sync_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_sync_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
- return celliax_serial_sync_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_sync_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><span class="cx">
</span><del>- return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_config(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_AT)
- return celliax_serial_config_AT(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_config_AT(tech_pvt);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
- return celliax_serial_config_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_config_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
- return celliax_serial_config_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_config_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>- return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_config_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- int res;
</del><ins>+        int res;
</ins><span class="cx">
</span><span class="cx"> /* initial_pause? */
</span><del>- if (tech_pvt->at_initial_pause) {
- DEBUGA_SKYPE("sleeping for %d usec\n", SKYPIAX_P_LOG, tech_pvt->at_initial_pause);
- usleep(tech_pvt->at_initial_pause);
- }
</del><ins>+        if (tech_pvt->at_initial_pause) {
+                DEBUGA_SKYPE("sleeping for %d usec\n", SKYPIAX_P_LOG, tech_pvt->at_initial_pause);
+                usleep(tech_pvt->at_initial_pause);
+        }
</ins><span class="cx">
</span><span class="cx"> /* go until first empty preinit string, or last preinit string */
</span><del>- while (1) {
</del><ins>+        while (1) {
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_preinit_1)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_1, tech_pvt->at_preinit_1_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_preinit_1, tech_pvt->at_preinit_1_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_preinit_1)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_1, tech_pvt->at_preinit_1_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_preinit_1, tech_pvt->at_preinit_1_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_preinit_2)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_2, tech_pvt->at_preinit_2_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_preinit_2, tech_pvt->at_preinit_2_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_preinit_2)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_2, tech_pvt->at_preinit_2_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_preinit_2, tech_pvt->at_preinit_2_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_preinit_3)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_3, tech_pvt->at_preinit_3_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_preinit_3, tech_pvt->at_preinit_3_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_preinit_3)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_3, tech_pvt->at_preinit_3_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_preinit_3, tech_pvt->at_preinit_3_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_preinit_4)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_4, tech_pvt->at_preinit_4_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_preinit_4, tech_pvt->at_preinit_4_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_preinit_4)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_4, tech_pvt->at_preinit_4_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_preinit_4, tech_pvt->at_preinit_4_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_preinit_5)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_5, tech_pvt->at_preinit_5_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_preinit_5, tech_pvt->at_preinit_5_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_preinit_5)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_5, tech_pvt->at_preinit_5_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_preinit_5, tech_pvt->at_preinit_5_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+                break;
+        }
</ins><span class="cx">
</span><span class="cx"> /* after_preinit_pause? */
</span><del>- if (tech_pvt->at_after_preinit_pause) {
- DEBUGA_SKYPE("sleeping for %d usec\n", SKYPIAX_P_LOG, tech_pvt->at_after_preinit_pause);
- usleep(tech_pvt->at_after_preinit_pause);
- }
</del><ins>+        if (tech_pvt->at_after_preinit_pause) {
+                DEBUGA_SKYPE("sleeping for %d usec\n", SKYPIAX_P_LOG, tech_pvt->at_after_preinit_pause);
+                usleep(tech_pvt->at_after_preinit_pause);
+        }
</ins><span class="cx">
</span><del>- /* phone, brother, art you alive? */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT");
- if (res) {
- ERRORA("no response to AT\n", SKYPIAX_P_LOG);
- return -1;
- }
- /* for motorola, bring it back to "normal" mode if it happens to be in another mode */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+mode=0");
- if (res) {
- DEBUGA_SKYPE("AT+mode=0 does not get OK from the phone. If it is NOT Motorola,"
- " no problem.\n", SKYPIAX_P_LOG);
- }
- usleep(50000);
- /* for motorola end */
</del><ins>+        /* phone, brother, art you alive? */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT");
+        if (res) {
+                ERRORA("no response to AT\n", SKYPIAX_P_LOG);
+                return -1;
+        }
+        /* for motorola, bring it back to "normal" mode if it happens to be in another mode */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+mode=0");
+        if (res) {
+                DEBUGA_SKYPE("AT+mode=0 does not get OK from the phone. If it is NOT Motorola," " no problem.\n", SKYPIAX_P_LOG);
+        }
+        usleep(50000);
+        /* for motorola end */
</ins><span class="cx">
</span><del>- /* reset AT configuration to phone default */
- res = celliax_serial_write_AT_ack(tech_pvt, "ATZ");
- if (res) {
- DEBUGA_SKYPE("ATZ failed\n", SKYPIAX_P_LOG);
- }
</del><ins>+        /* reset AT configuration to phone default */
+        res = celliax_serial_write_AT_ack(tech_pvt, "ATZ");
+        if (res) {
+                DEBUGA_SKYPE("ATZ failed\n", SKYPIAX_P_LOG);
+        }
</ins><span class="cx">
</span><del>- /* disable AT command echo */
- res = celliax_serial_write_AT_ack(tech_pvt, "ATE0");
- if (res) {
- DEBUGA_SKYPE("ATE0 failed\n", SKYPIAX_P_LOG);
- }
</del><ins>+        /* disable AT command echo */
+        res = celliax_serial_write_AT_ack(tech_pvt, "ATE0");
+        if (res) {
+                DEBUGA_SKYPE("ATE0 failed\n", SKYPIAX_P_LOG);
+        }
</ins><span class="cx">
</span><del>- /* disable extended error reporting */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMEE=0");
- if (res) {
- DEBUGA_SKYPE("AT+CMEE failed\n", SKYPIAX_P_LOG);
- }
</del><ins>+        /* disable extended error reporting */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMEE=0");
+        if (res) {
+                DEBUGA_SKYPE("AT+CMEE failed\n", SKYPIAX_P_LOG);
+        }
</ins><span class="cx">
</span><del>- /* various phone manufacturer identifier */
- char at_command[5];
- int i;
- for (i = 0; i < 10; i++) {
- memset(at_command, 0, sizeof(at_command));
- sprintf(at_command, "ATI%d", i);
- res = celliax_serial_write_AT_ack(tech_pvt, at_command);
- if (res) {
- DEBUGA_SKYPE("ATI%d command failed, continue\n", SKYPIAX_P_LOG, i);
- }
- }
</del><ins>+        /* various phone manufacturer identifier */
+        char at_command[5];
+        int i;
+        for (i = 0; i < 10; i++) {
+                memset(at_command, 0, sizeof(at_command));
+                sprintf(at_command, "ATI%d", i);
+                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
+                if (res) {
+                        DEBUGA_SKYPE("ATI%d command failed, continue\n", SKYPIAX_P_LOG, i);
+                }
+        }
</ins><span class="cx">
</span><del>- /* phone manufacturer */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CGMI");
- if (res) {
- DEBUGA_SKYPE("AT+CGMI failed\n", SKYPIAX_P_LOG);
- }
</del><ins>+        /* phone manufacturer */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CGMI");
+        if (res) {
+                DEBUGA_SKYPE("AT+CGMI failed\n", SKYPIAX_P_LOG);
+        }
</ins><span class="cx">
</span><del>- /* phone model */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CGMM");
- if (res) {
- DEBUGA_SKYPE("AT+CGMM failed\n", SKYPIAX_P_LOG);
- }
</del><ins>+        /* phone model */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CGMM");
+        if (res) {
+                DEBUGA_SKYPE("AT+CGMM failed\n", SKYPIAX_P_LOG);
+        }
</ins><span class="cx">
</span><del>- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CGSN");
- if (res) {
- DEBUGA_SKYPE("AT+CGSN failed\n", SKYPIAX_P_LOG);
- }
</del><ins>+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CGSN");
+        if (res) {
+                DEBUGA_SKYPE("AT+CGSN failed\n", SKYPIAX_P_LOG);
+        }
</ins><span class="cx">
</span><span class="cx"> /* this take a lot of time to complete on devices with slow serial link (eg.: 9600bps) */
</span><del>- /* signal incoming SMS with a +CMTI unsolicited msg */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CNMI=3,1,0,0,0");
- if (res) {
- DEBUGA_SKYPE("AT+CNMI=3,1,0,0,0 failed, continue\n", SKYPIAX_P_LOG);
- tech_pvt->sms_cnmi_not_supported = 1;
- tech_pvt->celliax_serial_sync_period = 30;
- }
- /* what is the Message Center address (number) to which the SMS has to be sent? */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCA?");
- if (res) {
- DEBUGA_SKYPE("AT+CSCA? failed, continue\n", SKYPIAX_P_LOG);
- }
- /* what is the Message Format of SMSs? */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMGF?");
- if (res) {
- DEBUGA_SKYPE("AT+CMGF? failed, continue\n", SKYPIAX_P_LOG);
- }
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMGF=1"); //TODO: support phones that only accept pdu mode
- if (res) {
- ERRORA("Error setting SMS sending mode to TEXT on the cellphone\n", SKYPIAX_P_LOG);
- return RESULT_FAILURE;
- }
- /* what is the Charset of SMSs? */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCS?");
- if (res) {
- DEBUGA_SKYPE("AT+CSCS? failed, continue\n", SKYPIAX_P_LOG);
- }
</del><ins>+        /* signal incoming SMS with a +CMTI unsolicited msg */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CNMI=3,1,0,0,0");
+        if (res) {
+                DEBUGA_SKYPE("AT+CNMI=3,1,0,0,0 failed, continue\n", SKYPIAX_P_LOG);
+                tech_pvt->sms_cnmi_not_supported = 1;
+                tech_pvt->celliax_serial_sync_period = 30;
+        }
+        /* what is the Message Center address (number) to which the SMS has to be sent? */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCA?");
+        if (res) {
+                DEBUGA_SKYPE("AT+CSCA? failed, continue\n", SKYPIAX_P_LOG);
+        }
+        /* what is the Message Format of SMSs? */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMGF?");
+        if (res) {
+                DEBUGA_SKYPE("AT+CMGF? failed, continue\n", SKYPIAX_P_LOG);
+        }
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMGF=1");        //TODO: support phones that only accept pdu mode
+        if (res) {
+                ERRORA("Error setting SMS sending mode to TEXT on the cellphone\n", SKYPIAX_P_LOG);
+                return RESULT_FAILURE;
+        }
+        /* what is the Charset of SMSs? */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCS?");
+        if (res) {
+                DEBUGA_SKYPE("AT+CSCS? failed, continue\n", SKYPIAX_P_LOG);
+        }
</ins><span class="cx">
</span><del>- tech_pvt->no_ucs2 = 0;
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
- if (res) {
- WARNINGA
- ("AT+CSCS=\"UCS2\" (set TE messages to ucs2) do not got OK from the phone, let's try with 'GSM'\n",
- SKYPIAX_P_LOG);
- tech_pvt->no_ucs2 = 1;
- }
</del><ins>+        tech_pvt->no_ucs2 = 0;
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
+        if (res) {
+                WARNINGA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) do not got OK from the phone, let's try with 'GSM'\n", SKYPIAX_P_LOG);
+                tech_pvt->no_ucs2 = 1;
+        }
</ins><span class="cx">
</span><del>- if (tech_pvt->no_ucs2) {
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"GSM\"");
- if (res) {
- WARNINGA("AT+CSCS=\"GSM\" (set TE messages to GSM) do not got OK from the phone\n",
- SKYPIAX_P_LOG);
- }
- //res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,16"); //"flash", class 0 sms 7 bit
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,0"); //normal, 7 bit message
- if (res) {
- WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", SKYPIAX_P_LOG);
- }
- } else {
- //res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,20"); //"flash", class 0 sms 16 bit unicode
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,8"); //unicode, 16 bit message
- if (res) {
- WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", SKYPIAX_P_LOG);
- }
- }
</del><ins>+        if (tech_pvt->no_ucs2) {
+                res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"GSM\"");
+                if (res) {
+                        WARNINGA("AT+CSCS=\"GSM\" (set TE messages to GSM) do not got OK from the phone\n", SKYPIAX_P_LOG);
+                }
+                //res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,16"); //"flash", class 0 sms 7 bit
+                res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,0");        //normal, 7 bit message
+                if (res) {
+                        WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", SKYPIAX_P_LOG);
+                }
+        } else {
+                //res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,20"); //"flash", class 0 sms 16 bit unicode
+                res = celliax_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,8");        //unicode, 16 bit message
+                if (res) {
+                        WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", SKYPIAX_P_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- /* is the unsolicited reporting of mobile equipment event supported? */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMER=?");
- if (res) {
- DEBUGA_SKYPE("AT+CMER=? failed, continue\n", SKYPIAX_P_LOG);
- }
- /* request unsolicited reporting of mobile equipment indicators' events, to be screened by categories reported by +CIND=? */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMER=3,0,0,1");
- if (res) {
- DEBUGA_SKYPE("AT+CMER=? failed, continue\n", SKYPIAX_P_LOG);
- }
</del><ins>+        /* is the unsolicited reporting of mobile equipment event supported? */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMER=?");
+        if (res) {
+                DEBUGA_SKYPE("AT+CMER=? failed, continue\n", SKYPIAX_P_LOG);
+        }
+        /* request unsolicited reporting of mobile equipment indicators' events, to be screened by categories reported by +CIND=? */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CMER=3,0,0,1");
+        if (res) {
+                DEBUGA_SKYPE("AT+CMER=? failed, continue\n", SKYPIAX_P_LOG);
+        }
</ins><span class="cx">
</span><del>- /* is the solicited reporting of mobile equipment indications supported? */
</del><ins>+        /* is the solicited reporting of mobile equipment indications supported? */
</ins><span class="cx">
</span><del>- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CIND=?");
- if (res) {
- DEBUGA_SKYPE("AT+CIND=? failed, continue\n", SKYPIAX_P_LOG);
- }
</del><ins>+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CIND=?");
+        if (res) {
+                DEBUGA_SKYPE("AT+CIND=? failed, continue\n", SKYPIAX_P_LOG);
+        }
</ins><span class="cx">
</span><del>- /* is the unsolicited reporting of call monitoring supported? sony-ericsson specific */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT*ECAM=?");
- if (res) {
- DEBUGA_SKYPE("AT*ECAM=? failed, continue\n", SKYPIAX_P_LOG);
- }
- /* enable the unsolicited reporting of call monitoring. sony-ericsson specific */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT*ECAM=1");
- if (res) {
- DEBUGA_SKYPE("AT*ECAM=1 failed, continue\n", SKYPIAX_P_LOG);
- tech_pvt->at_has_ecam = 0;
- } else {
- tech_pvt->at_has_ecam = 1;
- }
</del><ins>+        /* is the unsolicited reporting of call monitoring supported? sony-ericsson specific */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT*ECAM=?");
+        if (res) {
+                DEBUGA_SKYPE("AT*ECAM=? failed, continue\n", SKYPIAX_P_LOG);
+        }
+        /* enable the unsolicited reporting of call monitoring. sony-ericsson specific */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT*ECAM=1");
+        if (res) {
+                DEBUGA_SKYPE("AT*ECAM=1 failed, continue\n", SKYPIAX_P_LOG);
+                tech_pvt->at_has_ecam = 0;
+        } else {
+                tech_pvt->at_has_ecam = 1;
+        }
</ins><span class="cx">
</span><del>- /* disable unsolicited signaling of call list */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CLCC=0");
- if (res) {
- DEBUGA_SKYPE("AT+CLCC=0 failed, continue\n", SKYPIAX_P_LOG);
- tech_pvt->at_has_clcc = 0;
- } else {
- tech_pvt->at_has_clcc = 1;
- }
</del><ins>+        /* disable unsolicited signaling of call list */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CLCC=0");
+        if (res) {
+                DEBUGA_SKYPE("AT+CLCC=0 failed, continue\n", SKYPIAX_P_LOG);
+                tech_pvt->at_has_clcc = 0;
+        } else {
+                tech_pvt->at_has_clcc = 1;
+        }
</ins><span class="cx">
</span><del>- /* give unsolicited caller id when incoming call */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CLIP=1");
- if (res) {
- DEBUGA_SKYPE("AT+CLIP failed, continue\n", SKYPIAX_P_LOG);
- }
- /* for motorola */
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+MCST=1"); /* motorola call control codes
- (to know when call is disconnected (they
- don't give you "no carrier") */
- if (res) {
- DEBUGA_SKYPE("AT+MCST=1 does not get OK from the phone. If it is NOT Motorola,"
- " no problem.\n", SKYPIAX_P_LOG);
- }
- /* for motorola end */
</del><ins>+        /* give unsolicited caller id when incoming call */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CLIP=1");
+        if (res) {
+                DEBUGA_SKYPE("AT+CLIP failed, continue\n", SKYPIAX_P_LOG);
+        }
+        /* for motorola */
+        res = celliax_serial_write_AT_ack(tech_pvt, "AT+MCST=1");        /* motorola call control codes
+                                                                                                                                 (to know when call is disconnected (they
+                                                                                                                                 don't give you "no carrier") */
+        if (res) {
+                DEBUGA_SKYPE("AT+MCST=1 does not get OK from the phone. If it is NOT Motorola," " no problem.\n", SKYPIAX_P_LOG);
+        }
+        /* for motorola end */
</ins><span class="cx">
</span><span class="cx"> /* go until first empty postinit string, or last postinit string */
</span><del>- while (1) {
</del><ins>+        while (1) {
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_postinit_1)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_1, tech_pvt->at_postinit_1_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_postinit_1, tech_pvt->at_postinit_1_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_postinit_1)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_1, tech_pvt->at_postinit_1_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_postinit_1, tech_pvt->at_postinit_1_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_postinit_2)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_2, tech_pvt->at_postinit_2_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_postinit_2, tech_pvt->at_postinit_2_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_postinit_2)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_2, tech_pvt->at_postinit_2_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_postinit_2, tech_pvt->at_postinit_2_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_postinit_3)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_3, tech_pvt->at_postinit_3_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_postinit_3, tech_pvt->at_postinit_3_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_postinit_3)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_3, tech_pvt->at_postinit_3_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_postinit_3, tech_pvt->at_postinit_3_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_postinit_4)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_4, tech_pvt->at_postinit_4_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_postinit_4, tech_pvt->at_postinit_4_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_postinit_4)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_4, tech_pvt->at_postinit_4_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_postinit_4, tech_pvt->at_postinit_4_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->at_postinit_5)) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_5, tech_pvt->at_postinit_5_expect);
- if (res) {
- DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG,
- tech_pvt->at_postinit_5, tech_pvt->at_postinit_5_expect);
- }
- } else {
- break;
- }
</del><ins>+                if (strlen(tech_pvt->at_postinit_5)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_5, tech_pvt->at_postinit_5_expect);
+                        if (res) {
+                                DEBUGA_SKYPE("%s does not get %s from the phone. Continuing.\n", SKYPIAX_P_LOG, tech_pvt->at_postinit_5, tech_pvt->at_postinit_5_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+                break;
+        }
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> int celliax_serial_sync_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- usleep(10000); /* 10msec */
- time(&tech_pvt->celliax_serial_synced_timestamp);
- return 0;
</del><ins>+        usleep(10000);                                /* 10msec */
+        time(&tech_pvt->celliax_serial_synced_timestamp);
+        return 0;
</ins><span class="cx"> }
</span><del>-int celliax_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_usec,
- int timeout_sec, const char *expected_string, int expect_crlf)
</del><ins>+int celliax_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_usec, int timeout_sec, const char *expected_string, int expect_crlf)
</ins><span class="cx"> {
</span><del>- int select_err;
- int res;
- fd_set read_fds;
- struct timeval timeout;
- char tmp_answer[AT_BUFSIZ];
- char tmp_answer2[AT_BUFSIZ];
- char *tmp_answer_ptr;
- char *last_line_ptr;
- int i = 0;
- int read_count = 0;
- int la_counter = 0;
- int at_ack = -1;
- int la_read = 0;
</del><ins>+        int select_err;
+        int res;
+        fd_set read_fds;
+        struct timeval timeout;
+        char tmp_answer[AT_BUFSIZ];
+        char tmp_answer2[AT_BUFSIZ];
+        char *tmp_answer_ptr;
+        char *last_line_ptr;
+        int i = 0;
+        int read_count = 0;
+        int la_counter = 0;
+        int at_ack = -1;
+        int la_read = 0;
</ins><span class="cx">
</span><del>- FD_ZERO(&read_fds);
- FD_SET(tech_pvt->controldevfd, &read_fds);
</del><ins>+        FD_ZERO(&read_fds);
+        FD_SET(tech_pvt->controldevfd, &read_fds);
</ins><span class="cx">
</span><del>- //NOTICA (" INSIDE this celliax_serial_device %s \n", SKYPIAX_P_LOG, tech_pvt->controldevice_name);
- tmp_answer_ptr = tmp_answer;
- memset(tmp_answer, 0, sizeof(char) * AT_BUFSIZ);
</del><ins>+        //NOTICA (" INSIDE this celliax_serial_device %s \n", SKYPIAX_P_LOG, tech_pvt->controldevice_name);
+        tmp_answer_ptr = tmp_answer;
+        memset(tmp_answer, 0, sizeof(char) * AT_BUFSIZ);
</ins><span class="cx">
</span><del>- timeout.tv_sec = timeout_sec;
- timeout.tv_usec = timeout_usec;
- PUSHA_UNLOCKA(tech_pvt->controldev_lock);
- LOKKA(tech_pvt->controldev_lock);
</del><ins>+        timeout.tv_sec = timeout_sec;
+        timeout.tv_usec = timeout_usec;
+        PUSHA_UNLOCKA(tech_pvt->controldev_lock);
+        LOKKA(tech_pvt->controldev_lock);
</ins><span class="cx">
</span><del>- while ((select_err = select(tech_pvt->controldevfd + 1, &read_fds, NULL, NULL, &timeout)) > 0) {
- timeout.tv_sec = timeout_sec; //reset the timeout, linux modify it
- timeout.tv_usec = timeout_usec; //reset the timeout, linux modify it
- read_count =
- read(tech_pvt->controldevfd, tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer));
</del><ins>+        while ((select_err = select(tech_pvt->controldevfd + 1, &read_fds, NULL, NULL, &timeout)) > 0) {
+                timeout.tv_sec = timeout_sec;        //reset the timeout, linux modify it
+                timeout.tv_usec = timeout_usec;        //reset the timeout, linux modify it
+                read_count = read(tech_pvt->controldevfd, tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer));
</ins><span class="cx">
</span><del>- if (read_count == 0) {
- ERRORA
- ("read 0 bytes!!! Nenormalno! Marking this celliax_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n",
- SKYPIAX_P_LOG, tech_pvt->controldevice_name);
- tech_pvt->controldev_dead = 1;
- close(tech_pvt->controldevfd);
- UNLOCKA(tech_pvt->controldev_lock);
- if (tech_pvt->owner) {
- tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- }
- return -1;
- }
</del><ins>+                if (read_count == 0) {
+                        ERRORA
+                                ("read 0 bytes!!! Nenormalno! Marking this celliax_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n",
+                                 SKYPIAX_P_LOG, tech_pvt->controldevice_name);
+                        tech_pvt->controldev_dead = 1;
+                        close(tech_pvt->controldevfd);
+                        UNLOCKA(tech_pvt->controldev_lock);
+                        if (tech_pvt->owner) {
+                                tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                        }
+                        return -1;
+                }
</ins><span class="cx">
</span><del>- if (option_debug > 90) {
- //DEBUGA_SKYPE("1 read %d bytes, --|%s|--\n", SKYPIAX_P_LOG, read_count, tmp_answer_ptr);
- //DEBUGA_SKYPE("2 read %d bytes, --|%s|--\n", SKYPIAX_P_LOG, read_count, tmp_answer);
- }
- tmp_answer_ptr = tmp_answer_ptr + read_count;
</del><ins>+                if (option_debug > 90) {
+                        //DEBUGA_SKYPE("1 read %d bytes, --|%s|--\n", SKYPIAX_P_LOG, read_count, tmp_answer_ptr);
+                        //DEBUGA_SKYPE("2 read %d bytes, --|%s|--\n", SKYPIAX_P_LOG, read_count, tmp_answer);
+                }
+                tmp_answer_ptr = tmp_answer_ptr + read_count;
</ins><span class="cx">
</span><del>- char *token_ptr;
</del><ins>+                char *token_ptr;
</ins><span class="cx">
</span><del>- la_counter = 0;
- memset(tmp_answer2, 0, sizeof(char) * AT_BUFSIZ);
- strcpy(tmp_answer2, tmp_answer);
- if ((token_ptr = strtok(tmp_answer2, "\n\r"))) {
- last_line_ptr = token_ptr;
- strncpy(tech_pvt->line_array.result[la_counter], token_ptr, AT_MESG_MAX_LENGTH);
- if (strlen(token_ptr) > AT_MESG_MAX_LENGTH) {
- WARNINGA
- ("AT mesg longer than buffer, original message was: |%s|, in buffer only: |%s|\n",
- SKYPIAX_P_LOG, token_ptr, tech_pvt->line_array.result[la_counter]);
- }
- la_counter++;
- while ((token_ptr = strtok(NULL, "\n\r"))) {
- last_line_ptr = token_ptr;
- strncpy(tech_pvt->line_array.result[la_counter], token_ptr, AT_MESG_MAX_LENGTH);
- if (strlen(token_ptr) > AT_MESG_MAX_LENGTH) {
- WARNINGA
- ("AT mesg longer than buffer, original message was: |%s|, in buffer only: |%s|\n",
- SKYPIAX_P_LOG, token_ptr, tech_pvt->line_array.result[la_counter]);
- }
- la_counter++;
- }
- } else {
- last_line_ptr = tmp_answer;
- }
</del><ins>+                la_counter = 0;
+                memset(tmp_answer2, 0, sizeof(char) * AT_BUFSIZ);
+                strcpy(tmp_answer2, tmp_answer);
+                if ((token_ptr = strtok(tmp_answer2, "\n\r"))) {
+                        last_line_ptr = token_ptr;
+                        strncpy(tech_pvt->line_array.result[la_counter], token_ptr, AT_MESG_MAX_LENGTH);
+                        if (strlen(token_ptr) > AT_MESG_MAX_LENGTH) {
+                                WARNINGA
+                                        ("AT mesg longer than buffer, original message was: |%s|, in buffer only: |%s|\n",
+                                         SKYPIAX_P_LOG, token_ptr, tech_pvt->line_array.result[la_counter]);
+                        }
+                        la_counter++;
+                        while ((token_ptr = strtok(NULL, "\n\r"))) {
+                                last_line_ptr = token_ptr;
+                                strncpy(tech_pvt->line_array.result[la_counter], token_ptr, AT_MESG_MAX_LENGTH);
+                                if (strlen(token_ptr) > AT_MESG_MAX_LENGTH) {
+                                        WARNINGA
+                                                ("AT mesg longer than buffer, original message was: |%s|, in buffer only: |%s|\n",
+                                                 SKYPIAX_P_LOG, token_ptr, tech_pvt->line_array.result[la_counter]);
+                                }
+                                la_counter++;
+                        }
+                } else {
+                        last_line_ptr = tmp_answer;
+                }
</ins><span class="cx">
</span><del>- if (expected_string && !expect_crlf) {
- DEBUGA_SKYPE
- ("last_line_ptr=|%s|, expected_string=|%s|, expect_crlf=%d, memcmp(last_line_ptr, expected_string, strlen(expected_string)) = %d\n",
- SKYPIAX_P_LOG, last_line_ptr, expected_string, expect_crlf, memcmp(last_line_ptr,
- expected_string,
- strlen
- (expected_string)));
- }
</del><ins>+                if (expected_string && !expect_crlf) {
+                        DEBUGA_SKYPE
+                                ("last_line_ptr=|%s|, expected_string=|%s|, expect_crlf=%d, memcmp(last_line_ptr, expected_string, strlen(expected_string)) = %d\n",
+                                 SKYPIAX_P_LOG, last_line_ptr, expected_string, expect_crlf, memcmp(last_line_ptr, expected_string, strlen(expected_string)));
+                }
</ins><span class="cx">
</span><del>- if (expected_string && !expect_crlf
- && !memcmp(last_line_ptr, expected_string, strlen(expected_string))
- ) {
- strncpy(tech_pvt->line_array.result[la_counter], last_line_ptr, AT_MESG_MAX_LENGTH);
- // match expected string -> accept it withtout CRLF
- la_counter++;
</del><ins>+                if (expected_string && !expect_crlf && !memcmp(last_line_ptr, expected_string, strlen(expected_string))
+                        ) {
+                        strncpy(tech_pvt->line_array.result[la_counter], last_line_ptr, AT_MESG_MAX_LENGTH);
+                        // match expected string -> accept it withtout CRLF
+                        la_counter++;
</ins><span class="cx">
</span><del>- }
- /* if the last line read was not a complete line, we'll read the rest in the future */
- else if (tmp_answer[strlen(tmp_answer) - 1] != '\r'
- && tmp_answer[strlen(tmp_answer) - 1] != '\n')
- la_counter--;
</del><ins>+                }
+                /* if the last line read was not a complete line, we'll read the rest in the future */
+                else if (tmp_answer[strlen(tmp_answer) - 1] != '\r' && tmp_answer[strlen(tmp_answer) - 1] != '\n')
+                        la_counter--;
</ins><span class="cx">
</span><del>- /* let's list the complete lines read so far, without re-listing the lines that has yet been listed */
- if (option_debug > 1) {
- for (i = la_read; i < la_counter; i++)
- DEBUGA_SKYPE("Read line %d: |%s|\n", SKYPIAX_P_LOG, i, tech_pvt->line_array.result[i]);
- }
</del><ins>+                /* let's list the complete lines read so far, without re-listing the lines that has yet been listed */
+                if (option_debug > 1) {
+                        for (i = la_read; i < la_counter; i++)
+                                DEBUGA_SKYPE("Read line %d: |%s|\n", SKYPIAX_P_LOG, i, tech_pvt->line_array.result[i]);
+                }
</ins><span class="cx">
</span><del>- /* let's interpret the complete lines read so far (WITHOUT looking for OK, ERROR, and EXPECTED_STRING), without re-interpreting the lines that has been yet interpreted, so we're sure we don't miss anything */
- for (i = la_read; i < la_counter; i++) {
</del><ins>+                /* let's interpret the complete lines read so far (WITHOUT looking for OK, ERROR, and EXPECTED_STRING), without re-interpreting the lines that has been yet interpreted, so we're sure we don't miss anything */
+                for (i = la_read; i < la_counter; i++) {
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], "RING") == 0)) {
- /* with first RING we wait for callid */
- gettimeofday(&(tech_pvt->ringtime), NULL);
- /* give CALLID (+CLIP) a chance, wait for the next RING before answering */
- if (tech_pvt->phone_callflow == CALLFLOW_INCOMING_RING) {
- /* we're at the second ring, set the interface state, will be answered by celliax_do_monitor */
- DEBUGA_SKYPE("|%s| got second RING\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- tech_pvt->interface_state = SKYPIAX_STATE_RING;
- } else {
- /* we're at the first ring, so there is no CALLID yet thus clean the previous one
- just in case we don't receive the caller identification in this new call */
- memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
- memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
- /* only send AT+CLCC? if the device previously reported its support */
- if (tech_pvt->at_has_clcc != 0) {
- /* we're at the first ring, try to get CALLID (with +CLCC) */
- DEBUGA_SKYPE("|%s| got first RING, sending AT+CLCC?\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- res = celliax_serial_write_AT_noack(tech_pvt, "AT+CLCC?");
- if (res) {
- ERRORA("AT+CLCC? (call list) was not correctly sent to the phone\n",
- SKYPIAX_P_LOG);
- }
- } else {
- DEBUGA_SKYPE("|%s| got first RING, but not sending AT+CLCC? as this device "
- "seems not to support\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- }
- }
- tech_pvt->phone_callflow = CALLFLOW_INCOMING_RING;
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], "RING") == 0)) {
+                                /* with first RING we wait for callid */
+                                gettimeofday(&(tech_pvt->ringtime), NULL);
+                                /* give CALLID (+CLIP) a chance, wait for the next RING before answering */
+                                if (tech_pvt->phone_callflow == CALLFLOW_INCOMING_RING) {
+                                        /* we're at the second ring, set the interface state, will be answered by celliax_do_monitor */
+                                        DEBUGA_SKYPE("|%s| got second RING\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                        tech_pvt->interface_state = SKYPIAX_STATE_RING;
+                                } else {
+                                        /* we're at the first ring, so there is no CALLID yet thus clean the previous one
+                                         just in case we don't receive the caller identification in this new call */
+                                        memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
+                                        memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
+                                        /* only send AT+CLCC? if the device previously reported its support */
+                                        if (tech_pvt->at_has_clcc != 0) {
+                                                /* we're at the first ring, try to get CALLID (with +CLCC) */
+                                                DEBUGA_SKYPE("|%s| got first RING, sending AT+CLCC?\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                res = celliax_serial_write_AT_noack(tech_pvt, "AT+CLCC?");
+                                                if (res) {
+                                                        ERRORA("AT+CLCC? (call list) was not correctly sent to the phone\n", SKYPIAX_P_LOG);
+                                                }
+                                        } else {
+                                                DEBUGA_SKYPE("|%s| got first RING, but not sending AT+CLCC? as this device "
+                                                                         "seems not to support\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                        }
+                                }
+                                tech_pvt->phone_callflow = CALLFLOW_INCOMING_RING;
+                        }
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "+CLCC", 5) == 0)) {
- /* with clcc we wait for clip */
- memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
- memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
- int commacount = 0;
- int a = 0;
- int b = 0;
- int c = 0;
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "+CLCC", 5) == 0)) {
+                                /* with clcc we wait for clip */
+                                memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
+                                memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
+                                int commacount = 0;
+                                int a = 0;
+                                int b = 0;
+                                int c = 0;
</ins><span class="cx">
</span><del>- for (a = 0; a < strlen(tech_pvt->line_array.result[i]); a++) {
</del><ins>+                                for (a = 0; a < strlen(tech_pvt->line_array.result[i]); a++) {
</ins><span class="cx">
</span><del>- if (tech_pvt->line_array.result[i][a] == ',') {
- commacount++;
- }
- if (commacount == 5) {
- if (tech_pvt->line_array.result[i][a] != ',' && tech_pvt->line_array.result[i][a] != '"') {
- tech_pvt->callid_number[b] = tech_pvt->line_array.result[i][a];
- b++;
- }
- }
- if (commacount == 7) {
- if (tech_pvt->line_array.result[i][a] != ',' && tech_pvt->line_array.result[i][a] != '"') {
- tech_pvt->callid_name[c] = tech_pvt->line_array.result[i][a];
- c++;
- }
- }
- }
</del><ins>+                                        if (tech_pvt->line_array.result[i][a] == ',') {
+                                                commacount++;
+                                        }
+                                        if (commacount == 5) {
+                                                if (tech_pvt->line_array.result[i][a] != ',' && tech_pvt->line_array.result[i][a] != '"') {
+                                                        tech_pvt->callid_number[b] = tech_pvt->line_array.result[i][a];
+                                                        b++;
+                                                }
+                                        }
+                                        if (commacount == 7) {
+                                                if (tech_pvt->line_array.result[i][a] != ',' && tech_pvt->line_array.result[i][a] != '"') {
+                                                        tech_pvt->callid_name[c] = tech_pvt->line_array.result[i][a];
+                                                        c++;
+                                                }
+                                        }
+                                }
</ins><span class="cx">
</span><del>- tech_pvt->phone_callflow = CALLFLOW_INCOMING_RING;
- DEBUGA_SKYPE("|%s| CLCC CALLID: name is %s, number is %s\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i],
- tech_pvt->callid_name[0] ? tech_pvt->callid_name : "not available",
- tech_pvt->callid_number[0] ? tech_pvt->callid_number : "not available");
- }
</del><ins>+                                tech_pvt->phone_callflow = CALLFLOW_INCOMING_RING;
+                                DEBUGA_SKYPE("|%s| CLCC CALLID: name is %s, number is %s\n", SKYPIAX_P_LOG,
+                                                         tech_pvt->line_array.result[i],
+                                                         tech_pvt->callid_name[0] ? tech_pvt->callid_name : "not available",
+                                                         tech_pvt->callid_number[0] ? tech_pvt->callid_number : "not available");
+                        }
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "+CLIP", 5) == 0)) {
- /* with CLIP, we want to answer right away */
- memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
- memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "+CLIP", 5) == 0)) {
+                                /* with CLIP, we want to answer right away */
+                                memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
+                                memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
</ins><span class="cx">
</span><del>- int commacount = 0;
- int a = 0;
- int b = 0;
- int c = 0;
</del><ins>+                                int commacount = 0;
+                                int a = 0;
+                                int b = 0;
+                                int c = 0;
</ins><span class="cx">
</span><del>- for (a = 7; a < strlen(tech_pvt->line_array.result[i]); a++) {
- if (tech_pvt->line_array.result[i][a] == ',') {
- commacount++;
- }
- if (commacount == 0) {
- if (tech_pvt->line_array.result[i][a] != ',' && tech_pvt->line_array.result[i][a] != '"') {
- tech_pvt->callid_number[b] = tech_pvt->line_array.result[i][a];
- b++;
- }
- }
- if (commacount == 4) {
- if (tech_pvt->line_array.result[i][a] != ',' && tech_pvt->line_array.result[i][a] != '"') {
- tech_pvt->callid_name[c] = tech_pvt->line_array.result[i][a];
- c++;
- }
- }
- }
</del><ins>+                                for (a = 7; a < strlen(tech_pvt->line_array.result[i]); a++) {
+                                        if (tech_pvt->line_array.result[i][a] == ',') {
+                                                commacount++;
+                                        }
+                                        if (commacount == 0) {
+                                                if (tech_pvt->line_array.result[i][a] != ',' && tech_pvt->line_array.result[i][a] != '"') {
+                                                        tech_pvt->callid_number[b] = tech_pvt->line_array.result[i][a];
+                                                        b++;
+                                                }
+                                        }
+                                        if (commacount == 4) {
+                                                if (tech_pvt->line_array.result[i][a] != ',' && tech_pvt->line_array.result[i][a] != '"') {
+                                                        tech_pvt->callid_name[c] = tech_pvt->line_array.result[i][a];
+                                                        c++;
+                                                }
+                                        }
+                                }
</ins><span class="cx">
</span><del>- if (tech_pvt->interface_state != SKYPIAX_STATE_RING) {
- gettimeofday(&(tech_pvt->call_incoming_time), NULL);
- DEBUGA_SKYPE("SKYPIAX_STATE_RING call_incoming_time.tv_sec=%ld\n",
- SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec);
</del><ins>+                                if (tech_pvt->interface_state != SKYPIAX_STATE_RING) {
+                                        gettimeofday(&(tech_pvt->call_incoming_time), NULL);
+                                        DEBUGA_SKYPE("SKYPIAX_STATE_RING call_incoming_time.tv_sec=%ld\n", SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec);
</ins><span class="cx">
</span><del>- }
</del><ins>+                                }
</ins><span class="cx">
</span><del>- tech_pvt->interface_state = SKYPIAX_STATE_RING;
- tech_pvt->phone_callflow = CALLFLOW_INCOMING_RING;
- DEBUGA_SKYPE("|%s| CLIP INCOMING CALLID: name is %s, number is %s\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i],
- tech_pvt->callid_name[0] != 1 ? tech_pvt->callid_name : "not available",
- tech_pvt->callid_number[0] ? tech_pvt->callid_number : "not available");
- }
</del><ins>+                                tech_pvt->interface_state = SKYPIAX_STATE_RING;
+                                tech_pvt->phone_callflow = CALLFLOW_INCOMING_RING;
+                                DEBUGA_SKYPE("|%s| CLIP INCOMING CALLID: name is %s, number is %s\n", SKYPIAX_P_LOG,
+                                                         tech_pvt->line_array.result[i],
+                                                         tech_pvt->callid_name[0] != 1 ? tech_pvt->callid_name : "not available",
+                                                         tech_pvt->callid_number[0] ? tech_pvt->callid_number : "not available");
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], "BUSY") == 0)) {
- tech_pvt->phone_callflow = CALLFLOW_CALL_LINEBUSY;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_LINEBUSY\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
- ast_setstate(tech_pvt->owner, SKYPIAX_STATE_BUSY);
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_BUSY);
- } else {
- ERRORA("Why BUSY now?\n", SKYPIAX_P_LOG);
- }
- }
- if ((strcmp(tech_pvt->line_array.result[i], "NO ANSWER") == 0)) {
- tech_pvt->phone_callflow = CALLFLOW_CALL_NOANSWER;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_NOANSWER\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
- tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_NO_ANSWER;
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- } else {
- ERRORA("Why NO ANSWER now?\n", SKYPIAX_P_LOG);
- }
- }
- if ((strcmp(tech_pvt->line_array.result[i], "NO CARRIER") == 0)) {
- tech_pvt->phone_callflow = CALLFLOW_CALL_NOCARRIER;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_NOCARRIER\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
-                        //cicopet
-                celliax_hangup(tech_pvt);
- //tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
- //celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- } else {
- ERRORA("Why NO CARRIER now?\n", SKYPIAX_P_LOG);
- }
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], "BUSY") == 0)) {
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_LINEBUSY;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_LINEBUSY\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
+                                        ast_setstate(tech_pvt->owner, SKYPIAX_STATE_BUSY);
+                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_BUSY);
+                                } else {
+                                        ERRORA("Why BUSY now?\n", SKYPIAX_P_LOG);
+                                }
+                        }
+                        if ((strcmp(tech_pvt->line_array.result[i], "NO ANSWER") == 0)) {
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_NOANSWER;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_NOANSWER\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
+                                        tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_NO_ANSWER;
+                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                                } else {
+                                        ERRORA("Why NO ANSWER now?\n", SKYPIAX_P_LOG);
+                                }
+                        }
+                        if ((strcmp(tech_pvt->line_array.result[i], "NO CARRIER") == 0)) {
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_NOCARRIER;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_NOCARRIER\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
+                                        //cicopet
+                                        celliax_hangup(tech_pvt);
+                                        //tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        //celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                                } else {
+                                        ERRORA("Why NO CARRIER now?\n", SKYPIAX_P_LOG);
+                                }
+                        }
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "+CBC:", 5) == 0)) {
- int power_supply, battery_strenght, err;
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "+CBC:", 5) == 0)) {
+                                int power_supply, battery_strenght, err;
</ins><span class="cx">
</span><del>- power_supply = battery_strenght = 0;
</del><ins>+                                power_supply = battery_strenght = 0;
</ins><span class="cx">
</span><del>- err =
- sscanf(&tech_pvt->line_array.result[i][6], "%d,%d", &power_supply, &battery_strenght);
- if (err < 2) {
- DEBUGA_SKYPE("|%s| is not formatted as: |+CBC: xx,yy| now trying |+CBC:xx,yy|\n",
- SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</del><ins>+                                err = sscanf(&tech_pvt->line_array.result[i][6], "%d,%d", &power_supply, &battery_strenght);
+                                if (err < 2) {
+                                        DEBUGA_SKYPE("|%s| is not formatted as: |+CBC: xx,yy| now trying |+CBC:xx,yy|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- err =
- sscanf(&tech_pvt->line_array.result[i][5], "%d,%d", &power_supply,
- &battery_strenght);
- DEBUGA_SKYPE("|%s| +CBC: Powered by %s, battery strenght=%d\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i], power_supply ? "power supply" : "battery",
- battery_strenght);
</del><ins>+                                        err = sscanf(&tech_pvt->line_array.result[i][5], "%d,%d", &power_supply, &battery_strenght);
+                                        DEBUGA_SKYPE("|%s| +CBC: Powered by %s, battery strenght=%d\n", SKYPIAX_P_LOG,
+                                                                 tech_pvt->line_array.result[i], power_supply ? "power supply" : "battery", battery_strenght);
</ins><span class="cx">
</span><del>- }
</del><ins>+                                }
</ins><span class="cx">
</span><del>- if (err < 2) {
- DEBUGA_SKYPE("|%s| is not formatted as: |+CBC:xx,yy| giving up\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                                if (err < 2) {
+                                        DEBUGA_SKYPE("|%s| is not formatted as: |+CBC:xx,yy| giving up\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                }
</ins><span class="cx">
</span><del>- else {
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| +CBC: Powered by %s, battery strenght=%d\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i], power_supply ? "power supply" : "battery",
- battery_strenght);
- if (!power_supply) {
- if (battery_strenght < 10) {
- ERRORA("|%s| BATTERY ALMOST EXHAUSTED\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- } else if (battery_strenght < 20) {
- WARNINGA("|%s| BATTERY LOW\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</del><ins>+                                else {
+                                        if (option_debug > 1)
+                                                DEBUGA_SKYPE("|%s| +CBC: Powered by %s, battery strenght=%d\n", SKYPIAX_P_LOG,
+                                                                         tech_pvt->line_array.result[i], power_supply ? "power supply" : "battery", battery_strenght);
+                                        if (!power_supply) {
+                                                if (battery_strenght < 10) {
+                                                        ERRORA("|%s| BATTERY ALMOST EXHAUSTED\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                } else if (battery_strenght < 20) {
+                                                        WARNINGA("|%s| BATTERY LOW\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- }
</del><ins>+                                                }
</ins><span class="cx">
</span><del>- }
- }
</del><ins>+                                        }
+                                }
</ins><span class="cx">
</span><del>- }
</del><ins>+                        }
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "+CSQ:", 5) == 0)) {
- int signal_quality, ber, err;
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "+CSQ:", 5) == 0)) {
+                                int signal_quality, ber, err;
</ins><span class="cx">
</span><del>- signal_quality = ber = 0;
</del><ins>+                                signal_quality = ber = 0;
</ins><span class="cx">
</span><del>- err = sscanf(&tech_pvt->line_array.result[i][6], "%d,%d", &signal_quality, &ber);
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| +CSQ: Signal Quality: %d, Error Rate=%d\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i], signal_quality, ber);
- if (err < 2) {
- ERRORA("|%s| is not formatted as: |+CSQ: xx,yy|\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- } else {
- if (signal_quality < 11 || signal_quality == 99) {
- WARNINGA
- ("|%s| CELLPHONE GETS ALMOST NO SIGNAL, consider to move it or additional antenna\n",
- SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- } else if (signal_quality < 15) {
- WARNINGA("|%s| CELLPHONE GETS SIGNAL LOW\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
</del><ins>+                                err = sscanf(&tech_pvt->line_array.result[i][6], "%d,%d", &signal_quality, &ber);
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| +CSQ: Signal Quality: %d, Error Rate=%d\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i], signal_quality, ber);
+                                if (err < 2) {
+                                        ERRORA("|%s| is not formatted as: |+CSQ: xx,yy|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                } else {
+                                        if (signal_quality < 11 || signal_quality == 99) {
+                                                WARNINGA
+                                                        ("|%s| CELLPHONE GETS ALMOST NO SIGNAL, consider to move it or additional antenna\n",
+                                                         SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                        } else if (signal_quality < 15) {
+                                                WARNINGA("|%s| CELLPHONE GETS SIGNAL LOW\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- }
</del><ins>+                                        }
</ins><span class="cx">
</span><del>- }
</del><ins>+                                }
</ins><span class="cx">
</span><del>- }
- if ((strncmp(tech_pvt->line_array.result[i], "+CMGW:", 6) == 0)) {
- int err;
</del><ins>+                        }
+                        if ((strncmp(tech_pvt->line_array.result[i], "+CMGW:", 6) == 0)) {
+                                int err;
</ins><span class="cx">
</span><del>- err = sscanf(&tech_pvt->line_array.result[i][7], "%s", tech_pvt->at_cmgw);
- DEBUGA_SKYPE("|%s| +CMGW: %s\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i], tech_pvt->at_cmgw);
- if (err < 1) {
- ERRORA("|%s| is not formatted as: |+CMGW: xxxx|\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                                err = sscanf(&tech_pvt->line_array.result[i][7], "%s", tech_pvt->at_cmgw);
+                                DEBUGA_SKYPE("|%s| +CMGW: %s\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i], tech_pvt->at_cmgw);
+                                if (err < 1) {
+                                        ERRORA("|%s| is not formatted as: |+CMGW: xxxx|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                }
</ins><span class="cx">
</span><del>- }
</del><ins>+                        }
</ins><span class="cx">
</span><del>- /* at_call_* are unsolicited messages sent by the modem to signal us about call processing activity and events */
- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_idle) == 0)) {
- tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_IDLE\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
- DEBUGA_SKYPE("just received a remote HANGUP\n", SKYPIAX_P_LOG);
- tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- DEBUGA_SKYPE("just sent SKYPIAX_CONTROL_HANGUP\n", SKYPIAX_P_LOG);
- }
- }
</del><ins>+                        /* at_call_* are unsolicited messages sent by the modem to signal us about call processing activity and events */
+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_idle) == 0)) {
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_IDLE\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
+                                        DEBUGA_SKYPE("just received a remote HANGUP\n", SKYPIAX_P_LOG);
+                                        tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
+                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                                        DEBUGA_SKYPE("just sent SKYPIAX_CONTROL_HANGUP\n", SKYPIAX_P_LOG);
+                                }
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_incoming) == 0)) {
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_incoming) == 0)) {
</ins><span class="cx">
</span><del>- //char list_command[64];
</del><ins>+                                //char list_command[64];
</ins><span class="cx">
</span><del>- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_INCOMING\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
</del><ins>+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_INCOMING\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- if (tech_pvt->phone_callflow != CALLFLOW_CALL_INCOMING
- && tech_pvt->phone_callflow != CALLFLOW_INCOMING_RING) {
- //mark the time of CALLFLOW_CALL_INCOMING
- gettimeofday(&(tech_pvt->call_incoming_time), NULL);
- tech_pvt->phone_callflow = CALLFLOW_CALL_INCOMING;
- DEBUGA_SKYPE("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld\n",
- SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec);
</del><ins>+                                if (tech_pvt->phone_callflow != CALLFLOW_CALL_INCOMING && tech_pvt->phone_callflow != CALLFLOW_INCOMING_RING) {
+                                        //mark the time of CALLFLOW_CALL_INCOMING
+                                        gettimeofday(&(tech_pvt->call_incoming_time), NULL);
+                                        tech_pvt->phone_callflow = CALLFLOW_CALL_INCOMING;
+                                        DEBUGA_SKYPE("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld\n", SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec);
</ins><span class="cx">
</span><del>- }
- }
</del><ins>+                                }
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_active) == 0)) {
-         tech_pvt->phone_callflow = CALLFLOW_CALL_ACTIVE;
-         DEBUGA_SKYPE("|%s| CALLFLOW_CALL_ACTIVE\n", SKYPIAX_P_LOG,
-                         tech_pvt->line_array.result[i]);
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_active) == 0)) {
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_ACTIVE;
+                                DEBUGA_SKYPE("|%s| CALLFLOW_CALL_ACTIVE\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>-         if (tech_pvt->interface_state == CALLFLOW_CALL_DIALING) {
-                 DEBUGA_PBX("just received a remote ANSWER\n", SKYPIAX_P_LOG);
-                 if (tech_pvt->phone_callflow == SKYPIAX_STATE_UP) {
-                         //celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
-                         DEBUGA_PBX("just sent SKYPIAX_CONTROL_RINGING\n", SKYPIAX_P_LOG);
-                         DEBUGA_PBX("going to send SKYPIAX_CONTROL_ANSWER\n", SKYPIAX_P_LOG);
-                         //celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_ANSWER);
-                         tech_pvt->interface_state = CALLFLOW_CALL_REMOTEANSWER;
-                         DEBUGA_PBX("just sent SKYPIAX_CONTROL_ANSWER\n", SKYPIAX_P_LOG);
-                 }
-         } else {
-         }
-         //tech_pvt->interface_state = SKYPIAX_STATE_UP;
-         //DEBUGA_PBX("just interface_state UP\n", SKYPIAX_P_LOG);
- }
</del><ins>+                                if (tech_pvt->interface_state == CALLFLOW_CALL_DIALING) {
+                                        DEBUGA_PBX("just received a remote ANSWER\n", SKYPIAX_P_LOG);
+                                        if (tech_pvt->phone_callflow == SKYPIAX_STATE_UP) {
+                                                //celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
+                                                DEBUGA_PBX("just sent SKYPIAX_CONTROL_RINGING\n", SKYPIAX_P_LOG);
+                                                DEBUGA_PBX("going to send SKYPIAX_CONTROL_ANSWER\n", SKYPIAX_P_LOG);
+                                                //celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_ANSWER);
+                                                tech_pvt->interface_state = CALLFLOW_CALL_REMOTEANSWER;
+                                                DEBUGA_PBX("just sent SKYPIAX_CONTROL_ANSWER\n", SKYPIAX_P_LOG);
+                                        }
+                                } else {
+                                }
+                                //tech_pvt->interface_state = SKYPIAX_STATE_UP;
+                                //DEBUGA_PBX("just interface_state UP\n", SKYPIAX_P_LOG);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_calling) == 0)) {
- tech_pvt->phone_callflow = CALLFLOW_CALL_DIALING;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_DIALING\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_failed) == 0)) {
- tech_pvt->phone_callflow = CALLFLOW_CALL_FAILED;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_FAILED\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
- tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- }
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_calling) == 0)) {
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_DIALING;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_DIALING\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_failed) == 0)) {
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_FAILED;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_FAILED\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
+                                        tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                                }
+                        }
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "+CSCA:", 6) == 0)) { //TODO SMS FIXME in config!
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| +CSCA: Message Center Address!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "+CSCA:", 6) == 0)) {        //TODO SMS FIXME in config!
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| +CSCA: Message Center Address!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "+CMGF:", 6) == 0)) { //TODO SMS FIXME in config!
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| +CMGF: Message Format!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "+CMGF:", 6) == 0)) {        //TODO SMS FIXME in config!
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| +CMGF: Message Format!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "+CMTI:", 6) == 0)) { //TODO SMS FIXME in config!
- int err;
- int pos;
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "+CMTI:", 6) == 0)) {        //TODO SMS FIXME in config!
+                                int err;
+                                int pos;
</ins><span class="cx">
</span><del>- //FIXME all the following commands in config!
- if (option_debug)
- DEBUGA_SKYPE("|%s| +CMTI: Incoming SMS!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
</del><ins>+                                //FIXME all the following commands in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE("|%s| +CMTI: Incoming SMS!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- err = sscanf(&tech_pvt->line_array.result[i][12], "%d", &pos);
- if (err < 1) {
- ERRORA("|%s| is not formatted as: |+CMTI: \"MT\",xx|\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- } else {
- DEBUGA_SKYPE("|%s| +CMTI: Incoming SMS in position: %d!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i], pos);
- tech_pvt->unread_sms_msg_id = pos;
- usleep(1000);
</del><ins>+                                err = sscanf(&tech_pvt->line_array.result[i][12], "%d", &pos);
+                                if (err < 1) {
+                                        ERRORA("|%s| is not formatted as: |+CMTI: \"MT\",xx|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                } else {
+                                        DEBUGA_SKYPE("|%s| +CMTI: Incoming SMS in position: %d!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i], pos);
+                                        tech_pvt->unread_sms_msg_id = pos;
+                                        usleep(1000);
</ins><span class="cx">
</span><del>- if (tech_pvt->unread_sms_msg_id) {
- char at_command[256];
</del><ins>+                                        if (tech_pvt->unread_sms_msg_id) {
+                                                char at_command[256];
</ins><span class="cx">
</span><del>- 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, continuing\n",
- SKYPIAX_P_LOG);
- //memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
- }
- }
</del><ins>+                                                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, continuing\n", SKYPIAX_P_LOG);
+                                                                //memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
+                                                        }
+                                                }
</ins><span class="cx">
</span><del>- 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));
</del><ins>+                                                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));
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                                                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);
+                                                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->sms_message)) {
- //FIXME manager_event(EVENT_FLAG_SYSTEM, "CELLIAXincomingsms",
- //FIXME "Interface: %s\r\nSMS_Message: %s\r\n", tech_pvt->name,
- //FIXME 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;
</del><ins>+                                                if (strlen(tech_pvt->sms_message)) {
+                                                        //FIXME manager_event(EVENT_FLAG_SYSTEM, "CELLIAXincomingsms",
+                                                        //FIXME "Interface: %s\r\nSMS_Message: %s\r\n", tech_pvt->name,
+                                                        //FIXME 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;
</ins><span class="cx">
</span><del>- NOTICA("incoming SMS message:>>>%s<<<\n", SKYPIAX_P_LOG, tech_pvt->sms_message);
- pipe(fd1);
- pid1 = fork();
</del><ins>+                                                                NOTICA("incoming SMS message:>>>%s<<<\n", SKYPIAX_P_LOG, tech_pvt->sms_message);
+                                                                pipe(fd1);
+                                                                pid1 = fork();
</ins><span class="cx">
</span><del>- if (pid1 == 0) { //child
- int err;
</del><ins>+                                                                if (pid1 == 0) {        //child
+                                                                        int err;
</ins><span class="cx">
</span><del>- dup2(fd1[0], 0); // Connect stdin to pipe output
- close(fd1[1]); // close input pipe side
-                close(tech_pvt->controldevfd);
- 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
- }
</del><ins>+                                                                        dup2(fd1[0], 0);        // Connect stdin to pipe output
+                                                                        close(fd1[1]);        // close input pipe side
+                                                                        close(tech_pvt->controldevfd);
+                                                                        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
+                                                                }
</ins><span class="cx"> //starting here continue the parent
</span><del>- 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);
- }
- }
</del><ins>+                                                                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);
+                                                        }
+                                                }
</ins><span class="cx"> #endif
</span><del>- } //unread_msg_id
</del><ins>+                                        }                        //unread_msg_id
</ins><span class="cx">
</span><del>- } //CMTI well formatted
</del><ins>+                                }                                //CMTI well formatted
</ins><span class="cx">
</span><del>- } //CMTI
</del><ins>+                        }                                        //CMTI
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "+MMGL:", 6) == 0)) { //TODO MOTOROLA SMS FIXME in config!
- int err = 0;
- //int unread_msg_id=0;
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "+MMGL:", 6) == 0)) {        //TODO MOTOROLA SMS FIXME in config!
+                                int err = 0;
+                                //int unread_msg_id=0;
</ins><span class="cx">
</span><del>- if (option_debug)
- DEBUGA_SKYPE("|%s| +MMGL: Listing Motorola SMSs!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
</del><ins>+                                if (option_debug)
+                                        DEBUGA_SKYPE("|%s| +MMGL: Listing Motorola SMSs!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- err = sscanf(&tech_pvt->line_array.result[i][7], "%d", &tech_pvt->unread_sms_msg_id);
- if (err < 1) {
- ERRORA("|%s| is not formatted as: |+MMGL: xx|\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
- }
- if ((strncmp(tech_pvt->line_array.result[i], "+CMGL:", 6) == 0)) { //TODO SMS FIXME in config!
- if (option_debug)
- DEBUGA_SKYPE("|%s| +CMGL: Listing SMSs!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
- if ((strncmp(tech_pvt->line_array.result[i], "+MMGR:", 6) == 0)) { //TODO MOTOROLA SMS FIXME in config!
- if (option_debug)
- DEBUGA_SKYPE("|%s| +MMGR: Reading Motorola SMS!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- if (tech_pvt->reading_sms_msg)
- tech_pvt->reading_sms_msg++;
- }
- if ((strncmp(tech_pvt->line_array.result[i], "+CMGR: \"STO U", 13) == 0)) { //TODO SMS FIXME in config!
- if (option_debug)
- DEBUGA_SKYPE("|%s| +CMGR: Reading stored UNSENT SMS!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- } else if ((strncmp(tech_pvt->line_array.result[i], "+CMGR: \"STO S", 13) == 0)) { //TODO SMS FIXME in config!
- if (option_debug)
- DEBUGA_SKYPE("|%s| +CMGR: Reading stored SENT SMS!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- } else if ((strncmp(tech_pvt->line_array.result[i], "+CMGR: \"REC R", 13) == 0)) { //TODO SMS FIXME in config!
- if (option_debug)
- DEBUGA_SKYPE("|%s| +CMGR: Reading received READ SMS!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- } else if ((strncmp(tech_pvt->line_array.result[i], "+CMGR: \"REC U", 13) == 0)) { //TODO SMS FIXME in config!
- if (option_debug)
- DEBUGA_SKYPE("|%s| +CMGR: Reading received UNREAD SMS!\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- if (tech_pvt->reading_sms_msg)
- tech_pvt->reading_sms_msg++;
- }
</del><ins>+                                err = sscanf(&tech_pvt->line_array.result[i][7], "%d", &tech_pvt->unread_sms_msg_id);
+                                if (err < 1) {
+                                        ERRORA("|%s| is not formatted as: |+MMGL: xx|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                }
+                        }
+                        if ((strncmp(tech_pvt->line_array.result[i], "+CMGL:", 6) == 0)) {        //TODO SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE("|%s| +CMGL: Listing SMSs!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
+                        if ((strncmp(tech_pvt->line_array.result[i], "+MMGR:", 6) == 0)) {        //TODO MOTOROLA SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE("|%s| +MMGR: Reading Motorola SMS!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->reading_sms_msg)
+                                        tech_pvt->reading_sms_msg++;
+                        }
+                        if ((strncmp(tech_pvt->line_array.result[i], "+CMGR: \"STO U", 13) == 0)) {        //TODO SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE("|%s| +CMGR: Reading stored UNSENT SMS!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        } else if ((strncmp(tech_pvt->line_array.result[i], "+CMGR: \"STO S", 13) == 0)) {        //TODO SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE("|%s| +CMGR: Reading stored SENT SMS!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        } else if ((strncmp(tech_pvt->line_array.result[i], "+CMGR: \"REC R", 13) == 0)) {        //TODO SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE("|%s| +CMGR: Reading received READ SMS!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        } else if ((strncmp(tech_pvt->line_array.result[i], "+CMGR: \"REC U", 13) == 0)) {        //TODO SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE("|%s| +CMGR: Reading received UNREAD SMS!\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->reading_sms_msg)
+                                        tech_pvt->reading_sms_msg++;
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], "+MCST: 17") == 0)) { /* motorola call processing unsolicited messages */
- tech_pvt->phone_callflow = CALLFLOW_CALL_INFLUX;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_INFLUX\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], "+MCST: 17") == 0)) {        /* motorola call processing unsolicited messages */
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_INFLUX;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_INFLUX\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], "+MCST: 68") == 0)) { /* motorola call processing unsolicited messages */
- tech_pvt->phone_callflow = CALLFLOW_CALL_NOSERVICE;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_NOSERVICE\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
- tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- }
- }
- if ((strcmp(tech_pvt->line_array.result[i], "+MCST: 70") == 0)) { /* motorola call processing unsolicited messages */
- tech_pvt->phone_callflow = CALLFLOW_CALL_OUTGOINGRESTRICTED;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_OUTGOINGRESTRICTED\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
- tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- }
- }
- if ((strcmp(tech_pvt->line_array.result[i], "+MCST: 72") == 0)) { /* motorola call processing unsolicited messages */
- tech_pvt->phone_callflow = CALLFLOW_CALL_SECURITYFAIL;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| CALLFLOW_CALL_SECURITYFAIL\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
- tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- }
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], "+MCST: 68") == 0)) {        /* motorola call processing unsolicited messages */
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_NOSERVICE;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_NOSERVICE\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
+                                        tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                                }
+                        }
+                        if ((strcmp(tech_pvt->line_array.result[i], "+MCST: 70") == 0)) {        /* motorola call processing unsolicited messages */
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_OUTGOINGRESTRICTED;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_OUTGOINGRESTRICTED\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
+                                        tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                                }
+                        }
+                        if ((strcmp(tech_pvt->line_array.result[i], "+MCST: 72") == 0)) {        /* motorola call processing unsolicited messages */
+                                tech_pvt->phone_callflow = CALLFLOW_CALL_SECURITYFAIL;
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| CALLFLOW_CALL_SECURITYFAIL\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && tech_pvt->owner) {
+                                        tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                                }
+                        }
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "+CPBR", 5) == 0)) { /* phonebook stuff begins */
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "+CPBR", 5) == 0)) {        /* phonebook stuff begins */
</ins><span class="cx">
</span><del>- if (tech_pvt->phonebook_querying) { /* probably phonebook struct begins */
- int err, first_entry, last_entry, number_lenght, text_lenght;
</del><ins>+                                if (tech_pvt->phonebook_querying) {        /* probably phonebook struct begins */
+                                        int err, first_entry, last_entry, number_lenght, text_lenght;
</ins><span class="cx">
</span><del>- if (option_debug)
- DEBUGA_SKYPE("phonebook struct: |%s|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</del><ins>+                                        if (option_debug)
+                                                DEBUGA_SKYPE("phonebook struct: |%s|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- err =
- sscanf(&tech_pvt->line_array.result[i][8], "%d-%d),%d,%d", &first_entry, &last_entry,
- &number_lenght, &text_lenght);
- if (err < 4) {
</del><ins>+                                        err = sscanf(&tech_pvt->line_array.result[i][8], "%d-%d),%d,%d", &first_entry, &last_entry, &number_lenght, &text_lenght);
+                                        if (err < 4) {
</ins><span class="cx">
</span><del>- err =
- sscanf(&tech_pvt->line_array.result[i][7], "%d-%d,%d,%d", &first_entry,
- &last_entry, &number_lenght, &text_lenght);
- }
</del><ins>+                                                err = sscanf(&tech_pvt->line_array.result[i][7], "%d-%d,%d,%d", &first_entry, &last_entry, &number_lenght, &text_lenght);
+                                        }
</ins><span class="cx">
</span><del>- if (err < 4) {
- ERRORA
- ("phonebook struct: |%s| is nor formatted as: |+CPBR: (1-750),40,14| neither as: |+CPBR: 1-750,40,14|\n",
- SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- } else {
</del><ins>+                                        if (err < 4) {
+                                                ERRORA
+                                                        ("phonebook struct: |%s| is nor formatted as: |+CPBR: (1-750),40,14| neither as: |+CPBR: 1-750,40,14|\n",
+                                                         SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                        } else {
</ins><span class="cx">
</span><del>- if (option_debug)
- DEBUGA_SKYPE
- ("First entry: %d, last entry: %d, phone number max lenght: %d, text max lenght: %d\n",
- SKYPIAX_P_LOG, first_entry, last_entry, number_lenght, text_lenght);
- tech_pvt->phonebook_first_entry = first_entry;
- tech_pvt->phonebook_last_entry = last_entry;
- tech_pvt->phonebook_number_lenght = number_lenght;
- tech_pvt->phonebook_text_lenght = text_lenght;
- }
</del><ins>+                                                if (option_debug)
+                                                        DEBUGA_SKYPE
+                                                                ("First entry: %d, last entry: %d, phone number max lenght: %d, text max lenght: %d\n",
+                                                                 SKYPIAX_P_LOG, first_entry, last_entry, number_lenght, text_lenght);
+                                                tech_pvt->phonebook_first_entry = first_entry;
+                                                tech_pvt->phonebook_last_entry = last_entry;
+                                                tech_pvt->phonebook_number_lenght = number_lenght;
+                                                tech_pvt->phonebook_text_lenght = text_lenght;
+                                        }
</ins><span class="cx">
</span><del>- } else { /* probably phonebook entry begins */
</del><ins>+                                } else {                /* probably phonebook entry begins */
</ins><span class="cx">
</span><del>- if (tech_pvt->phonebook_listing) {
- int err, entry_id, entry_type;
</del><ins>+                                        if (tech_pvt->phonebook_listing) {
+                                                int err, entry_id, entry_type;
</ins><span class="cx">
</span><del>- char entry_number[256];
- char entry_text[256];
</del><ins>+                                                char entry_number[256];
+                                                char entry_text[256];
</ins><span class="cx">
</span><del>- if (option_debug)
- DEBUGA_SKYPE("phonebook entry: |%s|\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
</del><ins>+                                                if (option_debug)
+                                                        DEBUGA_SKYPE("phonebook entry: |%s|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- err =
- sscanf(&tech_pvt->line_array.result[i][7], "%d,\"%255[0-9+]\",%d,\"%255[^\"]\"",
- &entry_id, entry_number, &entry_type, entry_text);
- if (err < 4) {
- ERRORA
- ("err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\"+39025458068\",145,\"ciao a tutti\"|\n",
- SKYPIAX_P_LOG, err, tech_pvt->line_array.result[i]);
- } else {
- //TODO: sanitize entry_text
- if (option_debug)
- DEBUGA_SKYPE("Number: %s, Text: %s, Type: %d\n", SKYPIAX_P_LOG, entry_number,
- entry_text, entry_type);
- /* write entry in phonebook file */
- if (tech_pvt->phonebook_writing_fp) {
- celliax_dir_entry_extension++;
</del><ins>+                                                err =
+                                                        sscanf(&tech_pvt->line_array.result[i][7], "%d,\"%255[0-9+]\",%d,\"%255[^\"]\"", &entry_id, entry_number, &entry_type, entry_text);
+                                                if (err < 4) {
+                                                        ERRORA
+                                                                ("err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\"+39025458068\",145,\"ciao a tutti\"|\n",
+                                                                 SKYPIAX_P_LOG, err, tech_pvt->line_array.result[i]);
+                                                } else {
+                                                        //TODO: sanitize entry_text
+                                                        if (option_debug)
+                                                                DEBUGA_SKYPE("Number: %s, Text: %s, Type: %d\n", SKYPIAX_P_LOG, entry_number, entry_text, entry_type);
+                                                        /* write entry in phonebook file */
+                                                        if (tech_pvt->phonebook_writing_fp) {
+                                                                celliax_dir_entry_extension++;
</ins><span class="cx">
</span><del>- fprintf(tech_pvt->phonebook_writing_fp,
- "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromcell=%s|phonebook_entry_owner=%s\n",
- entry_number, entry_text, "no",
- tech_pvt->celliax_dir_entry_extension_prefix, "2",
- celliax_dir_entry_extension, "yes", "not_specified");
- fprintf(tech_pvt->phonebook_writing_fp,
- "%s => ,%sDO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromcell=%s|phonebook_entry_owner=%s\n",
- entry_number, entry_text, "no",
- tech_pvt->celliax_dir_entry_extension_prefix, "3",
- celliax_dir_entry_extension, "yes", "not_specified");
- }
- }
</del><ins>+                                                                fprintf(tech_pvt->phonebook_writing_fp,
+                                                                                "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromcell=%s|phonebook_entry_owner=%s\n",
+                                                                                entry_number, entry_text, "no",
+                                                                                tech_pvt->celliax_dir_entry_extension_prefix, "2", celliax_dir_entry_extension, "yes", "not_specified");
+                                                                fprintf(tech_pvt->phonebook_writing_fp,
+                                                                                "%s => ,%sDO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromcell=%s|phonebook_entry_owner=%s\n",
+                                                                                entry_number, entry_text, "no",
+                                                                                tech_pvt->celliax_dir_entry_extension_prefix, "3", celliax_dir_entry_extension, "yes", "not_specified");
+                                                        }
+                                                }
</ins><span class="cx">
</span><del>- }
</del><ins>+                                        }
</ins><span class="cx">
</span><del>- if (tech_pvt->phonebook_listing_received_calls) {
- int err, entry_id, entry_type;
</del><ins>+                                        if (tech_pvt->phonebook_listing_received_calls) {
+                                                int err, entry_id, entry_type;
</ins><span class="cx">
</span><del>- char entry_number[256] = "";
- char entry_text[256] = "";
</del><ins>+                                                char entry_number[256] = "";
+                                                char entry_text[256] = "";
</ins><span class="cx">
</span><del>- if (option_debug)
- DEBUGA_SKYPE("phonebook entry: |%s|\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
</del><ins>+                                                if (option_debug)
+                                                        DEBUGA_SKYPE("phonebook entry: |%s|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- err =
- sscanf(&tech_pvt->line_array.result[i][7], "%d,\"%255[0-9+]\",%d,\"%255[^\"]\"",
- &entry_id, entry_number, &entry_type, entry_text);
- if (err < 1) { //we match only on the progressive id, maybe the remote party has not sent its number, and/or there is no corresponding text entry in the phone directory
- ERRORA
- ("err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\"+39025458068\",145,\"ciao a tutti\"|\n",
- SKYPIAX_P_LOG, err, tech_pvt->line_array.result[i]);
- } else {
- //TODO: sanitize entry_text
</del><ins>+                                                err =
+                                                        sscanf(&tech_pvt->line_array.result[i][7], "%d,\"%255[0-9+]\",%d,\"%255[^\"]\"", &entry_id, entry_number, &entry_type, entry_text);
+                                                if (err < 1) {        //we match only on the progressive id, maybe the remote party has not sent its number, and/or there is no corresponding text entry in the phone directory
+                                                        ERRORA
+                                                                ("err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\"+39025458068\",145,\"ciao a tutti\"|\n",
+                                                                 SKYPIAX_P_LOG, err, tech_pvt->line_array.result[i]);
+                                                } else {
+                                                        //TODO: sanitize entry_text
</ins><span class="cx">
</span><del>- if (option_debug)
- DEBUGA_SKYPE("Number: %s, Text: %s, Type: %d\n", SKYPIAX_P_LOG, entry_number,
- entry_text, entry_type);
- memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
- memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
- strncpy(tech_pvt->callid_name, entry_text, sizeof(tech_pvt->callid_name));
- strncpy(tech_pvt->callid_number, entry_number, sizeof(tech_pvt->callid_number));
- if (option_debug)
- DEBUGA_SKYPE("incoming callid: Text: %s, Number: %s\n", SKYPIAX_P_LOG,
- tech_pvt->callid_name, tech_pvt->callid_number);
</del><ins>+                                                        if (option_debug)
+                                                                DEBUGA_SKYPE("Number: %s, Text: %s, Type: %d\n", SKYPIAX_P_LOG, entry_number, entry_text, entry_type);
+                                                        memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
+                                                        memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
+                                                        strncpy(tech_pvt->callid_name, entry_text, sizeof(tech_pvt->callid_name));
+                                                        strncpy(tech_pvt->callid_number, entry_number, sizeof(tech_pvt->callid_number));
+                                                        if (option_debug)
+                                                                DEBUGA_SKYPE("incoming callid: Text: %s, Number: %s\n", SKYPIAX_P_LOG, tech_pvt->callid_name, tech_pvt->callid_number);
</ins><span class="cx">
</span><del>- DEBUGA_SKYPE("|%s| CPBR INCOMING CALLID: name is %s, number is %s\n",
- SKYPIAX_P_LOG, tech_pvt->line_array.result[i],
- tech_pvt->callid_name[0] != 1 ? tech_pvt->callid_name : "not available",
- tech_pvt->callid_number[0] ? tech_pvt->callid_number : "not available");
</del><ins>+                                                        DEBUGA_SKYPE("|%s| CPBR INCOMING CALLID: name is %s, number is %s\n",
+                                                                                 SKYPIAX_P_LOG, tech_pvt->line_array.result[i],
+                                                                                 tech_pvt->callid_name[0] != 1 ? tech_pvt->callid_name : "not available",
+                                                                                 tech_pvt->callid_number[0] ? tech_pvt->callid_number : "not available");
</ins><span class="cx">
</span><del>- /* mark the time of RING */
- gettimeofday(&(tech_pvt->ringtime), NULL);
- tech_pvt->interface_state = SKYPIAX_STATE_RING;
- tech_pvt->phone_callflow = CALLFLOW_INCOMING_RING;
</del><ins>+                                                        /* mark the time of RING */
+                                                        gettimeofday(&(tech_pvt->ringtime), NULL);
+                                                        tech_pvt->interface_state = SKYPIAX_STATE_RING;
+                                                        tech_pvt->phone_callflow = CALLFLOW_INCOMING_RING;
</ins><span class="cx">
</span><del>- }
</del><ins>+                                                }
</ins><span class="cx">
</span><del>- }
</del><ins>+                                        }
</ins><span class="cx">
</span><del>- else {
- DEBUGA_SKYPE("phonebook entry: |%s|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</del><ins>+                                        else {
+                                                DEBUGA_SKYPE("phonebook entry: |%s|\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
</ins><span class="cx">
</span><del>- }
- }
</del><ins>+                                        }
+                                }
</ins><span class="cx">
</span><del>- }
</del><ins>+                        }
</ins><span class="cx">
</span><del>- if ((strncmp(tech_pvt->line_array.result[i], "*ECAV", 5) == 0) || (strncmp(tech_pvt->line_array.result[i], "*ECAM", 5) == 0)) { /* sony-ericsson call processing unsolicited messages */
- int res, ccid, ccstatus, calltype, processid, exitcause, number, type;
- res = ccid = ccstatus = calltype = processid = exitcause = number = type = 0;
- res =
- sscanf(&tech_pvt->line_array.result[i][6], "%d,%d,%d,%d,%d,%d,%d", &ccid, &ccstatus,
- &calltype, &processid, &exitcause, &number, &type);
- /* only changes the phone_callflow if enought parameters were parsed */
- if (res >= 3) {
- switch (ccstatus) {
- case 0:
- if (tech_pvt->owner) {
- ast_setstate(tech_pvt->owner, SKYPIAX_STATE_DOWN);
- tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- }
- tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: IDLE\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- break;
- case 1:
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: CALLING\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- break;
- case 2:
- if (tech_pvt->owner) {
- ast_setstate(tech_pvt->owner, SKYPIAX_STATE_DIALING);
- }
- tech_pvt->interface_state = CALLFLOW_CALL_DIALING;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: CONNECTING\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- break;
- case 3:
- if (tech_pvt->owner) {
- ast_setstate(tech_pvt->owner, SKYPIAX_STATE_UP);
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_ANSWER);
- }
- tech_pvt->phone_callflow = CALLFLOW_CALL_ACTIVE;
- tech_pvt->interface_state = SKYPIAX_STATE_UP;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: ACTIVE\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- break;
- case 4:
- if (option_debug > 1)
- DEBUGA_SKYPE
- ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle HOLD event\n",
- SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- break;
- case 5:
- if (option_debug > 1)
- DEBUGA_SKYPE
- ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle WAITING event\n",
- SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- break;
- case 6:
- if (option_debug > 1)
- DEBUGA_SKYPE
- ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle ALERTING event\n",
- SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- break;
- case 7:
- if (tech_pvt->owner) {
- ast_setstate(tech_pvt->owner, SKYPIAX_STATE_BUSY);
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_BUSY);
- }
- tech_pvt->phone_callflow = CALLFLOW_CALL_LINEBUSY;
- tech_pvt->interface_state = SKYPIAX_STATE_BUSY;
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: BUSY\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- break;
- }
- } else {
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: could not parse parameters\n",
- SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strncmp(tech_pvt->line_array.result[i], "*ECAV", 5) == 0) || (strncmp(tech_pvt->line_array.result[i], "*ECAM", 5) == 0)) {        /* sony-ericsson call processing unsolicited messages */
+                                int res, ccid, ccstatus, calltype, processid, exitcause, number, type;
+                                res = ccid = ccstatus = calltype = processid = exitcause = number = type = 0;
+                                res = sscanf(&tech_pvt->line_array.result[i][6], "%d,%d,%d,%d,%d,%d,%d", &ccid, &ccstatus, &calltype, &processid, &exitcause, &number, &type);
+                                /* only changes the phone_callflow if enought parameters were parsed */
+                                if (res >= 3) {
+                                        switch (ccstatus) {
+                                        case 0:
+                                                if (tech_pvt->owner) {
+                                                        ast_setstate(tech_pvt->owner, SKYPIAX_STATE_DOWN);
+                                                        tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
+                                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                                                }
+                                                tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
+                                                tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+                                                if (option_debug > 1)
+                                                        DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: IDLE\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                break;
+                                        case 1:
+                                                if (option_debug > 1)
+                                                        DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: CALLING\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                break;
+                                        case 2:
+                                                if (tech_pvt->owner) {
+                                                        ast_setstate(tech_pvt->owner, SKYPIAX_STATE_DIALING);
+                                                }
+                                                tech_pvt->interface_state = CALLFLOW_CALL_DIALING;
+                                                if (option_debug > 1)
+                                                        DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: CONNECTING\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                break;
+                                        case 3:
+                                                if (tech_pvt->owner) {
+                                                        ast_setstate(tech_pvt->owner, SKYPIAX_STATE_UP);
+                                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_ANSWER);
+                                                }
+                                                tech_pvt->phone_callflow = CALLFLOW_CALL_ACTIVE;
+                                                tech_pvt->interface_state = SKYPIAX_STATE_UP;
+                                                if (option_debug > 1)
+                                                        DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: ACTIVE\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                break;
+                                        case 4:
+                                                if (option_debug > 1)
+                                                        DEBUGA_SKYPE
+                                                                ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle HOLD event\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                break;
+                                        case 5:
+                                                if (option_debug > 1)
+                                                        DEBUGA_SKYPE
+                                                                ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle WAITING event\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                break;
+                                        case 6:
+                                                if (option_debug > 1)
+                                                        DEBUGA_SKYPE
+                                                                ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle ALERTING event\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                break;
+                                        case 7:
+                                                if (tech_pvt->owner) {
+                                                        ast_setstate(tech_pvt->owner, SKYPIAX_STATE_BUSY);
+                                                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_BUSY);
+                                                }
+                                                tech_pvt->phone_callflow = CALLFLOW_CALL_LINEBUSY;
+                                                tech_pvt->interface_state = SKYPIAX_STATE_BUSY;
+                                                if (option_debug > 1)
+                                                        DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: BUSY\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                                break;
+                                        }
+                                } else {
+                                        if (option_debug > 1)
+                                                DEBUGA_SKYPE("|%s| Sony-Ericsson *ECAM/*ECAV: could not parse parameters\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                }
</ins><span class="cx">
</span><del>- }
</del><ins>+                        }
</ins><span class="cx">
</span><del>- /* at_indicator_* are unsolicited messages sent by the phone to signal us that some of its visual indicators on its screen has changed, based on CIND CMER ETSI docs */
- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_noservice_string) == 0)) {
- if (option_debug > 1)
- ERRORA("|%s| at_indicator_noservice_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        /* at_indicator_* are unsolicited messages sent by the phone to signal us that some of its visual indicators on its screen has changed, based on CIND CMER ETSI docs */
+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_noservice_string) == 0)) {
+                                if (option_debug > 1)
+                                        ERRORA("|%s| at_indicator_noservice_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_nosignal_string) == 0)) {
- if (option_debug > 1)
- ERRORA("|%s| at_indicator_nosignal_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_nosignal_string) == 0)) {
+                                if (option_debug > 1)
+                                        ERRORA("|%s| at_indicator_nosignal_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_lowsignal_string) == 0)) {
- if (option_debug > 1)
- WARNINGA("|%s| at_indicator_lowsignal_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_lowsignal_string) == 0)) {
+                                if (option_debug > 1)
+                                        WARNINGA("|%s| at_indicator_lowsignal_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_lowbattchg_string) == 0)) {
- if (option_debug > 1)
- WARNINGA("|%s| at_indicator_lowbattchg_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_lowbattchg_string) == 0)) {
+                                if (option_debug > 1)
+                                        WARNINGA("|%s| at_indicator_lowbattchg_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_nobattchg_string) == 0)) {
- if (option_debug > 1)
- ERRORA("|%s| at_indicator_nobattchg_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_nobattchg_string) == 0)) {
+                                if (option_debug > 1)
+                                        ERRORA("|%s| at_indicator_nobattchg_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_callactive_string) == 0)) {
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| at_indicator_callactive_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_callactive_string) == 0)) {
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| at_indicator_callactive_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_nocallactive_string) == 0)) {
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| at_indicator_nocallactive_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_nocallactive_string) == 0)) {
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| at_indicator_nocallactive_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_nocallsetup_string) == 0)) {
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| at_indicator_nocallsetup_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_nocallsetup_string) == 0)) {
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| at_indicator_nocallsetup_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_callsetupincoming_string) ==
- 0)) {
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| at_indicator_callsetupincoming_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_callsetupincoming_string) == 0)) {
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| at_indicator_callsetupincoming_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_callsetupoutgoing_string) ==
- 0)) {
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| at_indicator_callsetupoutgoing_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_callsetupoutgoing_string) == 0)) {
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| at_indicator_callsetupoutgoing_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_callsetupremoteringing_string)
- == 0)) {
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| at_indicator_callsetupremoteringing_string\n", SKYPIAX_P_LOG,
- tech_pvt->line_array.result[i]);
- }
</del><ins>+                        if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_indicator_callsetupremoteringing_string)
+                                 == 0)) {
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("|%s| at_indicator_callsetupremoteringing_string\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                        }
</ins><span class="cx">
</span><del>- }
</del><ins>+                }
</ins><span class="cx">
</span><del>- /* let's look for OK, ERROR and EXPECTED_STRING in the complete lines read so far, without re-looking at the lines that has been yet looked at */
- for (i = la_read; i < la_counter; i++) {
- if (expected_string) {
- if ((strncmp(tech_pvt->line_array.result[i], expected_string, strlen(expected_string))
- == 0)) {
- if (option_debug > 1)
- DEBUGA_SKYPE("|%s| got what EXPECTED\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
- at_ack = AT_OK;
- }
- } else {
- if ((strcmp(tech_pvt->line_array.result[i], "OK") == 0)) {
- if (option_debug > 1)
- DEBUGA_SKYPE("got OK\n", SKYPIAX_P_LOG);
- at_ack = AT_OK;
- }
- }
- if ((strcmp(tech_pvt->line_array.result[i], "ERROR") == 0)) {
- if (option_debug > 1)
- DEBUGA_SKYPE("got ERROR\n", SKYPIAX_P_LOG);
- at_ack = AT_ERROR;
- }
</del><ins>+                /* let's look for OK, ERROR and EXPECTED_STRING in the complete lines read so far, without re-looking at the lines that has been yet looked at */
+                for (i = la_read; i < la_counter; i++) {
+                        if (expected_string) {
+                                if ((strncmp(tech_pvt->line_array.result[i], expected_string, strlen(expected_string))
+                                         == 0)) {
+                                        if (option_debug > 1)
+                                                DEBUGA_SKYPE("|%s| got what EXPECTED\n", SKYPIAX_P_LOG, tech_pvt->line_array.result[i]);
+                                        at_ack = AT_OK;
+                                }
+                        } else {
+                                if ((strcmp(tech_pvt->line_array.result[i], "OK") == 0)) {
+                                        if (option_debug > 1)
+                                                DEBUGA_SKYPE("got OK\n", SKYPIAX_P_LOG);
+                                        at_ack = AT_OK;
+                                }
+                        }
+                        if ((strcmp(tech_pvt->line_array.result[i], "ERROR") == 0)) {
+                                if (option_debug > 1)
+                                        DEBUGA_SKYPE("got ERROR\n", SKYPIAX_P_LOG);
+                                at_ack = AT_ERROR;
+                        }
</ins><span class="cx">
</span><del>- /* if we are reading an sms message from memory, put the line into the sms buffer if the line is not "OK" or "ERROR" */
- if (tech_pvt->reading_sms_msg > 1 && at_ack == -1) {
- int c;
- char sms_body[16000];
- int err;
</del><ins>+                        /* if we are reading an sms message from memory, put the line into the sms buffer if the line is not "OK" or "ERROR" */
+                        if (tech_pvt->reading_sms_msg > 1 && at_ack == -1) {
+                                int c;
+                                char sms_body[16000];
+                                int err;
</ins><span class="cx">
</span><del>- if (strncmp(tech_pvt->line_array.result[i], "+CMGR", 5) == 0) { /* we are reading the "header" of an SMS */
- char content[512];
- char content2[512];
</del><ins>+                                if (strncmp(tech_pvt->line_array.result[i], "+CMGR", 5) == 0) {        /* we are reading the "header" of an SMS */
+                                        char content[512];
+                                        char content2[512];
</ins><span class="cx">
</span><del>- memset(content, '\0', sizeof(content));
</del><ins>+                                        memset(content, '\0', sizeof(content));
</ins><span class="cx">
</span><del>- int inside_comma = 0;
- int inside_quote = 0;
- int d = 0;
</del><ins>+                                        int inside_comma = 0;
+                                        int inside_quote = 0;
+                                        int d = 0;
</ins><span class="cx">
</span><del>- for (c = 0; c < strlen(tech_pvt->line_array.result[i]); c++) {
- if (tech_pvt->line_array.result[i][c] == ','
- && tech_pvt->line_array.result[i][c - 1] != '\\' && inside_quote == 0) {
- if (inside_comma) {
- inside_comma = 0;
- //NOTICA("inside_comma=%d, inside_quote=%d, we're at=%s\n", SKYPIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
- } else {
- inside_comma = 1;
- //NOTICA("inside_comma=%d, inside_quote=%d, we're at=%s\n", SKYPIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
- }
- }
- if (tech_pvt->line_array.result[i][c] == '"'
- && tech_pvt->line_array.result[i][c - 1] != '\\') {
- if (inside_quote) {
- inside_quote = 0;
- //ERRORA("END_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", SKYPIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
- DEBUGA_SKYPE("content=%s\n", SKYPIAX_P_LOG, content);
</del><ins>+                                        for (c = 0; c < strlen(tech_pvt->line_array.result[i]); c++) {
+                                                if (tech_pvt->line_array.result[i][c] == ',' && tech_pvt->line_array.result[i][c - 1] != '\\' && inside_quote == 0) {
+                                                        if (inside_comma) {
+                                                                inside_comma = 0;
+                                                                //NOTICA("inside_comma=%d, inside_quote=%d, we're at=%s\n", SKYPIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
+                                                        } else {
+                                                                inside_comma = 1;
+                                                                //NOTICA("inside_comma=%d, inside_quote=%d, we're at=%s\n", SKYPIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
+                                                        }
+                                                }
+                                                if (tech_pvt->line_array.result[i][c] == '"' && tech_pvt->line_array.result[i][c - 1] != '\\') {
+                                                        if (inside_quote) {
+                                                                inside_quote = 0;
+                                                                //ERRORA("END_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", SKYPIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
+                                                                DEBUGA_SKYPE("content=%s\n", SKYPIAX_P_LOG, content);
</ins><span class="cx">
</span><del>- strncat(tech_pvt->sms_message, "---",
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
- strncat(tech_pvt->sms_message, content,
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
- strncat(tech_pvt->sms_message, "|||",
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</del><ins>+                                                                strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+                                                                strncat(tech_pvt->sms_message, content, ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+                                                                strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</ins><span class="cx">
</span><del>- memset(content2, '\0', sizeof(content2));
- err = ucs2_to_utf8(tech_pvt, content, content2, sizeof(content2));
</del><ins>+                                                                memset(content2, '\0', sizeof(content2));
+                                                                err = ucs2_to_utf8(tech_pvt, content, content2, sizeof(content2));
</ins><span class="cx">
</span><del>- strncat(tech_pvt->sms_message, "---",
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
- if (!err)
- strncat(tech_pvt->sms_message, content2,
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
- strncat(tech_pvt->sms_message, "|||",
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
- memset(content, '\0', sizeof(content));
- d = 0;
- } else {
- inside_quote = 1;
- //WARNINGA("START_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", SKYPIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
- }
- }
- if (inside_quote && tech_pvt->line_array.result[i][c] != '"') {
</del><ins>+                                                                strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+                                                                if (!err)
+                                                                        strncat(tech_pvt->sms_message, content2, ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+                                                                strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+                                                                memset(content, '\0', sizeof(content));
+                                                                d = 0;
+                                                        } else {
+                                                                inside_quote = 1;
+                                                                //WARNINGA("START_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", SKYPIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
+                                                        }
+                                                }
+                                                if (inside_quote && tech_pvt->line_array.result[i][c] != '"') {
</ins><span class="cx">
</span><del>- content[d] = tech_pvt->line_array.result[i][c];
- d++;
</del><ins>+                                                        content[d] = tech_pvt->line_array.result[i][c];
+                                                        d++;
</ins><span class="cx">
</span><del>- }
</del><ins>+                                                }
</ins><span class="cx">
</span><del>- }
- } //it was the +CMGR answer from the cellphone
- else {
- strncat(tech_pvt->sms_message, "---",
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
- strncat(tech_pvt->sms_message, tech_pvt->line_array.result[i],
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
- strncat(tech_pvt->sms_message, "|||",
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</del><ins>+                                        }
+                                }                                //it was the +CMGR answer from the cellphone
+                                else {
+                                        strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+                                        strncat(tech_pvt->sms_message, tech_pvt->line_array.result[i], ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+                                        strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</ins><span class="cx">
</span><del>- memset(sms_body, '\0', sizeof(sms_body));
- err = ucs2_to_utf8(tech_pvt, tech_pvt->line_array.result[i], sms_body, sizeof(sms_body));
</del><ins>+                                        memset(sms_body, '\0', sizeof(sms_body));
+                                        err = ucs2_to_utf8(tech_pvt, tech_pvt->line_array.result[i], sms_body, sizeof(sms_body));
</ins><span class="cx">
</span><del>- strncat(tech_pvt->sms_message, "---",
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
- if (!err)
- strncat(tech_pvt->sms_message, sms_body,
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
- strncat(tech_pvt->sms_message, "|||",
- ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</del><ins>+                                        strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+                                        if (!err)
+                                                strncat(tech_pvt->sms_message, sms_body, ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+                                        strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</ins><span class="cx">
</span><del>- DEBUGA_SKYPE("sms_message=%s\n", SKYPIAX_P_LOG, tech_pvt->sms_message);
</del><ins>+                                        DEBUGA_SKYPE("sms_message=%s\n", SKYPIAX_P_LOG, tech_pvt->sms_message);
</ins><span class="cx">
</span><del>- } //it was the UCS2 from cellphone
</del><ins>+                                }                                //it was the UCS2 from cellphone
</ins><span class="cx">
</span><del>- } //we were reading the SMS
</del><ins>+                        }                                        //we were reading the SMS
</ins><span class="cx">
</span><del>- }
</del><ins>+                }
</ins><span class="cx">
</span><del>- la_read = la_counter;
</del><ins>+                la_read = la_counter;
</ins><span class="cx">
</span><del>- if (look_for_ack && at_ack > -1)
- break;
</del><ins>+                if (look_for_ack && at_ack > -1)
+                        break;
</ins><span class="cx">
</span><del>- if (la_counter > AT_MESG_MAX_LINES) {
- ERRORA("Too many lines in result (>%d). Stopping reader.\n", SKYPIAX_P_LOG,
- AT_MESG_MAX_LINES);
- at_ack = AT_ERROR;
- break;
- }
- }
</del><ins>+                if (la_counter > AT_MESG_MAX_LINES) {
+                        ERRORA("Too many lines in result (>%d). Stopping reader.\n", SKYPIAX_P_LOG, AT_MESG_MAX_LINES);
+                        at_ack = AT_ERROR;
+                        break;
+                }
+        }
</ins><span class="cx">
</span><del>- UNLOCKA(tech_pvt->controldev_lock);
- POPPA_UNLOCKA(tech_pvt->controldev_lock);
- if (select_err == -1) {
- ERRORA("select returned -1 on %s, setting controldev_dead, error was: %s\n",
- SKYPIAX_P_LOG, tech_pvt->controldevice_name, strerror(errno));
- tech_pvt->controldev_dead = 1;
- close(tech_pvt->controldevfd);
- if (tech_pvt->owner)
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- return -1;
- }
</del><ins>+        UNLOCKA(tech_pvt->controldev_lock);
+        POPPA_UNLOCKA(tech_pvt->controldev_lock);
+        if (select_err == -1) {
+                ERRORA("select returned -1 on %s, setting controldev_dead, error was: %s\n", SKYPIAX_P_LOG, tech_pvt->controldevice_name, strerror(errno));
+                tech_pvt->controldev_dead = 1;
+                close(tech_pvt->controldevfd);
+                if (tech_pvt->owner)
+                        celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- if (tech_pvt->phone_callflow == CALLFLOW_CALL_INCOMING && tech_pvt->call_incoming_time.tv_sec) { //after three sec of CALLFLOW_CALL_INCOMING, we assume the phone is incapable of notifying RING (eg: motorola c350), so we try to answer
- char list_command[64];
- struct timeval call_incoming_timeout;
- gettimeofday(&call_incoming_timeout, NULL);
- call_incoming_timeout.tv_sec -= 3;
- DEBUGA_SKYPE
- ("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n",
- SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
- if (call_incoming_timeout.tv_sec > tech_pvt->call_incoming_time.tv_sec) {
</del><ins>+        if (tech_pvt->phone_callflow == CALLFLOW_CALL_INCOMING && tech_pvt->call_incoming_time.tv_sec) {        //after three sec of CALLFLOW_CALL_INCOMING, we assume the phone is incapable of notifying RING (eg: motorola c350), so we try to answer
+                char list_command[64];
+                struct timeval call_incoming_timeout;
+                gettimeofday(&call_incoming_timeout, NULL);
+                call_incoming_timeout.tv_sec -= 3;
+                DEBUGA_SKYPE
+                        ("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n",
+                         SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
+                if (call_incoming_timeout.tv_sec > tech_pvt->call_incoming_time.tv_sec) {
</ins><span class="cx">
</span><del>- tech_pvt->call_incoming_time.tv_sec = 0;
- tech_pvt->call_incoming_time.tv_usec = 0;
- DEBUGA_SKYPE
- ("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n",
- SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CPBS=RC");
- if (res) {
- ERRORA
- ("AT+CPBS=RC (select memory of received calls) was not answered by the phone\n",
- SKYPIAX_P_LOG);
- }
- tech_pvt->phonebook_querying = 1;
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CPBR=?");
- if (res) {
- ERRORA
- ("AT+CPBS=RC (select memory of received calls) was not answered by the phone\n",
- SKYPIAX_P_LOG);
- }
- tech_pvt->phonebook_querying = 0;
- sprintf(list_command, "AT+CPBR=%d,%d", tech_pvt->phonebook_first_entry,
- tech_pvt->phonebook_last_entry);
- tech_pvt->phonebook_listing_received_calls = 1;
- res = celliax_serial_write_AT_expect_longtime(tech_pvt, list_command, "OK");
- if (res) {
- WARNINGA("AT+CPBR=%d,%d failed, continue\n", SKYPIAX_P_LOG,
- tech_pvt->phonebook_first_entry, tech_pvt->phonebook_last_entry);
- }
- tech_pvt->phonebook_listing_received_calls = 0;
- }
- }
</del><ins>+                        tech_pvt->call_incoming_time.tv_sec = 0;
+                        tech_pvt->call_incoming_time.tv_usec = 0;
+                        DEBUGA_SKYPE
+                                ("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n",
+                                 SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
+                        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CPBS=RC");
+                        if (res) {
+                                ERRORA("AT+CPBS=RC (select memory of received calls) was not answered by the phone\n", SKYPIAX_P_LOG);
+                        }
+                        tech_pvt->phonebook_querying = 1;
+                        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CPBR=?");
+                        if (res) {
+                                ERRORA("AT+CPBS=RC (select memory of received calls) was not answered by the phone\n", SKYPIAX_P_LOG);
+                        }
+                        tech_pvt->phonebook_querying = 0;
+                        sprintf(list_command, "AT+CPBR=%d,%d", tech_pvt->phonebook_first_entry, tech_pvt->phonebook_last_entry);
+                        tech_pvt->phonebook_listing_received_calls = 1;
+                        res = celliax_serial_write_AT_expect_longtime(tech_pvt, list_command, "OK");
+                        if (res) {
+                                WARNINGA("AT+CPBR=%d,%d failed, continue\n", SKYPIAX_P_LOG, tech_pvt->phonebook_first_entry, tech_pvt->phonebook_last_entry);
+                        }
+                        tech_pvt->phonebook_listing_received_calls = 0;
+                }
+        }
</ins><span class="cx">
</span><del>- if (tech_pvt->phone_callflow == CALLFLOW_INCOMING_RING) {
- struct timeval call_incoming_timeout;
- gettimeofday(&call_incoming_timeout, NULL);
- call_incoming_timeout.tv_sec -= 10;
- DEBUGA_SKYPE
- ("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n",
- SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
- if (call_incoming_timeout.tv_sec > tech_pvt->ringtime.tv_sec) {
- ERRORA("Ringing stopped and I have not answered. Why?\n", SKYPIAX_P_LOG);
- DEBUGA_SKYPE
- ("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n",
- SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
- if (tech_pvt->owner) {
- celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
- tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
- }
- }
- }
- tech_pvt->line_array.elemcount = la_counter;
- //NOTICA (" OUTSIDE this celliax_serial_device %s \n", SKYPIAX_P_LOG, tech_pvt->controldevice_name);
- if (look_for_ack)
- return at_ack;
- else
- return 0;
</del><ins>+        if (tech_pvt->phone_callflow == CALLFLOW_INCOMING_RING) {
+                struct timeval call_incoming_timeout;
+                gettimeofday(&call_incoming_timeout, NULL);
+                call_incoming_timeout.tv_sec -= 10;
+                DEBUGA_SKYPE
+                        ("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n",
+                         SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
+                if (call_incoming_timeout.tv_sec > tech_pvt->ringtime.tv_sec) {
+                        ERRORA("Ringing stopped and I have not answered. Why?\n", SKYPIAX_P_LOG);
+                        DEBUGA_SKYPE
+                                ("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n",
+                                 SKYPIAX_P_LOG, tech_pvt->call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
+                        if (tech_pvt->owner) {
+                                celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_HANGUP);
+                                tech_pvt->owner->hangupcause = SKYPIAX_CAUSE_FAILURE;
+                        }
+                }
+        }
+        tech_pvt->line_array.elemcount = la_counter;
+        //NOTICA (" OUTSIDE this celliax_serial_device %s \n", SKYPIAX_P_LOG, tech_pvt->controldevice_name);
+        if (look_for_ack)
+                return at_ack;
+        else
+                return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_write_AT(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><del>- int howmany;
- int i;
- int res;
- int count;
</del><ins>+        int howmany;
+        int i;
+        int res;
+        int count;
</ins><span class="cx">
</span><del>- howmany = strlen(data);
</del><ins>+        howmany = strlen(data);
</ins><span class="cx">
</span><del>- for (i = 0; i < howmany; i++) {
- res = write(tech_pvt->controldevfd, &data[i], 1);
</del><ins>+        for (i = 0; i < howmany; i++) {
+                res = write(tech_pvt->controldevfd, &data[i], 1);
</ins><span class="cx">
</span><del>- if (res != 1) {
- DEBUGA_SKYPE("Error sending (%.1s): %d (%s)\n", SKYPIAX_P_LOG, &data[i], res,
- strerror(errno));
- usleep(100000);
- for (count = 0; count < 10; count++) {
- res = write(tech_pvt->controldevfd, &data[i], 1);
- if (res == 1) {
- DEBUGA_SKYPE("Successfully RE-sent (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i],
- count, res, strerror(errno));
- break;
- } else
- DEBUGA_SKYPE("Error RE-sending (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i],
- count, res, strerror(errno));
- usleep(100000);
</del><ins>+                if (res != 1) {
+                        DEBUGA_SKYPE("Error sending (%.1s): %d (%s)\n", SKYPIAX_P_LOG, &data[i], res, strerror(errno));
+                        usleep(100000);
+                        for (count = 0; count < 10; count++) {
+                                res = write(tech_pvt->controldevfd, &data[i], 1);
+                                if (res == 1) {
+                                        DEBUGA_SKYPE("Successfully RE-sent (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i], count, res, strerror(errno));
+                                        break;
+                                } else
+                                        DEBUGA_SKYPE("Error RE-sending (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i], count, res, strerror(errno));
+                                usleep(100000);
</ins><span class="cx">
</span><del>- }
- if (res != 1) {
- ERRORA("Error RE-sending (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i], count,
- res, strerror(errno));
- return -1;
- }
- }
- if (option_debug > 1)
- DEBUGA_SKYPE("sent data... (%.1s)\n", SKYPIAX_P_LOG, &data[i]);
- usleep(1000); /* release the cpu */
- }
</del><ins>+                        }
+                        if (res != 1) {
+                                ERRORA("Error RE-sending (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i], count, res, strerror(errno));
+                                return -1;
+                        }
+                }
+                if (option_debug > 1)
+                        DEBUGA_SKYPE("sent data... (%.1s)\n", SKYPIAX_P_LOG, &data[i]);
+                usleep(1000);                        /* release the cpu */
+        }
</ins><span class="cx">
</span><del>- res = write(tech_pvt->controldevfd, "\r", 1);
</del><ins>+        res = write(tech_pvt->controldevfd, "\r", 1);
</ins><span class="cx">
</span><del>- if (res != 1) {
- DEBUGA_SKYPE("Error sending (carriage return): %d (%s)\n", SKYPIAX_P_LOG, res,
- strerror(errno));
- usleep(100000);
- for (count = 0; count < 10; count++) {
- res = write(tech_pvt->controldevfd, "\r", 1);
</del><ins>+        if (res != 1) {
+                DEBUGA_SKYPE("Error sending (carriage return): %d (%s)\n", SKYPIAX_P_LOG, res, strerror(errno));
+                usleep(100000);
+                for (count = 0; count < 10; count++) {
+                        res = write(tech_pvt->controldevfd, "\r", 1);
</ins><span class="cx">
</span><del>- if (res == 1) {
- DEBUGA_SKYPE("Successfully RE-sent carriage return: %d %d (%s)\n", SKYPIAX_P_LOG,
- count, res, strerror(errno));
- break;
- } else
- DEBUGA_SKYPE("Error RE-sending (carriage return): %d %d (%s)\n", SKYPIAX_P_LOG,
- count, res, strerror(errno));
- usleep(100000);
</del><ins>+                        if (res == 1) {
+                                DEBUGA_SKYPE("Successfully RE-sent carriage return: %d %d (%s)\n", SKYPIAX_P_LOG, count, res, strerror(errno));
+                                break;
+                        } else
+                                DEBUGA_SKYPE("Error RE-sending (carriage return): %d %d (%s)\n", SKYPIAX_P_LOG, count, res, strerror(errno));
+                        usleep(100000);
</ins><span class="cx">
</span><del>- }
- if (res != 1) {
- ERRORA("Error RE-sending (carriage return): %d %d (%s)\n", SKYPIAX_P_LOG, count,
- res, strerror(errno));
- return -1;
- }
- }
- if (option_debug > 1)
- DEBUGA_SKYPE("sent (carriage return)\n", SKYPIAX_P_LOG);
- usleep(1000); /* release the cpu */
</del><ins>+                }
+                if (res != 1) {
+                        ERRORA("Error RE-sending (carriage return): %d %d (%s)\n", SKYPIAX_P_LOG, count, res, strerror(errno));
+                        return -1;
+                }
+        }
+        if (option_debug > 1)
+                DEBUGA_SKYPE("sent (carriage return)\n", SKYPIAX_P_LOG);
+        usleep(1000);                                /* release the cpu */
</ins><span class="cx">
</span><del>- return howmany;
</del><ins>+        return howmany;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_write_AT_nocr(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><del>- int howmany;
- int i;
- int res;
- int count;
</del><ins>+        int howmany;
+        int i;
+        int res;
+        int count;
</ins><span class="cx">
</span><del>- howmany = strlen(data);
</del><ins>+        howmany = strlen(data);
</ins><span class="cx">
</span><del>- for (i = 0; i < howmany; i++) {
- res = write(tech_pvt->controldevfd, &data[i], 1);
</del><ins>+        for (i = 0; i < howmany; i++) {
+                res = write(tech_pvt->controldevfd, &data[i], 1);
</ins><span class="cx">
</span><del>- if (res != 1) {
- DEBUGA_SKYPE("Error sending (%.1s): %d (%s)\n", SKYPIAX_P_LOG, &data[i], res,
- strerror(errno));
- usleep(100000);
- for (count = 0; count < 10; count++) {
- res = write(tech_pvt->controldevfd, &data[i], 1);
- if (res == 1)
- break;
- else
- DEBUGA_SKYPE("Error RE-sending (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i],
- count, res, strerror(errno));
- usleep(100000);
</del><ins>+                if (res != 1) {
+                        DEBUGA_SKYPE("Error sending (%.1s): %d (%s)\n", SKYPIAX_P_LOG, &data[i], res, strerror(errno));
+                        usleep(100000);
+                        for (count = 0; count < 10; count++) {
+                                res = write(tech_pvt->controldevfd, &data[i], 1);
+                                if (res == 1)
+                                        break;
+                                else
+                                        DEBUGA_SKYPE("Error RE-sending (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i], count, res, strerror(errno));
+                                usleep(100000);
</ins><span class="cx">
</span><del>- }
- if (res != 1) {
- ERRORA("Error RE-sending (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i], count,
- res, strerror(errno));
- return -1;
- }
- }
- if (option_debug > 1)
- DEBUGA_SKYPE("sent data... (%.1s)\n", SKYPIAX_P_LOG, &data[i]);
- usleep(1000); /* release the cpu */
- }
</del><ins>+                        }
+                        if (res != 1) {
+                                ERRORA("Error RE-sending (%.1s): %d %d (%s)\n", SKYPIAX_P_LOG, &data[i], count, res, strerror(errno));
+                                return -1;
+                        }
+                }
+                if (option_debug > 1)
+                        DEBUGA_SKYPE("sent data... (%.1s)\n", SKYPIAX_P_LOG, &data[i]);
+                usleep(1000);                        /* release the cpu */
+        }
</ins><span class="cx">
</span><del>- usleep(1000); /* release the cpu */
</del><ins>+        usleep(1000);                                /* release the cpu */
</ins><span class="cx">
</span><del>- return howmany;
</del><ins>+        return howmany;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_write_AT_noack(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- if (option_debug > 1)
- DEBUGA_SKYPE("celliax_serial_write_AT_noack: %s\n", SKYPIAX_P_LOG, data);
</del><ins>+        if (option_debug > 1)
+                DEBUGA_SKYPE("celliax_serial_write_AT_noack: %s\n", SKYPIAX_P_LOG, data);
</ins><span class="cx">
</span><del>- PUSHA_UNLOCKA(tech_pvt->controldev_lock);
- LOKKA(tech_pvt->controldev_lock);
- if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
</del><ins>+        PUSHA_UNLOCKA(tech_pvt->controldev_lock);
+        LOKKA(tech_pvt->controldev_lock);
+        if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
</ins><span class="cx">
</span><del>- ERRORA("Error sending data... (%s)\n", SKYPIAX_P_LOG, strerror(errno));
- UNLOCKA(tech_pvt->controldev_lock);
- return -1;
- }
- UNLOCKA(tech_pvt->controldev_lock);
- POPPA_UNLOCKA(tech_pvt->controldev_lock);
</del><ins>+                ERRORA("Error sending data... (%s)\n", SKYPIAX_P_LOG, strerror(errno));
+                UNLOCKA(tech_pvt->controldev_lock);
+                return -1;
+        }
+        UNLOCKA(tech_pvt->controldev_lock);
+        POPPA_UNLOCKA(tech_pvt->controldev_lock);
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_write_AT_ack(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><del>- int at_result = AT_ERROR;
</del><ins>+        int at_result = AT_ERROR;
</ins><span class="cx">
</span><del>- PUSHA_UNLOCKA(tech_pvt->controldev_lock);
- LOKKA(tech_pvt->controldev_lock);
- if (option_debug > 1)
- DEBUGA_SKYPE("sending: %s\n", SKYPIAX_P_LOG, data);
- if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
- ERRORA("Error sending data... (%s) \n", SKYPIAX_P_LOG, strerror(errno));
- UNLOCKA(tech_pvt->controldev_lock);
- return -1;
- }
</del><ins>+        PUSHA_UNLOCKA(tech_pvt->controldev_lock);
+        LOKKA(tech_pvt->controldev_lock);
+        if (option_debug > 1)
+                DEBUGA_SKYPE("sending: %s\n", SKYPIAX_P_LOG, data);
+        if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
+                ERRORA("Error sending data... (%s) \n", SKYPIAX_P_LOG, strerror(errno));
+                UNLOCKA(tech_pvt->controldev_lock);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, 2, NULL, 1); // 2.5 sec timeout
- UNLOCKA(tech_pvt->controldev_lock);
- POPPA_UNLOCKA(tech_pvt->controldev_lock);
</del><ins>+        at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, 2, NULL, 1);        // 2.5 sec timeout
+        UNLOCKA(tech_pvt->controldev_lock);
+        POPPA_UNLOCKA(tech_pvt->controldev_lock);
</ins><span class="cx">
</span><del>- return at_result;
</del><ins>+        return at_result;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_write_AT_ack_nocr_longtime(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><del>- int at_result = AT_ERROR;
</del><ins>+        int at_result = AT_ERROR;
</ins><span class="cx">
</span><del>- PUSHA_UNLOCKA(tech_pvt->controldev_lock);
- LOKKA(tech_pvt->controldev_lock);
- if (option_debug > 1)
- DEBUGA_SKYPE("sending: %s\n", SKYPIAX_P_LOG, data);
- if (celliax_serial_write_AT_nocr(tech_pvt, data) != strlen(data)) {
- ERRORA("Error sending data... (%s) \n", SKYPIAX_P_LOG, strerror(errno));
- UNLOCKA(tech_pvt->controldev_lock);
- return -1;
- }
</del><ins>+        PUSHA_UNLOCKA(tech_pvt->controldev_lock);
+        LOKKA(tech_pvt->controldev_lock);
+        if (option_debug > 1)
+                DEBUGA_SKYPE("sending: %s\n", SKYPIAX_P_LOG, data);
+        if (celliax_serial_write_AT_nocr(tech_pvt, data) != strlen(data)) {
+                ERRORA("Error sending data... (%s) \n", SKYPIAX_P_LOG, strerror(errno));
+                UNLOCKA(tech_pvt->controldev_lock);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, 20, NULL, 1); // 20.5 sec timeout
- UNLOCKA(tech_pvt->controldev_lock);
- POPPA_UNLOCKA(tech_pvt->controldev_lock);
</del><ins>+        at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, 20, NULL, 1);        // 20.5 sec timeout
+        UNLOCKA(tech_pvt->controldev_lock);
+        POPPA_UNLOCKA(tech_pvt->controldev_lock);
</ins><span class="cx">
</span><del>- return at_result;
</del><ins>+        return at_result;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-int celliax_serial_write_AT_expect1(private_t * tech_pvt, const char *data,
- const char *expected_string, int expect_crlf,
- int seconds)
</del><ins>+int celliax_serial_write_AT_expect1(private_t * tech_pvt, const char *data, const char *expected_string, int expect_crlf, int seconds)
</ins><span class="cx"> {
</span><del>- int at_result = AT_ERROR;
</del><ins>+        int at_result = AT_ERROR;
</ins><span class="cx">
</span><del>- PUSHA_UNLOCKA(tech_pvt->controldev_lock);
- LOKKA(tech_pvt->controldev_lock);
- if (option_debug > 1)
- DEBUGA_SKYPE("sending: %s, expecting: %s\n", SKYPIAX_P_LOG, data, expected_string);
- if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
- ERRORA("Error sending data... (%s) \n", SKYPIAX_P_LOG, strerror(errno));
- UNLOCKA(tech_pvt->controldev_lock);
- return -1;
- }
</del><ins>+        PUSHA_UNLOCKA(tech_pvt->controldev_lock);
+        LOKKA(tech_pvt->controldev_lock);
+        if (option_debug > 1)
+                DEBUGA_SKYPE("sending: %s, expecting: %s\n", SKYPIAX_P_LOG, data, expected_string);
+        if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
+                ERRORA("Error sending data... (%s) \n", SKYPIAX_P_LOG, strerror(errno));
+                UNLOCKA(tech_pvt->controldev_lock);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, seconds, expected_string, expect_crlf); // 20.5 sec timeout, used for querying the SIM and sending SMSs
- UNLOCKA(tech_pvt->controldev_lock);
- POPPA_UNLOCKA(tech_pvt->controldev_lock);
</del><ins>+        at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, seconds, expected_string, expect_crlf);        // 20.5 sec timeout, used for querying the SIM and sending SMSs
+        UNLOCKA(tech_pvt->controldev_lock);
+        POPPA_UNLOCKA(tech_pvt->controldev_lock);
</ins><span class="cx">
</span><del>- return at_result;
</del><ins>+        return at_result;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-int celliax_serial_AT_expect(private_t * tech_pvt, const char *expected_string,
- int expect_crlf, int seconds)
</del><ins>+int celliax_serial_AT_expect(private_t * tech_pvt, const char *expected_string, int expect_crlf, int seconds)
</ins><span class="cx"> {
</span><del>- int at_result = AT_ERROR;
</del><ins>+        int at_result = AT_ERROR;
</ins><span class="cx">
</span><del>- PUSHA_UNLOCKA(tech_pvt->controldev_lock);
- LOKKA(tech_pvt->controldev_lock);
- if (option_debug > 1)
- DEBUGA_SKYPE("expecting: %s\n", SKYPIAX_P_LOG, expected_string);
</del><ins>+        PUSHA_UNLOCKA(tech_pvt->controldev_lock);
+        LOKKA(tech_pvt->controldev_lock);
+        if (option_debug > 1)
+                DEBUGA_SKYPE("expecting: %s\n", SKYPIAX_P_LOG, expected_string);
</ins><span class="cx">
</span><del>- at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, seconds, expected_string, expect_crlf); // 20.5 sec timeout, used for querying the SIM and sending SMSs
- UNLOCKA(tech_pvt->controldev_lock);
- POPPA_UNLOCKA(tech_pvt->controldev_lock);
</del><ins>+        at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, seconds, expected_string, expect_crlf);        // 20.5 sec timeout, used for querying the SIM and sending SMSs
+        UNLOCKA(tech_pvt->controldev_lock);
+        POPPA_UNLOCKA(tech_pvt->controldev_lock);
</ins><span class="cx">
</span><del>- return at_result;
</del><ins>+        return at_result;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_answer(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_AT)
- return celliax_serial_answer_AT(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_answer_AT(tech_pvt);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
- return celliax_serial_answer_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_answer_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
- return celliax_serial_answer_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_answer_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>- return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> int celliax_serial_answer_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- int res;
</del><ins>+        int res;
</ins><span class="cx">
</span><del>- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_answer, tech_pvt->at_answer_expect);
- if (res) {
- DEBUGA_SKYPE
- ("at_answer command failed, command used: %s, expecting: %s, trying with AT+CKPD=\"S\"\n",
- SKYPIAX_P_LOG, tech_pvt->at_answer, tech_pvt->at_answer_expect);
</del><ins>+        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_answer, tech_pvt->at_answer_expect);
+        if (res) {
+                DEBUGA_SKYPE
+                        ("at_answer command failed, command used: %s, expecting: %s, trying with AT+CKPD=\"S\"\n",
+                         SKYPIAX_P_LOG, tech_pvt->at_answer, tech_pvt->at_answer_expect);
</ins><span class="cx">
</span><del>- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CKPD=\"S\"");
- if (res) {
- ERRORA("at_answer command failed, command used: 'AT+CKPD=\"S\"', giving up\n",
- SKYPIAX_P_LOG);
- return -1;
- }
- }
- //tech_pvt->interface_state = SKYPIAX_STATE_UP;
- //tech_pvt->phone_callflow = CALLFLOW_CALL_ACTIVE;
- DEBUGA_SKYPE("AT: call answered\n", SKYPIAX_P_LOG);
- return 0;
</del><ins>+                res = celliax_serial_write_AT_ack(tech_pvt, "AT+CKPD=\"S\"");
+                if (res) {
+                        ERRORA("at_answer command failed, command used: 'AT+CKPD=\"S\"', giving up\n", SKYPIAX_P_LOG);
+                        return -1;
+                }
+        }
+        //tech_pvt->interface_state = SKYPIAX_STATE_UP;
+        //tech_pvt->phone_callflow = CALLFLOW_CALL_ACTIVE;
+        DEBUGA_SKYPE("AT: call answered\n", SKYPIAX_P_LOG);
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_hangup(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_AT)
- return celliax_serial_hangup_AT(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_hangup_AT(tech_pvt);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
- return celliax_serial_hangup_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_hangup_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
- return celliax_serial_hangup_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_hangup_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>- return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> int celliax_serial_hangup_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- int res;
</del><ins>+        int res;
</ins><span class="cx">
</span><del>- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
- res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_hangup, tech_pvt->at_hangup_expect);
- if (res) {
- DEBUGA_SKYPE
- ("at_hangup command failed, command used: %s, trying to use AT+CKPD=\"EEE\"\n",
- SKYPIAX_P_LOG, tech_pvt->at_hangup);
- res = celliax_serial_write_AT_ack(tech_pvt, "AT+CKPD=\"EEE\"");
- if (res) {
- ERRORA("at_hangup command failed, command used: 'AT+CKPD=\"EEE\"'\n",
- SKYPIAX_P_LOG);
- return -1;
- }
- }
- }
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
- return 0;
</del><ins>+        if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
+                res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt->at_hangup, tech_pvt->at_hangup_expect);
+                if (res) {
+                        DEBUGA_SKYPE("at_hangup command failed, command used: %s, trying to use AT+CKPD=\"EEE\"\n", SKYPIAX_P_LOG, tech_pvt->at_hangup);
+                        res = celliax_serial_write_AT_ack(tech_pvt, "AT+CKPD=\"EEE\"");
+                        if (res) {
+                                ERRORA("at_hangup command failed, command used: 'AT+CKPD=\"EEE\"'\n", SKYPIAX_P_LOG);
+                                return -1;
+                        }
+                }
+        }
+        tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+        tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> int celliax_serial_call(private_t * tech_pvt, char *dstr)
</span><span class="cx"> {
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_AT)
- return celliax_serial_call_AT(tech_pvt, dstr);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_call_AT(tech_pvt, dstr);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
- return celliax_serial_call_FBUS2(tech_pvt, dstr);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_call_FBUS2(tech_pvt, dstr);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_NO_SERIAL)
- return 0;
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_NO_SERIAL)
+                return 0;
</ins><span class="cx"> #ifdef CELLIAX_CVM
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
- return celliax_serial_call_CVM_BUSMAIL(tech_pvt, dstr);
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_call_CVM_BUSMAIL(tech_pvt, dstr);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>- return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_call_AT(private_t * tech_pvt, char *dstr)
</span><span class="cx"> {
</span><del>- int res;
- char at_command[256];
</del><ins>+        int res;
+        char at_command[256];
</ins><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);
</del><ins>+        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);
</ins><span class="cx"> /*
</span><span class="cx"> size_t fixdstr = strspn(dstr, AST_DIGIT_ANYDIG);
</span><span class="cx"> if (fixdstr == 0) {
</span><span class="lines">@@ -3273,125 +3117,119 @@
</span><span class="cx"> return -1;
</span><span class="cx"> }
</span><span class="cx"> */
</span><del>- //dstr[fixdstr] = '\0';
- sprintf(at_command, "%s%s%s", tech_pvt->at_dial_pre_number, dstr, tech_pvt->at_dial_post_number);
- DEBUGA_PBX("Dialstring %s\n", SKYPIAX_P_LOG, at_command);
- 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, AST_CONTROL_ANSWER);
- //}
</del><ins>+        //dstr[fixdstr] = '\0';
+        sprintf(at_command, "%s%s%s", tech_pvt->at_dial_pre_number, dstr, tech_pvt->at_dial_post_number);
+        DEBUGA_PBX("Dialstring %s\n", SKYPIAX_P_LOG, at_command);
+        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, AST_CONTROL_ANSWER);
+        //}
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-int ucs2_to_utf8(private_t * tech_pvt, char *ucs2_in, char *utf8_out,
- size_t outbytesleft)
</del><ins>+int ucs2_to_utf8(private_t * tech_pvt, char *ucs2_in, char *utf8_out, size_t outbytesleft)
</ins><span class="cx"> {
</span><del>- char converted[16000];
- iconv_t iconv_format;
- int iconv_res;
- char *outbuf;
- char *inbuf;
- size_t inbytesleft;
- int c;
- char stringa[5];
- double hexnum;
- int i = 0;
</del><ins>+        char converted[16000];
+        iconv_t iconv_format;
+        int iconv_res;
+        char *outbuf;
+        char *inbuf;
+        size_t inbytesleft;
+        int c;
+        char stringa[5];
+        double hexnum;
+        int i = 0;
</ins><span class="cx">
</span><del>- memset(converted, '\0', sizeof(converted));
</del><ins>+        memset(converted, '\0', sizeof(converted));
</ins><span class="cx">
</span><del>- DEBUGA_SKYPE("ucs2_in=%s\n", SKYPIAX_P_LOG, ucs2_in);
- /* cicopet */
- for (c = 0; c < strlen(ucs2_in); c++) {
- sprintf(stringa, "0x%c%c", ucs2_in[c], ucs2_in[c + 1]);
- c++;
- hexnum = strtod(stringa, NULL);
- converted[i] = hexnum;
- i++;
- }
</del><ins>+        DEBUGA_SKYPE("ucs2_in=%s\n", SKYPIAX_P_LOG, ucs2_in);
+        /* cicopet */
+        for (c = 0; c < strlen(ucs2_in); c++) {
+                sprintf(stringa, "0x%c%c", ucs2_in[c], ucs2_in[c + 1]);
+                c++;
+                hexnum = strtod(stringa, NULL);
+                converted[i] = hexnum;
+                i++;
+        }
</ins><span class="cx">
</span><del>- outbuf = utf8_out;
- inbuf = converted;
</del><ins>+        outbuf = utf8_out;
+        inbuf = converted;
</ins><span class="cx">
</span><del>- iconv_format = iconv_open("UTF8", "UCS-2BE");
- if (iconv_format == (iconv_t) - 1) {
- ERRORA("error: %s\n", SKYPIAX_P_LOG, strerror(errno));
- return -1;
- }
</del><ins>+        iconv_format = iconv_open("UTF8", "UCS-2BE");
+        if (iconv_format == (iconv_t) - 1) {
+                ERRORA("error: %s\n", SKYPIAX_P_LOG, strerror(errno));
+                return -1;
+        }
</ins><span class="cx">
</span><del>- inbytesleft = i;
- iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
- if (iconv_res == (size_t) - 1) {
- DEBUGA_SKYPE("ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n",
- SKYPIAX_P_LOG, inbuf, (int)inbytesleft, outbuf, (int)outbytesleft, converted,
- utf8_out);
- DEBUGA_SKYPE("error: %s %d\n", SKYPIAX_P_LOG, strerror(errno), errno);
- return -1;
- }
- DEBUGA_SKYPE
- ("iconv_res=%d, in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n",
- SKYPIAX_P_LOG, iconv_res, inbuf, (int)inbytesleft, outbuf, (int)outbytesleft, converted,
- utf8_out);
- iconv_close(iconv_format);
</del><ins>+        inbytesleft = i;
+        iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+        if (iconv_res == (size_t) -1) {
+                DEBUGA_SKYPE("ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n",
+                                         SKYPIAX_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out);
+                DEBUGA_SKYPE("error: %s %d\n", SKYPIAX_P_LOG, strerror(errno), errno);
+                return -1;
+        }
+        DEBUGA_SKYPE
+                ("iconv_res=%d, in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n",
+                 SKYPIAX_P_LOG, iconv_res, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out);
+        iconv_close(iconv_format);
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-int utf_to_ucs2(private_t * tech_pvt, char *utf_in, size_t inbytesleft, char *ucs2_out,
- size_t outbytesleft)
</del><ins>+int utf_to_ucs2(private_t * tech_pvt, char *utf_in, size_t inbytesleft, char *ucs2_out, size_t outbytesleft)
</ins><span class="cx"> {
</span><del>- /* cicopet */
- iconv_t iconv_format;
- int iconv_res;
- char *outbuf;
- char *inbuf;
- char converted[16000];
- int i;
- char stringa[16];
- char stringa2[16];
</del><ins>+        /* cicopet */
+        iconv_t iconv_format;
+        int iconv_res;
+        char *outbuf;
+        char *inbuf;
+        char converted[16000];
+        int i;
+        char stringa[16];
+        char stringa2[16];
</ins><span class="cx">
</span><del>- memset(converted, '\0', sizeof(converted));
</del><ins>+        memset(converted, '\0', sizeof(converted));
</ins><span class="cx">
</span><del>- outbuf = converted;
- inbuf = utf_in;
</del><ins>+        outbuf = converted;
+        inbuf = utf_in;
</ins><span class="cx">
</span><del>- iconv_format = iconv_open("UCS-2BE", "UTF8");
- if (iconv_format == (iconv_t) - 1) {
- ERRORA("error: %s\n", SKYPIAX_P_LOG, strerror(errno));
- return -1;
- }
- outbytesleft = 16000;
</del><ins>+        iconv_format = iconv_open("UCS-2BE", "UTF8");
+        if (iconv_format == (iconv_t) - 1) {
+                ERRORA("error: %s\n", SKYPIAX_P_LOG, strerror(errno));
+                return -1;
+        }
+        outbytesleft = 16000;
</ins><span class="cx">
</span><del>- DEBUGA_SKYPE("in=%s, inleft=%d, out=%s, outleft=%d, utf_in=%s, converted=%s\n",
- SKYPIAX_P_LOG, inbuf, (int)inbytesleft, outbuf, (int)outbytesleft, utf_in, converted);
- iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
- if (iconv_res == (size_t) - 1) {
- ERRORA("error: %s %d\n", SKYPIAX_P_LOG, strerror(errno), errno);
- return -1;
- }
- DEBUGA_SKYPE
- ("iconv_res=%d, in=%s, inleft=%d, out=%s, outleft=%d, utf_in=%s, converted=%s\n",
- SKYPIAX_P_LOG, iconv_res, inbuf, (int)inbytesleft, outbuf, (int)outbytesleft, utf_in,
- converted);
- iconv_close(iconv_format);
</del><ins>+        DEBUGA_SKYPE("in=%s, inleft=%d, out=%s, outleft=%d, utf_in=%s, converted=%s\n",
+                                 SKYPIAX_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf_in, converted);
+        iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+        if (iconv_res == (size_t) -1) {
+                ERRORA("error: %s %d\n", SKYPIAX_P_LOG, strerror(errno), errno);
+                return -1;
+        }
+        DEBUGA_SKYPE
+                ("iconv_res=%d, in=%s, inleft=%d, out=%s, outleft=%d, utf_in=%s, converted=%s\n",
+                 SKYPIAX_P_LOG, iconv_res, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf_in, converted);
+        iconv_close(iconv_format);
</ins><span class="cx">
</span><del>- for (i = 0; i < 16000 - outbytesleft; i++) {
- memset(stringa, '\0', sizeof(stringa));
- memset(stringa2, '\0', sizeof(stringa2));
- sprintf(stringa, "%02X", converted[i]);
- DEBUGA_SKYPE("character is |%02X|\n", SKYPIAX_P_LOG, converted[i]);
- stringa2[0] = stringa[strlen(stringa) - 2];
- stringa2[1] = stringa[strlen(stringa) - 1];
- strncat(ucs2_out, stringa2, ((outbytesleft - strlen(ucs2_out)) - 1)); //add the received line to the buffer
- DEBUGA_SKYPE("stringa=%s, stringa2=%s, ucs2_out=%s\n", SKYPIAX_P_LOG, stringa, stringa2,
- ucs2_out);
- }
- return 0;
</del><ins>+        for (i = 0; i < 16000 - outbytesleft; i++) {
+                memset(stringa, '\0', sizeof(stringa));
+                memset(stringa2, '\0', sizeof(stringa2));
+                sprintf(stringa, "%02X", converted[i]);
+                DEBUGA_SKYPE("character is |%02X|\n", SKYPIAX_P_LOG, converted[i]);
+                stringa2[0] = stringa[strlen(stringa) - 2];
+                stringa2[1] = stringa[strlen(stringa) - 1];
+                strncat(ucs2_out, stringa2, ((outbytesleft - strlen(ucs2_out)) - 1));        //add the received line to the buffer
+                DEBUGA_SKYPE("stringa=%s, stringa2=%s, ucs2_out=%s\n", SKYPIAX_P_LOG, stringa, stringa2, ucs2_out);
+        }
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -3399,51 +3237,51 @@
</span><span class="cx"> * Part of PBX interface */
</span><span class="cx"> int celliax_answer(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- int res;
</del><ins>+        int res;
</ins><span class="cx">
</span><del>- if (option_debug) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
- /* do something to actually answer the call, if needed (eg. pick up the phone) */
- if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL) {
- if (celliax_serial_answer(tech_pvt)) {
- ERRORA("celliax_answer FAILED\n", SKYPIAX_P_LOG);
- if (option_debug) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- }
- }
- tech_pvt->interface_state = SKYPIAX_STATE_UP;
- tech_pvt->phone_callflow = CALLFLOW_CALL_ACTIVE;
</del><ins>+        if (option_debug) {
+                DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+        }
+        /* do something to actually answer the call, if needed (eg. pick up the phone) */
+        if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL) {
+                if (celliax_serial_answer(tech_pvt)) {
+                        ERRORA("celliax_answer FAILED\n", SKYPIAX_P_LOG);
+                        if (option_debug) {
+                                DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+                        }
+                        return -1;
+                }
+        }
+        tech_pvt->interface_state = SKYPIAX_STATE_UP;
+        tech_pvt->phone_callflow = CALLFLOW_CALL_ACTIVE;
</ins><span class="cx">
</span><del>- while (tech_pvt->interface_state == SKYPIAX_STATE_RING) {
- usleep(10000); //10msec
- }
- if (tech_pvt->interface_state != SKYPIAX_STATE_UP) {
- ERRORA("call answering failed\n", SKYPIAX_P_LOG);
- res = -1;
- } else {
- if (option_debug)
- DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG);
- res = 0;
</del><ins>+        while (tech_pvt->interface_state == SKYPIAX_STATE_RING) {
+                usleep(10000);                        //10msec
+        }
+        if (tech_pvt->interface_state != SKYPIAX_STATE_UP) {
+                ERRORA("call answering failed\n", SKYPIAX_P_LOG);
+                res = -1;
+        } else {
+                if (option_debug)
+                        DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG);
+                res = 0;
</ins><span class="cx"> #ifdef CELLIAX_PORTAUDIO
</span><del>- speex_echo_state_reset(tech_pvt->stream->echo_state);
</del><ins>+                speex_echo_state_reset(tech_pvt->stream->echo_state);
</ins><span class="cx"> #endif // CELLIAX_PORTAUDIO
</span><span class="cx">
</span><del>-                                                                        new_inbound_channel(tech_pvt);
- if (tech_pvt->owner) {
- DEBUGA_PBX("going to send SKYPIAX_STATE_UP\n", SKYPIAX_P_LOG);
- ast_setstate(tech_pvt->owner, SKYPIAX_STATE_UP);
- //ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_ANSWER);
- //celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_ANSWER);
- DEBUGA_PBX("just sent SKYPIAX_STATE_UP\n", SKYPIAX_P_LOG);
- }
- }
- if (option_debug) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return res;
</del><ins>+                new_inbound_channel(tech_pvt);
+                if (tech_pvt->owner) {
+                        DEBUGA_PBX("going to send SKYPIAX_STATE_UP\n", SKYPIAX_P_LOG);
+                        ast_setstate(tech_pvt->owner, SKYPIAX_STATE_UP);
+                        //ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_ANSWER);
+                        //celliax_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_ANSWER);
+                        DEBUGA_PBX("just sent SKYPIAX_STATE_UP\n", SKYPIAX_P_LOG);
+                }
+        }
+        if (option_debug) {
+                DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+        }
+        return res;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Hangup celliax call
</span><span class="lines">@@ -3452,376 +3290,353 @@
</span><span class="cx"> int celliax_hangup(private_t * tech_pvt)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- /* if there is not celliax pvt why we are here ? */
- if (!tech_pvt) {
- ERRORA("Asked to hangup channel not connected\n", SKYPIAX_P_LOG);
- return 0;
- }
</del><ins>+        /* if there is not celliax pvt why we are here ? */
+        if (!tech_pvt) {
+                ERRORA("Asked to hangup channel not connected\n", SKYPIAX_P_LOG);
+                return 0;
+        }
</ins><span class="cx">
</span><del>- DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG);
</del><ins>+        DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG);
</ins><span class="cx">
</span><span class="cx"> #ifdef NOTDEF
</span><del>- /* 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);
- }
</del><ins>+        /* 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);
+                }
</ins><span class="cx"> #else /* __CYGWIN__ */
</span><span class="cx"> /* allow the serial thread to die */
</span><del>- usleep(300000); //300msecs
</del><ins>+                usleep(300000);                        //300msecs
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>- }
- tech_pvt->controldev_thread = SKYPIAX_PTHREADT_NULL;
-#endif// NOTDEF
</del><ins>+        }
+        tech_pvt->controldev_thread = SKYPIAX_PTHREADT_NULL;
+#endif // NOTDEF
</ins><span class="cx">
</span><span class="cx">
</span><del>- if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL) {
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
- /* actually hangup through the serial port */
- if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL) {
- int res;
- res = celliax_serial_hangup(tech_pvt);
- if (res) {
- ERRORA("celliax_serial_hangup error: %d\n", SKYPIAX_P_LOG, res);
- if (option_debug) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- }
- }
</del><ins>+        if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL) {
+                if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
+                        /* actually hangup through the serial port */
+                        if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL) {
+                                int res;
+                                res = celliax_serial_hangup(tech_pvt);
+                                if (res) {
+                                        ERRORA("celliax_serial_hangup error: %d\n", SKYPIAX_P_LOG, res);
+                                        if (option_debug) {
+                                                DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+                                        }
+                                        return -1;
+                                }
+                        }
</ins><span class="cx">
</span><del>- while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
- usleep(10000); //10msec
- }
- if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
- ERRORA("call hangup failed\n", SKYPIAX_P_LOG);
- return -1;
- } else {
- DEBUGA_SKYPE("call hungup\n", SKYPIAX_P_LOG);
- }
- }
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
- }
</del><ins>+                        while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
+                                usleep(10000);        //10msec
+                        }
+                        if (tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
+                                ERRORA("call hangup failed\n", SKYPIAX_P_LOG);
+                                return -1;
+                        } else {
+                                DEBUGA_SKYPE("call hungup\n", SKYPIAX_P_LOG);
+                        }
+                }
+        } else {
+                tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+                tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
+        }
</ins><span class="cx">
</span><del>-                switch_set_flag(tech_pvt, TFLAG_HANGUP);
</del><ins>+        switch_set_flag(tech_pvt, TFLAG_HANGUP);
</ins><span class="cx"> #ifdef NOTDEF
</span><del>- /* if there is a dsp struct alloced, free it */
- if (tech_pvt->dsp) {
- ast_dsp_free(tech_pvt->dsp);
- tech_pvt->dsp = NULL;
- }
</del><ins>+        /* if there is a dsp struct alloced, free it */
+        if (tech_pvt->dsp) {
+                ast_dsp_free(tech_pvt->dsp);
+                tech_pvt->dsp = NULL;
+        }
</ins><span class="cx"> #ifndef __CYGWIN__
</span><span class="cx"> #ifdef CELLIAX_ALSA
</span><span class="cx"> /* restart alsa */
</span><del>- snd_pcm_drop(tech_pvt->alsap);
- snd_pcm_prepare(tech_pvt->alsap);
</del><ins>+        snd_pcm_drop(tech_pvt->alsap);
+        snd_pcm_prepare(tech_pvt->alsap);
</ins><span class="cx">
</span><del>- snd_pcm_prepare(tech_pvt->alsac);
- snd_pcm_start(tech_pvt->alsac);
</del><ins>+        snd_pcm_prepare(tech_pvt->alsac);
+        snd_pcm_start(tech_pvt->alsac);
</ins><span class="cx"> #endif /* CELLIAX_ALSA */
</span><span class="cx">
</span><span class="cx"> #endif /* __CYGWIN__ */
</span><span class="cx"> #ifdef CELLIAX_PORTAUDIO
</span><del>- speex_echo_state_reset(tech_pvt->stream->echo_state);
</del><ins>+        speex_echo_state_reset(tech_pvt->stream->echo_state);
</ins><span class="cx"> #endif // CELLIAX_PORTAUDIO
</span><span class="cx">
</span><del>- /* 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;
- }
- }
</del><ins>+        /* 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;
+                }
+        }
</ins><span class="cx"> #ifndef ASTERISK_VERSION_1_4
</span><del>- /* 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();
</del><ins>+        /* 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();
</ins><span class="cx"> #else /* ASTERISK_VERSION_1_4 */
</span><span class="cx">         ast_module_unref(ast_module_info->self);
</span><span class="cx"> #endif /* ASTERISK_VERSION_1_4 */
</span><span class="cx">
</span><del>- /* 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;
- }
</del><ins>+        /* 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;
+        }
</ins><span class="cx">
</span><del>- 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
- if (option_debug) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return 0;
</del><ins>+        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
+        if (option_debug) {
+                DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+        }
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> #ifdef NOTDEF
</span><span class="cx"> int celliax_serial_call_AT(private_t * tech_pvt, char *dstr)
</span><span class="cx"> {
</span><del>- int res;
- char at_command[256];
</del><ins>+        int res;
+        char at_command[256];
</ins><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);
- }
</del><ins>+        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);
+        }
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_console_at(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>- private_t * tech_pvt = celliax_console_find_desc(celliax_console_active);
- char at_cmd[1024];
- int i, a, c;
</del><ins>+        private_t *tech_pvt = celliax_console_find_desc(celliax_console_active);
+        char at_cmd[1024];
+        int i, a, c;
</ins><span class="cx">
</span><del>- 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;
- }
</del><ins>+        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;
+        }
</ins><span class="cx">
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int celliax_serial_getstatus_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- int res;
</del><ins>+        int res;
</ins><span class="cx">
</span><del>- 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;
- }
- }
</del><ins>+        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;
+                }
+        }
</ins><span class="cx">
</span><del>- 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);
</del><ins>+        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);
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+        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);
+        }
</ins><span class="cx">
</span><del>- 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!
</del><ins>+        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!
</ins><span class="cx">
</span><del>- 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];
</del><ins>+        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];
</ins><span class="cx">
</span><del>- 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));
- }
- }
</del><ins>+                                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));
+                                        }
+                                }
</ins><span class="cx">
</span><del>- 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));
</del><ins>+                                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));
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                                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);
+                                }
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->sms_message)) {
</del><ins>+                                if (strlen(tech_pvt->sms_message)) {
</ins><span class="cx">
</span><del>- manager_event(EVENT_FLAG_SYSTEM, "CELLIAXincomingsms",
- "Interface: %s\r\nSMS_Message: %s\r\n", tech_pvt->name, tech_pvt->sms_message);
</del><ins>+                                        manager_event(EVENT_FLAG_SYSTEM, "CELLIAXincomingsms", "Interface: %s\r\nSMS_Message: %s\r\n", tech_pvt->name, tech_pvt->sms_message);
</ins><span class="cx">
</span><del>- if (strlen(tech_pvt->sms_receiving_program)) {
- int fd1[2];
- pid_t pid1;
- char *arg1[] = { tech_pvt->sms_receiving_program, (char *) NULL };
- int i;
</del><ins>+                                        if (strlen(tech_pvt->sms_receiving_program)) {
+                                                int fd1[2];
+                                                pid_t pid1;
+                                                char *arg1[] = { tech_pvt->sms_receiving_program, (char *) NULL };
+                                                int i;
</ins><span class="cx">
</span><del>- NOTICA("incoming SMS message:>>>%s<<<\n", SKYPIAX_P_LOG, tech_pvt->sms_message);
- pipe(fd1);
- pid1 = fork();
</del><ins>+                                                NOTICA("incoming SMS message:>>>%s<<<\n", SKYPIAX_P_LOG, tech_pvt->sms_message);
+                                                pipe(fd1);
+                                                pid1 = fork();
</ins><span class="cx">
</span><del>- if (pid1 == 0) { //child
- int err;
</del><ins>+                                                if (pid1 == 0) {        //child
+                                                        int err;
</ins><span class="cx">
</span><del>- 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);
- }
- }
</del><ins>+                                                        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);
+                                        }
+                                }
</ins><span class="cx"> #endif
</span><del>- }
- }
- }
</del><ins>+                        }
+                }
+        }
</ins><span class="cx">
</span><del>- UNLOCKA(tech_pvt->controldev_lock);
- POPPA_UNLOCKA(tech_pvt->controldev_lock);
- return 0;
</del><ins>+        UNLOCKA(tech_pvt->controldev_lock);
+        POPPA_UNLOCKA(tech_pvt->controldev_lock);
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> #define SKYPIAX_ALSA
</span><span class="lines">@@ -3843,28 +3658,28 @@
</span><span class="cx"> */
</span><span class="cx"> int alsa_init(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- tech_pvt->alsac = alsa_open_dev(tech_pvt, SND_PCM_STREAM_CAPTURE);
- if (!tech_pvt->alsac) {
- ERRORA("Failed opening ALSA capture device: %s\n", SKYPIAX_P_LOG, tech_pvt->alsacname);
- if (alsa_shutdown(tech_pvt)) {
- ERRORA("alsa_shutdown failed\n", SKYPIAX_P_LOG);
- return -1;
- }
- return -1;
- }
- tech_pvt->alsap = alsa_open_dev(tech_pvt, SND_PCM_STREAM_PLAYBACK);
- if (!tech_pvt->alsap) {
- ERRORA("Failed opening ALSA playback device: %s\n", SKYPIAX_P_LOG, tech_pvt->alsapname);
- if (alsa_shutdown(tech_pvt)) {
- ERRORA("alsa_shutdown failed\n", SKYPIAX_P_LOG);
- return -1;
- }
- return -1;
- }
</del><ins>+        tech_pvt->alsac = alsa_open_dev(tech_pvt, SND_PCM_STREAM_CAPTURE);
+        if (!tech_pvt->alsac) {
+                ERRORA("Failed opening ALSA capture device: %s\n", SKYPIAX_P_LOG, tech_pvt->alsacname);
+                if (alsa_shutdown(tech_pvt)) {
+                        ERRORA("alsa_shutdown failed\n", SKYPIAX_P_LOG);
+                        return -1;
+                }
+                return -1;
+        }
+        tech_pvt->alsap = alsa_open_dev(tech_pvt, SND_PCM_STREAM_PLAYBACK);
+        if (!tech_pvt->alsap) {
+                ERRORA("Failed opening ALSA playback device: %s\n", SKYPIAX_P_LOG, tech_pvt->alsapname);
+                if (alsa_shutdown(tech_pvt)) {
+                        ERRORA("alsa_shutdown failed\n", SKYPIAX_P_LOG);
+                        return -1;
+                }
+                return -1;
+        }
</ins><span class="cx">
</span><del>- /* make valgrind very happy */
- snd_config_update_free_global();
- return 0;
</del><ins>+        /* make valgrind very happy */
+        snd_config_update_free_global();
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -3879,38 +3694,34 @@
</span><span class="cx"> int alsa_shutdown(private_t * tech_pvt)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- int err;
</del><ins>+        int err;
</ins><span class="cx">
</span><del>- if (tech_pvt->alsap) {
- err = snd_pcm_drop(tech_pvt->alsap);
- if (err < 0) {
- ERRORA("device [%s], snd_pcm_drop failed with error '%s'\n", SKYPIAX_P_LOG,
- tech_pvt->alsapname, snd_strerror(err));
- return -1;
- }
- err = snd_pcm_close(tech_pvt->alsap);
- if (err < 0) {
- ERRORA("device [%s], snd_pcm_close failed with error '%s'\n", SKYPIAX_P_LOG,
- tech_pvt->alsapname, snd_strerror(err));
- return -1;
- }
- }
- if (tech_pvt->alsac) {
- err = snd_pcm_drop(tech_pvt->alsac);
- if (err < 0) {
- ERRORA("device [%s], snd_pcm_drop failed with error '%s'\n", SKYPIAX_P_LOG,
- tech_pvt->alsacname, snd_strerror(err));
- return -1;
- }
- err = snd_pcm_close(tech_pvt->alsac);
- if (err < 0) {
- ERRORA("device [%s], snd_pcm_close failed with error '%s'\n", SKYPIAX_P_LOG,
- tech_pvt->alsacname, snd_strerror(err));
- return -1;
- }
- }
</del><ins>+        if (tech_pvt->alsap) {
+                err = snd_pcm_drop(tech_pvt->alsap);
+                if (err < 0) {
+                        ERRORA("device [%s], snd_pcm_drop failed with error '%s'\n", SKYPIAX_P_LOG, tech_pvt->alsapname, snd_strerror(err));
+                        return -1;
+                }
+                err = snd_pcm_close(tech_pvt->alsap);
+                if (err < 0) {
+                        ERRORA("device [%s], snd_pcm_close failed with error '%s'\n", SKYPIAX_P_LOG, tech_pvt->alsapname, snd_strerror(err));
+                        return -1;
+                }
+        }
+        if (tech_pvt->alsac) {
+                err = snd_pcm_drop(tech_pvt->alsac);
+                if (err < 0) {
+                        ERRORA("device [%s], snd_pcm_drop failed with error '%s'\n", SKYPIAX_P_LOG, tech_pvt->alsacname, snd_strerror(err));
+                        return -1;
+                }
+                err = snd_pcm_close(tech_pvt->alsac);
+                if (err < 0) {
+                        ERRORA("device [%s], snd_pcm_close failed with error '%s'\n", SKYPIAX_P_LOG, tech_pvt->alsacname, snd_strerror(err));
+                        return -1;
+                }
+        }
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -3925,328 +3736,320 @@
</span><span class="cx"> snd_pcm_t *alsa_open_dev(private_t * tech_pvt, snd_pcm_stream_t stream)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- snd_pcm_t *handle = NULL;
- snd_pcm_hw_params_t *params;
- snd_pcm_sw_params_t *swparams;
- snd_pcm_uframes_t buffer_size;
- int err;
- size_t n;
- //snd_pcm_uframes_t xfer_align;
- unsigned int rate;
- snd_pcm_uframes_t start_threshold, stop_threshold;
- snd_pcm_uframes_t period_size = 0;
- snd_pcm_uframes_t chunk_size = 0;
- int start_delay = 0;
- int stop_delay = 0;
- snd_pcm_state_t state;
- snd_pcm_info_t *info;
</del><ins>+        snd_pcm_t *handle = NULL;
+        snd_pcm_hw_params_t *params;
+        snd_pcm_sw_params_t *swparams;
+        snd_pcm_uframes_t buffer_size;
+        int err;
+        size_t n;
+        //snd_pcm_uframes_t xfer_align;
+        unsigned int rate;
+        snd_pcm_uframes_t start_threshold, stop_threshold;
+        snd_pcm_uframes_t period_size = 0;
+        snd_pcm_uframes_t chunk_size = 0;
+        int start_delay = 0;
+        int stop_delay = 0;
+        snd_pcm_state_t state;
+        snd_pcm_info_t *info;
</ins><span class="cx">
</span><del>- period_size = tech_pvt->alsa_period_size;
</del><ins>+        period_size = tech_pvt->alsa_period_size;
</ins><span class="cx">
</span><del>- snd_pcm_hw_params_alloca(&params);
- snd_pcm_sw_params_alloca(&swparams);
</del><ins>+        snd_pcm_hw_params_alloca(&params);
+        snd_pcm_sw_params_alloca(&swparams);
</ins><span class="cx">
</span><del>- if (stream == SND_PCM_STREAM_CAPTURE) {
- err = snd_pcm_open(&handle, tech_pvt->alsacname, stream, 0 | SND_PCM_NONBLOCK);
- } else {
- err = snd_pcm_open(&handle, tech_pvt->alsapname, stream, 0 | SND_PCM_NONBLOCK);
- }
- if (err < 0) {
- ERRORA
- ("snd_pcm_open failed with error '%s' on device '%s', if you are using a plughw:n device please change it to be a default:n device (so to allow it to be shared with other concurrent programs), or maybe you are using an ALSA voicemodem and slmodemd"
- " is running?\n", SKYPIAX_P_LOG, snd_strerror(err),
- stream == SND_PCM_STREAM_CAPTURE ? tech_pvt->alsacname : tech_pvt->alsapname);
- return NULL;
- }
</del><ins>+        if (stream == SND_PCM_STREAM_CAPTURE) {
+                err = snd_pcm_open(&handle, tech_pvt->alsacname, stream, 0 | SND_PCM_NONBLOCK);
+        } else {
+                err = snd_pcm_open(&handle, tech_pvt->alsapname, stream, 0 | SND_PCM_NONBLOCK);
+        }
+        if (err < 0) {
+                ERRORA
+                        ("snd_pcm_open failed with error '%s' on device '%s', if you are using a plughw:n device please change it to be a default:n device (so to allow it to be shared with other concurrent programs), or maybe you are using an ALSA voicemodem and slmodemd"
+                         " is running?\n", SKYPIAX_P_LOG, snd_strerror(err), stream == SND_PCM_STREAM_CAPTURE ? tech_pvt->alsacname : tech_pvt->alsapname);
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- snd_pcm_info_alloca(&info);
</del><ins>+        snd_pcm_info_alloca(&info);
</ins><span class="cx">
</span><del>- if ((err = snd_pcm_info(handle, info)) < 0) {
- ERRORA("info error: %s", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
</del><ins>+        if ((err = snd_pcm_info(handle, info)) < 0) {
+                ERRORA("info error: %s", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- err = snd_pcm_nonblock(handle, 1);
- if (err < 0) {
- ERRORA("nonblock setting error: %s", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
</del><ins>+        err = snd_pcm_nonblock(handle, 1);
+        if (err < 0) {
+                ERRORA("nonblock setting error: %s", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- err = snd_pcm_hw_params_any(handle, params);
- if (err < 0) {
- ERRORA("Broken configuration for this PCM, no configurations available: %s\n",
- SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
</del><ins>+        err = snd_pcm_hw_params_any(handle, params);
+        if (err < 0) {
+                ERRORA("Broken configuration for this PCM, no configurations available: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- err = snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
- if (err < 0) {
- ERRORA("Access type not available: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
- err = snd_pcm_hw_params_set_format(handle, params, celliax_format);
- if (err < 0) {
- ERRORA("Sample format non available: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
- err = snd_pcm_hw_params_set_channels(handle, params, 1);
- if (err < 0) {
- DEBUGA_SKYPE("Channels count set failed: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- }
</del><ins>+        err = snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
+        if (err < 0) {
+                ERRORA("Access type not available: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        err = snd_pcm_hw_params_set_format(handle, params, celliax_format);
+        if (err < 0) {
+                ERRORA("Sample format non available: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        err = snd_pcm_hw_params_set_channels(handle, params, 1);
+        if (err < 0) {
+                DEBUGA_SKYPE("Channels count set failed: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> #if 1
</span><del>- unsigned int chan_num;
- err = snd_pcm_hw_params_get_channels(params, &chan_num);
- if (err < 0) {
- ERRORA("Channels count non available: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
- if (chan_num < 1 || chan_num > 2) {
- ERRORA("Channels count MUST BE 1 or 2, it is: %d\n", SKYPIAX_P_LOG, chan_num);
- ERRORA("Channels count MUST BE 1 or 2, it is: %d on %s %s\n", SKYPIAX_P_LOG, chan_num,
- tech_pvt->alsapname, tech_pvt->alsacname);
- return NULL;
- } else {
- if (chan_num == 1) {
- if (stream == SND_PCM_STREAM_CAPTURE)
- tech_pvt->alsa_capture_is_mono = 1;
- else
- tech_pvt->alsa_play_is_mono = 1;
- } else {
- if (stream == SND_PCM_STREAM_CAPTURE)
- tech_pvt->alsa_capture_is_mono = 0;
- else
- tech_pvt->alsa_play_is_mono = 0;
- }
- }
</del><ins>+        unsigned int chan_num;
+        err = snd_pcm_hw_params_get_channels(params, &chan_num);
+        if (err < 0) {
+                ERRORA("Channels count non available: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        if (chan_num < 1 || chan_num > 2) {
+                ERRORA("Channels count MUST BE 1 or 2, it is: %d\n", SKYPIAX_P_LOG, chan_num);
+                ERRORA("Channels count MUST BE 1 or 2, it is: %d on %s %s\n", SKYPIAX_P_LOG, chan_num, tech_pvt->alsapname, tech_pvt->alsacname);
+                return NULL;
+        } else {
+                if (chan_num == 1) {
+                        if (stream == SND_PCM_STREAM_CAPTURE)
+                                tech_pvt->alsa_capture_is_mono = 1;
+                        else
+                                tech_pvt->alsa_play_is_mono = 1;
+                } else {
+                        if (stream == SND_PCM_STREAM_CAPTURE)
+                                tech_pvt->alsa_capture_is_mono = 0;
+                        else
+                                tech_pvt->alsa_play_is_mono = 0;
+                }
+        }
</ins><span class="cx"> #else
</span><del>- tech_pvt->alsa_capture_is_mono = 1;
- tech_pvt->alsa_play_is_mono = 1;
</del><ins>+        tech_pvt->alsa_capture_is_mono = 1;
+        tech_pvt->alsa_play_is_mono = 1;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if 0
</span><del>- unsigned int buffer_time = 0;
- unsigned int period_time = 0;
- snd_pcm_uframes_t period_frames = 0;
- snd_pcm_uframes_t buffer_frames = 0;
</del><ins>+        unsigned int buffer_time = 0;
+        unsigned int period_time = 0;
+        snd_pcm_uframes_t period_frames = 0;
+        snd_pcm_uframes_t buffer_frames = 0;
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+        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);
+        }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if 1
</span><del>- rate = tech_pvt->celliax_sound_rate;
- err = snd_pcm_hw_params_set_rate_near(handle, params, &rate, 0);
- if ((float) tech_pvt->celliax_sound_rate * 1.05 < rate
- || (float) tech_pvt->celliax_sound_rate * 0.95 > rate) {
- WARNINGA("Rate is not accurate (requested = %iHz, got = %iHz)\n", SKYPIAX_P_LOG,
- tech_pvt->celliax_sound_rate, rate);
- }
</del><ins>+        rate = tech_pvt->celliax_sound_rate;
+        err = snd_pcm_hw_params_set_rate_near(handle, params, &rate, 0);
+        if ((float) tech_pvt->celliax_sound_rate * 1.05 < rate || (float) tech_pvt->celliax_sound_rate * 0.95 > rate) {
+                WARNINGA("Rate is not accurate (requested = %iHz, got = %iHz)\n", SKYPIAX_P_LOG, tech_pvt->celliax_sound_rate, rate);
+        }
</ins><span class="cx">
</span><del>- if (err < 0) {
- ERRORA("Error setting rate: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
- tech_pvt->celliax_sound_rate = rate;
</del><ins>+        if (err < 0) {
+                ERRORA("Error setting rate: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        tech_pvt->celliax_sound_rate = rate;
</ins><span class="cx">
</span><del>- err = snd_pcm_hw_params_set_period_size_near(handle, params, &period_size, 0);
</del><ins>+        err = snd_pcm_hw_params_set_period_size_near(handle, params, &period_size, 0);
</ins><span class="cx">
</span><del>- if (err < 0) {
- ERRORA("Error setting period_size: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
</del><ins>+        if (err < 0) {
+                ERRORA("Error setting period_size: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- tech_pvt->alsa_period_size = period_size;
</del><ins>+        tech_pvt->alsa_period_size = period_size;
</ins><span class="cx">
</span><del>- tech_pvt->alsa_buffer_size = tech_pvt->alsa_period_size * tech_pvt->alsa_periods_in_buffer;
</del><ins>+        tech_pvt->alsa_buffer_size = tech_pvt->alsa_period_size * tech_pvt->alsa_periods_in_buffer;
</ins><span class="cx">
</span><del>- err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &tech_pvt->alsa_buffer_size);
</del><ins>+        err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &tech_pvt->alsa_buffer_size);
</ins><span class="cx">
</span><del>- if (err < 0) {
- ERRORA("Error setting buffer_size: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
</del><ins>+        if (err < 0) {
+                ERRORA("Error setting buffer_size: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- err = snd_pcm_hw_params(handle, params);
- if (err < 0) {
- ERRORA("Unable to install hw params: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
</del><ins>+        err = snd_pcm_hw_params(handle, params);
+        if (err < 0) {
+                ERRORA("Unable to install hw params: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- snd_pcm_hw_params_get_period_size(params, &chunk_size, 0);
- snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
- if (chunk_size == buffer_size) {
- ERRORA("Can't use period equal to buffer size (%lu == %lu)\n", SKYPIAX_P_LOG,
- chunk_size, buffer_size);
- return NULL;
- }
</del><ins>+        snd_pcm_hw_params_get_period_size(params, &chunk_size, 0);
+        snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
+        if (chunk_size == buffer_size) {
+                ERRORA("Can't use period equal to buffer size (%lu == %lu)\n", SKYPIAX_P_LOG, chunk_size, buffer_size);
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- snd_pcm_sw_params_current(handle, swparams);
</del><ins>+        snd_pcm_sw_params_current(handle, swparams);
</ins><span class="cx">
</span><span class="cx"> #if 0
</span><del>- 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);
</del><ins>+        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);
</ins><span class="cx">
</span><del>- 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);
</del><ins>+        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);
</ins><span class="cx">
</span><del>- 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);
</del><ins>+        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);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- /*
- if (sleep_min)
- xfer_align = 1;
- err = snd_pcm_sw_params_set_sleep_min(handle, swparams,
- 0);
</del><ins>+        /*
+         if (sleep_min)
+         xfer_align = 1;
+         err = snd_pcm_sw_params_set_sleep_min(handle, swparams,
+         0);
</ins><span class="cx">
</span><del>- if (err < 0) {
- ERRORA("Error setting slep_min: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- }
- */
- n = chunk_size;
- err = snd_pcm_sw_params_set_avail_min(handle, swparams, n);
- if (err < 0) {
- ERRORA("Error setting avail_min: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- }
</del><ins>+         if (err < 0) {
+         ERRORA("Error setting slep_min: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+         }
+         */
+        n = chunk_size;
+        err = snd_pcm_sw_params_set_avail_min(handle, swparams, n);
+        if (err < 0) {
+                ERRORA("Error setting avail_min: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> #if 0
</span><del>- /* 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;
</del><ins>+        /* 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;
</ins><span class="cx"> #endif
</span><del>- if (stream == SND_PCM_STREAM_CAPTURE) {
- start_delay = 1;
- }
- if (start_delay <= 0) {
- start_threshold = n + (double) rate *start_delay / 1000000;
- } else {
- start_threshold = (double) rate *start_delay / 1000000;
- }
- if (start_threshold < 1)
- start_threshold = 1;
- if (start_threshold > n)
- start_threshold = n;
- err = snd_pcm_sw_params_set_start_threshold(handle, swparams, start_threshold);
- if (err < 0) {
- ERRORA("Error setting start_threshold: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- }
</del><ins>+        if (stream == SND_PCM_STREAM_CAPTURE) {
+                start_delay = 1;
+        }
+        if (start_delay <= 0) {
+                start_threshold = n + (double) rate *start_delay / 1000000;
+        } else {
+                start_threshold = (double) rate *start_delay / 1000000;
+        }
+        if (start_threshold < 1)
+                start_threshold = 1;
+        if (start_threshold > n)
+                start_threshold = n;
+        err = snd_pcm_sw_params_set_start_threshold(handle, swparams, start_threshold);
+        if (err < 0) {
+                ERRORA("Error setting start_threshold: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx">
</span><del>- if (stop_delay <= 0)
- stop_threshold = buffer_size + (double) rate *stop_delay / 1000000;
- else
- stop_threshold = (double) rate *stop_delay / 1000000;
</del><ins>+        if (stop_delay <= 0)
+                stop_threshold = buffer_size + (double) rate *stop_delay / 1000000;
+        else
+                stop_threshold = (double) rate *stop_delay / 1000000;
</ins><span class="cx">
</span><del>- if (stream == SND_PCM_STREAM_CAPTURE) {
- stop_threshold = -1;
- }
</del><ins>+        if (stream == SND_PCM_STREAM_CAPTURE) {
+                stop_threshold = -1;
+        }
</ins><span class="cx">
</span><del>- err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold);
</del><ins>+        err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold);
</ins><span class="cx">
</span><del>- if (err < 0) {
- ERRORA("Error setting stop_threshold: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- }
</del><ins>+        if (err < 0) {
+                ERRORA("Error setting stop_threshold: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> #if 0
</span><del>- err = snd_pcm_sw_params_set_xfer_align(handle, swparams, xfer_align);
</del><ins>+        err = snd_pcm_sw_params_set_xfer_align(handle, swparams, xfer_align);
</ins><span class="cx">
</span><del>- if (err < 0) {
- ERRORA("Error setting xfer_align: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- }
</del><ins>+        if (err < 0) {
+                ERRORA("Error setting xfer_align: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- if (snd_pcm_sw_params(handle, swparams) < 0) {
- ERRORA("Error installing software parameters: %s\n", SKYPIAX_P_LOG,
- snd_strerror(err));
- }
</del><ins>+        if (snd_pcm_sw_params(handle, swparams) < 0) {
+                ERRORA("Error installing software parameters: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx">
</span><del>- err = snd_pcm_poll_descriptors_count(handle);
- if (err <= 0) {
- ERRORA("Unable to get a poll descriptors count, error is %s\n", SKYPIAX_P_LOG,
- snd_strerror(err));
- return NULL;
- }
</del><ins>+        err = snd_pcm_poll_descriptors_count(handle);
+        if (err <= 0) {
+                ERRORA("Unable to get a poll descriptors count, error is %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- if (err != 1) { //number of poll descriptors
- DEBUGA_SKYPE("Can't handle more than one device\n", SKYPIAX_P_LOG);
- return NULL;
- }
</del><ins>+        if (err != 1) {                                //number of poll descriptors
+                DEBUGA_SKYPE("Can't handle more than one device\n", SKYPIAX_P_LOG);
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- err = snd_pcm_poll_descriptors(handle, &tech_pvt->pfd, err);
- if (err != 1) {
- ERRORA("snd_pcm_poll_descriptors failed, %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
- DEBUGA_SKYPE("Acquired fd %d from the poll descriptor\n", SKYPIAX_P_LOG, tech_pvt->pfd.fd);
</del><ins>+        err = snd_pcm_poll_descriptors(handle, &tech_pvt->pfd, err);
+        if (err != 1) {
+                ERRORA("snd_pcm_poll_descriptors failed, %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        DEBUGA_SKYPE("Acquired fd %d from the poll descriptor\n", SKYPIAX_P_LOG, tech_pvt->pfd.fd);
</ins><span class="cx">
</span><del>- if (stream == SND_PCM_STREAM_CAPTURE) {
- tech_pvt->celliax_sound_capt_fd = tech_pvt->pfd.fd;
- }
</del><ins>+        if (stream == SND_PCM_STREAM_CAPTURE) {
+                tech_pvt->celliax_sound_capt_fd = tech_pvt->pfd.fd;
+        }
</ins><span class="cx">
</span><del>- state = snd_pcm_state(handle);
</del><ins>+        state = snd_pcm_state(handle);
</ins><span class="cx">
</span><del>- if (state != SND_PCM_STATE_RUNNING) {
- if (state != SND_PCM_STATE_PREPARED) {
- err = snd_pcm_prepare(handle);
- if (err) {
- ERRORA("snd_pcm_prepare failed, %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
- DEBUGA_SKYPE("prepared!\n", SKYPIAX_P_LOG);
- }
- if (stream == SND_PCM_STREAM_CAPTURE) {
- err = snd_pcm_start(handle);
- if (err) {
- ERRORA("snd_pcm_start failed, %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- return NULL;
- }
- DEBUGA_SKYPE("started!\n", SKYPIAX_P_LOG);
- }
- }
- if (option_debug > 1) {
- snd_output_t *output = NULL;
- err = snd_output_stdio_attach(&output, stdout, 0);
- if (err < 0) {
- ERRORA("snd_output_stdio_attach failed: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
- }
- snd_pcm_dump(handle, output);
- }
- if (option_debug > 1)
- DEBUGA_SKYPE("ALSA handle = %ld\n", SKYPIAX_P_LOG, (long int) handle);
- return handle;
</del><ins>+        if (state != SND_PCM_STATE_RUNNING) {
+                if (state != SND_PCM_STATE_PREPARED) {
+                        err = snd_pcm_prepare(handle);
+                        if (err) {
+                                ERRORA("snd_pcm_prepare failed, %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                                return NULL;
+                        }
+                        DEBUGA_SKYPE("prepared!\n", SKYPIAX_P_LOG);
+                }
+                if (stream == SND_PCM_STREAM_CAPTURE) {
+                        err = snd_pcm_start(handle);
+                        if (err) {
+                                ERRORA("snd_pcm_start failed, %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                                return NULL;
+                        }
+                        DEBUGA_SKYPE("started!\n", SKYPIAX_P_LOG);
+                }
+        }
+        if (option_debug > 1) {
+                snd_output_t *output = NULL;
+                err = snd_output_stdio_attach(&output, stdout, 0);
+                if (err < 0) {
+                        ERRORA("snd_output_stdio_attach failed: %s\n", SKYPIAX_P_LOG, snd_strerror(err));
+                }
+                snd_pcm_dump(handle, output);
+        }
+        if (option_debug > 1)
+                DEBUGA_SKYPE("ALSA handle = %ld\n", SKYPIAX_P_LOG, (long int) handle);
+        return handle;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4255,343 +4058,339 @@
</span><span class="cx">
</span><span class="cx"> struct ast_frame *alsa_read(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx">
</span><del>- //memset(&f, 0, sizeof(struct ast_frame)); //giova
</del><ins>+        //memset(&f, 0, sizeof(struct ast_frame)); //giova
</ins><span class="cx">
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx">
</span><del>- 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);
</del><ins>+        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);
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                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);
+        }
</ins><span class="cx">
</span><del>- buf = __buf + AST_FRIENDLY_OFFSET / 2;
- buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
</del><ins>+        buf = __buf + AST_FRIENDLY_OFFSET / 2;
+        buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
</ins><span class="cx">
</span><del>- 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);
</del><ins>+        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);
</ins><span class="cx">
</span><del>- 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++;
- }
- }
</del><ins>+                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++;
+                }
+        }
</ins><span class="cx">
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx">
</span><del>- } 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);
</del><ins>+        } 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);
</ins><span class="cx">
</span><del>- 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);
</del><ins>+                        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);
</ins><span class="cx">
</span><del>- 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++;
- }
- }
</del><ins>+                                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++;
+                                }
+                        }
</ins><span class="cx">
</span><del>- }
- } 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;
</del><ins>+                }
+        } 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;
</ins><span class="cx">
</span><del>- if (readpos >= SKYPIAX_FRAME_SIZE) {
- /* A real frame */
- readpos = 0;
- left = SKYPIAX_FRAME_SIZE;
</del><ins>+        if (readpos >= SKYPIAX_FRAME_SIZE) {
+                /* A real frame */
+                readpos = 0;
+                left = SKYPIAX_FRAME_SIZE;
</ins><span class="cx">
</span><del>- 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;
</del><ins>+                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;
</ins><span class="cx"> #ifdef ALSA_MONITOR
</span><del>- alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
</del><ins>+                alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- }
- return &f;
</del><ins>+        }
+        return &f;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Write audio frames to interface */
</span><span class="cx"> int alsa_write(private_t * tech_pvt, struct ast_frame *f)
</span><span class="cx"> {
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx">
</span><del>- /* 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;
</del><ins>+        /* 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;
</ins><span class="cx"> #ifdef ALSA_MONITOR
</span><del>- alsa_monitor_write(sizbuf, len);
</del><ins>+                alsa_monitor_write(sizbuf, len);
</ins><span class="cx"> #endif
</span><del>- state = snd_pcm_state(tech_pvt->alsap);
- if (state == SND_PCM_STATE_XRUN) {
- int i;
</del><ins>+                state = snd_pcm_state(tech_pvt->alsap);
+                if (state == SND_PCM_STATE_XRUN) {
+                        int i;
</ins><span class="cx">
</span><del>- 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;
- }
- }
- }
</del><ins>+                        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;
+                                        }
+                                }
+                        }
</ins><span class="cx">
</span><del>- }
</del><ins>+                }
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                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);
+                }
</ins><span class="cx">
</span><del>- 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));
</del><ins>+                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));
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                        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);
+                }
</ins><span class="cx">
</span><del>- if ( /* delayp1 != 0 && delayp1 != 160 */
- delayp1 < 160 || delayp2 > tech_pvt->alsa_buffer_size) {
</del><ins>+                if (                                        /* delayp1 != 0 && delayp1 != 160 */
+                         delayp1 < 160 || delayp2 > tech_pvt->alsa_buffer_size) {
</ins><span class="cx">
</span><del>- 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 {
</del><ins>+                        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 {
</ins><span class="cx">
</span><del>- 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;
- }
- }
</del><ins>+                                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;
+                                        }
+                                }
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                                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);
+                        }
</ins><span class="cx">
</span><del>- }
</del><ins>+                }
</ins><span class="cx">
</span><del>- 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 {
</del><ins>+                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 {
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                                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);
+                                }
</ins><span class="cx">
</span><del>- }
</del><ins>+                        }
</ins><span class="cx">
</span><del>- } 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));
- }
- }
- }
</del><ins>+                } 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));
+                        }
+                }
+        }
</ins><span class="cx">
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif //NOTDEF
</span><span class="lines">@@ -4610,11 +4409,11 @@
</span><span class="cx">         //celliax_signaling_write(tech_pvt, "SET AEC OFF");
</span><span class="cx">         //celliax_sleep(10000);
</span><span class="cx">
</span><del>-celliax_serial_call(tech_pvt, rdest);
</del><ins>+        celliax_serial_call(tech_pvt, rdest);
</ins><span class="cx">         //sprintf(msg_to_skype, "CALL %s", rdest);
</span><span class="cx">         //if (celliax_signaling_write(tech_pvt, msg_to_skype) < 0) {
</span><del>-                //ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG);
-                //return -1;
</del><ins>+        //ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG);
+        //return -1;
</ins><span class="cx">         //}
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -4625,305 +4424,302 @@
</span><span class="cx">
</span><span class="cx">         DEBUGA_SKYPE("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
</span><span class="cx">         //celliax_signaling_write(tech_pvt, msg_to_skype);
</span><del>- if (tech_pvt->controldevprotocol == PROTOCOL_AT && tech_pvt->at_send_dtmf[0]) {
- int res = 0;
- char at_command[256];
</del><ins>+        if (tech_pvt->controldevprotocol == PROTOCOL_AT && tech_pvt->at_send_dtmf[0]) {
+                int res = 0;
+                char at_command[256];
</ins><span class="cx">
</span><del>- memset(at_command, '\0', 256);
- sprintf(at_command, "%s=\"%c\"", tech_pvt->at_send_dtmf, digit);
- res = celliax_serial_write_AT_ack(tech_pvt, at_command);
- if (res) {
- ERRORA("senddigit command failed, command used: '%s=\"%c\"', giving up\n",
- SKYPIAX_P_LOG, tech_pvt->at_send_dtmf, digit);
- }
- }
</del><ins>+                memset(at_command, '\0', 256);
+                sprintf(at_command, "%s=\"%c\"", tech_pvt->at_send_dtmf, digit);
+                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
+                if (res) {
+                        ERRORA("senddigit command failed, command used: '%s=\"%c\"', giving up\n", SKYPIAX_P_LOG, tech_pvt->at_send_dtmf, digit);
+                }
+        }
</ins><span class="cx">
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*! \brief Write audio frames to interface */
</span><del>-int alsa_write(private_t * tech_pvt, short * data, int datalen)
</del><ins>+int alsa_write(private_t * tech_pvt, short *data, int datalen)
</ins><span class="cx"> {
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx">
</span><del>- //ERRORA("data=%p, datalen=%d\n", SKYPIAX_P_LOG, (void *)data, datalen);
- /* We have to digest the frame in 160-byte portions */
- if (datalen > sizeof(sizbuf) - sizpos) {
- ERRORA("Frame too large\n", SKYPIAX_P_LOG);
- res = -1;
- } else {
- memcpy(sizbuf + sizpos, data, datalen);
- len += datalen;
- pos = 0;
</del><ins>+        //ERRORA("data=%p, datalen=%d\n", SKYPIAX_P_LOG, (void *)data, datalen);
+        /* We have to digest the frame in 160-byte portions */
+        if (datalen > sizeof(sizbuf) - sizpos) {
+                ERRORA("Frame too large\n", SKYPIAX_P_LOG);
+                res = -1;
+        } else {
+                memcpy(sizbuf + sizpos, data, datalen);
+                len += datalen;
+                pos = 0;
</ins><span class="cx"> #ifdef ALSA_MONITOR
</span><del>- alsa_monitor_write(sizbuf, len);
</del><ins>+                alsa_monitor_write(sizbuf, len);
</ins><span class="cx"> #endif
</span><del>- state = snd_pcm_state(tech_pvt->alsap);
- if (state == SND_PCM_STATE_XRUN) {
- int i;
</del><ins>+                state = snd_pcm_state(tech_pvt->alsap);
+                if (state == SND_PCM_STATE_XRUN) {
+                        int i;
</ins><span class="cx">
</span><del>- 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;
- }
- }
- }
</del><ins>+                        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;
+                                        }
+                                }
+                        }
</ins><span class="cx">
</span><del>- }
</del><ins>+                }
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                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);
+                }
</ins><span class="cx">
</span><del>- 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));
</del><ins>+                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));
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                        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);
+                }
</ins><span class="cx">
</span><del>- if ( /* delayp1 != 0 && delayp1 != 160 */
- delayp1 < 160 || delayp2 > tech_pvt->alsa_buffer_size) {
</del><ins>+                if (                                        /* delayp1 != 0 && delayp1 != 160 */
+                         delayp1 < 160 || delayp2 > tech_pvt->alsa_buffer_size) {
</ins><span class="cx">
</span><del>- 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 {
</del><ins>+                        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 {
</ins><span class="cx">
</span><del>- 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;
- }
- }
</del><ins>+                                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;
+                                        }
+                                }
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                                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);
+                        }
</ins><span class="cx">
</span><del>- }
</del><ins>+                }
</ins><span class="cx">
</span><del>- memset(sizbuf2, 0, sizeof(sizbuf2));
- 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]; // 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 {
</del><ins>+                memset(sizbuf2, 0, sizeof(sizbuf2));
+                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];        // 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 {
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+                                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);
+                                }
</ins><span class="cx">
</span><del>- }
</del><ins>+                        }
</ins><span class="cx">
</span><del>- } 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));
- }
- }
- }
</del><ins>+                } 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));
+                        }
+                }
+        }
</ins><span class="cx">
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #define AST_FRIENDLY_OFFSET 0
</span><del>-int alsa_read(private_t * tech_pvt, short * data, int datalen)
</del><ins>+int alsa_read(private_t * tech_pvt, short *data, int datalen)
</ins><span class="cx"> {
</span><del>- //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;
- static int left;
- snd_pcm_state_t state;
- int r = 0;
- int off = 0;
- int error = 0;
- //time_t now_timestamp;
</del><ins>+        //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;
+        static int left;
+        snd_pcm_state_t state;
+        int r = 0;
+        int off = 0;
+        int error = 0;
+        //time_t now_timestamp;
</ins><span class="cx">
</span><del>- //DEBUGA_SKYPE("buf=%p, datalen=%d, left=%d\n", SKYPIAX_P_LOG, (void *)buf, datalen, left);
- //memset(&f, 0, sizeof(struct ast_frame)); //giova
</del><ins>+        //DEBUGA_SKYPE("buf=%p, datalen=%d, left=%d\n", SKYPIAX_P_LOG, (void *)buf, datalen, left);
+        //memset(&f, 0, sizeof(struct ast_frame)); //giova
</ins><span class="cx">
</span><span class="cx"> #ifdef NOTDEF
</span><del>- 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><ins>+        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
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-left = datalen;
</del><ins>+        left = datalen;
</ins><span class="cx">
</span><del>- struct timeval to;
- fd_set rfds;
-int result;
</del><ins>+        struct timeval to;
+        fd_set rfds;
+        int result;
</ins><span class="cx">
</span><span class="cx">
</span><del>- FD_ZERO(&rfds);
- FD_SET(tech_pvt->celliax_sound_capt_fd, &rfds);
</del><ins>+        FD_ZERO(&rfds);
+        FD_SET(tech_pvt->celliax_sound_capt_fd, &rfds);
</ins><span class="cx">
</span><del>- /* 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 */
- result = select(tech_pvt->celliax_sound_capt_fd + 1, &rfds, NULL, NULL, &to);
</del><ins>+        /* 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 */
+        result = select(tech_pvt->celliax_sound_capt_fd + 1, &rfds, NULL, NULL, &to);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- /* 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));
</del><ins>+        /* 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));
</ins><span class="cx"> //FIXME what to do here? is the interface that failed signaled? which interface we have to disable?
</span><del>- //return NULL;
- }
- }
- /* If there are no file descriptors changed, just continue */
</del><ins>+                        //return NULL;
+                }
+        }
+        /* If there are no file descriptors changed, just continue */
</ins><span class="cx">
</span><del>- if (result == 0) {
- usleep(10000); //let's breath
- ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, result, strerror(errno));
- }
</del><ins>+        if (result == 0) {
+                usleep(10000);                        //let's breath
+                ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, result, strerror(errno));
+        }
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -4943,111 +4739,108 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- 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);
</del><ins>+        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);
</ins><span class="cx">
</span><del>- 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 r;
- }
- 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 r;
- }
- DEBUGA_SKYPE("started!\n", SKYPIAX_P_LOG);
- usleep(1000);
- }
</del><ins>+                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 r;
+                        }
+                        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 r;
+                }
+                DEBUGA_SKYPE("started!\n", SKYPIAX_P_LOG);
+                usleep(1000);
+        }
</ins><span class="cx">
</span><del>- buf = __buf + AST_FRIENDLY_OFFSET / 2;
- buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
</del><ins>+        buf = __buf + AST_FRIENDLY_OFFSET / 2;
+        buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
</ins><span class="cx">
</span><del>- if (tech_pvt->alsa_capture_is_mono) {
- //DEBUGA_SKYPE("buf=%p, buf+readpos=%p, datalen=%d, left=%d\n", SKYPIAX_P_LOG, (void *)buf, (void *)(buf + readpos), datalen, left);
- r = snd_pcm_readi(tech_pvt->alsac, buf + readpos, left);
- } else {
- r = snd_pcm_readi(tech_pvt->alsac, buf2 + (readpos * 2), left);
</del><ins>+        if (tech_pvt->alsa_capture_is_mono) {
+                //DEBUGA_SKYPE("buf=%p, buf+readpos=%p, datalen=%d, left=%d\n", SKYPIAX_P_LOG, (void *)buf, (void *)(buf + readpos), datalen, left);
+                r = snd_pcm_readi(tech_pvt->alsac, buf + readpos, left);
+        } else {
+                r = snd_pcm_readi(tech_pvt->alsac, buf2 + (readpos * 2), left);
</ins><span class="cx">
</span><del>- 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++;
- }
- }
</del><ins>+                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++;
+                }
+        }
</ins><span class="cx">
</span><del>- if (r == -EPIPE) {
- ERRORA("XRUN read\n\n\n\n\n", SKYPIAX_P_LOG);
- return r;
- } else if (r == -ESTRPIPE) {
- ERRORA("-ESTRPIPE\n", SKYPIAX_P_LOG);
- return r;
</del><ins>+        if (r == -EPIPE) {
+                ERRORA("XRUN read\n\n\n\n\n", SKYPIAX_P_LOG);
+                return r;
+        } else if (r == -ESTRPIPE) {
+                ERRORA("-ESTRPIPE\n", SKYPIAX_P_LOG);
+                return r;
</ins><span class="cx">
</span><del>- } 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);
</del><ins>+        } 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);
</ins><span class="cx">
</span><del>- 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);
</del><ins>+                        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);
</ins><span class="cx">
</span><del>- 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++;
- }
- }
</del><ins>+                                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++;
+                                }
+                        }
</ins><span class="cx">
</span><del>- }
- } 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;
</del><ins>+                }
+        } 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;
</ins><span class="cx">
</span><del>- if (readpos >= SKYPIAX_FRAME_SIZE) {
- /* A real frame */
- readpos = 0;
- left = SKYPIAX_FRAME_SIZE;
-int i;
-for(i=0; i<r; i++)
-data[i] = buf[i];
</del><ins>+        if (readpos >= SKYPIAX_FRAME_SIZE) {
+                /* A real frame */
+                readpos = 0;
+                left = SKYPIAX_FRAME_SIZE;
+                int i;
+                for (i = 0; i < r; i++)
+                        data[i] = buf[i];
</ins><span class="cx">
</span><span class="cx"> #ifdef NOTDEF
</span><del>- 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;
</del><ins>+                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;
</ins><span class="cx"> #ifdef ALSA_MONITOR
</span><del>- alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
</del><ins>+                alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
</ins><span class="cx"> #endif
</span><span class="cx"> #endif //NOTDEF
</span><span class="cx">
</span><del>- }
- return r;
</del><ins>+        }
+        return r;
</ins><span class="cx"> }
</span><del>-
-
</del></span></pre></div>
<a id="freeswitchbranchesgmaruzzmod_celliaxmod_celliaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c (14675 => 14676)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c        2009-08-29 13:15:21 UTC (rev 14675)
+++ freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c        2009-08-29 13:24:59 UTC (rev 14676)
</span><span class="lines">@@ -253,28 +253,26 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-int res;
-                                 res = alsa_init(tech_pvt);
-                                 if (res == -1) {
-                                         ERRORA("Failed initializing sound device\n", SKYPIAX_P_LOG);
-                                         /* we failed, free the PVT */
-                                         //if (tmp)
-                                                 //free(tmp);
-                                         //return NULL;
-                                 }
</del><ins>+        int res;
+        res = alsa_init(tech_pvt);
+        if (res == -1) {
+                ERRORA("Failed initializing sound device\n", SKYPIAX_P_LOG);
+                /* we failed, free the PVT */
+                //if (tmp)
+                //free(tmp);
+                //return NULL;
+        }
+        //teletone_dtmf_detect_init(&tech_pvt->dtmf_detect, tech_pvt->read_codec.implementation->actual_samples_per_second);
+        teletone_dtmf_detect_init(&tech_pvt->dtmf_detect, 8000);
</ins><span class="cx">
</span><del>-
-
- //teletone_dtmf_detect_init(&tech_pvt->dtmf_detect, tech_pvt->read_codec.implementation->actual_samples_per_second);
- teletone_dtmf_detect_init(&tech_pvt->dtmf_detect, 8000);
-
-        if (switch_core_timer_init(&tech_pvt->timer, "soft", 20, tech_pvt->read_codec.implementation->samples_per_packet, celliax_module_pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_core_timer_init(&tech_pvt->timer, "soft", 20, tech_pvt->read_codec.implementation->samples_per_packet, celliax_module_pool) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 ERRORA("setup timer failed\n", SKYPIAX_P_LOG);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><del>-switch_clear_flag(tech_pvt, TFLAG_HANGUP);        
</del><ins>+        switch_clear_flag(tech_pvt, TFLAG_HANGUP);
</ins><span class="cx">         DEBUGA_SKYPE("celliax_codec SUCCESS\n", SKYPIAX_P_LOG);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -479,9 +477,9 @@
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->write_codec);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                        switch_core_timer_destroy(&tech_pvt->timer);
</del><ins>+                switch_core_timer_destroy(&tech_pvt->timer);
</ins><span class="cx">
</span><del>-alsa_shutdown(tech_pvt);
</del><ins>+                alsa_shutdown(tech_pvt);
</ins><span class="cx">
</span><span class="cx">                 *tech_pvt->session_uuid_str = '\0';
</span><span class="cx">                 tech_pvt->interface_state = SKYPIAX_STATE_IDLE;
</span><span class="lines">@@ -635,7 +633,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
</del><ins>+static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t * dtmf)
</ins><span class="cx"> {
</span><span class="cx">         private_t *tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="lines">@@ -670,67 +668,62 @@
</span><span class="cx">         tech_pvt->read_frame.flags = SFF_NONE;
</span><span class="cx">         *frame = NULL;
</span><span class="cx">
</span><del>-                if (switch_test_flag(tech_pvt, TFLAG_HANGUP)) {
</del><ins>+        if (switch_test_flag(tech_pvt, TFLAG_HANGUP)) {
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><del>-                }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-int samples;
</del><ins>+        int samples;
</ins><span class="cx">
</span><del>-                //if ((samples = snd_pcm_readi(tech_pvt->alsac, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
-                if ((samples = alsa_read(tech_pvt, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet )) > 0)
</del><ins>+        //if ((samples = snd_pcm_readi(tech_pvt->alsac, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
+        if ((samples = alsa_read(tech_pvt, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0) {
+                tech_pvt->read_frame.datalen = samples * 2;
+                tech_pvt->read_frame.samples = samples;
</ins><span class="cx">
</span><ins>+                switch_core_timer_check(&tech_pvt->timer, SWITCH_TRUE);
+                tech_pvt->read_frame.timestamp = tech_pvt->timer.samplecount;
+                *frame = &tech_pvt->read_frame;
</ins><span class="cx">
</span><del>-{
-                        tech_pvt->read_frame.datalen = samples * 2;
-                        tech_pvt->read_frame.samples = samples;
</del><ins>+                //status = SWITCH_STATUS_SUCCESS;
+                switch_set_flag(tech_pvt, TFLAG_VOICE);
+        }
</ins><span class="cx">
</span><del>-                        switch_core_timer_check(&tech_pvt->timer, SWITCH_TRUE);
-                        tech_pvt->read_frame.timestamp = tech_pvt->timer.samplecount;
-                        *frame = &tech_pvt->read_frame;
-
-                        //status = SWITCH_STATUS_SUCCESS;
-                        switch_set_flag(tech_pvt, TFLAG_VOICE);
-                }
-
-if(samples != 160)
</del><ins>+        if (samples != 160)
</ins><span class="cx">                 ERRORA("samples=%d\n", SKYPIAX_P_LOG, samples);
</span><span class="cx">
</span><del>-                //WARNINGA("samples=%d\n", SKYPIAX_P_LOG, samples);
</del><ins>+        //WARNINGA("samples=%d\n", SKYPIAX_P_LOG, samples);
</ins><span class="cx">
</span><span class="cx"> //usleep(17000);
</span><span class="cx"> //usleep(17000);
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- char digit_str[256];
</del><ins>+        char digit_str[256];
</ins><span class="cx">
</span><span class="cx">
</span><del>- memset(digit_str, 0, sizeof(digit_str));
- teletone_dtmf_detect(&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
- teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
</del><ins>+        memset(digit_str, 0, sizeof(digit_str));
+        teletone_dtmf_detect(&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
+        teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
</ins><span class="cx">
</span><del>- if (digit_str[0]) {
- switch_time_t new_dtmf_timestamp = switch_time_now();
- if((new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp) > 350000) { //FIXME: make it configurable
- char *p = digit_str;
- switch_channel_t *channel = switch_core_session_get_channel(session);
</del><ins>+        if (digit_str[0]) {
+                switch_time_t new_dtmf_timestamp = switch_time_now();
+                if ((new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp) > 350000) {        //FIXME: make it configurable
+                        char *p = digit_str;
+                        switch_channel_t *channel = switch_core_session_get_channel(session);
</ins><span class="cx">
</span><del>- while(p && *p) {
- switch_dtmf_t dtmf;
- dtmf.digit = *p;
- dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
- switch_channel_queue_dtmf(channel, &dtmf);
- p++;
- }
- NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPIAX_P_LOG, digit_str, (unsigned int)new_dtmf_timestamp, (unsigned int)(new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
- tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
- }
- }
-
-
-
</del><ins>+                        while (p && *p) {
+                                switch_dtmf_t dtmf;
+                                dtmf.digit = *p;
+                                dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+                                switch_channel_queue_dtmf(channel, &dtmf);
+                                p++;
+                        }
+                        NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPIAX_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
+                                 (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
+                        tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
+                }
+        }
</ins><span class="cx"> #ifdef NOTDEF
</span><span class="cx">
</span><span class="cx">         if (!celliax_audio_read(tech_pvt)) {
</span><span class="lines">@@ -766,7 +759,7 @@
</span><span class="cx">                                 switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2);
</span><span class="cx">                         }
</span><span class="cx"> #endif
</span><del>-                //WARNINGA("HERE\n", SKYPIAX_P_LOG);
</del><ins>+                        //WARNINGA("HERE\n", SKYPIAX_P_LOG);
</ins><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -815,23 +808,22 @@
</span><span class="cx">
</span><span class="cx">         sent = frame->datalen;
</span><span class="cx">
</span><del>-                //ERRORA("PLAY \n", SKYPIAX_P_LOG);
-         //snd_pcm_writei(tech_pvt->alsap, (short *) frame->data, (int) (frame->datalen / 2));
</del><ins>+        //ERRORA("PLAY \n", SKYPIAX_P_LOG);
+        //snd_pcm_writei(tech_pvt->alsap, (short *) frame->data, (int) (frame->datalen / 2));
</ins><span class="cx">
</span><del>- sent = alsa_write(tech_pvt, frame->data, (int) (frame->datalen));
</del><ins>+        sent = alsa_write(tech_pvt, frame->data, (int) (frame->datalen));
</ins><span class="cx">
</span><del>-#ifdef NOTDEF //FIXME
</del><ins>+#ifdef NOTDEF                                        //FIXME
</ins><span class="cx"> #ifdef WIN32
</span><span class="cx">         switch_file_write(tech_pvt->audioskypepipe[1], frame->data, &sent);
</span><span class="cx"> #else /* WIN32 */
</span><span class="cx">         sent = write(tech_pvt->audioskypepipe[1], frame->data, sent);
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> #endif //NOTDEF
</span><del>-        if (sent && sent != frame->datalen/2 && sent != -1) {
</del><ins>+        if (sent && sent != frame->datalen / 2 && sent != -1) {
</ins><span class="cx">                 DEBUGA_SKYPE("sent %d\n", SKYPIAX_P_LOG, sent);
</span><span class="cx">         }
</span><del>-
-                //NOTICA("sent=%d\n", SKYPIAX_P_LOG, sent);
</del><ins>+        //NOTICA("sent=%d\n", SKYPIAX_P_LOG, sent);
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1056,7 +1048,7 @@
</span><span class="cx"> *
</span><span class="cx"> */
</span><span class="cx"> #ifdef NOTDEF
</span><del>-static void *SWITCH_THREAD_FUNC celliax_signaling_thread_func(switch_thread_t * thread, void *obj)
</del><ins>+static void *SWITCH_THREAD_FUNC celliax_signaling_thread_func(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         private_t *tech_pvt = obj;
</span><span class="cx">         int res;
</span><span class="lines">@@ -1116,7 +1108,7 @@
</span><span class="cx">         }
</span><span class="cx">         return NULL;
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx">
</span><span class="cx"> /* BEGIN: Changes heres */
</span><span class="cx"> static switch_status_t load_config(int reload_type)
</span><span class="lines">@@ -1302,8 +1294,7 @@
</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
</del><ins>+#ifdef NOTDEF
</ins><span class="cx"> #ifndef WIN32
</span><span class="cx">                         if (!XInitThreads()) {
</span><span class="cx">                                 ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
</span><span class="lines">@@ -1313,7 +1304,7 @@
</span><span class="cx">                         switch_sleep(100);
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx">
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><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">@@ -1351,109 +1342,109 @@
</span><span class="cx">                                 globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol = controldevprotocol;
</span><span class="cx">
</span><span class="cx">
</span><del>-        switch_mutex_init(&globals.SKYPIAX_INTERFACES[interface_id].controldev_lock, SWITCH_MUTEX_NESTED, celliax_module_pool);
</del><ins>+                                switch_mutex_init(&globals.SKYPIAX_INTERFACES[interface_id].controldev_lock, SWITCH_MUTEX_NESTED, celliax_module_pool);
</ins><span class="cx"> /*********************/
</span><span class="cx"> #ifdef NOTDEF
</span><del>- .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;
</del><ins>+                                .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;
</ins><span class="cx"> #ifndef GIOVA48
</span><del>- .celliax_sound_rate = 8000;
</del><ins>+                                .celliax_sound_rate = 8000;
</ins><span class="cx"> #else // GIOVA48
</span><del>- .celliax_sound_rate = 48000;
</del><ins>+                                .celliax_sound_rate = 48000;
</ins><span class="cx"> #endif // GIOVA48
</span><del>- .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
- //at_dial_pre_number = "AT+CKPD=\"";
-switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_pre_number, "ATD");
- //.at_dial_post_number = "S\"";
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_post_number , ";");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_expect , "OK");
- globals.SKYPIAX_INTERFACES[interface_id].at_early_audio = 0;
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_hangup , "ATH");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_hangup_expect , "OK");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_answer , "ATA");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_answer_expect , "OK");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_send_dtmf , "AT+VTS");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_1 , "");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_1_expect , "");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_2 , "");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_2_expect , "");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_3 , "");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_3_expect , "");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_4 , "");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_4_expect , "");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_5 , "");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_5_expect , "");
- globals.SKYPIAX_INTERFACES[interface_id].at_after_preinit_pause = 500000;
- globals.SKYPIAX_INTERFACES[interface_id].at_initial_pause = 500000;
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_1 , "at+cmic=0,9");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_1_expect , "OK");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_2 , "AT+CKPD=\"EEE\"");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_2_expect , "OK");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_3 , "AT+CSSN=1,0");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_3_expect , "OK");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_4 , "at+sidet=0");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_4_expect , "OK");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_5 , "at+clvl=99");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_5_expect , "OK");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_battchg , "AT+CBC");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_battchg_expect , "OK");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_signal , "AT+CSQ");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_signal_expect , "OK");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_idle , "+MCST: 1");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_incoming , "+MCST: 2");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_active , "+CSSI: 7");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_failed , "+MCST: 65");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_calling , "+CSSI: 1");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_noservice_string , "CIEV: 2;0");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nosignal_string , "CIEV: 5;0");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_lowsignal_string , "CIEV: 5;1");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_lowbattchg_string , "CIEV: 0;1");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nobattchg_string , "CIEV: 0;0");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callactive_string , "CIEV: 3;1");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nocallactive_string , "CIEV: 3;0");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nocallsetup_string , "CIEV: 6;0");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupincoming_string , "CIEV: 6;1");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupoutgoing_string , "CIEV: 6;2");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupremoteringing_string , "CIEV: 6;3");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].sms_receiving_program , "/usr/local/bin/ciapalo");
- globals.SKYPIAX_INTERFACES[interface_id].at_has_clcc = 0;
- globals.SKYPIAX_INTERFACES[interface_id].at_has_ecam = 0;
</del><ins>+                                .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
+                                //at_dial_pre_number = "AT+CKPD=\"";
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_pre_number, "ATD");
+                                //.at_dial_post_number = "S\"";
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_post_number, ";");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_expect, "OK");
+                                globals.SKYPIAX_INTERFACES[interface_id].at_early_audio = 0;
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_hangup, "ATH");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_hangup_expect, "OK");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_answer, "ATA");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_answer_expect, "OK");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_send_dtmf, "AT+VTS");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_1, "");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_1_expect, "");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_2, "");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_2_expect, "");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_3, "");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_3_expect, "");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_4, "");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_4_expect, "");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_5, "");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_5_expect, "");
+                                globals.SKYPIAX_INTERFACES[interface_id].at_after_preinit_pause = 500000;
+                                globals.SKYPIAX_INTERFACES[interface_id].at_initial_pause = 500000;
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_1, "at+cmic=0,9");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_1_expect, "OK");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_2, "AT+CKPD=\"EEE\"");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_2_expect, "OK");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_3, "AT+CSSN=1,0");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_3_expect, "OK");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_4, "at+sidet=0");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_4_expect, "OK");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_5, "at+clvl=99");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_5_expect, "OK");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_battchg, "AT+CBC");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_battchg_expect, "OK");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_signal, "AT+CSQ");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_signal_expect, "OK");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_idle, "+MCST: 1");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_incoming, "+MCST: 2");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_active, "+CSSI: 7");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_failed, "+MCST: 65");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_calling, "+CSSI: 1");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_noservice_string, "CIEV: 2;0");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nosignal_string, "CIEV: 5;0");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_lowsignal_string, "CIEV: 5;1");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_lowbattchg_string, "CIEV: 0;1");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nobattchg_string, "CIEV: 0;0");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callactive_string, "CIEV: 3;1");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nocallactive_string, "CIEV: 3;0");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nocallsetup_string, "CIEV: 6;0");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupincoming_string, "CIEV: 6;1");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupoutgoing_string, "CIEV: 6;2");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupremoteringing_string, "CIEV: 6;3");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].sms_receiving_program, "/usr/local/bin/ciapalo");
+                                globals.SKYPIAX_INTERFACES[interface_id].at_has_clcc = 0;
+                                globals.SKYPIAX_INTERFACES[interface_id].at_has_ecam = 0;
</ins><span class="cx">
</span><del>- globals.SKYPIAX_INTERFACES[interface_id].alsa_period_size = 160;
- globals.SKYPIAX_INTERFACES[interface_id].alsa_periods_in_buffer = 4;
- globals.SKYPIAX_INTERFACES[interface_id].celliax_sound_rate = 8000;
</del><ins>+                                globals.SKYPIAX_INTERFACES[interface_id].alsa_period_size = 160;
+                                globals.SKYPIAX_INTERFACES[interface_id].alsa_periods_in_buffer = 4;
+                                globals.SKYPIAX_INTERFACES[interface_id].celliax_sound_rate = 8000;
</ins><span class="cx">
</span><del>- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].alsacname , "plughw:1");
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].alsapname , "plughw:1");
</del><ins>+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].alsacname, "plughw:1");
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].alsapname, "plughw:1");
</ins><span class="cx">
</span><span class="cx">
</span><del>- globals.SKYPIAX_INTERFACES[interface_id].alsa_play_is_mono = 1;
- globals.SKYPIAX_INTERFACES[interface_id].alsa_capture_is_mono = 1;
</del><ins>+                                globals.SKYPIAX_INTERFACES[interface_id].alsa_play_is_mono = 1;
+                                globals.SKYPIAX_INTERFACES[interface_id].alsa_capture_is_mono = 1;
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1486,54 +1477,57 @@
</span><span class="cx">                                          SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
</span><span class="cx">                                 WARNINGA("STARTING interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
</span><span class="cx">
</span><del>-                                int res=0;
</del><ins>+                                int res = 0;
</ins><span class="cx">
</span><del>- /* init the serial port */
- if (globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
- globals.SKYPIAX_INTERFACES[interface_id].controldevfd = celliax_serial_init(&globals.SKYPIAX_INTERFACES[interface_id], globals.SKYPIAX_INTERFACES[interface_id].controldevice_speed);
- if (globals.SKYPIAX_INTERFACES[interface_id].controldevfd < 1) {
- ERRORA("celliax_serial_init failed\n", SKYPIAX_P_LOG);
- //celliax_sound_shutdown(tmp);
- //if (tmp)
- //free(tmp);
- //return NULL;
- }
- }
</del><ins>+                                /* init the serial port */
+                                if (globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
+                                        globals.SKYPIAX_INTERFACES[interface_id].controldevfd =
+                                                celliax_serial_init(&globals.SKYPIAX_INTERFACES[interface_id], globals.SKYPIAX_INTERFACES[interface_id].controldevice_speed);
+                                        if (globals.SKYPIAX_INTERFACES[interface_id].controldevfd < 1) {
+                                                ERRORA("celliax_serial_init failed\n", SKYPIAX_P_LOG);
+                                                //celliax_sound_shutdown(tmp);
+                                                //if (tmp)
+                                                //free(tmp);
+                                                //return NULL;
+                                        }
+                                }
</ins><span class="cx">
</span><del>- /* config the phone/modem on the serial port */
- if (globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
- //int res;
- res = celliax_serial_config(&globals.SKYPIAX_INTERFACES[interface_id]);
- if (res) {
- ERRORA("celliax_serial_config failed\n", SKYPIAX_P_LOG);
- //celliax_sound_shutdown(tmp);
- //if (tmp)
- //free(tmp);
- //return NULL;
- }
- }
</del><ins>+                                /* config the phone/modem on the serial port */
+                                if (globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
+                                        //int res;
+                                        res = celliax_serial_config(&globals.SKYPIAX_INTERFACES[interface_id]);
+                                        if (res) {
+                                                ERRORA("celliax_serial_config failed\n", SKYPIAX_P_LOG);
+                                                //celliax_sound_shutdown(tmp);
+                                                //if (tmp)
+                                                //free(tmp);
+                                                //return NULL;
+                                        }
+                                }
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">                                 switch_sleep(100000);
</span><span class="cx">                                 switch_threadattr_create(&celliax_api_thread_attr, celliax_module_pool);
</span><span class="cx">                                 switch_threadattr_stacksize_set(celliax_api_thread_attr, SWITCH_THREAD_STACKSIZE);
</span><del>-                                switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].celliax_api_thread, celliax_api_thread_attr, celliax_do_skypeapi_thread, &globals.SKYPIAX_INTERFACES[interface_id], celliax_module_pool);
</del><ins>+                                switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].celliax_api_thread, celliax_api_thread_attr, celliax_do_skypeapi_thread,
+                                                                         &globals.SKYPIAX_INTERFACES[interface_id], celliax_module_pool);
</ins><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;
-                                 }
</del><ins>+#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;
+                                }
</ins><span class="cx">
</span><span class="cx">                                 switch_threadattr_create(&celliax_signaling_thread_attr, celliax_module_pool);
</span><span class="cx">                                 switch_threadattr_stacksize_set(celliax_signaling_thread_attr, SWITCH_THREAD_STACKSIZE);
</span><del>-                                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);
</del><ins>+                                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);
</ins><span class="cx">
</span><span class="cx">                                 switch_sleep(100000);
</span><span class="cx">
</span><span class="lines">@@ -1582,7 +1576,7 @@
</span><span class="cx">                                         switch_xml_free(xml);
</span><span class="cx">                                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                                 }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx">
</span><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="lines">@@ -1667,7 +1661,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>-
</del><span class="cx"> #ifdef NOTDEF
</span><span class="cx">                         if (globals.SKYPIAX_INTERFACES[interface_id].celliax_api_thread) {
</span><span class="cx"> #ifdef WIN32
</span><span class="lines">@@ -1690,7 +1683,7 @@
</span><span class="cx">                                 XSync(tech_pvt->SkypiaxHandles.disp, False);
</span><span class="cx"> #endif
</span><span class="cx">                         }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx">                         x = 10;
</span><span class="cx">                         while (x) {                        //FIXME 0.5 seconds?
</span><span class="cx">                                 x--;
</span><span class="lines">@@ -1730,18 +1723,18 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #ifdef NOTDEF
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_tcp_srv_thread(switch_thread_t * thread, void *obj)
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_tcp_srv_thread(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         return celliax_do_tcp_srv_thread_func(obj);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_tcp_cli_thread(switch_thread_t * thread, void *obj)
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_tcp_cli_thread(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         return celliax_do_tcp_cli_thread_func(obj);
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx">
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_skypeapi_thread(switch_thread_t * thread, void *obj)
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_skypeapi_thread(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         return celliax_do_skypeapi_thread_func(obj);
</span><span class="cx"> }
</span><span class="lines">@@ -1810,7 +1803,7 @@
</span><span class="cx">
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx">
</span><span class="cx"> int new_inbound_channel(private_t * tech_pvt)
</span><span class="cx"> {
</span><span class="lines">@@ -1941,8 +1934,8 @@
</span><span class="cx">         }
</span><span class="cx">         if (channel) {
</span><span class="cx">                 switch_channel_mark_answered(channel);
</span><del>-tech_pvt->phone_callflow = SKYPIAX_STATE_UP;
-tech_pvt->interface_state = SKYPIAX_STATE_UP;
</del><ins>+                tech_pvt->phone_callflow = SKYPIAX_STATE_UP;
+                tech_pvt->interface_state = SKYPIAX_STATE_UP;
</ins><span class="cx">                 //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
</span><span class="cx">         } else {
</span><span class="cx">                 ERRORA("No channel???\n", SKYPIAX_P_LOG);
</span><span class="lines">@@ -2062,8 +2055,7 @@
</span><span class="cx">                                 if (strlen(globals.SKYPIAX_INTERFACES[i].name)
</span><span class="cx">                                         && (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[1], strlen(argv[1])) == 0)) {
</span><span class="cx">                                         globals.sk_console = &globals.SKYPIAX_INTERFACES[i];
</span><del>-                                        stream->write_function(stream,
-                                                                                 "sk console is now: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPIAX_INTERFACES[i].name);
</del><ins>+                                        stream->write_function(stream, "sk console is now: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPIAX_INTERFACES[i].name);
</ins><span class="cx">                                         stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name);
</span><span class="cx">                                         found = 1;
</span><span class="cx">                                         break;
</span><span class="lines">@@ -2190,8 +2182,7 @@
</span><span class="cx">                                 found = 1;
</span><span class="cx">                                 DEBUGA_SKYPE
</span><span class="cx">                                         ("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",
</span><del>-                                         SKYPIAX_P_LOG, giovatech->name, giovatech->interface_state,
-                                         giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value)
</del><ins>+                                         SKYPIAX_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value)
</ins><span class="cx">                                         if (tech_pvt->interface_state == SKYPIAX_STATE_PRERING) {
</span><span class="cx">                                         tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
</span><span class="cx">                                 } else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPIAX_STATE_DOWN) {
</span><span class="lines">@@ -2245,7 +2236,7 @@
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><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 class="lines">@@ -2267,8 +2258,7 @@
</span><span class="cx">                                 found = 1;
</span><span class="cx">                                 DEBUGA_SKYPE
</span><span class="cx">                                         ("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",
</span><del>-                                         SKYPIAX_P_LOG, giovatech->name, giovatech->interface_state,
-                                         giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value)
</del><ins>+                                         SKYPIAX_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value)
</ins><span class="cx">                                         break;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -2376,28 +2366,26 @@
</span><span class="cx">                         int res;
</span><span class="cx">                         //celliax_sleep(1000000); //1 sec
</span><span class="cx">                         //DEBUGA_SKYPE("ciao!\n", SKYPIAX_P_LOG);
</span><del>-                        res=celliax_serial_read(tech_pvt);
- if (res == -1) { //manage the graceful interface shutdown
- tech_pvt->controldev_dead = 1;
- close(tech_pvt->controldevfd);
- ERRORA("celliax_serial_monitor failed, declaring %s dead\n", SKYPIAX_P_LOG,
- tech_pvt->controldevice_name);
- } else if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL
- && tech_pvt->interface_state == SKYPIAX_STATE_RING) {
- WARNINGA("INCOMING RING, let's take the incoming call\n", SKYPIAX_P_LOG);
</del><ins>+                        res = celliax_serial_read(tech_pvt);
+                        if (res == -1) {        //manage the graceful interface shutdown
+                                tech_pvt->controldev_dead = 1;
+                                close(tech_pvt->controldevfd);
+                                ERRORA("celliax_serial_monitor failed, declaring %s dead\n", SKYPIAX_P_LOG, tech_pvt->controldevice_name);
+                        } else if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL && tech_pvt->interface_state == SKYPIAX_STATE_RING) {
+                                WARNINGA("INCOMING RING, let's take the incoming call\n", SKYPIAX_P_LOG);
</ins><span class="cx">                                 celliax_answer(tech_pvt);
</span><span class="cx">                                 //new_inbound_channel(tech_pvt);
</span><del>- //FIXME if (!celliax_new(p, AST_STATE_RING, tech_pvt->context)) {
- //FIXME ERRORA("celliax_new failed! BAD BAD BAD\n", CELLIAX_P_LOG);
- //FIXME }
- } else if (tech_pvt->interface_state == CALLFLOW_CALL_REMOTEANSWER) {
- WARNINGA("REMOTE PARTY ANSWERED\n", SKYPIAX_P_LOG);
-outbound_channel_answered(tech_pvt);
</del><ins>+                                //FIXME if (!celliax_new(p, AST_STATE_RING, tech_pvt->context)) {
+                                //FIXME ERRORA("celliax_new failed! BAD BAD BAD\n", CELLIAX_P_LOG);
+                                //FIXME }
+                        } else if (tech_pvt->interface_state == CALLFLOW_CALL_REMOTEANSWER) {
+                                WARNINGA("REMOTE PARTY ANSWERED\n", SKYPIAX_P_LOG);
+                                outbound_channel_answered(tech_pvt);
</ins><span class="cx">                                 //new_inbound_channel(tech_pvt);
</span><del>- //FIXME if (!celliax_new(p, AST_STATE_RING, tech_pvt->context)) {
- //FIXME ERRORA("celliax_new failed! BAD BAD BAD\n", CELLIAX_P_LOG);
- //FIXME }
- }
</del><ins>+                                //FIXME if (!celliax_new(p, AST_STATE_RING, tech_pvt->context)) {
+                                //FIXME ERRORA("celliax_new failed! BAD BAD BAD\n", CELLIAX_P_LOG);
+                                //FIXME }
+                        }
</ins><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="cx">                 ERRORA("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n", SKYPIAX_P_LOG);
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>