Merged revisions 183126 via svnmerge from
[asterisk/asterisk.git] / include / asterisk / features.h
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
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.
13  *
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.
17  */
18
19 /*! \file
20  * \brief Call Parking and Pickup API 
21  * Includes code and algorithms from the Zapata library.
22  */
23
24 #ifndef _AST_FEATURES_H
25 #define _AST_FEATURES_H
26
27 #include "asterisk/pbx.h"
28 #include "asterisk/linkedlists.h"
29
30 #define FEATURE_MAX_LEN         11
31 #define FEATURE_APP_LEN         64
32 #define FEATURE_APP_ARGS_LEN    256
33 #define FEATURE_SNAME_LEN       32
34 #define FEATURE_EXTEN_LEN       32
35 #define FEATURE_MOH_LEN         80  /* same as MAX_MUSICCLASS from channel.h */
36
37 #define PARK_APP_NAME "Park"
38
39 #define AST_FEATURE_RETURN_HANGUP           -1
40 #define AST_FEATURE_RETURN_SUCCESSBREAK     0
41 #define AST_FEATURE_RETURN_PBX_KEEPALIVE    AST_PBX_KEEPALIVE
42 #define AST_FEATURE_RETURN_NO_HANGUP_PEER   AST_PBX_NO_HANGUP_PEER
43 #define AST_FEATURE_RETURN_PASSDIGITS       21
44 #define AST_FEATURE_RETURN_STOREDIGITS      22
45 #define AST_FEATURE_RETURN_SUCCESS          23
46 #define AST_FEATURE_RETURN_KEEPTRYING       24
47 #define AST_FEATURE_RETURN_PARKFAILED       25
48
49 #define FEATURE_SENSE_CHAN      (1 << 0)
50 #define FEATURE_SENSE_PEER      (1 << 1)
51
52 typedef int (*ast_feature_operation)(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense, void *data);
53
54 /*! \brief main call feature structure */
55
56 enum {
57         AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0),
58         AST_FEATURE_FLAG_ONPEER =    (1 << 1),
59         AST_FEATURE_FLAG_ONSELF =    (1 << 2),
60         AST_FEATURE_FLAG_BYCALLEE =  (1 << 3),
61         AST_FEATURE_FLAG_BYCALLER =  (1 << 4),
62         AST_FEATURE_FLAG_BYBOTH  =   (3 << 3),
63 };
64
65 struct ast_call_feature {
66         int feature_mask;
67         char *fname;
68         char sname[FEATURE_SNAME_LEN];
69         char exten[FEATURE_MAX_LEN];
70         char default_exten[FEATURE_MAX_LEN];
71         ast_feature_operation operation;
72         unsigned int flags;
73         char app[FEATURE_APP_LEN];              
74         char app_args[FEATURE_APP_ARGS_LEN];
75         char moh_class[FEATURE_MOH_LEN];
76         AST_LIST_ENTRY(ast_call_feature) feature_entry;
77 };
78
79 /*!
80  * \brief Park a call and read back parked location 
81  * \param chan the channel to actually be parked
82  * \param host the channel which will have the parked location read to.
83  * \param timeout is a timeout in milliseconds
84  * \param extout is a parameter to an int that will hold the parked location, or NULL if you want.
85  * 
86  * Park the channel chan, and read back the parked location to the host. 
87  * If the call is not picked up within a specified period of time, 
88  * then the call will return to the last step that it was in 
89  * (in terms of exten, priority and context)
90  * \retval 0 on success.
91  * \retval -1 on failure.
92 */
93 int ast_park_call(struct ast_channel *chan, struct ast_channel *host, int timeout, int *extout);
94
95 /*! 
96  * \brief Park a call via a masqueraded channel
97  * \param rchan the real channel to be parked
98  * \param host the channel to have the parking read to.
99  * \param timeout is a timeout in milliseconds
100  * \param extout is a parameter to an int that will hold the parked location, or NULL if you want.
101  * 
102  * Masquerade the channel rchan into a new, empty channel which is then parked with ast_park_call
103  * \retval 0 on success.
104  * \retval -1 on failure.
105 */
106 int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *host, int timeout, int *extout);
107
108 /*! 
109  * \brief Determine system parking extension
110  * \returns the call parking extension for drivers that provide special call parking help 
111 */
112 const char *ast_parking_ext(void);
113
114 /*! \brief Determine system call pickup extension */
115 const char *ast_pickup_ext(void);
116
117 /*! \brief Bridge a call, optionally allowing redirection */
118 int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer,struct ast_bridge_config *config);
119
120 /*! \brief Pickup a call */
121 int ast_pickup_call(struct ast_channel *chan);
122
123 /*! \brief register new feature into feature_set 
124    \param feature an ast_call_feature object which contains a keysequence
125    and a callback function which is called when this keysequence is pressed
126    during a call. */
127 void ast_register_feature(struct ast_call_feature *feature);
128
129 /*! \brief unregister feature from feature_set
130     \param feature the ast_call_feature object which was registered before*/
131 void ast_unregister_feature(struct ast_call_feature *feature);
132
133 /*! \brief detect a feature before bridging 
134     \para chan, ast_flags ptr, code, ast_call_feature ptr to be set if found */
135 int ast_feature_detect(struct ast_channel *chan, struct ast_flags *features, char *code, struct ast_call_feature *feature);
136
137 /*! \brief look for a call feature entry by its sname
138         \param name a string ptr, should match "automon", "blindxfer", "atxfer", etc. */
139 struct ast_call_feature *ast_find_call_feature(const char *name);
140
141 void ast_rdlock_call_features(void);
142 void ast_unlock_call_features(void);
143
144 /*! \brief Reload call features from features.conf */
145 int ast_features_reload(void);
146
147 #endif /* _AST_FEATURES_H */