Merge pull request #272 in FS/freeswitch from ~TONICH/freeswitch-fs-7612:FS-7612 to master

* commit 'b7e70bf1410f2975bfb40fc5729d8378dfea464c':
  FS-7612: callflow section in json_cdr as array.
This commit is contained in:
Mike Jerris 2015-06-08 10:48:28 -05:00
commit 04b75faea2
1 changed files with 12 additions and 11 deletions

View File

@ -2704,8 +2704,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_json_cdr(switch_core_session
cJSON *cdr = cJSON_CreateObject(); cJSON *cdr = cJSON_CreateObject();
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *caller_profile; switch_caller_profile_t *caller_profile;
cJSON *variables, *j_main_cp, *j_caller_profile, *j_caller_extension, *j_caller_extension_apps, *j_times, cJSON *variables, *j_main_cp, *j_caller_profile, *j_caller_extension, *j_caller_extension_apps, *j_times, *j_application,
*j_application, *j_callflow, *j_inner_extension, *j_app_log, *j_apps, *j_o, *j_o_profiles, *j_channel_data; *j_callflow, *j_profile, *j_inner_extension, *j_app_log, *j_apps, *j_o, *j_o_profiles, *j_channel_data;
switch_app_log_t *app_log; switch_app_log_t *app_log;
char tmp[512], *f; char tmp[512], *f;
@ -2759,18 +2759,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_json_cdr(switch_core_session
caller_profile = switch_channel_get_caller_profile(channel); caller_profile = switch_channel_get_caller_profile(channel);
j_callflow = cJSON_CreateArray();
cJSON_AddItemToObject(cdr, "callflow", j_callflow);
while (caller_profile) { while (caller_profile) {
j_callflow = cJSON_CreateObject(); j_profile = cJSON_CreateObject();
cJSON_AddItemToObject(cdr, "callflow", j_callflow);
if (!zstr(caller_profile->dialplan)) { if (!zstr(caller_profile->dialplan)) {
cJSON_AddItemToObject(j_callflow, "dialplan", cJSON_CreateString((char *)caller_profile->dialplan)); cJSON_AddItemToObject(j_profile, "dialplan", cJSON_CreateString((char *)caller_profile->dialplan));
} }
if (!zstr(caller_profile->profile_index)) { if (!zstr(caller_profile->profile_index)) {
cJSON_AddItemToObject(j_callflow, "profile_index", cJSON_CreateString((char *)caller_profile->profile_index)); cJSON_AddItemToObject(j_profile, "profile_index", cJSON_CreateString((char *)caller_profile->profile_index));
} }
if (caller_profile->caller_extension) { if (caller_profile->caller_extension) {
@ -2779,7 +2780,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_json_cdr(switch_core_session
j_caller_extension = cJSON_CreateObject(); j_caller_extension = cJSON_CreateObject();
j_caller_extension_apps = cJSON_CreateArray(); j_caller_extension_apps = cJSON_CreateArray();
cJSON_AddItemToObject(j_callflow, "extension", j_caller_extension); cJSON_AddItemToObject(j_profile, "extension", j_caller_extension);
cJSON_AddItemToObject(j_caller_extension, "name", cJSON_CreateString(caller_profile->caller_extension->extension_name)); cJSON_AddItemToObject(j_caller_extension, "name", cJSON_CreateString(caller_profile->caller_extension->extension_name));
cJSON_AddItemToObject(j_caller_extension, "number", cJSON_CreateString(caller_profile->caller_extension->extension_number)); cJSON_AddItemToObject(j_caller_extension, "number", cJSON_CreateString(caller_profile->caller_extension->extension_number));
@ -2840,7 +2841,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_json_cdr(switch_core_session
} }
j_main_cp = cJSON_CreateObject(); j_main_cp = cJSON_CreateObject();
cJSON_AddItemToObject(j_callflow, "caller_profile", j_main_cp); cJSON_AddItemToObject(j_profile, "caller_profile", j_main_cp);
switch_ivr_set_json_profile_data(j_main_cp, caller_profile); switch_ivr_set_json_profile_data(j_main_cp, caller_profile);
@ -2881,7 +2882,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_json_cdr(switch_core_session
if (caller_profile->times) { if (caller_profile->times) {
j_times = cJSON_CreateObject(); j_times = cJSON_CreateObject();
cJSON_AddItemToObject(j_callflow, "times", j_times); cJSON_AddItemToObject(j_profile, "times", j_times);
switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->created); switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->created);
cJSON_AddItemToObject(j_times, "created_time", cJSON_CreateString(tmp)); cJSON_AddItemToObject(j_times, "created_time", cJSON_CreateString(tmp));
@ -2917,7 +2918,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_json_cdr(switch_core_session
cJSON_AddItemToObject(j_times, "transfer_time", cJSON_CreateString(tmp)); cJSON_AddItemToObject(j_times, "transfer_time", cJSON_CreateString(tmp));
} }
cJSON_AddItemToArray(j_callflow, j_profile);
caller_profile = caller_profile->next; caller_profile = caller_profile->next;
} }