Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

switch_caller.c File Reference


Defines

#define profile_dup(a, b, p)   if (!switch_strlen_zero(a)) { b = switch_core_strdup(p, a); } else { b = SWITCH_BLANK_STRING; }
#define profile_dup_clean(a, b, p)   if (!switch_strlen_zero(a)) { b = switch_clean_string(switch_core_strdup(p, a)); } else { b = SWITCH_BLANK_STRING; }

Functions

switch_caller_profile_tswitch_caller_profile_new (switch_memory_pool_t *pool, const char *username, const char *dialplan, const char *caller_id_name, const char *caller_id_number, const char *network_addr, const char *ani, const char *aniii, const char *rdnis, const char *source, const char *context, const char *destination_number)
switch_caller_profile_tswitch_caller_profile_dup (switch_memory_pool_t *pool, switch_caller_profile_t *tocopy)
switch_caller_profile_tswitch_caller_profile_clone (switch_core_session_t *session, switch_caller_profile_t *tocopy)
const char * switch_caller_get_field_by_name (switch_caller_profile_t *caller_profile, const char *name)
void switch_caller_profile_event_set_data (switch_caller_profile_t *caller_profile, const char *prefix, switch_event_t *event)
switch_caller_extension_tswitch_caller_extension_new (switch_core_session_t *session, const char *extension_name, const char *extension_number)
void switch_caller_extension_add_application (switch_core_session_t *session, switch_caller_extension_t *caller_extension, const char *application_name, const char *application_data)


Define Documentation

#define profile_dup a,
b,
 )     if (!switch_strlen_zero(a)) { b = switch_core_strdup(p, a); } else { b = SWITCH_BLANK_STRING; }
 

#define profile_dup_clean a,
b,
 )     if (!switch_strlen_zero(a)) { b = switch_clean_string(switch_core_strdup(p, a)); } else { b = SWITCH_BLANK_STRING; }
 


Function Documentation

void switch_caller_extension_add_application switch_core_session_t session,
switch_caller_extension_t caller_extension,
const char *  application_name,
const char *  application_data
 

00294 {
00295         switch_caller_application_t *caller_application = NULL;
00296 
00297         switch_assert(session != NULL);
00298 
00299         if ((caller_application = switch_core_session_alloc(session, sizeof(switch_caller_application_t))) != 0) {
00300                 caller_application->application_name = switch_core_session_strdup(session, application_name);
00301                 caller_application->application_data = switch_core_session_strdup(session, application_data);
00302                 if (!caller_extension->applications) {
00303                         caller_extension->applications = caller_application;
00304                 } else if (caller_extension->last_application) {
00305                         caller_extension->last_application->next = caller_application;
00306                 }
00307 
00308                 caller_extension->last_application = caller_application;
00309                 caller_extension->current_application = caller_extension->applications;
00310         }
00311 
00312 }

switch_caller_extension_t* switch_caller_extension_new switch_core_session_t session,
const char *  extension_name,
const char *  extension_number
 

00280 {
00281         switch_caller_extension_t *caller_extension = NULL;
00282 
00283         if ((caller_extension = switch_core_session_alloc(session, sizeof(switch_caller_extension_t))) != 0) {
00284                 caller_extension->extension_name = switch_core_session_strdup(session, extension_name);
00285                 caller_extension->extension_number = switch_core_session_strdup(session, extension_number);
00286                 caller_extension->current_application = caller_extension->last_application = caller_extension->applications;
00287         }
00288 
00289         return caller_extension;
00290 }

const char* switch_caller_get_field_by_name switch_caller_profile_t caller_profile,
const char *  name
 

00125 {
00126         if (!strcasecmp(name, "dialplan")) {
00127                 return caller_profile->dialplan;
00128         }
00129         if (!strcasecmp(name, "username")) {
00130                 return caller_profile->username;
00131         }
00132         if (!strcasecmp(name, "caller_id_name")) {
00133                 return caller_profile->caller_id_name;
00134         }
00135         if (!strcasecmp(name, "ani")) {
00136                 return caller_profile->ani;
00137         }
00138         if (!strcasecmp(name, "aniii")) {
00139                 return caller_profile->aniii;
00140         }
00141         if (!strcasecmp(name, "caller_id_number")) {
00142                 return caller_profile->caller_id_number;
00143         }
00144         if (!strcasecmp(name, "network_addr")) {
00145                 return caller_profile->network_addr;
00146         }
00147         if (!strcasecmp(name, "rdnis")) {
00148                 return caller_profile->rdnis;
00149         }
00150         if (!strcasecmp(name, "destination_number")) {
00151                 return caller_profile->destination_number;
00152         }
00153         if (!strcasecmp(name, "uuid")) {
00154                 return caller_profile->uuid;
00155         }
00156         if (!strcasecmp(name, "source")) {
00157                 return caller_profile->source;
00158         }
00159         if (!strcasecmp(name, "context")) {
00160                 return caller_profile->context;
00161         }
00162 
00163         if (!strcasecmp(name, "chan_name")) {
00164                 return caller_profile->chan_name;
00165         }
00166 
00167         if (!strcasecmp(name, "profile_index")) {
00168                 return caller_profile->profile_index;
00169         }
00170 
00171         if (!strcasecmp(name, "caller_ton")) {
00172                 return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_ton);
00173         }
00174         if (!strcasecmp(name, "caller_numplan")) {
00175                 return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_numplan);
00176         }
00177         if (!strcasecmp(name, "destination_number_ton")) {
00178                 return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_ton);
00179         }
00180         if (!strcasecmp(name, "destination_number_numplan")) {
00181                 return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_numplan);
00182         }
00183         if (!strcasecmp(name, "ani_ton")) {
00184                 return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_ton);
00185         }
00186         if (!strcasecmp(name, "ani_numplan")) {
00187                 return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_numplan);
00188         }
00189         if (!strcasecmp(name, "rdnis_ton")) {
00190                 return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_ton);
00191         }
00192         if (!strcasecmp(name, "rdnis_numplan")) {
00193                 return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_numplan);
00194         }
00195         return NULL;
00196 }

Here is the call graph for this function:

switch_caller_profile_t* switch_caller_profile_clone switch_core_session_t session,
switch_caller_profile_t tocopy
 

00116 {
00117         switch_memory_pool_t *pool;
00118 
00119         pool = switch_core_session_get_pool(session);
00120 
00121         return switch_caller_profile_dup(pool, tocopy);
00122 }

Here is the call graph for this function:

switch_caller_profile_t* switch_caller_profile_dup switch_memory_pool_t pool,
switch_caller_profile_t tocopy
 

00081 {
00082         switch_caller_profile_t *profile = NULL;
00083 
00084         profile = switch_core_alloc(pool, sizeof(*profile));
00085         switch_assert(profile != NULL);
00086 
00087         profile_dup(tocopy->username, profile->username, pool);
00088         profile_dup(tocopy->dialplan, profile->dialplan, pool);
00089         profile_dup(tocopy->caller_id_name, profile->caller_id_name, pool);
00090         profile_dup(tocopy->caller_id_number, profile->caller_id_number, pool);
00091         profile_dup(tocopy->network_addr, profile->network_addr, pool);
00092         profile_dup(tocopy->ani, profile->ani, pool);
00093         profile_dup(tocopy->aniii, profile->aniii, pool);
00094         profile_dup(tocopy->rdnis, profile->rdnis, pool);
00095         profile_dup(tocopy->source, profile->source, pool);
00096         profile_dup(tocopy->context, profile->context, pool);
00097         profile_dup(tocopy->destination_number, profile->destination_number, pool);
00098         profile_dup(tocopy->uuid, profile->uuid, pool);
00099         profile_dup(tocopy->chan_name, profile->chan_name, pool);
00100 
00101         profile->caller_ton = tocopy->caller_ton;
00102         profile->caller_numplan = tocopy->caller_numplan;
00103         profile->ani_ton = tocopy->ani_ton;
00104         profile->ani_numplan = tocopy->ani_numplan;
00105         profile->rdnis_ton = tocopy->rdnis_ton;
00106         profile->rdnis_numplan = tocopy->rdnis_numplan;
00107         profile->destination_number_ton = tocopy->destination_number_ton;
00108         profile->destination_number_numplan = tocopy->destination_number_numplan;
00109         profile->flags = tocopy->flags;
00110         profile->pool = pool;
00111 
00112         return profile;
00113 }

void switch_caller_profile_event_set_data switch_caller_profile_t caller_profile,
const char *  prefix,
switch_event_t event
 

00199 {
00200         char header_name[1024];
00201 
00202         if (!switch_strlen_zero(caller_profile->username)) {
00203                 switch_snprintf(header_name, sizeof(header_name), "%s-Username", prefix);
00204                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->username);
00205         }
00206         if (!switch_strlen_zero(caller_profile->dialplan)) {
00207                 switch_snprintf(header_name, sizeof(header_name), "%s-Dialplan", prefix);
00208                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->dialplan);
00209         }
00210         if (!switch_strlen_zero(caller_profile->caller_id_name)) {
00211                 switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Name", prefix);
00212                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->caller_id_name);
00213         }
00214         if (!switch_strlen_zero(caller_profile->caller_id_number)) {
00215                 switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Number", prefix);
00216                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->caller_id_number);
00217         }
00218         if (!switch_strlen_zero(caller_profile->network_addr)) {
00219                 switch_snprintf(header_name, sizeof(header_name), "%s-Network-Addr", prefix);
00220                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->network_addr);
00221         }
00222         if (!switch_strlen_zero(caller_profile->ani)) {
00223                 switch_snprintf(header_name, sizeof(header_name), "%s-ANI", prefix);
00224                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->ani);
00225         }
00226         if (!switch_strlen_zero(caller_profile->aniii)) {
00227                 switch_snprintf(header_name, sizeof(header_name), "%s-ANI-II", prefix);
00228                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->aniii);
00229         }
00230         if (!switch_strlen_zero(caller_profile->destination_number)) {
00231                 switch_snprintf(header_name, sizeof(header_name), "%s-Destination-Number", prefix);
00232                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->destination_number);
00233         }
00234         if (!switch_strlen_zero(caller_profile->uuid)) {
00235                 switch_snprintf(header_name, sizeof(header_name), "%s-Unique-ID", prefix);
00236                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->uuid);
00237         }
00238         if (!switch_strlen_zero(caller_profile->source)) {
00239                 switch_snprintf(header_name, sizeof(header_name), "%s-Source", prefix);
00240                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->source);
00241         }
00242         if (!switch_strlen_zero(caller_profile->context)) {
00243                 switch_snprintf(header_name, sizeof(header_name), "%s-Context", prefix);
00244                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->context);
00245         }
00246         if (!switch_strlen_zero(caller_profile->rdnis)) {
00247                 switch_snprintf(header_name, sizeof(header_name), "%s-RDNIS", prefix);
00248                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->rdnis);
00249         }
00250         if (!switch_strlen_zero(caller_profile->chan_name)) {
00251                 switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix);
00252                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->chan_name);
00253         }
00254         if (!switch_strlen_zero(caller_profile->profile_index)) {
00255                 switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Index", prefix);
00256                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->profile_index);
00257         }
00258         if (caller_profile->times) {
00259                 switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Created-Time", prefix);
00260                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);
00261                 switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Answered-Time", prefix);
00262                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
00263                 switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Hangup-Time", prefix);
00264                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);
00265                 switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Transfer-Time", prefix);
00266                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);
00267         }
00268 
00269         switch_snprintf(header_name, sizeof(header_name), "%s-Screen-Bit", prefix);
00270         switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "yes" : "no");
00271 
00272         switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Name", prefix);
00273         switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "yes" : "no");
00274 
00275         switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Number", prefix);
00276         switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "yes" : "no");
00277 }

Here is the call graph for this function:

switch_caller_profile_t* switch_caller_profile_new switch_memory_pool_t pool,
const char *  username,
const char *  dialplan,
const char *  caller_id_name,
const char *  caller_id_number,
const char *  network_addr,
const char *  ani,
const char *  aniii,
const char *  rdnis,
const char *  source,
const char *  context,
const char *  destination_number
 

00051 {
00052         switch_caller_profile_t *profile = NULL;
00053 
00054         profile = switch_core_alloc(pool, sizeof(*profile));
00055         switch_assert(profile != NULL);
00056                 
00057         if (!context) {
00058                 context = "default";
00059         }
00060 
00061         profile_dup_clean(username, profile->username, pool);
00062         profile_dup_clean(dialplan, profile->dialplan, pool);
00063         profile_dup_clean(caller_id_name, profile->caller_id_name, pool);
00064         profile_dup_clean(caller_id_number, profile->caller_id_number, pool);
00065         profile_dup_clean(network_addr, profile->network_addr, pool);
00066         profile_dup_clean(ani, profile->ani, pool);
00067         profile_dup_clean(aniii, profile->aniii, pool);
00068         profile_dup_clean(rdnis, profile->rdnis, pool);
00069         profile_dup_clean(source, profile->source, pool);
00070         profile_dup_clean(context, profile->context, pool);
00071         profile_dup_clean(destination_number, profile->destination_number, pool);
00072         profile->uuid = SWITCH_BLANK_STRING;
00073         profile->chan_name = SWITCH_BLANK_STRING;
00074 
00075         switch_set_flag(profile, SWITCH_CPF_SCREEN);
00076         profile->pool = pool;
00077         return profile;
00078 }


Generated on Mon May 26 22:06:51 2008 for FreeSWITCH by  doxygen 1.3.9.1