Fri Sep 25 19:28:11 2009

Asterisk developer's documentation


devicestate.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  * \brief Device state management
00021  */
00022 
00023 #ifndef _ASTERISK_DEVICESTATE_H
00024 #define _ASTERISK_DEVICESTATE_H
00025 
00026 #if defined(__cplusplus) || defined(c_plusplus)
00027 extern "C" {
00028 #endif
00029 
00030 /*! Device is valid but channel didn't know state */
00031 #define AST_DEVICE_UNKNOWN 0
00032 /*! Device is not used */
00033 #define AST_DEVICE_NOT_INUSE  1
00034 /*! Device is in use */
00035 #define AST_DEVICE_INUSE   2
00036 /*! Device is busy */
00037 #define AST_DEVICE_BUSY    3
00038 /*! Device is invalid */
00039 #define AST_DEVICE_INVALID 4
00040 /*! Device is unavailable */
00041 #define AST_DEVICE_UNAVAILABLE   5
00042 /*! Device is ringing */
00043 #define AST_DEVICE_RINGING 6
00044 /*! Device is ringing *and* in use */
00045 #define AST_DEVICE_RINGINUSE  7
00046 /*! Device is on hold */
00047 #define AST_DEVICE_ONHOLD  8
00048 
00049 /*! \brief Devicestate watcher call back */
00050 typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data, char *cid_num, char *cid_name);
00051 
00052 /*!  \brief Devicestate provider call back */
00053 typedef int (*ast_devstate_prov_cb_type)(const char *data);
00054 
00055 /*! \brief Convert device state to text string for output 
00056  * \param devstate Current device state 
00057  */
00058 const char *devstate2str(int devstate);
00059 
00060 /*! \brief Search the Channels by Name
00061  * \param device like a dialstring
00062  * Search the Device in active channels by compare the channelname against 
00063  * the devicename. Compared are only the first chars to the first '-' char.
00064  * Returns an AST_DEVICE_UNKNOWN if no channel found or
00065  * AST_DEVICE_INUSE if a channel is found
00066  */
00067 int ast_parse_device_state(const char *device);
00068 
00069 /*! \brief Asks a channel for device state
00070  * \param device like a dialstring
00071  * Asks a channel for device state, data is  normaly a number from dialstring
00072  * used by the low level module
00073  * Trys the channel devicestate callback if not supported search in the
00074  * active channels list for the device.
00075  * Returns an AST_DEVICE_??? state -1 on failure
00076  */
00077 int ast_device_state(const char *device);
00078 
00079 /*! \brief Tells Asterisk the State for Device is changed
00080  * \param fmt devicename like a dialstring with format parameters
00081  * Asterisk polls the new extensionstates and calls the registered
00082  * callbacks for the changed extensions
00083  * Returns 0 on success, -1 on failure
00084  */
00085 int ast_device_state_changed(const char *fmt, ...)
00086    __attribute__ ((format (printf, 1, 2)));
00087 
00088 
00089 /*! \brief Tells Asterisk the State for Device is changed 
00090  * \param device devicename like a dialstring
00091  * Asterisk polls the new extensionstates and calls the registered
00092  * callbacks for the changed extensions
00093  * Returns 0 on success, -1 on failure
00094  */
00095 int ast_device_state_changed_literal(const char *device, const char *cid_num, const char *cid_name);
00096 
00097 /*! \brief Registers a device state change callback 
00098  * \param callback Callback
00099  * \param data to pass to callback
00100  * The callback is called if the state for extension is changed
00101  * Return -1 on failure, ID on success
00102  */ 
00103 int ast_devstate_add(ast_devstate_cb_type callback, void *data);
00104 
00105 /*! \brief Unregisters a device state change callback 
00106  * \param callback Callback
00107  * \param data to pass to callback
00108  * The callback is called if the state for extension is changed
00109  * Return -1 on failure, ID on success
00110  */ 
00111 void ast_devstate_del(ast_devstate_cb_type callback, void *data);
00112 
00113 /*! \brief Add device state provider 
00114  * \param label to use in hint, like label:object
00115  * \param callback Callback
00116  * \retval -1 failure
00117  * \retval 0 success
00118  */ 
00119 int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback);
00120 
00121 /*! \brief Remove device state provider 
00122  * \param label to use in hint, like label:object
00123  * \return nothing
00124  */ 
00125 void ast_devstate_prov_del(const char *label);
00126 
00127 int ast_device_state_engine_init(void);
00128 
00129 #if defined(__cplusplus) || defined(c_plusplus)
00130 }
00131 #endif
00132 
00133 #endif /* _ASTERISK_DEVICESTATE_H */

Generated on Fri Sep 25 19:28:11 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.5