[Freeswitch-svn] [commit] r5669 - in freeswitch/trunk/src: . include
Freeswitch SVN
mikej at freeswitch.org
Tue Aug 28 12:41:39 EDT 2007
Author: mikej
Date: Tue Aug 28 12:41:38 2007
New Revision: 5669
Modified:
freeswitch/trunk/src/include/switch_caller.h
freeswitch/trunk/src/switch_caller.c
Log:
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.
Modified: freeswitch/trunk/src/include/switch_caller.h
==============================================================================
--- freeswitch/trunk/src/include/switch_caller.h (original)
+++ freeswitch/trunk/src/include/switch_caller.h Tue Aug 28 12:41:38 2007
@@ -99,6 +99,7 @@
struct switch_caller_profile *originatee_caller_profile;
struct switch_channel_timetable *times;
struct switch_caller_extension *caller_extension;
+ switch_memory_pool_t *pool;
struct switch_caller_profile *next;
};
@@ -189,10 +190,16 @@
\param session session associated with the profile (bound by scope)
\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);
/*!
+ \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
\param caller_profile the desired profile
\param prefix a prefix string to all of the field names (for uniqueness)
Modified: freeswitch/trunk/src/switch_caller.c
==============================================================================
--- freeswitch/trunk/src/switch_caller.c (original)
+++ freeswitch/trunk/src/switch_caller.c Tue Aug 28 12:41:38 2007
@@ -63,29 +63,31 @@
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)));
switch_set_flag(profile, SWITCH_CPF_SCREEN);
+ profile->pool = pool;
}
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;
- if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile_t))) != 0) {
- profile->username = switch_core_session_strdup(session, tocopy->username);
- profile->dialplan = switch_core_session_strdup(session, tocopy->dialplan);
- profile->caller_id_name = switch_core_session_strdup(session, tocopy->caller_id_name);
- profile->ani = switch_core_session_strdup(session, tocopy->ani);
- profile->aniii = switch_core_session_strdup(session, tocopy->aniii);
- profile->caller_id_number = switch_core_session_strdup(session, tocopy->caller_id_number);
- profile->network_addr = switch_core_session_strdup(session, tocopy->network_addr);
- profile->rdnis = switch_core_session_strdup(session, tocopy->rdnis);
- profile->destination_number = switch_core_session_strdup(session, tocopy->destination_number);
- profile->uuid = switch_core_session_strdup(session, tocopy->uuid);
- profile->source = switch_core_session_strdup(session, tocopy->source);
- profile->context = switch_core_session_strdup(session, tocopy->context);
- profile->chan_name = switch_core_session_strdup(session, tocopy->chan_name);
+
+ if ((profile = switch_core_alloc(pool, sizeof(switch_caller_profile_t))) != 0) {
+ profile->username = switch_core_strdup(pool, tocopy->username);
+ profile->dialplan = switch_core_strdup(pool, tocopy->dialplan);
+ profile->caller_id_name = switch_core_strdup(pool, tocopy->caller_id_name);
+ profile->ani = switch_core_strdup(pool, tocopy->ani);
+ profile->aniii = switch_core_strdup(pool, tocopy->aniii);
+ profile->caller_id_number = switch_core_strdup(pool, tocopy->caller_id_number);
+ profile->network_addr = switch_core_strdup(pool, tocopy->network_addr);
+ profile->rdnis = switch_core_strdup(pool, tocopy->rdnis);
+ profile->destination_number = switch_core_strdup(pool, tocopy->destination_number);
+ profile->uuid = switch_core_strdup(pool, tocopy->uuid);
+ profile->source = switch_core_strdup(pool, tocopy->source);
+ 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_numplan = tocopy->caller_numplan;
profile->ani_ton = tocopy->ani_ton;
@@ -95,11 +97,23 @@
profile->destination_number_ton = tocopy->destination_number_ton;
profile->destination_number_numplan = tocopy->destination_number_numplan;
profile->flags = tocopy->flags;
+ profile->pool = pool;
}
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)
{
if (!strcasecmp(name, "dialplan")) {
@@ -141,6 +155,30 @@
if (!strcasecmp(name, "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;
}
More information about the Freeswitch-svn
mailing list