Sat Mar 24 23:26:04 2007

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 
00045 typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data);
00046 
00047 /*! \brief Convert device state to text string for output 
00048  * \param devstate Current device state 
00049  */
00050 const char *devstate2str(int devstate);
00051 
00052 /*! \brief Search the Channels by Name
00053  * \param device like a dialstring
00054  * Search the Device in active channels by compare the channelname against 
00055  * the devicename. Compared are only the first chars to the first '-' char.
00056  * Returns an AST_DEVICE_UNKNOWN if no channel found or
00057  * AST_DEVICE_INUSE if a channel is found
00058  */
00059 int ast_parse_device_state(const char *device);
00060 
00061 /*! \brief Asks a channel for device state
00062  * \param device like a dialstring
00063  * Asks a channel for device state, data is  normaly a number from dialstring
00064  * used by the low level module
00065  * Trys the channel devicestate callback if not supported search in the
00066  * active channels list for the device.
00067  * Returns an AST_DEVICE_??? state -1 on failure
00068  */
00069 int ast_device_state(const char *device);
00070 
00071 /*! \brief Tells Asterisk the State for Device is changed
00072  * \param fmt devicename like a dialstring with format parameters
00073  * Asterisk polls the new extensionstates and calls the registered
00074  * callbacks for the changed extensions
00075  * Returns 0 on success, -1 on failure
00076  */
00077 int ast_device_state_changed(const char *fmt, ...)
00078    __attribute__ ((format (printf, 1, 2)));
00079 
00080 
00081 /*! \brief Tells Asterisk the State for Device is changed 
00082  * \param device devicename like a dialstrin
00083  * Asterisk polls the new extensionstates and calls the registered
00084  * callbacks for the changed extensions
00085  * Returns 0 on success, -1 on failure
00086  */
00087 int ast_device_state_changed_literal(const char *device);
00088 
00089 /*! \brief Registers a device state change callback 
00090  * \param callback Callback
00091  * \param data to pass to callback
00092  * The callback is called if the state for extension is changed
00093  * Return -1 on failure, ID on success
00094  */ 
00095 int ast_devstate_add(ast_devstate_cb_type callback, void *data);
00096 void ast_devstate_del(ast_devstate_cb_type callback, void *data);
00097 
00098 int ast_device_state_engine_init(void);
00099 
00100 #if defined(__cplusplus) || defined(c_plusplus)
00101 }
00102 #endif
00103 
00104 #endif /* _ASTERISK_DEVICESTATE_H */

Generated on Sat Mar 24 23:26:04 2007 for Asterisk - the Open Source PBX by  doxygen 1.4.6