This change allows the disconnect feature (as in "one-touch" in features.c)
[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 FEATURE_RETURN_HANGUP           -1
40 #define FEATURE_RETURN_SUCCESSBREAK      0
41 #define FEATURE_RETURN_PASSDIGITS        21
42 #define FEATURE_RETURN_STOREDIGITS       22
43 #define FEATURE_RETURN_SUCCESS           23
44 #define FEATURE_RETURN_KEEPTRYING    24
45
46 typedef int (*feature_operation)(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense, void *data);
47
48 /*! \brief main call feature structure */
49
50 enum {
51         AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0),
52         AST_FEATURE_FLAG_ONPEER =    (1 << 1),
53         AST_FEATURE_FLAG_ONSELF =    (1 << 2),
54         AST_FEATURE_FLAG_BYCALLEE =  (1 << 3),
55         AST_FEATURE_FLAG_BYCALLER =  (1 << 4),
56         AST_FEATURE_FLAG_BYBOTH  =   (3 << 3),
57 };
58
59 struct ast_call_feature {
60         int feature_mask;
61         char *fname;
62         char sname[FEATURE_SNAME_LEN];
63         char exten[FEATURE_MAX_LEN];
64         char default_exten[FEATURE_MAX_LEN];
65         feature_operation operation;
66         unsigned int flags;
67         char app[FEATURE_APP_LEN];              
68         char app_args[FEATURE_APP_ARGS_LEN];
69         char moh_class[FEATURE_MOH_LEN];
70         AST_LIST_ENTRY(ast_call_feature) feature_entry;
71 };
72
73 #define AST_FEATURE_RETURN_HANGUP                   FEATURE_RETURN_HANGUP
74 #define AST_FEATURE_RETURN_SUCCESSBREAK             FEATURE_RETURN_SUCCESSBREAK
75 #define AST_FEATURE_RETURN_PASSDIGITS               FEATURE_RETURN_PASSDIGITS
76 #define AST_FEATURE_RETURN_STOREDIGITS              FEATURE_RETURN_STOREDIGITS
77 #define AST_FEATURE_RETURN_SUCCESS                  FEATURE_RETURN_SUCCESS
78 #define AST_FEATURE_RETURN_KEEPTRYING               FEATURE_RETURN_KEEPTRYING
79
80 struct feature_interpret_result {
81     struct ast_call_feature *builtin_feature;
82     struct ast_call_feature *dynamic_features[20];
83     struct ast_call_feature *group_features[20];
84     int num_dyn_features;
85     int num_grp_features;
86 };
87
88 /*!
89  * \brief Park a call and read back parked location 
90  * \param chan the channel to actually be parked
91  * \param host the channel which will have the parked location read to.
92  * \param timeout is a timeout in milliseconds
93  * \param extout is a parameter to an int that will hold the parked location, or NULL if you want.
94  * 
95  * Park the channel chan, and read back the parked location to the host. 
96  * If the call is not picked up within a specified period of time, 
97  * then the call will return to the last step that it was in 
98  * (in terms of exten, priority and context)
99  * \retval 0 on success.
100  * \retval -1 on failure.
101 */
102 int ast_park_call(struct ast_channel *chan, struct ast_channel *host, int timeout, int *extout);
103
104 /*! 
105  * \brief Park a call via a masqueraded channel
106  * \param rchan the real channel to be parked
107  * \param host the channel to have the parking read to.
108  * \param timeout is a timeout in milliseconds
109  * \param extout is a parameter to an int that will hold the parked location, or NULL if you want.
110  * 
111  * Masquerade the channel rchan into a new, empty channel which is then parked with ast_park_call
112  * \retval 0 on success.
113  * \retval -1 on failure.
114 */
115 int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *host, int timeout, int *extout);
116
117 /*! 
118  * \brief Determine system parking extension
119  * \returns the call parking extension for drivers that provide special call parking help 
120 */
121 const char *ast_parking_ext(void);
122
123 /*! \brief Determine system call pickup extension */
124 const char *ast_pickup_ext(void);
125
126 /*! \brief Bridge a call, optionally allowing redirection */
127 int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer,struct ast_bridge_config *config);
128
129 /*! \brief Pickup a call */
130 int ast_pickup_call(struct ast_channel *chan);
131
132 /*! \brief register new feature into feature_set 
133    \param feature an ast_call_feature object which contains a keysequence
134    and a callback function which is called when this keysequence is pressed
135    during a call. */
136 void ast_register_feature(struct ast_call_feature *feature);
137
138 /*! \brief unregister feature from feature_set
139     \param feature the ast_call_feature object which was registered before*/
140 void ast_unregister_feature(struct ast_call_feature *feature);
141
142 int ast_feature_detect(struct ast_channel *chan, const struct ast_flags *features, char *code, struct feature_interpret_result *result, const char *dynamic_features);
143
144 void ast_features_lock(void);
145 void ast_features_unlock(void);
146
147
148 /*! \brief look for a call feature entry by its sname
149         \param name a string ptr, should match "automon", "blindxfer", "atxfer", etc. */
150 struct ast_call_feature *ast_find_call_feature(const char *name);
151
152 void ast_rdlock_call_features(void);
153 void ast_unlock_call_features(void);
154
155 /*! \brief Reload call features from features.conf */
156 int ast_features_reload(void);
157
158 #endif /* _AST_FEATURES_H */