diff --git a/src/mod/endpoints/mod_skypopen/mod_skypopen.c b/src/mod/endpoints/mod_skypopen/mod_skypopen.c index 15f1aa4cbc..bfbc732c7d 100644 --- a/src/mod/endpoints/mod_skypopen/mod_skypopen.c +++ b/src/mod/endpoints/mod_skypopen/mod_skypopen.c @@ -586,7 +586,7 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int tech_pvt = switch_core_session_get_private(session); switch_assert(tech_pvt != NULL); - DEBUGA_SKYPE("%s CHANNEL KILL_CHANNEL\n", SKYPOPEN_P_LOG, tech_pvt->name); + //DEBUGA_SKYPE("%s CHANNEL KILL_CHANNEL\n", SKYPOPEN_P_LOG, tech_pvt->name); switch (sig) { case SWITCH_SIG_KILL: switch_mutex_lock(tech_pvt->flag_mutex); @@ -2536,16 +2536,54 @@ int skypopen_answer(private_t * tech_pvt) switch_mutex_unlock(globals.mutex); 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) { char msg_to_skype[1024]; int i; int found = 0; private_t *giovatech; struct timeval timenow; + char *id = tech_pvt->ring_id; + char *value = tech_pvt->ring_value; switch_mutex_lock(globals.mutex); + gettimeofday(&timenow, NULL); + for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { + if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { + + giovatech = &globals.SKYPOPEN_INTERFACES[i]; + /* 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 + 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); + if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) { + tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; + } + + +#if 0 + + + else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) { + WARNINGA("Why an interface_state %d HERE?\n", SKYPOPEN_P_LOG, tech_pvt->interface_state); + tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; + } + + *tech_pvt->answer_id = '\0'; + *tech_pvt->answer_value = '\0'; + *tech_pvt->ring_id = '\0'; + *tech_pvt->ring_value = '\0'; +#endif //0 + break; + } + } + } + + + /*****************************************/ +#if 0 gettimeofday(&timenow, NULL); for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { @@ -2561,6 +2599,39 @@ int skypopen_transfer(private_t * tech_pvt, char *id, char *value) } } } +#endif //0 + for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { + if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { + + giovatech = &globals.SKYPOPEN_INTERFACES[i]; + /* let's look for a DOWN one */ + NOTICA ("LOOKING (name=%s, giovatech->interface_state=%d == SKYPOPEN_STATE_DOWN[%d]) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, SKYPOPEN_STATE_DOWN, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, value); + 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; + 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) { + tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; + } + + +#if 0 + + + else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) { + WARNINGA("Why an interface_state %d HERE?\n", SKYPOPEN_P_LOG, tech_pvt->interface_state); + tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; + } + + *tech_pvt->answer_id = '\0'; + *tech_pvt->answer_value = '\0'; + *tech_pvt->ring_id = '\0'; + *tech_pvt->ring_value = '\0'; +#endif //0 + break; + } + } + } + if (found) { switch_mutex_unlock(globals.mutex); diff --git a/src/mod/endpoints/mod_skypopen/skypopen.h b/src/mod/endpoints/mod_skypopen/skypopen.h index 9128d887d2..77e00dace5 100644 --- a/src/mod/endpoints/mod_skypopen/skypopen.h +++ b/src/mod/endpoints/mod_skypopen/skypopen.h @@ -335,7 +335,8 @@ int remote_party_is_ringing(private_t * tech_pvt); int remote_party_is_early_media(private_t * tech_pvt); //int skypopen_answer(private_t * tech_pvt, char *id, char *value); int skypopen_answer(private_t * tech_pvt); -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); #ifndef WIN32 int skypopen_socket_create_and_bind(private_t * tech_pvt, int *which_port); #else diff --git a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c index a15b5643aa..ad69980388 100644 --- a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c +++ b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c @@ -215,12 +215,12 @@ int skypopen_signaling_read(private_t * tech_pvt) tech_pvt->interface_state = SKYPOPEN_STATE_ERROR_DOUBLE_CALL; } else if (!strncasecmp(message, "ERROR 592 ALTER CALL", 19)) { NOTICA("Skype got ERROR about TRANSFERRING, no problem: |||%s|||\n", SKYPOPEN_P_LOG, message); - } else if (!strncasecmp(message, "ERROR 559 CALL", 13)) { + } else if (!strncasecmp(message, "ERROR 559 CALL", 13) | !strncasecmp(message, "ERROR 556 CALL", 13)) { if (tech_pvt->interface_state == SKYPOPEN_STATE_PREANSWER) { DEBUGA_SKYPE("Skype got ERROR about a failed action (probably TRYING to ANSWER A CALL), let's go down: |||%s|||\n", SKYPOPEN_P_LOG, message); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - ERRORA("skype_call now is DOWN\n", SKYPOPEN_P_LOG); + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPOPEN_P_LOG); tech_pvt->skype_call_id[0] = '\0'; tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; return CALLFLOW_INCOMING_HANGUP; @@ -490,9 +490,13 @@ int skypopen_signaling_read(private_t * tech_pvt) /* this is the call in which we are calling out */ DEBUGA_SKYPE("Call %s DO NOTHING\n", SKYPOPEN_P_LOG, id); } else { - skypopen_sleep(400000); //0.4 seconds DEBUGA_SKYPE("Call %s TRY TRANSFER\n", SKYPOPEN_P_LOG, id); - skypopen_transfer(tech_pvt, id, value); + skypopen_strncpy(tech_pvt->ring_id, id, sizeof(tech_pvt->ring_id)); + skypopen_strncpy(tech_pvt->ring_value, value, sizeof(tech_pvt->ring_value)); + skypopen_strncpy(tech_pvt->answer_id, id, sizeof(tech_pvt->answer_id)); + skypopen_strncpy(tech_pvt->answer_value, value, sizeof(tech_pvt->answer_value)); + //skypopen_transfer(tech_pvt, id, value); + skypopen_transfer(tech_pvt); } } }