presence tweak

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9363 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-08-25 16:30:28 +00:00
parent 24d4819b50
commit ca79084134
7 changed files with 38 additions and 12 deletions

View File

@ -145,8 +145,9 @@ SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, s
\param channel the channel to initilize \param channel the channel to initilize
\param rpid the rpid if for the icon to use \param rpid the rpid if for the icon to use
\param status the status message \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 \brief Uninitalize a channel

View File

@ -606,6 +606,26 @@ SWITCH_STANDARD_APP(answer_function)
switch_channel_answer(switch_core_session_get_channel(session)); 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_STANDARD_APP(pre_answer_function)
{ {
switch_channel_pre_answer(switch_core_session_get_channel(session)); 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, "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, "[<cause>]", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[<cause>]", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "set_name", "Name the channel", "Name the channel", set_name_function, "<name>", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "set_name", "Name the channel", "Name the channel", set_name_function, "<name>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "presence", "Send Presence", "Send Presence.", presence_function, "<rpid> <status> [<id>]", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, "<log_level> <log_string>", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, "<log_level> <log_string>", 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, "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); SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA);

View File

@ -242,7 +242,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
if (tech_pvt->max_missed_packets) { if (tech_pvt->max_missed_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, 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 ((buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
if ((bsession = switch_core_session_locate(buuid))) { if ((bsession = switch_core_session_locate(buuid))) {

View File

@ -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_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
if (!switch_stristr("sendonly", r_sdp)) { if (!switch_stristr("sendonly", r_sdp)) {
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD); 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)) { } else if (switch_stristr("sendonly", r_sdp)) {
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD); 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);
} }

View File

@ -2087,7 +2087,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
const char *stream; const char *stream;
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD); 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) { if (tech_pvt->max_missed_hold_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, 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_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);
} }
} }

View File

@ -389,9 +389,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, s
return SWITCH_STATUS_SUCCESS; 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_t *event;
switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN; 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; type = SWITCH_EVENT_PRESENCE_OUT;
} }
if (!id) {
id = switch_channel_get_variable(channel, "presence_id");
}
if (!id) { if (!id) {
return; return;
} }
@ -783,7 +786,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
if (channel->state >= CS_ROUTING) { if (channel->state >= CS_ROUTING) {
switch_clear_flag(channel, CF_TRANSFER); 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) { 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_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_kill_channel(channel->session, SWITCH_SIG_KILL);
switch_core_session_signal_state_change(channel->session); switch_core_session_signal_state_change(channel->session);

View File

@ -1028,6 +1028,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(switch_c
{ {
const switch_application_interface_t *application_interface; const switch_application_interface_t *application_interface;
char *expanded = NULL; char *expanded = NULL;
const char *var;
if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) { 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); 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); 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; char *myarg = NULL;
if (expanded) { if (expanded) {
myarg = switch_mprintf("%s(%s)", app, 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); myarg = switch_mprintf("%s", app);
} }
if (myarg) { if (myarg) {
switch_channel_presence(session->channel, "unknown", myarg); switch_channel_presence(session->channel, "unknown", myarg, NULL);
switch_safe_free(myarg); switch_safe_free(myarg);
} }
} }