summaryrefslogtreecommitdiff
path: root/include/asterisk/features_config.h
blob: 1bce50bba23733dcc5803bdf384c0ce4d29c5c0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2013, Digium, Inc.
*
* Mark Michelson <mmichelson@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/

#ifndef _FEATURES_CONFIG_H
#define _FEATURES_CONFIG_H

#include "asterisk/stringfields.h"

struct ast_channel;

/*!
 * \brief General features configuration items
 */
struct ast_features_general_config {
	AST_DECLARE_STRING_FIELDS(
		/*! Sound played when automon or automixmon features are used */
		AST_STRING_FIELD(courtesytone);
		/*! Sound played when automon or automixmon features fail when used */
		AST_STRING_FIELD(recordingfailsound);
	);
	/*! Milliseconds allowed between digit presses when entering feature code */
	unsigned int featuredigittimeout;
};

/*!
 * \brief Get the general configuration options for a channel
 *
 * \note The channel should be locked before calling this function.
 * \note The returned value has its reference count incremented.
 *
 * If no channel is provided, then the global features configuration is returned.
 *
 * \param chan The channel to get configuration options for
 * \retval NULL Failed to get configuration
 * \retval non-NULL The general features configuration
 */
struct ast_features_general_config *ast_get_chan_features_general_config(struct ast_channel *chan);

/*!
 * \brief Feature configuration relating to transfers
 */
struct ast_features_xfer_config {
	AST_DECLARE_STRING_FIELDS (
		/*! Sound to play when transfer succeeds */
		AST_STRING_FIELD(xfersound);
		/*! Sound to play when transfer fails */
		AST_STRING_FIELD(xferfailsound);
		/*! DTMF sequence used to abort an attempted atxfer */
		AST_STRING_FIELD(atxferabort);
		/*! DTMF sequence used to complete an attempted atxfer */
		AST_STRING_FIELD(atxfercomplete);
		/*! DTMF sequence used to turn an attempted atxfer into a three-way call */
		AST_STRING_FIELD(atxferthreeway);
		/*! DTMF sequence used to swap which party the transferer is talking to */
		AST_STRING_FIELD(atxferswap);
		/*! Sound played when an invalid extension is dialed, and the transferer should retry. */
		AST_STRING_FIELD(transferretrysound);
		/*! Sound played when an invalid extension is dialed, and the transferer is being returned to the call. */
		AST_STRING_FIELD(transferinvalidsound);
	);
	/*! Seconds allowed between digit presses when dialing transfer destination */
	unsigned int transferdigittimeout;
	/*! Seconds to wait for the transfer target to answer a transferred call */
	unsigned int atxfernoanswertimeout;
	/*! Seconds to wait before attempting to re-dial the transfer target */
	unsigned int atxferloopdelay;
	/*! Number of times to re-attempt dialing the transfer target */
	unsigned int atxfercallbackretries;
	/*! Determines if the call is dropped on attended transfer failure */
	unsigned int atxferdropcall;
	/*! Number of dial attempts allowed for blind/attended transfers */
	unsigned int transferdialattempts;
};

/*!
 * \brief Get the transfer configuration options for a channel
 *
 * \note The channel should be locked before calling this function.
 * \note The returned value has its reference count incremented.
 *
 * If no channel is provided, then the global transfer configuration is returned.
 *
 * \param chan The channel to get configuration options for
 * \retval NULL Failed to get configuration
 * \retval non-NULL The transfer features configuration
 */
struct ast_features_xfer_config *ast_get_chan_features_xfer_config(struct ast_channel *chan);

/*!
 * \brief Get the transfer configuration option xferfailsound
 *
 * \note The channel should be locked before calling this function.
 * \note The returned value has to be freed.
 *
 * If no channel is provided, then option is pulled from the global
 * transfer configuration.
 *
 * \param chan The channel to get configuration options for
 * \retval NULL Failed to get configuration
 * \retval non-NULL The xferfailsound
 */
char *ast_get_chan_features_xferfailsound(struct ast_channel *chan);

/*!
 * \brief Get the transfer configuration option atxferabort
 *
 * \note The channel should be locked before calling this function.
 * \note The returned value has to be freed.
 *
 * If no channel is provided, then option is pulled from the global
 * transfer configuration.
 *
 * \param chan The channel to get configuration options for
 * \retval NULL Failed to get configuration
 * \retval non-NULL The atxferabort
 */
char *ast_get_chan_features_atxferabort(struct ast_channel *chan);

/*!
 * \brief Configuration relating to call pickup
 */
struct ast_features_pickup_config {
	AST_DECLARE_STRING_FIELDS (
		/*! Digit sequence to press to pick up a ringing call */
		AST_STRING_FIELD(pickupexten);
		/*! Sound to play to picker when pickup succeeds */
		AST_STRING_FIELD(pickupsound);
		/*! Sound to play to picker when pickup fails */
		AST_STRING_FIELD(pickupfailsound);
	);
};

/*!
 * \brief Get the pickup configuration options for a channel
 *
 * \note The channel should be locked before calling this function.
 * \note The returned value has its reference count incremented.
 *
 * If no channel is provided, then the global pickup configuration is returned.
 *
 * \param chan The channel to get configuration options for
 * \retval NULL Failed to get configuration
 * \retval non-NULL The pickup features configuration
 */
struct ast_features_pickup_config *ast_get_chan_features_pickup_config(struct ast_channel *chan);

/*!
 * \brief Configuration for the builtin features
 */
struct ast_featuremap_config {
	AST_DECLARE_STRING_FIELDS (
		/*! Blind transfer DTMF code */
		AST_STRING_FIELD(blindxfer);
		/*! Disconnect DTMF code */
		AST_STRING_FIELD(disconnect);
		/*! Automon DTMF code */
		AST_STRING_FIELD(automon);
		/*! Attended Transfer DTMF code */
		AST_STRING_FIELD(atxfer);
		/*! One-touch parking DTMF code */
		AST_STRING_FIELD(parkcall);
		/*! Automixmon DTMF code */
		AST_STRING_FIELD(automixmon);
	);
};

/*!
 * \brief Get the featuremap configuration options for a channel
 *
 * \note The channel should be locked before calling this function.
 * \note The returned value has its reference count incremented.
 *
 * If no channel is provided, then the global featuremap configuration is returned.
 *
 * \param chan The channel to get configuration options for
 * \retval NULL Failed to get configuration
 * \retval non-NULL The pickup features configuration
 */
struct ast_featuremap_config *ast_get_chan_featuremap_config(struct ast_channel *chan);

/*!
 * \brief Get the DTMF code for a builtin feature
 *
 * \note The channel should be locked before calling this function
 *
 * If no channel is provided, then the global setting for the option is returned.
 *
 * \param chan The channel to get the option from
 * \param feature The short name of the feature (as it appears in features.conf)
 * \param[out] buf The buffer to write the DTMF value into
 * \param size The size of the buffer in bytes
 * \retval 0 Success
 * \retval non-zero Unrecognized builtin feature name
 */
int ast_get_builtin_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len);

/*!
 * \brief Get the DTMF code for a call feature
 *
 * \note The channel should be locked before calling this function
 *
 * If no channel is provided, then the global setting for the option is returned.
 *
 * This function is like \ref ast_get_builtin_feature except that it will
 * also check the applicationmap in addition to the builtin features.
 *
 * \param chan The channel to get the option from
 * \param feature The short name of the feature
 * \param[out] buf The buffer to write the DTMF value into
 * \param size The size of the buffer in bytes
 * \retval 0 Success
 * \retval non-zero Unrecognized feature name
 */
int ast_get_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len);

#define AST_FEATURE_MAX_LEN 11

/*!
 * \brief An applicationmap configuration item
 */
struct ast_applicationmap_item {
	AST_DECLARE_STRING_FIELDS (
		/* Name of the item */
		AST_STRING_FIELD(name);
		/* Name Dialplan application that is invoked by the feature */
		AST_STRING_FIELD(app);
		/* Data to pass to the application */
		AST_STRING_FIELD(app_data);
		/* Music-on-hold class to play to party on which feature is not activated */
		AST_STRING_FIELD(moh_class);
	);
	/* DTMF key sequence used to activate the feature */
	char dtmf[AST_FEATURE_MAX_LEN];
	/* If true, activate on party that input the sequence, otherwise activate on the other party */
	unsigned int activate_on_self;
};

/*!
 * \brief Get the applicationmap for a given channel.
 *
 * \note The channel should be locked before calling this function.
 *
 * This uses the value of the DYNAMIC_FEATURES channel variable to build a
 * custom applicationmap for this channel. The returned container has
 * applicationmap_items inside.
 *
 * \param chan The channel for which applicationmap is being retrieved.
 * \retval NULL An error occurred or the channel has no dynamic features.
 * \retval non-NULL A container of applicationmap_items pertaining to the channel.
 */
struct ao2_container *ast_get_chan_applicationmap(struct ast_channel *chan);

void ast_features_config_shutdown(void);

int ast_features_config_reload(void);

int ast_features_config_init(void);

#endif /* _FEATURES_CONFIG_H */