Added devicestate option.
This commit is contained in:
parent
9eac4f7df4
commit
4c1ebe93fa
3
CHANGES
3
CHANGES
|
@ -5,6 +5,9 @@ HEAD
|
||||||
------------------
|
------------------
|
||||||
- send local DATE/TIME with CONNECT when in NT-mode.
|
- send local DATE/TIME with CONNECT when in NT-mode.
|
||||||
- added transfergroup config option to set controllers allowed for transfer.
|
- added transfergroup config option to set controllers allowed for transfer.
|
||||||
|
- send Sending-Complete if overlap dialing is not used.
|
||||||
|
- fixed numberingplan for 'connectedṅumber'.
|
||||||
|
- added devicestate option.
|
||||||
|
|
||||||
chan_capi-1.0.2
|
chan_capi-1.0.2
|
||||||
------------------
|
------------------
|
||||||
|
|
51
chan_capi.c
51
chan_capi.c
|
@ -4902,15 +4902,60 @@ static int pbx_capi_indicate(struct ast_channel *c, int condition)
|
||||||
*/
|
*/
|
||||||
static int pbx_capi_devicestate(void *data)
|
static int pbx_capi_devicestate(void *data)
|
||||||
{
|
{
|
||||||
int res = AST_DEVICE_UNKNOWN;
|
char *s;
|
||||||
|
char *target;
|
||||||
|
int res = AST_DEVICE_INVALID;
|
||||||
|
struct capi_pvt *i;
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
cc_verbose(3, 1, VERBOSE_PREFIX_2 "No data for capi_devicestate\n");
|
cc_verbose(3, 1, VERBOSE_PREFIX_2 "No data for capi_devicestate\n");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_verbose(3, 1, VERBOSE_PREFIX_4 "CAPI devicestate requested for %s\n",
|
s = ast_strdupa(data);
|
||||||
(char *)data);
|
target = strsep(&s, "/");
|
||||||
|
|
||||||
|
cc_mutex_lock(&iflock);
|
||||||
|
for (i = capi_iflist; i; i = i->next) {
|
||||||
|
if (!(strcmp(target, i->vname)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cc_mutex_unlock(&iflock);
|
||||||
|
|
||||||
|
if (!i) {
|
||||||
|
cc_log(LOG_WARNING, "Unknown target '%s' for devicestate.\n",
|
||||||
|
target);
|
||||||
|
} else {
|
||||||
|
switch (i->state) {
|
||||||
|
case 0:
|
||||||
|
case CAPI_STATE_DISCONNECTED:
|
||||||
|
case CAPI_STATE_DISCONNECTING:
|
||||||
|
res = AST_DEVICE_NOT_INUSE;
|
||||||
|
break;
|
||||||
|
case CAPI_STATE_ALERTING:
|
||||||
|
res = AST_DEVICE_RINGINUSE;
|
||||||
|
break;
|
||||||
|
case CAPI_STATE_DID:
|
||||||
|
case CAPI_STATE_INCALL:
|
||||||
|
res = AST_DEVICE_RINGING;
|
||||||
|
break;
|
||||||
|
case CAPI_STATE_ONHOLD:
|
||||||
|
res = AST_DEVICE_ONHOLD;
|
||||||
|
break;
|
||||||
|
case CAPI_STATE_CONNECTED:
|
||||||
|
case CAPI_STATE_CONNECTPENDING:
|
||||||
|
case CAPI_STATE_ANSWERING:
|
||||||
|
res = AST_DEVICE_INUSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res = AST_DEVICE_UNKNOWN;
|
||||||
|
break;
|
||||||
|
/* AST_DEVICE_BUSY */
|
||||||
|
/* AST_DEVICE_UNAVAILABLE */
|
||||||
|
}
|
||||||
|
cc_verbose(3, 1, VERBOSE_PREFIX_4 "CAPI devicestate requested for %s is '%s'\n",
|
||||||
|
(char *)data, devstate2str(res));
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue