Add callstate (and color) for busy and diverted calls.

Diverted calls were shown as in call and busy calls as rejected.
This commit is contained in:
Kristian Høgh 2016-10-25 11:00:02 +02:00
parent 93246b8bfc
commit 39c2484651
3 changed files with 16 additions and 0 deletions

View File

@ -165,5 +165,9 @@ sip_attr_color_state(const char *value)
return COLOR_PAIR(CP_RED_ON_DEF);
if (!strcmp(value, call_state_to_str(SIP_CALLSTATE_REJECTED)))
return COLOR_PAIR(CP_RED_ON_DEF);
if (!strcmp(value, call_state_to_str(SIP_CALLSTATE_BUSY)))
return COLOR_PAIR(CP_MAGENTA_ON_DEF);
if (!strcmp(value, call_state_to_str(SIP_CALLSTATE_DIVERTED)))
return COLOR_PAIR(CP_CYAN_ON_DEF);
return 0;
}

View File

@ -218,9 +218,15 @@ call_update_state(sip_call_t *call, sip_msg_t *msg)
} else if (reqresp == SIP_METHOD_CANCEL) {
// Alice is not in the mood
call->state = SIP_CALLSTATE_CANCELLED;
} else if ((reqresp == 480) || (reqresp == 486)) {
// Bob is busy
call->state = SIP_CALLSTATE_BUSY;
} else if (reqresp > 400 && call->invitecseq == msg->cseq) {
// Bob is not in the mood
call->state = SIP_CALLSTATE_REJECTED;
} else if (reqresp > 300) {
// Bob has diversion
call->state = SIP_CALLSTATE_DIVERTED;
}
} else if (call->state == SIP_CALLSTATE_INCALL) {
if (reqresp == SIP_METHOD_BYE) {
@ -306,6 +312,10 @@ call_state_to_str(int state)
return "CANCELLED";
case SIP_CALLSTATE_REJECTED:
return "REJECTED";
case SIP_CALLSTATE_BUSY:
return "BUSY";
case SIP_CALLSTATE_DIVERTED:
return "DIVERTED";
case SIP_CALLSTATE_COMPLETED:
return "COMPLETED";
}

View File

@ -47,6 +47,8 @@ enum call_state
SIP_CALLSTATE_INCALL,
SIP_CALLSTATE_CANCELLED,
SIP_CALLSTATE_REJECTED,
SIP_CALLSTATE_DIVERTED,
SIP_CALLSTATE_BUSY,
SIP_CALLSTATE_COMPLETED
};