提交 6df9d441 authored 作者: Anthony Minessale's avatar Anthony Minessale

auto update displays in more places

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15110 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 eea99cb1
......@@ -67,6 +67,10 @@ SWITCH_BEGIN_EXTERN_C
const char *caller_id_name;
/*! Caller ID Number */
const char *caller_id_number;
/*! Callee ID Name */
const char *callee_id_name;
/*! Callee ID Number */
const char *callee_id_number;
uint8_t caller_ton;
uint8_t caller_numplan;
/*! Caller Network Address (when applicable) */
......
......@@ -92,7 +92,7 @@ struct switch_core_session_message {
const char *_file;
const char *_func;
int _line;
const char *string_array_arg[10];
};
/*! \brief A generic object to pass as a thread's session object to allow mutiple arguements and a pool */
......
......@@ -408,6 +408,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
switch_originate_flag_t flags
);
SWITCH_DECLARE(void) switch_ivr_bridge_display(switch_core_session_t *session, switch_core_session_t *peer_session);
/*!
\brief Bridge Audio from one session to another
\param session one session
......
......@@ -792,7 +792,7 @@ SWITCH_STANDARD_APP(set_profile_var_function)
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n");
} else {
name = switch_core_session_strdup(session, data);
name = switch_core_strdup(caller_profile->pool, data);
val = strchr(name, '=');
if (val) {
......@@ -816,6 +816,12 @@ SWITCH_STANDARD_APP(set_profile_var_function)
if (!strcasecmp(name, "caller_id_number")) {
caller_profile->caller_id_number = val;
}
if (!strcasecmp(name, "callee_id_name")) {
caller_profile->callee_id_name = val;
}
if (!strcasecmp(name, "callee_id_number")) {
caller_profile->callee_id_number = val;
}
if (val && !strcasecmp(name, "caller_ton")) {
caller_profile->caller_ton = (uint8_t) atoi(val);
}
......
......@@ -175,7 +175,7 @@ static switch_status_t sofia_on_execute(switch_core_session_t *session)
return SWITCH_STATUS_SUCCESS;
}
char * generate_pai_str(switch_core_session_t *session)
char *generate_pai_str(switch_core_session_t *session)
{
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
const char *callee_name = NULL, *callee_number = NULL;
......@@ -185,6 +185,12 @@ char * generate_pai_str(switch_core_session_t *session)
if (!(callee_number = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_number"))) {
callee_number = tech_pvt->caller_profile->destination_number;
}
if (!strchr(callee_number, '@')) {
char *tmp = switch_core_session_sprintf(session, "sip:%s@cluecon.com", callee_number);
callee_number = tmp;
}
pai = switch_core_session_sprintf(tech_pvt->session, "P-Asserted-Identity: \"%s\" <%s>", callee_name, callee_number);
}
return pai;
......@@ -1257,20 +1263,46 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
case SWITCH_MESSAGE_INDICATE_DISPLAY:
{
if (!switch_strlen_zero(msg->string_arg)) {
const char *name = msg->string_array_arg[0], *number = msg->string_array_arg[1];
char *arg = NULL;
char *argv[2] = { 0 };
int argc;
if (switch_strlen_zero(name) && !switch_strlen_zero(msg->string_arg)) {
arg = strdup(msg->string_arg);
switch_assert(arg);
argc = switch_separate_string(arg, '|', argv, (sizeof(argv) / sizeof(argv[0])));
name = argv[0];
number = argv[1];
}
if (!switch_strlen_zero(name)) {
char message[256] = "";
const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent");
if (switch_strlen_zero(number)) {
number = tech_pvt->caller_profile->destination_number;
}
if (ua && switch_stristr("snom", ua)) {
snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", msg->string_arg, tech_pvt->caller_profile->destination_number);
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
} else if (ua && switch_stristr("polycom", ua)) {
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", msg->string_arg, tech_pvt->caller_profile->destination_number);
snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", name, number);
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
SIPTAG_PAYLOAD_STR(message), TAG_END());
} else if (ua && (switch_stristr("polycom", ua) || switch_stristr("FreeSWITCH", ua))) {
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", name, number);
nua_update(tech_pvt->nh,
TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)),
TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
TAG_END());
}
}
switch_safe_free(arg);
}
break;
......@@ -1284,11 +1316,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (ua && switch_stristr("snom", ua)) {
snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", msg->string_arg, tech_pvt->caller_profile->destination_number);
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
SIPTAG_PAYLOAD_STR(message), TAG_END());
} else if (ua && switch_stristr("polycom", ua)) {
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", msg->string_arg, tech_pvt->caller_profile->destination_number);
nua_update(tech_pvt->nh,
TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)),
TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
TAG_END());
}
}
......@@ -1553,6 +1588,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
end_lock:
if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) {
sofia_send_callee_id(session, NULL, NULL);
}
switch_mutex_unlock(tech_pvt->sofia_mutex);
end:
......@@ -2669,12 +2708,12 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
{
switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
switch_core_session_t *nsession = NULL;
char *data, *profile_name, *dest;
char *data, *profile_name, *dest, *dest_num = NULL;
sofia_profile_t *profile = NULL;
switch_caller_profile_t *caller_profile = NULL;
private_object_t *tech_pvt = NULL;
switch_channel_t *nchannel;
char *host = NULL, *dest_to = NULL;
char *host = NULL, *dest_to = NULL, *p;
const char *hval = NULL;
*new_session = NULL;
......@@ -2894,8 +2933,16 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
}
switch_channel_set_variable(nchannel, "sip_destination_url", tech_pvt->dest);
dest_num = switch_core_session_strdup(nsession, dest);
if ((p = strchr(dest_num, ':'))) {
dest_num = p + 1;
if ((p = strchr(dest_num, '@'))) {
*p = '\0';
}
}
caller_profile = switch_caller_profile_clone(nsession, outbound_profile);
caller_profile->destination_number = switch_core_strdup(caller_profile->pool, dest);
caller_profile->destination_number = switch_core_strdup(caller_profile->pool, dest_num);
switch_channel_set_caller_profile(nchannel, caller_profile);
switch_channel_set_flag(nchannel, CF_OUTBOUND);
sofia_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
......
......@@ -147,7 +147,8 @@ typedef struct sip_alias_node sip_alias_node_t;
typedef enum {
MFLAG_REFER = (1 << 0),
MFLAG_REGISTER = (1 << 1)
MFLAG_REGISTER = (1 << 1),
MFLAG_UPDATE = (1 << 2)
} MFLAGS;
typedef enum {
......@@ -910,3 +911,6 @@ void sofia_glue_free_destination(sofia_destination_t *dst);
switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype, const char *body, const char *o_contact, const char *network_ip);
char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix);
void sofia_glue_set_extra_headers(switch_channel_t *channel, sip_t const *sip, const char *prefix);
void sofia_info_send_sipfrag(switch_core_session_t *aleg, switch_core_session_t *bleg);
void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *profile, sip_t const *sip, switch_bool_t send);
void sofia_send_callee_id(switch_core_session_t *session, const char *name, const char *number);
......@@ -78,7 +78,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor
profile_dup_clean(destination_number, profile->destination_number, pool);
profile->uuid = SWITCH_BLANK_STRING;
profile->chan_name = SWITCH_BLANK_STRING;
profile->callee_id_name = SWITCH_BLANK_STRING;
profile->callee_id_number = SWITCH_BLANK_STRING;
switch_set_flag(profile, SWITCH_CPF_SCREEN);
profile->pool = pool;
return profile;
......@@ -95,6 +96,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_dup(switch_memor
profile_dup(tocopy->dialplan, profile->dialplan, pool);
profile_dup(tocopy->caller_id_name, profile->caller_id_name, pool);
profile_dup(tocopy->caller_id_number, profile->caller_id_number, pool);
profile_dup(tocopy->callee_id_name, profile->callee_id_name, pool);
profile_dup(tocopy->callee_id_number, profile->callee_id_number, pool);
profile_dup(tocopy->network_addr, profile->network_addr, pool);
profile_dup(tocopy->ani, profile->ani, pool);
profile_dup(tocopy->aniii, profile->aniii, pool);
......@@ -139,15 +142,21 @@ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(switch_caller_profi
if (!strcasecmp(name, "caller_id_name")) {
return caller_profile->caller_id_name;
}
if (!strcasecmp(name, "caller_id_number")) {
return caller_profile->caller_id_number;
}
if (!strcasecmp(name, "callee_id_name")) {
return caller_profile->callee_id_name;
}
if (!strcasecmp(name, "callee_id_number")) {
return caller_profile->callee_id_number;
}
if (!strcasecmp(name, "ani")) {
return caller_profile->ani;
}
if (!strcasecmp(name, "aniii")) {
return caller_profile->aniii;
}
if (!strcasecmp(name, "caller_id_number")) {
return caller_profile->caller_id_number;
}
if (!strcasecmp(name, "network_addr")) {
return caller_profile->network_addr;
}
......
......@@ -78,6 +78,58 @@ static void launch_video(struct vid_helper *vh)
}
#endif
static void send_display(switch_core_session_t *session, switch_core_session_t *peer_session) {
switch_core_session_message_t msg = { 0 };
switch_caller_profile_t *caller_profile;
switch_channel_t *caller_channel;
const char *name, *number;
caller_channel = switch_core_session_get_channel(session);
caller_profile = switch_channel_get_caller_profile(caller_channel);
if (switch_channel_direction(caller_channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
name = caller_profile->callee_id_name;
number = caller_profile->callee_id_number;
if (switch_strlen_zero(name)) {
name = caller_profile->destination_number;
}
if (switch_strlen_zero(number)) {
number = caller_profile->destination_number;
}
} else {
name = caller_profile->caller_id_name;
number = caller_profile->caller_id_number;
if (switch_strlen_zero(name)) {
name = caller_profile->destination_number;
}
if (switch_strlen_zero(number)) {
number = caller_profile->destination_number;
}
}
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
msg.string_array_arg[0] = name;
msg.string_array_arg[1] = number;
msg.from = __FILE__;
switch_core_session_receive_message(peer_session, &msg);
}
SWITCH_DECLARE(void) switch_ivr_bridge_display(switch_core_session_t *session, switch_core_session_t *peer_session)
{
send_display(session, peer_session);
send_display(peer_session, session);
}
struct switch_ivr_bridge_data {
switch_core_session_t *session;
char b_uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
......@@ -838,6 +890,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Call has no media... Redirecting to signal bridge.\n");
return switch_ivr_signal_bridge(session, peer_session);
}
switch_ivr_bridge_display(session, peer_session);
switch_channel_set_flag(caller_channel, CF_BRIDGE_ORIGINATOR);
......@@ -1084,8 +1138,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu
switch_core_session_t *originator_session, *originatee_session, *swap_session;
switch_channel_t *originator_channel, *originatee_channel, *swap_channel;
switch_status_t status = SWITCH_STATUS_FALSE;
switch_caller_profile_t *cp, *originator_cp, *originatee_cp;
char *p;
switch_caller_profile_t *originator_cp, *originatee_cp;
switch_channel_state_t state;
if ((originator_session = switch_core_session_locate(originator_uuid))) {
......@@ -1153,26 +1206,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu
switch_channel_set_variable(originator_channel, "original_caller_id_name", originator_cp->caller_id_name);
switch_channel_set_variable(originator_channel, "original_caller_id_number", originator_cp->caller_id_number);
cp = switch_caller_profile_clone(originatee_session, originatee_cp);
cp->destination_number = switch_core_strdup(cp->pool, originator_cp->caller_id_number);
cp->caller_id_number = switch_core_strdup(cp->pool, originator_cp->caller_id_number);
cp->caller_id_name = switch_core_strdup(cp->pool, originator_cp->caller_id_name);
cp->rdnis = switch_core_strdup(cp->pool, originatee_cp->destination_number);
if ((p = strchr(cp->rdnis, '@'))) {
*p = '\0';
}
switch_channel_set_caller_profile(originatee_channel, cp);
switch_channel_set_originator_caller_profile(originatee_channel, switch_caller_profile_clone(originatee_session, originator_cp));
cp = switch_caller_profile_clone(originator_session, originator_cp);
cp->destination_number = switch_core_strdup(cp->pool, originatee_cp->caller_id_number);
cp->caller_id_number = switch_core_strdup(cp->pool, originatee_cp->caller_id_number);
cp->caller_id_name = switch_core_strdup(cp->pool, originatee_cp->caller_id_name);
cp->rdnis = switch_core_strdup(cp->pool, originator_cp->destination_number);
if ((p = strchr(cp->rdnis, '@'))) {
*p = '\0';
}
switch_channel_set_caller_profile(originator_channel, cp);
switch_channel_set_originator_caller_profile(originatee_channel, switch_caller_profile_clone(originatee_session, originator_cp));
switch_channel_set_originatee_caller_profile(originator_channel, switch_caller_profile_clone(originator_session, originatee_cp));
switch_channel_stop_broadcast(originator_channel);
......@@ -1203,6 +1238,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu
status = SWITCH_STATUS_SUCCESS;
switch_ivr_bridge_display(originator_session, originatee_session);
/* release the read locks we have on the channels */
switch_core_session_rwunlock(originator_session);
switch_core_session_rwunlock(originatee_session);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论