diff --git a/src/mod/endpoints/mod_skypopen/mod_skypopen.c b/src/mod/endpoints/mod_skypopen/mod_skypopen.c index babf5b1364..167357f47d 100644 --- a/src/mod/endpoints/mod_skypopen/mod_skypopen.c +++ b/src/mod/endpoints/mod_skypopen/mod_skypopen.c @@ -450,6 +450,8 @@ static switch_status_t channel_on_init(switch_core_session_t *session) channel = switch_core_session_get_channel(session); switch_assert(channel != NULL); + memset(tech_pvt->skype_voicemail_id, '\0', sizeof(tech_pvt->skype_voicemail_id)); + memset(tech_pvt->skype_voicemail_id_greeting, '\0', sizeof(tech_pvt->skype_voicemail_id_greeting)); switch_channel_set_variable(channel, "skype_user", tech_pvt->skype_user); switch_mutex_lock(tech_pvt->flag_mutex); switch_set_flag(tech_pvt, TFLAG_IO); @@ -621,15 +623,26 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session) if (strlen(tech_pvt->skype_call_id)) { DEBUGA_SKYPE("hanging up skype call: %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id); + if(strlen(tech_pvt->skype_voicemail_id_greeting)){ + sprintf(msg_to_skype, "ALTER VOICEMAIL %s STOPPLAYBACK", tech_pvt->skype_voicemail_id_greeting); + skypopen_signaling_write(tech_pvt, msg_to_skype); + switch_sleep(MS_SKYPOPEN * 1000 * 100);//XXX FIXME 2000 millisecs, 2 seconds, so it will record at least 1 second + } + + if(strlen(tech_pvt->skype_voicemail_id_greeting)){ + sprintf(msg_to_skype, "ALTER VOICEMAIL %s DELETE", tech_pvt->skype_voicemail_id_greeting); + skypopen_signaling_write(tech_pvt, msg_to_skype); + switch_sleep(MS_SKYPOPEN * 1000 * 10);//XXX FIXME 200 millisecs + } if(strlen(tech_pvt->skype_voicemail_id)){ sprintf(msg_to_skype, "ALTER VOICEMAIL %s STOPRECORDING", tech_pvt->skype_voicemail_id); skypopen_signaling_write(tech_pvt, msg_to_skype); - switch_sleep(MS_SKYPOPEN * 1000 * 3);//XXX FIXME ?? + switch_sleep(MS_SKYPOPEN * 1000 * 10);//XXX FIXME 200 millisecs } - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id); skypopen_signaling_write(tech_pvt, msg_to_skype); + sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id); + skypopen_signaling_write(tech_pvt, msg_to_skype); } DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPOPEN_P_LOG, tech_pvt->name); switch_mutex_lock(globals.mutex); diff --git a/src/mod/endpoints/mod_skypopen/skypopen.h b/src/mod/endpoints/mod_skypopen/skypopen.h index b2ee69235a..69cda02b9a 100644 --- a/src/mod/endpoints/mod_skypopen/skypopen.h +++ b/src/mod/endpoints/mod_skypopen/skypopen.h @@ -358,6 +358,7 @@ struct private_object { char message[4096]; char skype_voicemail_id[512]; + char skype_voicemail_id_greeting[512]; }; typedef struct private_object private_t; diff --git a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c index e961549d7e..6bd7d2f9af 100644 --- a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c +++ b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c @@ -245,6 +245,10 @@ int skypopen_signaling_read(private_t *tech_pvt) } else if (!strncasecmp(message, "ERROR 99 CALL", 12)) { DEBUGA_SKYPE("Skype got ERROR: |||%s|||, another call is active on this interface\n\n\n", SKYPOPEN_P_LOG, message); tech_pvt->interface_state = SKYPOPEN_STATE_ERROR_DOUBLE_CALL; + } else if (!strncasecmp(message, "ERROR 531 VOICEMAIL", 18)) { + NOTICA("Skype got ERROR about VOICEMAIL, no problem: |||%s|||\n", SKYPOPEN_P_LOG, message); + } else if (!strncasecmp(message, "ERROR 529 VOICEMAIL", 18)) { + NOTICA("Skype got ERROR about VOICEMAIL, no problem: |||%s|||\n", SKYPOPEN_P_LOG, message); } 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) | !strncasecmp(message, "ERROR 556 CALL", 13)) { @@ -563,38 +567,15 @@ int skypopen_signaling_read(private_t *tech_pvt) DEBUGA_SKYPE("VOICEMAIL %s OUTPUT\n", SKYPOPEN_P_LOG, id); sprintf(msg_to_skype, "ALTER VOICEMAIL %s SET_OUTPUT PORT=\"%d\"", id, tech_pvt->tcp_srv_port); skypopen_signaling_write(tech_pvt, msg_to_skype); + sprintf(tech_pvt->skype_voicemail_id_greeting, "%s", id); } else if (!strcasecmp(prop, "TYPE") && !strcasecmp(value, "OUTGOING") ) { DEBUGA_SKYPE("VOICEMAIL OUTGOING id is %s\n", SKYPOPEN_P_LOG, id); sprintf(tech_pvt->skype_voicemail_id, "%s", id); } else if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "PLAYED") ) { - switch_core_session_t *session = NULL; + switch_ivr_broadcast( tech_pvt->session_uuid_str, "gentones::%(500,0,800)",SMF_ECHO_ALEG|SMF_ECHO_BLEG); + memset(tech_pvt->skype_voicemail_id_greeting, '\0', sizeof(tech_pvt->skype_voicemail_id_greeting)); - session = switch_core_session_locate(tech_pvt->session_uuid_str); - if (session) { - char digit_str[2]; - char *p = digit_str; - switch_channel_t *channel = switch_core_session_get_channel(session); - - digit_str[0]='1'; - digit_str[1]='\0'; - - if (channel) { - - while (p && *p) { - switch_dtmf_t dtmf = { 0 }; - dtmf.digit = *p; - dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION; - switch_channel_queue_dtmf(channel, &dtmf); - p++; - } - } else { - WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG); - } - switch_core_session_rwunlock(session); - } else { - WARNINGA("NO SESSION ?\n", SKYPOPEN_P_LOG); - } } }