2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2007, Digium, Inc.
6 * Joshua Colp <jcolp@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.
23 #ifndef _ASTERISK_DIAL_H
24 #define _ASTERISK_DIAL_H
26 #if defined(__cplusplus) || defined(c_plusplus)
30 /*! \brief Main dialing structure. Contains global options, channels being dialed, and more! */
33 /*! \brief Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more! */
34 struct ast_dial_channel;
36 /*! \brief List of options that are applicable either globally or per dialed channel */
37 enum ast_dial_option {
38 AST_DIAL_OPTION_RINGING, /*!< Always indicate ringing to caller */
39 AST_DIAL_OPTION_ANSWER_EXEC, /*!< Execute application upon answer in async mode */
40 AST_DIAL_OPTION_MAX, /*!< End terminator -- must always remain last */
43 /*! \brief List of return codes for dial run API calls */
44 enum ast_dial_result {
45 AST_DIAL_RESULT_INVALID = 0, /*!< Invalid options were passed to run function */
46 AST_DIAL_RESULT_FAILED, /*!< Attempts to dial failed before reaching critical state */
47 AST_DIAL_RESULT_TRYING, /*!< Currently trying to dial */
48 AST_DIAL_RESULT_RINGING, /*!< Dial is presently ringing */
49 AST_DIAL_RESULT_PROGRESS, /*!< Dial is presently progressing */
50 AST_DIAL_RESULT_PROCEEDING, /*!< Dial is presently proceeding */
51 AST_DIAL_RESULT_ANSWERED, /*!< A channel was answered */
52 AST_DIAL_RESULT_TIMEOUT, /*!< Timeout was tripped, nobody answered */
53 AST_DIAL_RESULT_HANGUP, /*!< Caller hung up */
54 AST_DIAL_RESULT_UNANSWERED, /*!< Nobody answered */
57 /*! \brief New dialing structure
58 * \note Create a dialing structure
59 * \return Returns a calloc'd ast_dial structure, NULL on failure
61 struct ast_dial *ast_dial_create(void);
63 /*! \brief Append a channel
64 * \note Appends a channel to a dialing structure
65 * \return Returns channel reference number on success, -1 on failure
67 int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device);
69 /*! \brief Execute dialing synchronously or asynchronously
70 * \note Dials channels in a dial structure.
71 * \return Returns dial result code. (TRYING/INVALID/FAILED/ANSWERED/TIMEOUT/UNANSWERED).
73 enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async);
75 /*! \brief Return channel that answered
76 * \note Returns the Asterisk channel that answered
77 * \param dial Dialing structure
79 struct ast_channel *ast_dial_answered(struct ast_dial *dial);
81 /*! \brief Return status of dial
82 * \note Returns the status of the dial attempt
83 * \param dial Dialing structure
85 enum ast_dial_result ast_dial_status(struct ast_dial *dial);
87 /*! \brief Cancel async thread
88 * \note Cancel a running async thread
89 * \param dial Dialing structure
91 enum ast_dial_result ast_dial_join(struct ast_dial *dial);
93 /*! \brief Hangup channels
94 * \note Hangup all active channels
95 * \param dial Dialing structure
97 void ast_dial_hangup(struct ast_dial *dial);
99 /*! \brief Destroys a dialing structure
100 * \note Cancels dialing and destroys (free's) the given ast_dial structure
101 * \param dial Dialing structure to free
102 * \return Returns 0 on success, -1 on failure
104 int ast_dial_destroy(struct ast_dial *dial);
106 /*! \brief Enables an option globally
107 * \param dial Dial structure to enable option on
108 * \param option Option to enable
109 * \param data Data to pass to this option (not always needed)
110 * \return Returns 0 on success, -1 on failure
112 int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data);
114 /*! \brief Enables an option per channel
115 * \param dial Dial structure
116 * \param num Channel number to enable option on
117 * \param option Option to enable
118 * \param data Data to pass to this option (not always needed)
119 * \return Returns 0 on success, -1 on failure
121 int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data);
123 /*! \brief Disables an option globally
124 * \param dial Dial structure to disable option on
125 * \param option Option to disable
126 * \return Returns 0 on success, -1 on failure
128 int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option);
130 /*! \brief Disables an option per channel
131 * \param dial Dial structure
132 * \param num Channel number to disable option on
133 * \param option Option to disable
134 * \return Returns 0 on success, -1 on failure
136 int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option);
138 #if defined(__cplusplus) || defined(c_plusplus)
142 #endif /* _ASTERISK_DIAL_H */