提交 352cc958 authored 作者: Michael Jerris's avatar Michael Jerris

add ability to match in dialplan to the ton and numplan caller profile fields.…

add ability to match in dialplan to the ton and numplan caller profile fields. added switch_caller_profile_dup function to be used in the future for places where we copy one profile to another to reduce code duplication.  add "pool" member to the caller profile for when we need to allocate strings off that pool.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5669 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 8dc23d38
...@@ -99,6 +99,7 @@ SWITCH_BEGIN_EXTERN_C ...@@ -99,6 +99,7 @@ SWITCH_BEGIN_EXTERN_C
struct switch_caller_profile *originatee_caller_profile; struct switch_caller_profile *originatee_caller_profile;
struct switch_channel_timetable *times; struct switch_channel_timetable *times;
struct switch_caller_extension *caller_extension; struct switch_caller_extension *caller_extension;
switch_memory_pool_t *pool;
struct switch_caller_profile *next; struct switch_caller_profile *next;
}; };
...@@ -189,9 +190,15 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor ...@@ -189,9 +190,15 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor
\param session session associated with the profile (bound by scope) \param session session associated with the profile (bound by scope)
\param tocopy the existing profile \param tocopy the existing profile
*/ */
SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy); SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy);
/*!
\brief Duplicate an existing caller profile object
\param pool pool to duplicate with
\param tocopy the existing profile
*/
SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_dup(switch_memory_pool_t *pool, switch_caller_profile_t *tocopy);
/*! /*!
\brief Add headers to an existing event in regards to a specific profile \brief Add headers to an existing event in regards to a specific profile
\param caller_profile the desired profile \param caller_profile the desired profile
......
...@@ -63,29 +63,31 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor ...@@ -63,29 +63,31 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor
profile->context = switch_clean_string(switch_core_strdup(pool, switch_str_nil(context))); profile->context = switch_clean_string(switch_core_strdup(pool, switch_str_nil(context)));
profile->destination_number = switch_clean_string(switch_core_strdup(pool, switch_str_nil(destination_number))); profile->destination_number = switch_clean_string(switch_core_strdup(pool, switch_str_nil(destination_number)));
switch_set_flag(profile, SWITCH_CPF_SCREEN); switch_set_flag(profile, SWITCH_CPF_SCREEN);
profile->pool = pool;
} }
return profile; return profile;
} }
SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy) SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_dup(switch_memory_pool_t *pool, switch_caller_profile_t *tocopy)
{ {
switch_caller_profile_t *profile = NULL; switch_caller_profile_t *profile = NULL;
if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile_t))) != 0) {
profile->username = switch_core_session_strdup(session, tocopy->username); if ((profile = switch_core_alloc(pool, sizeof(switch_caller_profile_t))) != 0) {
profile->dialplan = switch_core_session_strdup(session, tocopy->dialplan); profile->username = switch_core_strdup(pool, tocopy->username);
profile->caller_id_name = switch_core_session_strdup(session, tocopy->caller_id_name); profile->dialplan = switch_core_strdup(pool, tocopy->dialplan);
profile->ani = switch_core_session_strdup(session, tocopy->ani); profile->caller_id_name = switch_core_strdup(pool, tocopy->caller_id_name);
profile->aniii = switch_core_session_strdup(session, tocopy->aniii); profile->ani = switch_core_strdup(pool, tocopy->ani);
profile->caller_id_number = switch_core_session_strdup(session, tocopy->caller_id_number); profile->aniii = switch_core_strdup(pool, tocopy->aniii);
profile->network_addr = switch_core_session_strdup(session, tocopy->network_addr); profile->caller_id_number = switch_core_strdup(pool, tocopy->caller_id_number);
profile->rdnis = switch_core_session_strdup(session, tocopy->rdnis); profile->network_addr = switch_core_strdup(pool, tocopy->network_addr);
profile->destination_number = switch_core_session_strdup(session, tocopy->destination_number); profile->rdnis = switch_core_strdup(pool, tocopy->rdnis);
profile->uuid = switch_core_session_strdup(session, tocopy->uuid); profile->destination_number = switch_core_strdup(pool, tocopy->destination_number);
profile->source = switch_core_session_strdup(session, tocopy->source); profile->uuid = switch_core_strdup(pool, tocopy->uuid);
profile->context = switch_core_session_strdup(session, tocopy->context); profile->source = switch_core_strdup(pool, tocopy->source);
profile->chan_name = switch_core_session_strdup(session, tocopy->chan_name); profile->context = switch_core_strdup(pool, tocopy->context);
profile->chan_name = switch_core_strdup(pool, tocopy->chan_name);
profile->caller_ton = tocopy->caller_ton; profile->caller_ton = tocopy->caller_ton;
profile->caller_numplan = tocopy->caller_numplan; profile->caller_numplan = tocopy->caller_numplan;
profile->ani_ton = tocopy->ani_ton; profile->ani_ton = tocopy->ani_ton;
...@@ -95,11 +97,23 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_cor ...@@ -95,11 +97,23 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_cor
profile->destination_number_ton = tocopy->destination_number_ton; profile->destination_number_ton = tocopy->destination_number_ton;
profile->destination_number_numplan = tocopy->destination_number_numplan; profile->destination_number_numplan = tocopy->destination_number_numplan;
profile->flags = tocopy->flags; profile->flags = tocopy->flags;
profile->pool = pool;
} }
return profile; return profile;
} }
SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy)
{
switch_memory_pool_t *pool;
pool = switch_core_session_get_pool(session);
return switch_caller_profile_dup(pool, tocopy);
}
SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, const char *name) SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, const char *name)
{ {
if (!strcasecmp(name, "dialplan")) { if (!strcasecmp(name, "dialplan")) {
...@@ -141,6 +155,30 @@ SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t * ...@@ -141,6 +155,30 @@ SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *
if (!strcasecmp(name, "chan_name")) { if (!strcasecmp(name, "chan_name")) {
return caller_profile->chan_name; return caller_profile->chan_name;
} }
if (!strcasecmp(name, "caller_ton")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_ton);
}
if (!strcasecmp(name, "caller_numplan")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_numplan);
}
if (!strcasecmp(name, "destination_number_ton")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_ton);
}
if (!strcasecmp(name, "destination_number_numplan")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_numplan);
}
if (!strcasecmp(name, "ani_ton")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_ton);
}
if (!strcasecmp(name, "ani_numplan")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_numplan);
}
if (!strcasecmp(name, "rdnis_ton")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_ton);
}
if (!strcasecmp(name, "rdnis_numplan")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_numplan);
}
return NULL; return NULL;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论