diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-02-13 22:02:20 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-02-13 22:02:20 +0000 |
commit | bb6564f8e744f7c8b28ba9a03b3f8f852952b5eb (patch) | |
tree | 6c0ae108c47a878e9cc329ef2c330982e02b80a3 /include | |
parent | 76f1766c9ff8e9d1c5c9e094b21ef880379b858e (diff) |
This introduces a new dialplan function, DEVSTATE, which allows you to do some
pretty cool things.
First, you can get the device state of anything in the dialplan:
NoOp(SIP/mypeer has state ${DEVSTATE(SIP/mypeer)})
NoOp(The conference room 1234 has state ${DEVSTATE(MeetMe:1234)})
Most importantly, this allows you to create custom device states so you can
control phone lamps directly from the dialplan.
Set(DEVSTATE(Custom:mycustomlamp)=BUSY)
...
exten => mycustomlamp,hint,Custom:mycustomlamp
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@54261 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/cli.h | 4 | ||||
-rw-r--r-- | include/asterisk/devicestate.h | 51 |
2 files changed, 34 insertions, 21 deletions
diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h index 43a900811..9214a7d63 100644 --- a/include/asterisk/cli.h +++ b/include/asterisk/cli.h @@ -235,7 +235,7 @@ int ast_cli_register(struct ast_cli_entry *e); * \param e pointer to first cli entry to register * \param len number of entries to register */ -void ast_cli_register_multiple(struct ast_cli_entry *e, int len); +int ast_cli_register_multiple(struct ast_cli_entry *e, int len); /*! \brief Unregisters a command or an array of commands * @@ -250,7 +250,7 @@ int ast_cli_unregister(struct ast_cli_entry *e); * \param e pointer to first cli entry to unregister * \param len number of entries to unregister */ -void ast_cli_unregister_multiple(struct ast_cli_entry *e, int len); +int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len); /*! \brief Readline madness * Useful for readline, that's about it diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h index 042ffc2cf..dd7b939be 100644 --- a/include/asterisk/devicestate.h +++ b/include/asterisk/devicestate.h @@ -28,29 +28,42 @@ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif -/*! @name DeviceStates */ -/*! \@{ */ -#define AST_DEVICE_UNKNOWN 0 /*!< Device is valid but channel didn't know state */ -#define AST_DEVICE_NOT_INUSE 1 /*!< Device is not used */ -#define AST_DEVICE_INUSE 2 /*!< Device is in use */ -#define AST_DEVICE_BUSY 3 /*!< Device is busy */ -#define AST_DEVICE_INVALID 4 /*!< Device is invalid */ -#define AST_DEVICE_UNAVAILABLE 5 /*!< Device is unavailable */ -#define AST_DEVICE_RINGING 6 /*!< Device is ringing */ -#define AST_DEVICE_RINGINUSE 7 /*!< Device is ringing *and* in use */ -#define AST_DEVICE_ONHOLD 8 /*!< Device is on hold */ -/*! \@} */ + +/*! Device States */ +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 */ +}; /*! \brief Devicestate watcher call back */ -typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data); +typedef int (*ast_devstate_cb_type)(const char *dev, enum ast_device_state state, void *data); /*! \brief Devicestate provider call back */ -typedef int (*ast_devstate_prov_cb_type)(const char *data); +typedef enum ast_device_state (*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 Convert device state to text string that is easier to parse + * \param devstate Current device state + */ +const char *ast_devstate_str(enum ast_device_state devstate); + +/*! \brief Convert device state from text to integer value + * \param The text representing the device state. Valid values are anything + * that comes after AST_DEVICE_ in one of the defined values. + * \return The AST_DEVICE_ integer value + */ +enum ast_device_state ast_devstate_val(const char *val); /*! \brief Search the Channels by Name * \param device like a dialstring @@ -59,7 +72,7 @@ const char *devstate2str(int devstate); * Returns an AST_DEVICE_UNKNOWN if no channel found or * AST_DEVICE_INUSE if a channel is found */ -int ast_parse_device_state(const char *device); +enum ast_device_state ast_parse_device_state(const char *device); /*! \brief Asks a channel for device state * \param device like a dialstring @@ -69,7 +82,7 @@ int ast_parse_device_state(const char *device); * active channels list for the device. * Returns an AST_DEVICE_??? state -1 on failure */ -int ast_device_state(const char *device); +enum ast_device_state ast_device_state(const char *device); /*! \brief Tells Asterisk the State for Device is changed * \param fmt devicename like a dialstring with format parameters @@ -115,9 +128,9 @@ int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback) /*! \brief Remove device state provider * \param label to use in hint, like label:object - * \return nothing + * Return -1 on failure, 0 on success */ -void ast_devstate_prov_del(const char *label); +int ast_devstate_prov_del(const char *label); int ast_device_state_engine_init(void); |