skypopen: indented

This commit is contained in:
Giovanni Maruzzelli 2010-10-26 05:07:22 -05:00
parent 994cdbd183
commit 7d7f23cebb
3 changed files with 522 additions and 505 deletions

View File

@ -560,7 +560,6 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id); sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
skypopen_signaling_write(tech_pvt, msg_to_skype); skypopen_signaling_write(tech_pvt, msg_to_skype);
} }
#if 0 #if 0
switch_sleep(1500000); //XXX 1.5 seconds, let's the audio tcp threads die XXX switch_sleep(1500000); //XXX 1.5 seconds, let's the audio tcp threads die XXX
//FIXME must not allow using the tech_pvt while this sleeps, so must implement a check on interface_state //FIXME must not allow using the tech_pvt while this sleeps, so must implement a check on interface_state
@ -668,7 +667,8 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
WARNINGA("FYI %s CHANNEL in CS_NEW state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); WARNINGA("FYI %s CHANNEL in CS_NEW state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel));
} }
if (switch_channel_get_state(channel) != CS_NEW && switch_channel_get_state(channel) < CS_EXECUTE) { if (switch_channel_get_state(channel) != CS_NEW && switch_channel_get_state(channel) < CS_EXECUTE) {
WARNINGA("FYI %s CHANNEL in %d state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel), switch_channel_get_state(channel)); WARNINGA("FYI %s CHANNEL in %d state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel),
switch_channel_get_state(channel));
} }
switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_IO);
switch_clear_flag(tech_pvt, TFLAG_VOICE); switch_clear_flag(tech_pvt, TFLAG_VOICE);
@ -1653,7 +1653,8 @@ static switch_status_t load_config(int reload_type)
switch_threadattr_detach_set(skypopen_api_thread_attr, 0); switch_threadattr_detach_set(skypopen_api_thread_attr, 0);
switch_threadattr_stacksize_set(skypopen_api_thread_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_stacksize_set(skypopen_api_thread_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread, switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread,
skypopen_api_thread_attr, skypopen_do_skypeapi_thread, &globals.SKYPOPEN_INTERFACES[interface_id], skypopen_module_pool); skypopen_api_thread_attr, skypopen_do_skypeapi_thread, &globals.SKYPOPEN_INTERFACES[interface_id],
skypopen_module_pool);
switch_sleep(100000); switch_sleep(100000);
@ -1758,7 +1759,8 @@ static switch_status_t load_config(int reload_type)
DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].report_incoming_chatmessages=%d\n", SKYPOPEN_P_LOG, i, i, DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].report_incoming_chatmessages=%d\n", SKYPOPEN_P_LOG, i, i,
globals.SKYPOPEN_INTERFACES[i].report_incoming_chatmessages); globals.SKYPOPEN_INTERFACES[i].report_incoming_chatmessages);
DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].silent_mode=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].silent_mode); DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].silent_mode=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].silent_mode);
DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].write_silence_when_idle=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].write_silence_when_idle); DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].write_silence_when_idle=%d\n", SKYPOPEN_P_LOG, i, i,
globals.SKYPOPEN_INTERFACES[i].write_silence_when_idle);
DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].setsockopt=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].setsockopt); DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].setsockopt=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].setsockopt);
} }
} }
@ -1814,7 +1816,8 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
if (strlen(globals.SKYPOPEN_INTERFACES[i].name) if (strlen(globals.SKYPOPEN_INTERFACES[i].name)
&& (strncmp(globals.SKYPOPEN_INTERFACES[i].name, hint, strlen(hint)) == 0)) { && (strncmp(globals.SKYPOPEN_INTERFACES[i].name, hint, strlen(hint)) == 0)) {
tech_pvt = &globals.SKYPOPEN_INTERFACES[i]; tech_pvt = &globals.SKYPOPEN_INTERFACES[i];
DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i, globals.SKYPOPEN_INTERFACES[i].name); DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i,
globals.SKYPOPEN_INTERFACES[i].name);
found = 1; found = 1;
break; break;
} }
@ -1825,7 +1828,8 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
if (strlen(globals.SKYPOPEN_INTERFACES[i].name) if (strlen(globals.SKYPOPEN_INTERFACES[i].name)
&& (strncmp(globals.SKYPOPEN_INTERFACES[i].skype_user, from, strlen(from)) == 0)) { && (strncmp(globals.SKYPOPEN_INTERFACES[i].skype_user, from, strlen(from)) == 0)) {
tech_pvt = &globals.SKYPOPEN_INTERFACES[i]; tech_pvt = &globals.SKYPOPEN_INTERFACES[i];
DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i, globals.SKYPOPEN_INTERFACES[i].name); DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i,
globals.SKYPOPEN_INTERFACES[i].name);
found = 1; found = 1;
break; break;
} }
@ -1890,7 +1894,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypopen_load)
#endif #endif
// CLOUDTREE (Thomas Hazel) - load_configs no longer locks things up, no need to fail load // CLOUDTREE (Thomas Hazel) - load_configs no longer locks things up, no need to fail load
/*if (*/ load_config(FULL_RELOAD); /* != SWITCH_STATUS_SUCCESS) { /*if ( */ load_config(FULL_RELOAD);
/* != SWITCH_STATUS_SUCCESS) {
running = 0; running = 0;
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
@ -1919,7 +1924,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypopen_load)
SWITCH_ADD_API(commands_api_interface, "sk", "Skypopen console commands", sk_function, SK_SYNTAX); SWITCH_ADD_API(commands_api_interface, "sk", "Skypopen console commands", sk_function, SK_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "skypopen", "Skypopen interface commands", skypopen_function, SKYPOPEN_SYNTAX); SWITCH_ADD_API(commands_api_interface, "skypopen", "Skypopen interface commands", skypopen_function, SKYPOPEN_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "skypopen_chat", "Skypopen_chat interface remote_skypename TEXT", skypopen_chat_function, SKYPOPEN_CHAT_SYNTAX); SWITCH_ADD_API(commands_api_interface, "skypopen_chat", "Skypopen_chat interface remote_skypename TEXT", skypopen_chat_function,
SKYPOPEN_CHAT_SYNTAX);
SWITCH_ADD_CHAT(chat_interface, MDL_CHAT_PROTO, chat_send); SWITCH_ADD_CHAT(chat_interface, MDL_CHAT_PROTO, chat_send);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
@ -2518,7 +2524,10 @@ int skypopen_partner_handle_ring(private_t * tech_pvt)
giovatech = &globals.SKYPOPEN_INTERFACES[i]; giovatech = &globals.SKYPOPEN_INTERFACES[i];
if ((giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->ring_value, value)) && ((((timenow.tv_sec - giovatech->ring_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->ring_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds if ((giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->ring_value, value)) && ((((timenow.tv_sec - giovatech->ring_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->ring_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds
found = 1; found = 1;
DEBUGA_SKYPE ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value); DEBUGA_SKYPE
("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number,
value);
if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) { if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) {
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
} else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) { } else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) {
@ -2616,7 +2625,10 @@ int skypopen_answer(private_t * tech_pvt)
giovatech = &globals.SKYPOPEN_INTERFACES[i]; giovatech = &globals.SKYPOPEN_INTERFACES[i];
if (strlen(giovatech->skype_call_id) && (giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->callid_number, value)) && ((((timenow.tv_sec - giovatech->answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->answer_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds if (strlen(giovatech->skype_call_id) && (giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->callid_number, value)) && ((((timenow.tv_sec - giovatech->answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->answer_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds
found = 1; found = 1;
DEBUGA_SKYPE ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value); DEBUGA_SKYPE
("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number,
value);
if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) { if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) {
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
} else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) { } else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) {
@ -2691,6 +2703,7 @@ int skypopen_answer(private_t * tech_pvt)
switch_mutex_unlock(globals.mutex); switch_mutex_unlock(globals.mutex);
return 0; return 0;
} }
//int skypopen_transfer(private_t * tech_pvt, char *id, char *value) //int skypopen_transfer(private_t * tech_pvt, char *id, char *value)
int skypopen_transfer(private_t *tech_pvt) int skypopen_transfer(private_t *tech_pvt)
{ {
@ -2712,12 +2725,13 @@ int skypopen_transfer(private_t * tech_pvt)
/* let's look for a RINGING one */ /* let's look for a RINGING one */
if ((giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->ring_value, value)) && ((((timenow.tv_sec - giovatech->ring_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->ring_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds if ((giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->ring_value, value)) && ((((timenow.tv_sec - giovatech->ring_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->ring_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds
found = 1; found = 1;
DEBUGA_SKYPE ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value); DEBUGA_SKYPE
("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number,
value);
if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) { if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) {
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
} }
#if 0 #if 0
@ -2762,12 +2776,13 @@ int skypopen_transfer(private_t * tech_pvt)
/* let's look for a DOWN one */ /* let's look for a DOWN one */
if ((giovatech->interface_state == SKYPOPEN_STATE_DOWN || giovatech->interface_state == 0) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user))) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds if ((giovatech->interface_state == SKYPOPEN_STATE_DOWN || giovatech->interface_state == 0) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user))) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds
found = 1; found = 1;
DEBUGA_SKYPE ("FOUND (name=%s, giovatech->interface_state=%d == SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value); DEBUGA_SKYPE
("FOUND (name=%s, giovatech->interface_state=%d == SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n",
SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number,
value);
if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) { if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) {
tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; tech_pvt->interface_state = SKYPOPEN_STATE_DOWN;
} }
#if 0 #if 0

View File

@ -571,7 +571,8 @@ int skypopen_signaling_read(private_t * tech_pvt)
skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
/* we are NOT inside an active call */ /* we are NOT inside an active call */
DEBUGA_SKYPE("NO ACTIVE calls in this moment, skype_call %s is RINGING, to ask PARTNER_DISPNAME and PARTNER_HANDLE\n", SKYPOPEN_P_LOG, id); DEBUGA_SKYPE("NO ACTIVE calls in this moment, skype_call %s is RINGING, to ask PARTNER_DISPNAME and PARTNER_HANDLE\n",
SKYPOPEN_P_LOG, id);
sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
skypopen_signaling_write(tech_pvt, msg_to_skype); skypopen_signaling_write(tech_pvt, msg_to_skype);
skypopen_sleep(100); skypopen_sleep(100);
@ -591,7 +592,8 @@ int skypopen_signaling_read(private_t * tech_pvt)
DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n", SKYPOPEN_P_LOG, id); DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n", SKYPOPEN_P_LOG, id);
if (!remote_party_is_ringing(tech_pvt)) { if (!remote_party_is_ringing(tech_pvt)) {
WARNINGA("We are getting the RINGING from a call we canceled, trying to get out hanging up call id: %s.\n", SKYPOPEN_P_LOG, id); WARNINGA("We are getting the RINGING from a call we canceled, trying to get out hanging up call id: %s.\n",
SKYPOPEN_P_LOG, id);
sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
skypopen_signaling_write(tech_pvt, msg_to_skype); skypopen_signaling_write(tech_pvt, msg_to_skype);
sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id); sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id);