Properly play a holdtime message if the announce-holdtime option is
[asterisk-bristuff.git] / include / asterisk / devicestate.h
blobed9022fbd96763f9a71a70ce5ea5ea41ff080a70
1 /*
2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
19 /*! \file
20 * \brief Device state management
23 #ifndef _ASTERISK_DEVICESTATE_H
24 #define _ASTERISK_DEVICESTATE_H
26 #if defined(__cplusplus) || defined(c_plusplus)
27 extern "C" {
28 #endif
30 /*! Device is valid but channel didn't know state */
31 #define AST_DEVICE_UNKNOWN 0
32 /*! Device is not used */
33 #define AST_DEVICE_NOT_INUSE 1
34 /*! Device is in use */
35 #define AST_DEVICE_INUSE 2
36 /*! Device is busy */
37 #define AST_DEVICE_BUSY 3
38 /*! Device is invalid */
39 #define AST_DEVICE_INVALID 4
40 /*! Device is unavailable */
41 #define AST_DEVICE_UNAVAILABLE 5
42 /*! Device is ringing */
43 #define AST_DEVICE_RINGING 6
44 /*! Device is ringing *and* in use */
45 #define AST_DEVICE_RINGINUSE 7
46 /*! Device is on hold */
47 #define AST_DEVICE_ONHOLD 8
49 /*! \brief Devicestate watcher call back */
50 typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data);
52 /*! \brief Devicestate provider call back */
53 typedef int (*ast_devstate_prov_cb_type)(const char *data);
55 /*! \brief Convert device state to text string for output
56 * \param devstate Current device state
58 const char *devstate2str(int devstate);
60 /*! \brief Search the Channels by Name
61 * \param device like a dialstring
62 * Search the Device in active channels by compare the channelname against
63 * the devicename. Compared are only the first chars to the first '-' char.
64 * Returns an AST_DEVICE_UNKNOWN if no channel found or
65 * AST_DEVICE_INUSE if a channel is found
67 int ast_parse_device_state(const char *device);
69 /*! \brief Asks a channel for device state
70 * \param device like a dialstring
71 * Asks a channel for device state, data is normaly a number from dialstring
72 * used by the low level module
73 * Trys the channel devicestate callback if not supported search in the
74 * active channels list for the device.
75 * Returns an AST_DEVICE_??? state -1 on failure
77 int ast_device_state(const char *device);
79 /*! \brief Tells Asterisk the State for Device is changed
80 * \param fmt devicename like a dialstring with format parameters
81 * Asterisk polls the new extensionstates and calls the registered
82 * callbacks for the changed extensions
83 * Returns 0 on success, -1 on failure
85 int ast_device_state_changed(const char *fmt, ...)
86 __attribute__ ((format (printf, 1, 2)));
89 /*! \brief Tells Asterisk the State for Device is changed
90 * \param device devicename like a dialstring
91 * Asterisk polls the new extensionstates and calls the registered
92 * callbacks for the changed extensions
93 * Returns 0 on success, -1 on failure
95 int ast_device_state_changed_literal(const char *device);
97 /*! \brief Registers a device state change callback
98 * \param callback Callback
99 * \param data to pass to callback
100 * The callback is called if the state for extension is changed
101 * Return -1 on failure, ID on success
103 int ast_devstate_add(ast_devstate_cb_type callback, void *data);
105 /*! \brief Unregisters a device state change callback
106 * \param callback Callback
107 * \param data to pass to callback
108 * The callback is called if the state for extension is changed
109 * Return -1 on failure, ID on success
111 void ast_devstate_del(ast_devstate_cb_type callback, void *data);
113 /*! \brief Add device state provider
114 * \param label to use in hint, like label:object
115 * \param callback Callback
116 * \retval -1 failure
117 * \retval 0 success
119 int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback);
121 /*! \brief Remove device state provider
122 * \param label to use in hint, like label:object
123 * \return nothing
125 void ast_devstate_prov_del(const char *label);
127 int ast_device_state_engine_init(void);
129 #if defined(__cplusplus) || defined(c_plusplus)
131 #endif
133 #endif /* _ASTERISK_DEVICESTATE_H */