FS-4902 --resolve

This commit is contained in:
Anthony Minessale 2012-12-03 16:39:09 -06:00
parent 8790476f0f
commit e1094cbd0f
1 changed files with 54 additions and 10 deletions

View File

@ -119,7 +119,10 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
switch_app_log_t *app_log;
bson cdr;
int is_b;
int callflow_idx = 0;
switch_hold_record_t *hold_record = switch_channel_get_hold_record(channel), *hr;
char *tmp;
char idx_buffer[4];
if (globals.shutdown) {
return SWITCH_STATUS_SUCCESS;
@ -170,26 +173,52 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
/* App log */
if ((app_log = switch_core_session_get_app_log(session))) {
int idx = 0;
switch_app_log_t *ap;
bson_append_start_object(&cdr, "app_log");
bson_append_start_array(&cdr, "app_log");
for (ap = app_log; ap; ap = ap->next) {
bson_append_start_object(&cdr, "application");
switch_snprintf(idx_buffer, sizeof(idx_buffer), "%d", idx);
bson_append_start_object(&cdr, idx_buffer);
bson_append_string(&cdr, "app_name", ap->app);
bson_append_string(&cdr, "app_data", switch_str_nil(ap->arg));
bson_append_long(&cdr, "app_stamp", ap->stamp);
bson_append_finish_object(&cdr); /* application */
idx++;
}
bson_append_finish_object(&cdr); /* app_log */
bson_append_finish_array(&cdr); /* app_log */
}
/* Hold */
if (hold_record) {
int idx = 0;
bson_append_start_array(&cdr, "hold_record");
for (hr = hold_record; hr ; hr = hr->next) {
switch_snprintf(idx_buffer, sizeof(idx_buffer), "%d", idx);
bson_append_start_object(&cdr, idx_buffer);
bson_append_long(&cdr, "on", hr->on);
bson_append_long(&cdr, "off", hr->off);
if (hr->uuid) {
bson_append_string(&cdr, "bridged_to", hr->uuid);
}
bson_append_finish_object(&cdr);
idx++;
}
bson_append_finish_array(&cdr);
}
/* Callflow */
caller_profile = switch_channel_get_caller_profile(channel);
/* Start callflow array */
bson_append_start_array(&cdr, "callflow");
while (caller_profile) {
bson_append_start_object(&cdr, "callflow");
snprintf(idx_buffer, sizeof(idx_buffer), "%d", callflow_idx);
bson_append_start_object(&cdr, idx_buffer);
if (!zstr(caller_profile->dialplan)) {
bson_append_string(&cdr, "dialplan", caller_profile->dialplan);
@ -262,37 +291,49 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
set_bson_profile_data(&cdr, caller_profile);
if (caller_profile->origination_caller_profile) {
int idx = 0;
switch_caller_profile_t *cp = NULL;
bson_append_start_object(&cdr, "origination");
/* Start origination array */
bson_append_start_array(&cdr, "origination");
for (cp = caller_profile->origination_caller_profile; cp; cp = cp->next) {
bson_append_start_object(&cdr, "origination_caller_profile");
snprintf(idx_buffer, sizeof(idx_buffer), "%d", idx);
bson_append_start_object(&cdr, idx_buffer);
set_bson_profile_data(&cdr, cp);
bson_append_finish_object(&cdr);
idx++;
}
bson_append_finish_object(&cdr); /* origination */
}
if (caller_profile->originator_caller_profile) {
int idx = 0;
switch_caller_profile_t *cp = NULL;
bson_append_start_object(&cdr, "originator");
/* Start originator array */
bson_append_start_array(&cdr, "originator");
for (cp = caller_profile->originator_caller_profile; cp; cp = cp->next) {
bson_append_start_object(&cdr, "originator_caller_profile");
snprintf(idx_buffer, sizeof(idx_buffer), "%d", idx);
bson_append_start_object(&cdr, idx_buffer);
set_bson_profile_data(&cdr, cp);
bson_append_finish_object(&cdr);
idx++;
}
bson_append_finish_object(&cdr); /* originator */
}
if (caller_profile->originatee_caller_profile) {
int idx = 0;
switch_caller_profile_t *cp = NULL;
bson_append_start_object(&cdr, "originatee");
/* Start originatee array */
bson_append_start_array(&cdr, "originatee");
for (cp = caller_profile->originatee_caller_profile; cp; cp = cp->next) {
bson_append_start_object(&cdr, "originatee_caller_profile");
snprintf(idx_buffer, sizeof(idx_buffer), "%d", idx);
bson_append_start_object(&cdr, idx_buffer);
set_bson_profile_data(&cdr, cp);
bson_append_finish_object(&cdr);
idx++;
}
bson_append_finish_object(&cdr); /* originatee */
}
@ -320,8 +361,11 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
bson_append_finish_object(&cdr); /* callflow */
caller_profile = caller_profile->next;
callflow_idx++; /* increment callflow_idx */
}
bson_append_finish_array(&cdr);
bson_finish(&cdr);
switch_mutex_lock(globals.mongo_mutex);