fix a bunch of stuff

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7854 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-03-11 03:45:16 +00:00
parent dc5c28e1f9
commit 74a3d8ab95
17 changed files with 139 additions and 65 deletions
@@ -1081,7 +1081,7 @@ SWITCH_STANDARD_API(sched_broadcast_function)
return SWITCH_STATUS_SUCCESS;
}
#define HOLD_SYNTAX "<uuid>"
#define HOLD_SYNTAX "<uuid> [<display>]"
SWITCH_STANDARD_API(uuid_hold_function)
{
char *mycmd = NULL, *argv[4] = { 0 };
@@ -1102,7 +1102,49 @@ SWITCH_STANDARD_API(uuid_hold_function)
if (!strcasecmp(argv[0], "off")) {
status = switch_ivr_unhold_uuid(argv[1]);
} else {
status = switch_ivr_hold_uuid(argv[0]);
status = switch_ivr_hold_uuid(argv[0], argv[1]);
}
}
if (status == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK Success\n");
} else {
stream->write_function(stream, "-ERR Operation Failed\n");
}
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS;
}
#define DISPLAY_SYNTAX "<uuid> <display>"
SWITCH_STANDARD_API(uuid_display_function)
{
char *mycmd = NULL, *argv[2] = { 0 };
int argc = 0;
switch_status_t status = SWITCH_STATUS_FALSE;
if (session) {
return status;
}
if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc < 2 || switch_strlen_zero(argv[0]) || switch_strlen_zero(argv[1])) {
stream->write_function(stream, "-USAGE: %s\n", HOLD_SYNTAX);
} else {
switch_core_session_message_t msg = { 0 };
switch_core_session_t *lsession = NULL;
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
msg.string_arg = argv[1];
msg.from = __FILE__;
if ((lsession = switch_core_session_locate(argv[0]))) {
status = switch_core_session_receive_message(lsession, &msg);
switch_core_session_rwunlock(lsession);
}
}
@@ -2152,6 +2194,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
SWITCH_ADD_API(commands_api_interface, "uuid_broadcast", "broadcast", uuid_broadcast_function, BROADCAST_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "hold", "hold (depricated)", uuid_hold_function, HOLD_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_display", "change display", uuid_display_function, DISPLAY_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "media", "media (depricated)", uuid_media_function, MEDIA_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "fsctl", "control messages", ctl_function, CTL_SYNTAX);
@@ -374,6 +374,17 @@ SWITCH_STANDARD_APP(redirect_function)
switch_core_session_receive_message(session, &msg);
}
SWITCH_STANDARD_APP(display_function)
{
switch_core_session_message_t msg = { 0 };
/* Tell the channel to redirect */
msg.from = __FILE__;
msg.string_arg = data;
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
switch_core_session_receive_message(session, &msg);
}
SWITCH_STANDARD_APP(respond_function)
{
switch_core_session_message_t msg = { 0 };
@@ -1588,6 +1599,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE);
SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "deflect", "Send call deflect", "Send a call deflect.", deflect_function, "<deflect_data>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "reject", "Send session reject (depricated)", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
-4
View File
@@ -572,10 +572,6 @@ SWITCH_STANDARD_DIALPLAN(enum_dialplan_hunt)
free_results(&results);
}
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
}
return extension;
}
@@ -284,10 +284,6 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
switch_config_close_file(&cfg);
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
}
return extension;
}
@@ -138,11 +138,6 @@ SWITCH_STANDARD_DIALPLAN(directory_dialplan_hunt)
switch_core_directory_close(&dh);
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
}
return extension;
}
@@ -274,10 +274,6 @@ SWITCH_STANDARD_DIALPLAN(dialplan_hunt)
switch_xml_free(xml);
xml = NULL;
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
}
done:
switch_xml_free(xml);
return extension;
+19 -1
View File
@@ -100,12 +100,14 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
if (sofia_glue_do_invite(session) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
assert( switch_channel_get_state(channel) != CS_INIT);
return SWITCH_STATUS_FALSE;
}
}
/* Move Channel's State Machine to RING */
switch_channel_set_state(channel, CS_RING);
assert( switch_channel_get_state(channel) != CS_INIT);
return SWITCH_STATUS_SUCCESS;
}
@@ -538,6 +540,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
tech_pvt->read_frame.flags = SFF_NONE;
status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
if (status == SWITCH_STATUS_TIMEOUT) {
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_MEDIA_TIMEOUT);
@@ -552,7 +555,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, &dtmf);
switch_channel_queue_dtmf(channel, &dtmf);
}
if (tech_pvt->read_frame.datalen > 0) {
size_t bytes = 0;
int frames = 1;
@@ -844,10 +847,25 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
}
break;
case SWITCH_MESSAGE_INDICATE_DISPLAY:
{
if (!switch_strlen_zero(msg->string_arg)) {
char message[256] = "";
snprintf(message, sizeof(message), "From:\r\nTo: \"%s\"\r\n", msg->string_arg);
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
}
}
break;
case SWITCH_MESSAGE_INDICATE_HOLD:
{
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
sofia_glue_do_invite(session);
if (!switch_strlen_zero(msg->string_arg)) {
char message[256] = "";
snprintf(message, sizeof(message), "From:\r\nTo: \"%s\"\r\n", msg->string_arg);
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
}
}
break;