diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 9b197fc93b..b2485def1d 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -145,8 +145,9 @@ SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, s \param channel the channel to initilize \param rpid the rpid if for the icon to use \param status the status message + \param id presence id */ -SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status); +SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status, const char *id); /*! \brief Uninitalize a channel diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 9ea624cedf..281775da11 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -606,6 +606,26 @@ SWITCH_STANDARD_APP(answer_function) switch_channel_answer(switch_core_session_get_channel(session)); } +SWITCH_STANDARD_APP(presence_function) +{ + char *argv[6] = { 0 }; + int argc; + char *mydata = NULL; + switch_channel_t *channel = switch_core_session_get_channel(session); + + if (switch_strlen_zero(data) || !(mydata = switch_core_session_strdup(session, data))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n"); + return; + } + + if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 2) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n"); + return; + } + + switch_channel_presence(channel, argv[0], argv[1], argv[2]); +} + SWITCH_STANDARD_APP(pre_answer_function) { switch_channel_pre_answer(switch_core_session_get_channel(session)); @@ -2248,6 +2268,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[]", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "set_name", "Name the channel", "Name the channel", set_name_function, "", SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "presence", "Send Presence", "Send Presence.", presence_function, " []", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, " ", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index c882e58005..76389b8443 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -242,7 +242,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) if (tech_pvt->max_missed_packets) { switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets); } - switch_channel_presence(tech_pvt->channel, "unknown", "unhold"); + switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL); if ((buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { if ((bsession = switch_core_session_locate(buuid))) { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 8fdb2374fb..e30d1adb97 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2389,11 +2389,11 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) { if (!switch_stristr("sendonly", r_sdp)) { switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD); - switch_channel_presence(tech_pvt->channel, "unknown", "unhold"); + switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL); } } else if (switch_stristr("sendonly", r_sdp)) { switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD); - switch_channel_presence(tech_pvt->channel, "unknown", "hold"); + switch_channel_presence(tech_pvt->channel, "unknown", "hold", NULL); } diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index abc1e5ce01..40539f7bb8 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -2087,7 +2087,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * const char *stream; switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD); - switch_channel_presence(tech_pvt->channel, "unknown", "hold"); + switch_channel_presence(tech_pvt->channel, "unknown", "hold", NULL); if (tech_pvt->max_missed_hold_packets) { switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_hold_packets); @@ -2134,7 +2134,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * } switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD); - switch_channel_presence(tech_pvt->channel, "unknown", "unhold"); + switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL); } } diff --git a/src/switch_channel.c b/src/switch_channel.c index 4384bb83f1..f833092d1f 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -389,9 +389,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, s return SWITCH_STATUS_SUCCESS; } -SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status) +SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status, const char *id) { - const char *id = switch_channel_get_variable(channel, "presence_id"); switch_event_t *event; switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN; @@ -399,6 +398,10 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch type = SWITCH_EVENT_PRESENCE_OUT; } + if (!id) { + id = switch_channel_get_variable(channel, "presence_id"); + } + if (!id) { return; } @@ -783,7 +786,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state( if (channel->state >= CS_ROUTING) { switch_clear_flag(channel, CF_TRANSFER); - switch_channel_presence(channel, "unknown", (char *) state_names[state]); + switch_channel_presence(channel, "unknown", (char *) state_names[state], NULL); } if (state < CS_HANGUP) { @@ -1360,7 +1363,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan } switch_channel_set_variable(channel, "hangup_cause", switch_channel_cause2str(channel->hangup_cause)); - switch_channel_presence(channel, "unavailable", switch_channel_cause2str(channel->hangup_cause)); + switch_channel_presence(channel, "unavailable", switch_channel_cause2str(channel->hangup_cause), NULL); switch_core_session_kill_channel(channel->session, SWITCH_SIG_KILL); switch_core_session_signal_state_change(channel->session); diff --git a/src/switch_core_session.c b/src/switch_core_session.c index ec99cb02c4..de3af6b705 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -1028,6 +1028,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(switch_c { const switch_application_interface_t *application_interface; char *expanded = NULL; + const char *var; if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", app); @@ -1058,7 +1059,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(switch_c switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Expanded String %s(%s)\n", switch_channel_get_name(session->channel), app, expanded); } - if (switch_channel_get_variable(session->channel, "presence_id")) { + if ((var = switch_channel_get_variable(session->channel, "verbose_presence")) && switch_true(var)) { char *myarg = NULL; if (expanded) { myarg = switch_mprintf("%s(%s)", app, expanded); @@ -1068,7 +1069,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(switch_c myarg = switch_mprintf("%s", app); } if (myarg) { - switch_channel_presence(session->channel, "unknown", myarg); + switch_channel_presence(session->channel, "unknown", myarg, NULL); switch_safe_free(myarg); } }