Adds DAHDI support alongside Zaptel. DAHDI usage favored, but all Zap stuff should...
[asterisk-bristuff.git] / include / asterisk / dial.h
blob525f425a083bdfe37b72923193a893ca91dc82b1
1 /*
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.
19 /*! \file
20 * \brief Dialing API
23 #ifndef _ASTERISK_DIAL_H
24 #define _ASTERISK_DIAL_H
26 #if defined(__cplusplus) || defined(c_plusplus)
27 extern "C" {
28 #endif
30 /*! \brief Main dialing structure. Contains global options, channels being dialed, and more! */
31 struct ast_dial;
33 /*! \brief Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more! */
34 struct ast_dial_channel;
36 typedef void (*ast_dial_state_callback)(struct ast_dial *);
38 /*! \brief List of options that are applicable either globally or per dialed channel */
39 enum ast_dial_option {
40 AST_DIAL_OPTION_RINGING, /*!< Always indicate ringing to caller */
41 AST_DIAL_OPTION_ANSWER_EXEC, /*!< Execute application upon answer in async mode */
42 AST_DIAL_OPTION_MAX, /*!< End terminator -- must always remain last */
45 /*! \brief List of return codes for dial run API calls */
46 enum ast_dial_result {
47 AST_DIAL_RESULT_INVALID, /*!< Invalid options were passed to run function */
48 AST_DIAL_RESULT_FAILED, /*!< Attempts to dial failed before reaching critical state */
49 AST_DIAL_RESULT_TRYING, /*!< Currently trying to dial */
50 AST_DIAL_RESULT_RINGING, /*!< Dial is presently ringing */
51 AST_DIAL_RESULT_PROGRESS, /*!< Dial is presently progressing */
52 AST_DIAL_RESULT_PROCEEDING, /*!< Dial is presently proceeding */
53 AST_DIAL_RESULT_ANSWERED, /*!< A channel was answered */
54 AST_DIAL_RESULT_TIMEOUT, /*!< Timeout was tripped, nobody answered */
55 AST_DIAL_RESULT_HANGUP, /*!< Caller hung up */
56 AST_DIAL_RESULT_UNANSWERED, /*!< Nobody answered */
59 /*! \brief New dialing structure
60 * \note Create a dialing structure
61 * \return Returns a calloc'd ast_dial structure, NULL on failure
63 struct ast_dial *ast_dial_create(void);
65 /*! \brief Append a channel
66 * \note Appends a channel to a dialing structure
67 * \return Returns channel reference number on success, -1 on failure
69 int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device);
71 /*! \brief Execute dialing synchronously or asynchronously
72 * \note Dials channels in a dial structure.
73 * \return Returns dial result code. (TRYING/INVALID/FAILED/ANSWERED/TIMEOUT/UNANSWERED).
75 enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async);
77 /*! \brief Return channel that answered
78 * \note Returns the Asterisk channel that answered
79 * \param dial Dialing structure
81 struct ast_channel *ast_dial_answered(struct ast_dial *dial);
83 /*! \brief Return state of dial
84 * \note Returns the state of the dial attempt
85 * \param dial Dialing structure
87 enum ast_dial_result ast_dial_state(struct ast_dial *dial);
89 /*! \brief Cancel async thread
90 * \note Cancel a running async thread
91 * \param dial Dialing structure
93 enum ast_dial_result ast_dial_join(struct ast_dial *dial);
95 /*! \brief Hangup channels
96 * \note Hangup all active channels
97 * \param dial Dialing structure
99 void ast_dial_hangup(struct ast_dial *dial);
101 /*! \brief Destroys a dialing structure
102 * \note Cancels dialing and destroys (free's) the given ast_dial structure
103 * \param dial Dialing structure to free
104 * \return Returns 0 on success, -1 on failure
106 int ast_dial_destroy(struct ast_dial *dial);
108 /*! \brief Enables an option globally
109 * \param dial Dial structure to enable option on
110 * \param option Option to enable
111 * \param data Data to pass to this option (not always needed)
112 * \return Returns 0 on success, -1 on failure
114 int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data);
116 /*! \brief Enables an option per channel
117 * \param dial Dial structure
118 * \param num Channel number to enable option on
119 * \param option Option to enable
120 * \param data Data to pass to this option (not always needed)
121 * \return Returns 0 on success, -1 on failure
123 int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data);
125 /*! \brief Disables an option globally
126 * \param dial Dial structure to disable option on
127 * \param option Option to disable
128 * \return Returns 0 on success, -1 on failure
130 int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option);
132 /*! \brief Disables an option per channel
133 * \param dial Dial structure
134 * \param num Channel number to disable option on
135 * \param option Option to disable
136 * \return Returns 0 on success, -1 on failure
138 int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option);
140 /*! \brief Set a callback for state changes
141 * \param dial The dial structure to watch for state changes
142 * \param callback the callback
143 * \return nothing
145 void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback);
147 #if defined(__cplusplus) || defined(c_plusplus)
149 #endif
151 #endif /* _ASTERISK_DIAL_H */