Modified: freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.c (15048 => 15049)
--- freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.c 2009-10-02 14:21:17 UTC (rev 15048)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.c 2009-10-02 14:28:15 UTC (rev 15049)
@@ -521,7 +521,7 @@
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
-tech_pvt->phone_callflow = CALLFLOW_CALL_HANGUP_REQUESTED;
+ tech_pvt->phone_callflow = CALLFLOW_CALL_HANGUP_REQUESTED;
if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
@@ -852,7 +852,7 @@
//ERRORA("%s CHANNEL INIT\n", GSMOPEN_P_LOG, tech_pvt->name);
switch_set_flag(tech_pvt, TFLAG_IO);
-gsmopen_serial_answer(tech_pvt);
+ gsmopen_serial_answer(tech_pvt);
/* Move channel's state machine to ROUTING. This means the call is trying
to get from the initial start where the call because, to the point
@@ -1103,11 +1103,8 @@
* \brief This thread runs during a call, and monitor the interface for signaling, like hangup, caller id, etc most of signaling is handled inside the gsmopen_signaling_read function
*
*/
-/* BEGIN: Changes heres */
-
static switch_status_t load_config(int reload_type)
-/* END: Changes heres */
{
char *cf = "gsmopen.conf";
switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
@@ -1168,76 +1165,74 @@
char *enable_callerid = "true";
- char *at_dial_pre_number= "ATD";
- char *at_dial_post_number= ";";
- char *at_dial_expect= "OK";
- char *at_hangup= "ATH";
- char *at_hangup_expect= "OK";
- char *at_answer= "ATA";
- char *at_answer_expect= "OK";
- char *at_send_dtmf= "AT+VTS";
- char *at_preinit_1= "";
- char *at_preinit_1_expect= "";
- char *at_preinit_2= "";
- char *at_preinit_2_expect= "";
- char *at_preinit_3= "";
- char *at_preinit_3_expect= "";
- char *at_preinit_4= "";
- char *at_preinit_4_expect= "";
- char *at_preinit_5= "";
- char *at_preinit_5_expect= "";
- char *at_postinit_1= "at+cmic=0,9";
- char *at_postinit_1_expect= "OK";
- char *at_postinit_2= "AT+CKPD=\"EEE\"";
- char *at_postinit_2_expect= "OK";
- char *at_postinit_3= "AT+CSSN=1,0";
- char *at_postinit_3_expect= "OK";
- char *at_postinit_4= "at+sidet=0";
- char *at_postinit_4_expect= "OK";
- char *at_postinit_5= "at+clvl=99";
- char *at_postinit_5_expect= "OK";
- char *at_query_battchg= "AT+CBC";
- char *at_query_battchg_expect= "OK";
- char *at_query_signal= "AT+CSQ";
- char *at_query_signal_expect= "OK";
- char *at_call_idle= "+MCST: 1";
- char *at_call_incoming= "+MCST: 2";
- char *at_call_active= "+CSSI: 7";
- char *at_call_failed= "+MCST: 65";
- char *at_call_calling= "+CSSI: 1";
- char *at_indicator_noservice_string= "CIEV: 2;0";
- char *at_indicator_nosignal_string= "CIEV: 5;0";
- char *at_indicator_lowsignal_string= "CIEV: 5;1";
- char *at_indicator_lowbattchg_string= "CIEV: 0;1";
- char *at_indicator_nobattchg_string= "CIEV: 0;0";
- char *at_indicator_callactive_string= "CIEV: 3;1";
- char *at_indicator_nocallactive_string= "CIEV: 3;0";
- char *at_indicator_nocallsetup_string= "CIEV: 6;0";
- char *at_indicator_callsetupincoming_string= "CIEV: 6;1";
- char *at_indicator_callsetupoutgoing_string= "CIEV: 6;2";
- char *at_indicator_callsetupremoteringing_string= "CIEV: 6;3";
- char *sms_receiving_program= "/usr/local/bin/ciapalo";
- char *alsacname= "plughw:1";
- char *alsapname= "plughw:1";
- char *at_early_audio ="0";
- char *at_after_preinit_pause="500000";
- char *at_initial_pause="500000";
- char *at_has_clcc="0";
- char *at_has_ecam="0";
- char *alsa_period_size="160";
- char *alsa_periods_in_buffer="4";
- char *gsmopen_sound_rate="8000";
- char *alsa_play_is_mono="1";
- char *alsa_capture_is_mono="1";
- char *capture_boost="5";
- char *playback_boost="10";
+ char *at_dial_pre_number = "ATD";
+ char *at_dial_post_number = ";";
+ char *at_dial_expect = "OK";
+ char *at_hangup = "ATH";
+ char *at_hangup_expect = "OK";
+ char *at_answer = "ATA";
+ char *at_answer_expect = "OK";
+ char *at_send_dtmf = "AT+VTS";
+ char *at_preinit_1 = "";
+ char *at_preinit_1_expect = "";
+ char *at_preinit_2 = "";
+ char *at_preinit_2_expect = "";
+ char *at_preinit_3 = "";
+ char *at_preinit_3_expect = "";
+ char *at_preinit_4 = "";
+ char *at_preinit_4_expect = "";
+ char *at_preinit_5 = "";
+ char *at_preinit_5_expect = "";
+ char *at_postinit_1 = "at+cmic=0,9";
+ char *at_postinit_1_expect = "OK";
+ char *at_postinit_2 = "AT+CKPD=\"EEE\"";
+ char *at_postinit_2_expect = "OK";
+ char *at_postinit_3 = "AT+CSSN=1,0";
+ char *at_postinit_3_expect = "OK";
+ char *at_postinit_4 = "at+sidet=0";
+ char *at_postinit_4_expect = "OK";
+ char *at_postinit_5 = "at+clvl=99";
+ char *at_postinit_5_expect = "OK";
+ char *at_query_battchg = "AT+CBC";
+ char *at_query_battchg_expect = "OK";
+ char *at_query_signal = "AT+CSQ";
+ char *at_query_signal_expect = "OK";
+ char *at_call_idle = "+MCST: 1";
+ char *at_call_incoming = "+MCST: 2";
+ char *at_call_active = "+CSSI: 7";
+ char *at_call_failed = "+MCST: 65";
+ char *at_call_calling = "+CSSI: 1";
+ char *at_indicator_noservice_string = "CIEV: 2;0";
+ char *at_indicator_nosignal_string = "CIEV: 5;0";
+ char *at_indicator_lowsignal_string = "CIEV: 5;1";
+ char *at_indicator_lowbattchg_string = "CIEV: 0;1";
+ char *at_indicator_nobattchg_string = "CIEV: 0;0";
+ char *at_indicator_callactive_string = "CIEV: 3;1";
+ char *at_indicator_nocallactive_string = "CIEV: 3;0";
+ char *at_indicator_nocallsetup_string = "CIEV: 6;0";
+ char *at_indicator_callsetupincoming_string = "CIEV: 6;1";
+ char *at_indicator_callsetupoutgoing_string = "CIEV: 6;2";
+ char *at_indicator_callsetupremoteringing_string = "CIEV: 6;3";
+ char *sms_receiving_program = "/usr/local/bin/ciapalo";
+ char *alsacname = "plughw:1";
+ char *alsapname = "plughw:1";
+ char *at_early_audio = "0";
+ char *at_after_preinit_pause = "500000";
+ char *at_initial_pause = "500000";
+ char *at_has_clcc = "0";
+ char *at_has_ecam = "0";
+ char *alsa_period_size = "160";
+ char *alsa_periods_in_buffer = "4";
+ char *gsmopen_sound_rate = "8000";
+ char *alsa_play_is_mono = "1";
+ char *alsa_capture_is_mono = "1";
+ char *capture_boost = "5";
+ char *playback_boost = "10";
uint32_t interface_id = 0;
- //uint32_t to=0;
- //uint32_t max=0;
- uint32_t controldevice_speed = B115200; //FIXME TODO
- uint32_t controldevprotocol = PROTOCOL_AT; //FIXME TODO
- uint32_t running =1; //FIXME TODO
+ uint32_t controldevice_speed = B115200; //FIXME TODO
+ uint32_t controldevprotocol = PROTOCOL_AT; //FIXME TODO
+ uint32_t running = 1; //FIXME TODO
@@ -1430,51 +1425,51 @@
continue;
}
- if(!switch_is_number(at_early_audio)) {
+ if (!switch_is_number(at_early_audio)) {
ERRORA("interface param 'at_early_audio' MUST be a number, now at_early_audio='%s'\n", GSMOPEN_P_LOG, at_early_audio);
continue;
}
- if(!switch_is_number(at_after_preinit_pause)) {
+ if (!switch_is_number(at_after_preinit_pause)) {
ERRORA("interface param 'at_after_preinit_pause' MUST be a number, now at_after_preinit_pause='%s'\n", GSMOPEN_P_LOG, at_after_preinit_pause);
continue;
}
- if(!switch_is_number(at_initial_pause)) {
+ if (!switch_is_number(at_initial_pause)) {
ERRORA("interface param 'at_initial_pause' MUST be a number, now at_initial_pause='%s'\n", GSMOPEN_P_LOG, at_initial_pause);
continue;
}
- if(!switch_is_number(at_has_clcc)) {
+ if (!switch_is_number(at_has_clcc)) {
ERRORA("interface param 'at_has_clcc' MUST be a number, now at_has_clcc='%s'\n", GSMOPEN_P_LOG, at_has_clcc);
continue;
}
- if(!switch_is_number(at_has_ecam)) {
+ if (!switch_is_number(at_has_ecam)) {
ERRORA("interface param 'at_has_ecam' MUST be a number, now at_has_ecam='%s'\n", GSMOPEN_P_LOG, at_has_ecam);
continue;
}
- if(!switch_is_number(alsa_period_size)) {
+ if (!switch_is_number(alsa_period_size)) {
ERRORA("interface param 'alsa_period_size' MUST be a number, now alsa_period_size='%s'\n", GSMOPEN_P_LOG, alsa_period_size);
continue;
}
- if(!switch_is_number(alsa_periods_in_buffer)) {
+ if (!switch_is_number(alsa_periods_in_buffer)) {
ERRORA("interface param 'alsa_periods_in_buffer' MUST be a number, now alsa_periods_in_buffer='%s'\n", GSMOPEN_P_LOG, alsa_periods_in_buffer);
continue;
}
- if(!switch_is_number(gsmopen_sound_rate)) {
+ if (!switch_is_number(gsmopen_sound_rate)) {
ERRORA("interface param 'gsmopen_sound_rate' MUST be a number, now gsmopen_sound_rate='%s'\n", GSMOPEN_P_LOG, gsmopen_sound_rate);
continue;
}
- if(!switch_is_number(alsa_play_is_mono)) {
+ if (!switch_is_number(alsa_play_is_mono)) {
ERRORA("interface param 'alsa_play_is_mono' MUST be a number, now alsa_play_is_mono='%s'\n", GSMOPEN_P_LOG, alsa_play_is_mono);
continue;
}
- if(!switch_is_number(alsa_capture_is_mono)) {
+ if (!switch_is_number(alsa_capture_is_mono)) {
ERRORA("interface param 'alsa_capture_is_mono' MUST be a number, now alsa_capture_is_mono='%s'\n", GSMOPEN_P_LOG, alsa_capture_is_mono);
continue;
}
- if(!switch_is_number(capture_boost)) {
+ if (!switch_is_number(capture_boost)) {
ERRORA("interface param 'capture_boost' MUST be a number, now capture_boost='%s'\n", GSMOPEN_P_LOG, capture_boost);
continue;
}
- if(!switch_is_number(playback_boost)) {
+ if (!switch_is_number(playback_boost)) {
ERRORA("interface param 'playback_boost' MUST be a number, now playback_boost='%s'\n", GSMOPEN_P_LOG, playback_boost);
continue;
}
@@ -1493,19 +1488,15 @@
switch_mutex_init(&globals.GSMOPEN_INTERFACES[interface_id].controldev_lock, SWITCH_MUTEX_NESTED, gsmopen_module_pool);
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].id , id );
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].name , name );
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].context , context );
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].dialplan , dialplan );
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].destination , destination );
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].controldevice_name , controldevice_name );
- //FIXME switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].digit_timeout , digit_timeout );
- //FIXME switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].max_digits , max_digits );
- //FIXME switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].hotline , hotline );
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].dial_regex , dial_regex );
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].hold_music , hold_music );
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].fail_dial_regex , fail_dial_regex );
- //FIXME switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].enable_callerid , enable_callerid );
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].id, id);
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].name, name);
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].context, context);
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].dialplan, dialplan);
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].destination, destination);
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].controldevice_name, controldevice_name);
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].dial_regex, dial_regex);
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].hold_music, hold_music);
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].fail_dial_regex, fail_dial_regex);
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].at_dial_pre_number, at_dial_pre_number);
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].at_dial_post_number, at_dial_post_number);
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].at_dial_expect, at_dial_expect);
@@ -1553,7 +1544,8 @@
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].at_indicator_nocallsetup_string, at_indicator_nocallsetup_string);
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].at_indicator_callsetupincoming_string, at_indicator_callsetupincoming_string);
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].at_indicator_callsetupoutgoing_string, at_indicator_callsetupoutgoing_string);
- switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].at_indicator_callsetupremoteringing_string, at_indicator_callsetupremoteringing_string);
+ switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].at_indicator_callsetupremoteringing_string,
+ at_indicator_callsetupremoteringing_string);
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].sms_receiving_program, sms_receiving_program);
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].alsacname, alsacname);
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].alsapname, alsapname);
@@ -1573,21 +1565,9 @@
- globals.GSMOPEN_INTERFACES[interface_id].controldevice_speed = controldevice_speed;
- globals.GSMOPEN_INTERFACES[interface_id].controldevprotocol = controldevprotocol;
- //globals.GSMOPEN_INTERFACES[interface_id].at_early_audio = at_early_audio;
- //globals.GSMOPEN_INTERFACES[interface_id].at_after_preinit_pause = at_after_preinit_pause;
- //globals.GSMOPEN_INTERFACES[interface_id].at_initial_pause = at_initial_pause;
- //globals.GSMOPEN_INTERFACES[interface_id].at_has_clcc = at_has_clcc;
- //globals.GSMOPEN_INTERFACES[interface_id].at_has_ecam = at_has_ecam;
- //globals.GSMOPEN_INTERFACES[interface_id].alsa_period_size = alsa_period_size;
- //globals.GSMOPEN_INTERFACES[interface_id].alsa_periods_in_buffer = alsa_periods_in_buffer;
- //globals.GSMOPEN_INTERFACES[interface_id].gsmopen_sound_rate = gsmopen_sound_rate;
- //globals.GSMOPEN_INTERFACES[interface_id].alsa_play_is_mono = alsa_play_is_mono;
- //globals.GSMOPEN_INTERFACES[interface_id].alsa_capture_is_mono = alsa_capture_is_mono;
- //globals.GSMOPEN_INTERFACES[interface_id].capture_boost = capture_boost;
- //globals.GSMOPEN_INTERFACES[interface_id].playback_boost = playback_boost;
- globals.GSMOPEN_INTERFACES[interface_id].running = running; //FIXME
+ globals.GSMOPEN_INTERFACES[interface_id].controldevice_speed = controldevice_speed; //FIXME
+ globals.GSMOPEN_INTERFACES[interface_id].controldevprotocol = controldevprotocol; //FIXME
+ globals.GSMOPEN_INTERFACES[interface_id].running = running; //FIXME
@@ -1611,35 +1591,26 @@
if (globals.GSMOPEN_INTERFACES[interface_id].controldevfd < 1) {
ERRORA("gsmopen_serial_init failed\n", GSMOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
- //gsmopen_sound_shutdown(tmp);
- //if (tmp)
- //free(tmp);
- //return NULL;
}
}
/* config the phone/modem on the serial port */
if (globals.GSMOPEN_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
- //int res;
res = gsmopen_serial_config(&globals.GSMOPEN_INTERFACES[interface_id]);
if (res) {
ERRORA("gsmopen_serial_config failed\n", GSMOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
- //gsmopen_sound_shutdown(tmp);
- //if (tmp)
- //free(tmp);
- //return NULL;
}
}
- gsmopen_store_boost("5", &globals.GSMOPEN_INTERFACES[interface_id].capture_boost); //FIXME
- gsmopen_store_boost("10", &globals.GSMOPEN_INTERFACES[interface_id].playback_boost); //FIXME
+ gsmopen_store_boost("5", &globals.GSMOPEN_INTERFACES[interface_id].capture_boost); //FIXME
+ gsmopen_store_boost("10", &globals.GSMOPEN_INTERFACES[interface_id].playback_boost); //FIXME
switch_sleep(100000);
switch_threadattr_create(&gsmopen_api_thread_attr, gsmopen_module_pool);
switch_threadattr_stacksize_set(gsmopen_api_thread_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&globals.GSMOPEN_INTERFACES[interface_id].gsmopen_api_thread, gsmopen_api_thread_attr, gsmopen_do_gsmopenapi_thread,
- &globals.GSMOPEN_INTERFACES[interface_id], gsmopen_module_pool);
+ &globals.GSMOPEN_INTERFACES[interface_id], gsmopen_module_pool);
switch_sleep(100000);
WARNINGA("STARTED interface_id=%d\n", GSMOPEN_P_LOG, interface_id);
@@ -1680,19 +1651,20 @@
static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint)
{
char *user, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL;
- private_t * tech_pvt=NULL;
- int i=0, found=0;
+ private_t *tech_pvt = NULL;
+ int i = 0, found = 0;
switch_assert(proto != NULL);
- DEBUGA_GSMOPEN("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", GSMOPEN_P_LOG, proto, from, to, subject, body, type, hint?hint:"NULL");
+ DEBUGA_GSMOPEN("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", GSMOPEN_P_LOG, proto, from, to, subject, body, type,
+ hint ? hint : "NULL");
if (!to || !strlen(to)) {
ERRORA("Missing To: header.\n", GSMOPEN_P_LOG);
return SWITCH_STATUS_SUCCESS;
}
- if ((!from && !hint) || (!strlen(from) && !strlen(hint)) ) {
+ if ((!from && !hint) || (!strlen(from) && !strlen(hint))) {
ERRORA("Missing From: AND Hint: headers.\n", GSMOPEN_P_LOG);
return SWITCH_STATUS_SUCCESS;
}
@@ -1706,47 +1678,49 @@
}
}
-if(!strlen(hint)){ //FIXME FIXME FIXME
- hint=from;
-}
+ if (!strlen(hint)) { //FIXME FIXME FIXME
+ hint = from;
+ }
if (to && (user = strdup(to))) {
if ((host = strchr(user, '@'))) {
*host++ = '\0';
}
- DEBUGA_GSMOPEN("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", GSMOPEN_P_LOG, proto, from, to, subject, body, type, hint?hint:"NULL");
+ DEBUGA_GSMOPEN("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", GSMOPEN_P_LOG, proto, from, to, subject, body, type,
+ hint ? hint : "NULL");
if (hint && strlen(hint)) {
//in hint we receive the interface name to use
for (i = 0; !found && i < GSMOPEN_MAX_INTERFACES; i++) {
if (strlen(globals.GSMOPEN_INTERFACES[i].name)
- && (strncmp(globals.GSMOPEN_INTERFACES[i].name, hint, strlen(hint)) == 0)) {
+ && (strncmp(globals.GSMOPEN_INTERFACES[i].name, hint, strlen(hint)) == 0)) {
tech_pvt = &globals.GSMOPEN_INTERFACES[i];
DEBUGA_GSMOPEN("Using interface: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", GSMOPEN_P_LOG, i, globals.GSMOPEN_INTERFACES[i].name);
found = 1;
break;
}
}
- } /* FIXME add a tech_pvt member for the SIM telephone number //else {
- //we have no a predefined interface name to use (hint is NULL), so let's choose an interface from the username (from)
- for (i = 0; !found && i < GSMOPEN_MAX_INTERFACES; i++) {
- if (strlen(globals.GSMOPEN_INTERFACES[i].name)
- && (strncmp(globals.GSMOPEN_INTERFACES[i].skype_user, from, strlen(from)) == 0)) {
- tech_pvt = &globals.GSMOPEN_INTERFACES[i];
- DEBUGA_GSMOPEN("Using interface: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", GSMOPEN_P_LOG, i, globals.GSMOPEN_INTERFACES[i].name);
- found = 1;
- break;
- }
- }
- }
- */
+ } /* FIXME add a tech_pvt member for the SIM telephone number //else {
+ //we have no a predefined interface name to use (hint is NULL), so let's choose an interface from the username (from)
+ for (i = 0; !found && i < GSMOPEN_MAX_INTERFACES; i++) {
+ if (strlen(globals.GSMOPEN_INTERFACES[i].name)
+ && (strncmp(globals.GSMOPEN_INTERFACES[i].skype_user, from, strlen(from)) == 0)) {
+ tech_pvt = &globals.GSMOPEN_INTERFACES[i];
+ DEBUGA_GSMOPEN("Using interface: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", GSMOPEN_P_LOG, i, globals.GSMOPEN_INTERFACES[i].name);
+ found = 1;
+ break;
+ }
+ }
+ }
+ */
if (!found) {
- ERRORA("ERROR: A GSMopen interface with name='%s' or one with SIM_number='%s' was not found\n", GSMOPEN_P_LOG, hint?hint:"NULL", from?from:"NULL");
+ ERRORA("ERROR: A GSMopen interface with name='%s' or one with SIM_number='%s' was not found\n", GSMOPEN_P_LOG, hint ? hint : "NULL",
+ from ? from : "NULL");
goto end;
} else {
- gsmopen_sendsms(tech_pvt, (char *)to, (char *)body);
+ gsmopen_sendsms(tech_pvt, (char *) to, (char *) body);
}
}
-end:
+ end:
switch_safe_free(user);
switch_safe_free(f_user);
return SWITCH_STATUS_SUCCESS;
@@ -1768,10 +1742,10 @@
return SWITCH_STATUS_FALSE;
}
- if (switch_event_reserve_subclass(MY_EVENT_INCOMING_SMS) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
- return SWITCH_STATUS_GENERR;
- }
+ if (switch_event_reserve_subclass(MY_EVENT_INCOMING_SMS) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
+ return SWITCH_STATUS_GENERR;
+ }
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
gsmopen_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
@@ -1849,7 +1823,7 @@
}
- switch_event_free_subclass(MY_EVENT_INCOMING_SMS);
+ switch_event_free_subclass(MY_EVENT_INCOMING_SMS);
switch_safe_free(globals.dialplan);
switch_safe_free(globals.context);
@@ -2384,7 +2358,8 @@
close(tech_pvt->controldevfd);
ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name);
switch_sleep(1000000);
- } else if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL && tech_pvt->interface_state == GSMOPEN_STATE_RING && tech_pvt->phone_callflow != CALLFLOW_CALL_HANGUP_REQUESTED ) {
+ } else if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL && tech_pvt->interface_state == GSMOPEN_STATE_RING
+ && tech_pvt->phone_callflow != CALLFLOW_CALL_HANGUP_REQUESTED) {
WARNINGA("INCOMING RING\n", GSMOPEN_P_LOG);
gsmopen_ring(tech_pvt);
@@ -2427,6 +2402,7 @@
return NULL;
}
+
#ifdef NOTDEF
int sms_incoming(private_t * tech_pvt, char *value)
{
@@ -2446,7 +2422,7 @@
return 0;
}
-#endif// NOTDEF
+#endif // NOTDEF
SWITCH_STANDARD_API(sendsms_function)
@@ -2491,7 +2467,8 @@
return SWITCH_STATUS_SUCCESS;
} else {
//gsmopen_sendsms(tech_pvt, (char *) argv[1], (char *) argv[2]);
- NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", GSMOPEN_P_LOG, MDL_CHAT_PROTO, tech_pvt->name, argv[1], "SIMPLE MESSAGE", switch_str_nil(argv[2]), tech_pvt->name);
+ NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", GSMOPEN_P_LOG, MDL_CHAT_PROTO, tech_pvt->name, argv[1],
+ "SIMPLE MESSAGE", switch_str_nil(argv[2]), tech_pvt->name);
chat_send(MDL_CHAT_PROTO, tech_pvt->name, argv[1], "SIMPLE MESSAGE", switch_str_nil(argv[2]), NULL, tech_pvt->name);
}
@@ -2513,7 +2490,8 @@
int event_sent_to_esl = 0;
DEBUGA_GSMOPEN("received SMS on interface %s: %s\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_message);
- DEBUGA_GSMOPEN("received SMS on interface %s: DATE=%s, SENDER=%s, BODY=%s\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_date, tech_pvt->sms_sender, tech_pvt->sms_body);
+ DEBUGA_GSMOPEN("received SMS on interface %s: DATE=%s, SENDER=%s, BODY=%s\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_date, tech_pvt->sms_sender,
+ tech_pvt->sms_body);
if (!switch_strlen_zero(tech_pvt->session_uuid_str)) {
session = switch_core_session_locate(tech_pvt->session_uuid_str);
@@ -2523,28 +2501,28 @@
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name);
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->sms_sender);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "date", tech_pvt->sms_date);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "date", tech_pvt->sms_date);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE");
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname);
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id);
switch_event_add_body(event, "%s", tech_pvt->sms_body);
- if(session){
+ if (session) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true");
if (switch_core_session_queue_event(session, &event) != SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
switch_event_fire(&event);
}
- } else { //no session
+ } else { //no session
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "false");
switch_event_fire(&event);
- event_sent_to_esl=1;
+ event_sent_to_esl = 1;
}
- }else{
+ } else {
ERRORA("cannot create event on interface %s. WHY?????\n", GSMOPEN_P_LOG, tech_pvt->name);
}
- if(!event_sent_to_esl){
+ if (!event_sent_to_esl) {
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
@@ -2552,27 +2530,27 @@
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname);
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->chatmessages[which].from_handle);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->sms_sender);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "date", tech_pvt->sms_date);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "date", tech_pvt->sms_date);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE");
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname);
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id);
switch_event_add_body(event, "%s", tech_pvt->sms_body);
- if(session){
+ if (session) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true");
- } else { //no session
+ } else { //no session
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "false");
}
switch_event_fire(&event);
- } else{
+ } else {
ERRORA("cannot create event on interface %s. WHY?????\n", GSMOPEN_P_LOG, tech_pvt->name);
}
}
- if(session){
+ if (session) {
switch_core_session_rwunlock(session);
}
//memset(&tech_pvt->chatmessages[which], '\0', sizeof(&tech_pvt->chatmessages[which]) );
- memset(tech_pvt->sms_message, '\0', sizeof(tech_pvt->sms_message) );
+ memset(tech_pvt->sms_message, '\0', sizeof(tech_pvt->sms_message));
return 0;
}
@@ -2606,7 +2584,7 @@
for (i = 0; !found && i < GSMOPEN_MAX_INTERFACES; i++) {
/* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */
if (strlen(globals.GSMOPEN_INTERFACES[i].name)
- && (strncmp(globals.GSMOPEN_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
+ && (strncmp(globals.GSMOPEN_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
tech_pvt = &globals.GSMOPEN_INTERFACES[i];
stream->write_function(stream, "Using interface: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", i, globals.GSMOPEN_INTERFACES[i].name);
found = 1;
@@ -2623,9 +2601,11 @@
//chat_send(p*roto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint);
//chat_send(MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, hint);
- NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", GSMOPEN_P_LOG, MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt->name);
+ NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", GSMOPEN_P_LOG, MDL_CHAT_PROTO, tech_pvt->skype_user,
+ argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt->name);
- chat_send(MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt->name);
+ chat_send(MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]),
+ NULL, tech_pvt->name);
//NOTICA("TEXT is: %s\n", GSMOPEN_P_LOG, (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1] );
//snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", argv[1]);
@@ -2639,21 +2619,22 @@
#ifdef NOTDEF
- found=0;
+ found = 0;
- while(!found){
- for(i=0; i<MAX_CHATS; i++){
- if(!strcmp(tech_pvt->chats[i].dialog_partner, argv[1]) ){
- snprintf(skype_msg, sizeof(skype_msg), "CHATMESSAGE %s %s", tech_pvt->chats[i].chatname, (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]);
+ while (!found) {
+ for (i = 0; i < MAX_CHATS; i++) {
+ if (!strcmp(tech_pvt->chats[i].dialog_partner, argv[1])) {
+ snprintf(skype_msg, sizeof(skype_msg), "CHATMESSAGE %s %s", tech_pvt->chats[i].chatname,
+ (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]);
skypiax_signaling_write(tech_pvt, skype_msg);
- found=1;
+ found = 1;
break;
}
}
- if(found){
+ if (found) {
break;
}
- if(tried > 1000){
+ if (tried > 1000) {
stream->write_function(stream, "ERROR: no chat with dialog_partner='%s' was found\n", argv[1]);
break;
}
@@ -2661,12 +2642,12 @@
}
#endif //NOTDEF
-end:
+ end:
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS;
}
-#endif// NOTDEF
+#endif // NOTDEF
/* For Emacs: