[asterisk-commits] russell: trunk r203702 - in /trunk: include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 26 14:31:18 CDT 2009
Author: russell
Date: Fri Jun 26 14:31:14 2009
New Revision: 203702
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=203702
Log:
Make invalid hints report Unavailable instead of Idle.
(closes issue #14413)
Reported by: pj
Modified:
trunk/include/asterisk/devicestate.h
trunk/main/devicestate.c
trunk/main/pbx.c
Modified: trunk/include/asterisk/devicestate.h
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/include/asterisk/devicestate.h?view=diff&rev=203702&r1=203701&r2=203702
==============================================================================
--- trunk/include/asterisk/devicestate.h (original)
+++ trunk/include/asterisk/devicestate.h Fri Jun 26 14:31:14 2009
@@ -253,6 +253,7 @@
* This struct is only here so that it can be easily declared on the stack.
*/
struct ast_devstate_aggregate {
+ unsigned int all_unknown:1;
unsigned int all_unavail:1;
unsigned int all_busy:1;
unsigned int all_free:1;
Modified: trunk/main/devicestate.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/main/devicestate.c?view=diff&rev=203702&r1=203701&r2=203702
==============================================================================
--- trunk/main/devicestate.c (original)
+++ trunk/main/devicestate.c Fri Jun 26 14:31:14 2009
@@ -350,9 +350,6 @@
res = ast_parse_device_state(device);
- if (res == AST_DEVICE_UNKNOWN)
- return AST_DEVICE_NOT_INUSE;
-
return res;
}
@@ -733,6 +730,7 @@
{
memset(agg, 0, sizeof(*agg));
+ agg->all_unknown = 1;
agg->all_unavail = 1;
agg->all_busy = 1;
agg->all_free = 1;
@@ -742,6 +740,7 @@
{
switch (state) {
case AST_DEVICE_NOT_INUSE:
+ agg->all_unknown = 0;
agg->all_unavail = 0;
agg->all_busy = 0;
break;
@@ -750,12 +749,14 @@
agg->all_busy = 0;
agg->all_unavail = 0;
agg->all_free = 0;
+ agg->all_unknown = 0;
break;
case AST_DEVICE_RINGING:
agg->ring = 1;
agg->all_busy = 0;
agg->all_unavail = 0;
agg->all_free = 0;
+ agg->all_unknown = 0;
break;
case AST_DEVICE_RINGINUSE:
agg->in_use = 1;
@@ -763,19 +764,23 @@
agg->all_busy = 0;
agg->all_unavail = 0;
agg->all_free = 0;
+ agg->all_unknown = 0;
break;
case AST_DEVICE_ONHOLD:
+ agg->all_unknown = 0;
agg->all_unavail = 0;
agg->all_free = 0;
agg->on_hold = 1;
break;
case AST_DEVICE_BUSY:
+ agg->all_unknown = 0;
agg->all_unavail = 0;
agg->all_free = 0;
agg->busy = 1;
agg->in_use = 1;
break;
case AST_DEVICE_UNAVAILABLE:
+ agg->all_unknown = 0;
case AST_DEVICE_INVALID:
agg->all_busy = 0;
agg->all_free = 0;
@@ -787,26 +792,37 @@
enum ast_device_state ast_devstate_aggregate_result(struct ast_devstate_aggregate *agg)
{
- if (agg->all_free)
+ if (agg->all_unknown) {
+ return AST_DEVICE_UNKNOWN;
+ }
+
+ if (agg->all_free) {
return AST_DEVICE_NOT_INUSE;
-
- if ((agg->in_use || agg->on_hold) && agg->ring)
+ }
+
+ if ((agg->in_use || agg->on_hold) && agg->ring) {
return AST_DEVICE_RINGINUSE;
-
- if (agg->all_busy)
+ }
+
+ if (agg->all_busy) {
return AST_DEVICE_BUSY;
-
- if (agg->in_use)
+ }
+
+ if (agg->in_use) {
return AST_DEVICE_INUSE;
-
- if (agg->ring)
+ }
+
+ if (agg->ring) {
return AST_DEVICE_RINGING;
-
- if (agg->on_hold)
+ }
+
+ if (agg->on_hold) {
return AST_DEVICE_ONHOLD;
-
- if (agg->all_unavail)
+ }
+
+ if (agg->all_unavail) {
return AST_DEVICE_UNAVAILABLE;
+ }
return AST_DEVICE_NOT_INUSE;
}
Modified: trunk/main/pbx.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/main/pbx.c?view=diff&rev=203702&r1=203701&r2=203702
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Fri Jun 26 14:31:14 2009
@@ -4101,8 +4101,9 @@
rest = ast_str_buffer(hint); /* One or more devices separated with a & character */
- while ( (cur = strsep(&rest, "&")) )
+ while ( (cur = strsep(&rest, "&")) ) {
ast_devstate_aggregate_add(&agg, ast_device_state(cur));
+ }
state = ast_devstate_aggregate_result(&agg);
@@ -4112,6 +4113,8 @@
case AST_DEVICE_BUSY:
return AST_EXTENSION_BUSY;
case AST_DEVICE_UNAVAILABLE:
+ case AST_DEVICE_UNKNOWN:
+ case AST_DEVICE_INVALID:
return AST_EXTENSION_UNAVAILABLE;
case AST_DEVICE_RINGINUSE:
return (AST_EXTENSION_INUSE | AST_EXTENSION_RINGING);
@@ -4119,8 +4122,6 @@
return AST_EXTENSION_RINGING;
case AST_DEVICE_INUSE:
return AST_EXTENSION_INUSE;
- case AST_DEVICE_UNKNOWN:
- case AST_DEVICE_INVALID:
case AST_DEVICE_NOT_INUSE:
return AST_EXTENSION_NOT_INUSE;
}
More information about the asterisk-commits
mailing list