mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Improved mapping of extension states from combined device states.
This fixes a few issues with incorrect extension states and adds a cli command, core show device2extenstate, to display all possible state mappings. (closes issue #15413) Reported by: legart Patches: exten_helper.diff uploaded by dvossel (license 671) Tested by: dvossel, legart, amilcar Review: https://reviewboard.asterisk.org/r/301/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@204681 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -27,24 +27,18 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*! Device is valid but channel didn't know state */
|
||||
#define AST_DEVICE_UNKNOWN 0
|
||||
/*! Device is not used */
|
||||
#define AST_DEVICE_NOT_INUSE 1
|
||||
/*! Device is in use */
|
||||
#define AST_DEVICE_INUSE 2
|
||||
/*! Device is busy */
|
||||
#define AST_DEVICE_BUSY 3
|
||||
/*! Device is invalid */
|
||||
#define AST_DEVICE_INVALID 4
|
||||
/*! Device is unavailable */
|
||||
#define AST_DEVICE_UNAVAILABLE 5
|
||||
/*! Device is ringing */
|
||||
#define AST_DEVICE_RINGING 6
|
||||
/*! Device is ringing *and* in use */
|
||||
#define AST_DEVICE_RINGINUSE 7
|
||||
/*! Device is on hold */
|
||||
#define AST_DEVICE_ONHOLD 8
|
||||
enum ast_device_state {
|
||||
AST_DEVICE_UNKNOWN, /*!< Device is valid but channel didn't know state */
|
||||
AST_DEVICE_NOT_INUSE, /*!< Device is not used */
|
||||
AST_DEVICE_INUSE, /*!< Device is in use */
|
||||
AST_DEVICE_BUSY, /*!< Device is busy */
|
||||
AST_DEVICE_INVALID, /*!< Device is invalid */
|
||||
AST_DEVICE_UNAVAILABLE, /*!< Device is unavailable */
|
||||
AST_DEVICE_RINGING, /*!< Device is ringing */
|
||||
AST_DEVICE_RINGINUSE, /*!< Device is ringing *and* in use */
|
||||
AST_DEVICE_ONHOLD, /*!< Device is on hold */
|
||||
AST_DEVICE_TOTAL, /*!< Total num of device states, used for testing */
|
||||
};
|
||||
|
||||
/*! \brief Devicestate watcher call back */
|
||||
typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data);
|
||||
@@ -55,7 +49,7 @@ typedef int (*ast_devstate_prov_cb_type)(const char *data);
|
||||
/*! \brief Convert device state to text string for output
|
||||
* \param devstate Current device state
|
||||
*/
|
||||
const char *devstate2str(int devstate);
|
||||
const char *devstate2str(enum ast_device_state devstate);
|
||||
|
||||
/*! \brief Search the Channels by Name
|
||||
* \param device like a dialstring
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "asterisk/sched.h"
|
||||
#include "asterisk/channel.h"
|
||||
#include "asterisk/linkedlists.h"
|
||||
#include "asterisk/devicestate.h"
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
@@ -305,6 +306,64 @@ int ast_register_application(const char *app, int (*execute)(struct ast_channel
|
||||
*/
|
||||
int ast_unregister_application(const char *app);
|
||||
|
||||
/*!
|
||||
* \brief An object to hold state when calculating aggregate device state
|
||||
*/
|
||||
struct ast_devstate_aggregate;
|
||||
|
||||
/*!
|
||||
* \brief Initialize aggregate device state
|
||||
*
|
||||
* \param[in] agg the state object
|
||||
*
|
||||
* \return nothing
|
||||
*/
|
||||
void ast_devstate_aggregate_init(struct ast_devstate_aggregate *agg);
|
||||
|
||||
/*!
|
||||
* \brief Add a device state to the aggregate device state
|
||||
*
|
||||
* \param[in] agg the state object
|
||||
* \param[in] state the state to add
|
||||
*
|
||||
* \return nothing
|
||||
*/
|
||||
void ast_devstate_aggregate_add(struct ast_devstate_aggregate *agg, enum ast_device_state state);
|
||||
|
||||
/*!
|
||||
* \brief Get the aggregate device state result
|
||||
*
|
||||
* \param[in] agg the state object
|
||||
*
|
||||
* \return the aggregate device state after adding some number of device states.
|
||||
*/
|
||||
enum ast_device_state ast_devstate_aggregate_result(struct ast_devstate_aggregate *agg);
|
||||
|
||||
/*!
|
||||
* \brief Map devstate to an extension state.
|
||||
*
|
||||
* \param[in] device state
|
||||
*
|
||||
* \return the extension state mapping.
|
||||
*/
|
||||
enum ast_extension_states ast_devstate_to_extenstate(enum ast_device_state devstate);
|
||||
|
||||
/*!
|
||||
* \brief You shouldn't care about the contents of this struct
|
||||
*
|
||||
* This struct is only here so that it can be easily declared on the stack.
|
||||
*/
|
||||
struct ast_devstate_aggregate {
|
||||
unsigned int all_unavail:1;
|
||||
unsigned int all_busy:1;
|
||||
unsigned int all_free:1;
|
||||
unsigned int all_unknown:1;
|
||||
unsigned int on_hold:1;
|
||||
unsigned int busy:1;
|
||||
unsigned int in_use:1;
|
||||
unsigned int ring:1;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Uses hint and devicestate callback to get the state of an extension
|
||||
*
|
||||
|
Reference in New Issue
Block a user