Added devicestate option.

This commit is contained in:
MelwareDE 2007-10-20 14:07:01 +00:00
parent 9eac4f7df4
commit 4c1ebe93fa
2 changed files with 51 additions and 3 deletions

View File

@ -5,6 +5,9 @@ HEAD
------------------
- send local DATE/TIME with CONNECT when in NT-mode.
- 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
------------------

View File

@ -4902,15 +4902,60 @@ static int pbx_capi_indicate(struct ast_channel *c, int condition)
*/
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) {
cc_verbose(3, 1, VERBOSE_PREFIX_2 "No data for capi_devicestate\n");
return res;
}
cc_verbose(3, 1, VERBOSE_PREFIX_4 "CAPI devicestate requested for %s\n",
(char *)data);
s = ast_strdupa(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;
}