Skip to content

Commit

Permalink
call_center: fix MI cc_list_calls state print
Browse files Browse the repository at this point in the history
(cherry picked from commit 09c3fb9)
  • Loading branch information
razvancrainea committed Feb 12, 2021
1 parent 5e27350 commit db38a22
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
14 changes: 5 additions & 9 deletions modules/call_center/call_center.c
Expand Up @@ -1239,13 +1239,9 @@ static struct mi_root* mi_cc_list_calls(struct mi_root *cmd_tree, void *param)
struct mi_node *node;
struct mi_node *rpl;
struct mi_attr *attr;
str *state;
char *p;
int len;
static str call_state[12]= {{"none", 4},
{"welcome", 7},
{"queued", 6},
{"toagent", 7},
{"ended", 5}};

rpl_tree = init_mi_tree( 200, MI_SSTR("OK") );
if ( rpl_tree==NULL)
Expand All @@ -1269,10 +1265,10 @@ static struct mi_root* mi_cc_list_calls(struct mi_root *cmd_tree, void *param)
goto error;
if(call->ign_cback)
attr = add_mi_attr( node, MI_DUP_VALUE, MI_SSTR("State"), MI_SSTR("ignored"));
else
attr = add_mi_attr( node, MI_DUP_VALUE, MI_SSTR("State"), call_state[call->state].s, call_state[call->state].len);
if (attr==NULL)
goto error;
else {
state = call_state_str(call->state);
attr = add_mi_attr( node, MI_DUP_VALUE, MI_SSTR("State"), state->s, state->len);
}

LM_DBG("call->recv_time= %d, ticks= %d\n", call->recv_time, get_ticks());
if(call->state != CC_CALL_ENDED)
Expand Down
18 changes: 18 additions & 0 deletions modules/call_center/cc_data.h
Expand Up @@ -155,6 +155,24 @@ typedef enum {
CC_CALL_ENDED
} call_state;

static inline str *call_state_str(call_state state)
{
static str call_state_s[] = {
str_init("none"),
str_init("welcome"),
str_init("dissuading1"),
str_init("dissuading2"),
str_init("queued"),
str_init("preagent"),
str_init("toagent"),
str_init("ended"),
/* unused */
str_init("unknown"),
};
int size = (sizeof(call_state_s)/sizeof(call_state_s[0]));
return &call_state_s[(state < size - 1)?state:size - 1];
}

#define FSTAT_INCALL (1<<0)
#define FSTAT_DIST (1<<1)
#define FSTAT_ANSW (1<<2)
Expand Down

0 comments on commit db38a22

Please sign in to comment.