![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
dial.h
Go to the documentation of this file.
00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 1999 - 2007, Digium, Inc. 00005 * 00006 * Joshua Colp <jcolp@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 Dialing API 00021 */ 00022 00023 #ifndef _ASTERISK_DIAL_H 00024 #define _ASTERISK_DIAL_H 00025 00026 #if defined(__cplusplus) || defined(c_plusplus) 00027 extern "C" { 00028 #endif 00029 00030 /*! \brief Main dialing structure. Contains global options, channels being dialed, and more! */ 00031 struct ast_dial; 00032 00033 /*! \brief Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more! */ 00034 struct ast_dial_channel; 00035 00036 /*! \brief List of options that are applicable either globally or per dialed channel */ 00037 enum ast_dial_option { 00038 AST_DIAL_OPTION_RINGING, /*!< Always indicate ringing to caller */ 00039 AST_DIAL_OPTION_ANSWER_EXEC, /*!< Execute application upon answer in async mode */ 00040 AST_DIAL_OPTION_MAX, /*!< End terminator -- must always remain last */ 00041 }; 00042 00043 /*! \brief List of return codes for dial run API calls */ 00044 enum ast_dial_result { 00045 AST_DIAL_RESULT_INVALID = 0, /*!< Invalid options were passed to run function */ 00046 AST_DIAL_RESULT_FAILED, /*!< Attempts to dial failed before reaching critical state */ 00047 AST_DIAL_RESULT_TRYING, /*!< Currently trying to dial */ 00048 AST_DIAL_RESULT_RINGING, /*!< Dial is presently ringing */ 00049 AST_DIAL_RESULT_PROGRESS, /*!< Dial is presently progressing */ 00050 AST_DIAL_RESULT_PROCEEDING, /*!< Dial is presently proceeding */ 00051 AST_DIAL_RESULT_ANSWERED, /*!< A channel was answered */ 00052 AST_DIAL_RESULT_TIMEOUT, /*!< Timeout was tripped, nobody answered */ 00053 AST_DIAL_RESULT_HANGUP, /*!< Caller hung up */ 00054 AST_DIAL_RESULT_UNANSWERED, /*!< Nobody answered */ 00055 }; 00056 00057 /*! \brief New dialing structure 00058 * \note Create a dialing structure 00059 * \return Returns a calloc'd ast_dial structure, NULL on failure 00060 */ 00061 struct ast_dial *ast_dial_create(void); 00062 00063 /*! \brief Append a channel 00064 * \note Appends a channel to a dialing structure 00065 * \return Returns channel reference number on success, -1 on failure 00066 */ 00067 int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device); 00068 00069 /*! \brief Execute dialing synchronously or asynchronously 00070 * \note Dials channels in a dial structure. 00071 * \return Returns dial result code. (TRYING/INVALID/FAILED/ANSWERED/TIMEOUT/UNANSWERED). 00072 */ 00073 enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async); 00074 00075 /*! \brief Return channel that answered 00076 * \note Returns the Asterisk channel that answered 00077 * \param dial Dialing structure 00078 */ 00079 struct ast_channel *ast_dial_answered(struct ast_dial *dial); 00080 00081 /*! \brief Return status of dial 00082 * \note Returns the status of the dial attempt 00083 * \param dial Dialing structure 00084 */ 00085 enum ast_dial_result ast_dial_status(struct ast_dial *dial); 00086 00087 /*! \brief Cancel async thread 00088 * \note Cancel a running async thread 00089 * \param dial Dialing structure 00090 */ 00091 enum ast_dial_result ast_dial_join(struct ast_dial *dial); 00092 00093 /*! \brief Hangup channels 00094 * \note Hangup all active channels 00095 * \param dial Dialing structure 00096 */ 00097 void ast_dial_hangup(struct ast_dial *dial); 00098 00099 /*! \brief Destroys a dialing structure 00100 * \note Cancels dialing and destroys (free's) the given ast_dial structure 00101 * \param dial Dialing structure to free 00102 * \return Returns 0 on success, -1 on failure 00103 */ 00104 int ast_dial_destroy(struct ast_dial *dial); 00105 00106 /*! \brief Enables an option globally 00107 * \param dial Dial structure to enable option on 00108 * \param option Option to enable 00109 * \param data Data to pass to this option (not always needed) 00110 * \return Returns 0 on success, -1 on failure 00111 */ 00112 int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data); 00113 00114 /*! \brief Enables an option per channel 00115 * \param dial Dial structure 00116 * \param num Channel number to enable option on 00117 * \param option Option to enable 00118 * \param data Data to pass to this option (not always needed) 00119 * \return Returns 0 on success, -1 on failure 00120 */ 00121 int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data); 00122 00123 /*! \brief Disables an option globally 00124 * \param dial Dial structure to disable option on 00125 * \param option Option to disable 00126 * \return Returns 0 on success, -1 on failure 00127 */ 00128 int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option); 00129 00130 /*! \brief Disables an option per channel 00131 * \param dial Dial structure 00132 * \param num Channel number to disable option on 00133 * \param option Option to disable 00134 * \return Returns 0 on success, -1 on failure 00135 */ 00136 int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option); 00137 00138 #if defined(__cplusplus) || defined(c_plusplus) 00139 } 00140 #endif 00141 00142 #endif /* _ASTERISK_DIAL_H */