mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-08 19:08:14 +00:00
various devicestate fixes (issue #5081, take two)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6496 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
47
channel.c
47
channel.c
@@ -2808,34 +2808,25 @@ void ast_set_callerid(struct ast_channel *chan, const char *callerid, const char
|
|||||||
|
|
||||||
int ast_setstate(struct ast_channel *chan, int state)
|
int ast_setstate(struct ast_channel *chan, int state)
|
||||||
{
|
{
|
||||||
if (chan->_state != state) {
|
int oldstate = chan->_state;
|
||||||
int oldstate = chan->_state;
|
|
||||||
chan->_state = state;
|
if (oldstate == state)
|
||||||
if (oldstate == AST_STATE_DOWN) {
|
return 0;
|
||||||
ast_device_state_changed(chan->name);
|
|
||||||
manager_event(EVENT_FLAG_CALL, "Newchannel",
|
chan->_state = state;
|
||||||
"Channel: %s\r\n"
|
ast_device_state_changed(chan->name);
|
||||||
"State: %s\r\n"
|
manager_event(EVENT_FLAG_CALL,
|
||||||
"CallerID: %s\r\n"
|
(oldstate == AST_STATE_DOWN) ? "Newchannel" : "Newstate",
|
||||||
"CallerIDName: %s\r\n"
|
"Channel: %s\r\n"
|
||||||
"Uniqueid: %s\r\n",
|
"State: %s\r\n"
|
||||||
chan->name, ast_state2str(chan->_state),
|
"CallerID: %s\r\n"
|
||||||
chan->cid.cid_num ? chan->cid.cid_num : "<unknown>",
|
"CallerIDName: %s\r\n"
|
||||||
chan->cid.cid_name ? chan->cid.cid_name : "<unknown>",
|
"Uniqueid: %s\r\n",
|
||||||
chan->uniqueid);
|
chan->name, ast_state2str(chan->_state),
|
||||||
} else {
|
chan->cid.cid_num ? chan->cid.cid_num : "<unknown>",
|
||||||
manager_event(EVENT_FLAG_CALL, "Newstate",
|
chan->cid.cid_name ? chan->cid.cid_name : "<unknown>",
|
||||||
"Channel: %s\r\n"
|
chan->uniqueid);
|
||||||
"State: %s\r\n"
|
|
||||||
"CallerID: %s\r\n"
|
|
||||||
"CallerIDName: %s\r\n"
|
|
||||||
"Uniqueid: %s\r\n",
|
|
||||||
chan->name, ast_state2str(chan->_state),
|
|
||||||
chan->cid.cid_num ? chan->cid.cid_num : "<unknown>",
|
|
||||||
chan->cid.cid_name ? chan->cid.cid_name : "<unknown>",
|
|
||||||
chan->uniqueid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9114,9 +9114,8 @@ static int iax2_devicestate(void *data)
|
|||||||
/* Peer is registered, or have default IP address
|
/* Peer is registered, or have default IP address
|
||||||
and a valid registration */
|
and a valid registration */
|
||||||
if (p->historicms == 0 || p->historicms <= p->maxms)
|
if (p->historicms == 0 || p->historicms <= p->maxms)
|
||||||
res = AST_DEVICE_NOT_INUSE;
|
/* let the core figure out whether it is in use or not */
|
||||||
else
|
res = AST_DEVICE_UNKNOWN;
|
||||||
res = AST_DEVICE_UNKNOWN; /* Not reachable */
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (option_debug > 2)
|
if (option_debug > 2)
|
||||||
|
|||||||
@@ -109,9 +109,16 @@ int ast_device_state(const char *device)
|
|||||||
return ast_parse_device_state(device); /* No, try the generic function */
|
return ast_parse_device_state(device); /* No, try the generic function */
|
||||||
else {
|
else {
|
||||||
res = chan_tech->devicestate(number); /* Ask the channel driver for device state */
|
res = chan_tech->devicestate(number); /* Ask the channel driver for device state */
|
||||||
if (res == AST_DEVICE_UNKNOWN)
|
if (res == AST_DEVICE_UNKNOWN) {
|
||||||
return ast_parse_device_state(device);
|
res = ast_parse_device_state(device);
|
||||||
else
|
/* at this point we know the device exists, but the channel driver
|
||||||
|
could not give us a state; if there is no channel state available,
|
||||||
|
it must be 'not in use'
|
||||||
|
*/
|
||||||
|
if (res == AST_DEVICE_UNKNOWN)
|
||||||
|
res = AST_DEVICE_NOT_INUSE;
|
||||||
|
return res;
|
||||||
|
} else
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user