Merged revisions 205409 via svnmerge from
[asterisk/asterisk.git] / main / pbx.c
index 5e31078..f733423 100644 (file)
@@ -4083,6 +4083,32 @@ static struct ast_exten *ast_hint_extension(struct ast_channel *c, const char *c
        return e;
 }
 
+enum ast_extension_states ast_devstate_to_extenstate(enum ast_device_state devstate)
+{
+       switch (devstate) {
+       case AST_DEVICE_ONHOLD:
+               return AST_EXTENSION_ONHOLD;
+       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);
+       case AST_DEVICE_RINGING:
+               return AST_EXTENSION_RINGING;
+       case AST_DEVICE_INUSE:
+               return AST_EXTENSION_INUSE;
+       case AST_DEVICE_NOT_INUSE:
+               return AST_EXTENSION_NOT_INUSE;
+       case AST_DEVICE_TOTAL: /* not a device state, included for completeness */
+               break;
+       }
+
+       return AST_EXTENSION_NOT_INUSE;
+}
+
 /*! \brief Check state of extension by using hints */
 static int ast_extension_state2(struct ast_exten *e)
 {