Add small documentation update to func_callcompletion.c.
[asterisk/asterisk.git] / funcs / func_callcompletion.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2010, Digium, Inc.
5  *
6  * Mark Michelson <mmichelson@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 Completion Supplementary Services implementation
21  * \author Mark Michelson <mmichelson@digium.com>
22  */
23
24 #include "asterisk.h"
25
26 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
27
28 #include "asterisk/module.h"
29 #include "asterisk/channel.h"
30 #include "asterisk/ccss.h"
31 #include "asterisk/pbx.h"
32
33 /*** DOCUMENTATION
34         <function name="CALLCOMPLETION" language="en_US">
35                 <synopsis>
36                         Get or set a call completion configuration parameter for a channel.
37                 </synopsis>
38                 <syntax>
39                         <parameter name="option" required="true">
40                                 <para>The allowable options are:</para>
41                                 <enumlist>
42                                         <enum name="cc_agent_policy" />
43                                         <enum name="cc_monitor_policy" />
44                                         <enum name="cc_offer_timer" />
45                                         <enum name="ccnr_available_timer" />
46                                         <enum name="ccbs_available_timer" />
47                                         <enum name="cc_recall_timer" />
48                                         <enum name="cc_max_agents" />
49                                         <enum name="cc_max_monitors" />
50                                         <enum name="cc_callback_macro" />
51                                         <enum name="cc_agent_dialstring" />
52                                 </enumlist>
53                         </parameter>
54                 </syntax>
55                 <description>
56                         <para>The CALLCOMPLETION function can be used to get or set a call
57                         completion configuration parameter for a channel. Note that setting
58                         a configuration parameter will only change the parameter for the
59                         duration of the call.
60                         
61                         For more information on call completion in Asterisk, see <filename>doc/tex/ccss.tex</filename>.
62                         For more information on call completion parameters, see <filename>configs/ccss.conf.sample</filename>.</para>
63                 </description>
64         </function>
65  ***/
66
67 static int acf_cc_read(struct ast_channel *chan, const char *name, char *data,
68                 char *buf, size_t buf_len)
69 {
70         struct ast_cc_config_params *cc_params;
71         int res;
72
73         ast_channel_lock(chan);
74         if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
75                 ast_channel_unlock(chan);
76                 return -1;
77         }
78
79         res = ast_cc_get_param(cc_params, data, buf, buf_len);
80         ast_channel_unlock(chan);
81         return res;
82 }
83
84 static int acf_cc_write(struct ast_channel *chan, const char *cmd, char *data,
85                 const char *value)
86 {
87         struct ast_cc_config_params *cc_params;
88         int res;
89
90         ast_channel_lock(chan);
91         if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
92                 ast_channel_unlock(chan);
93                 return -1;
94         }
95
96         res = ast_cc_set_param(cc_params, data, value);
97         ast_channel_unlock(chan);
98         return res;
99 }
100
101 static struct ast_custom_function cc_function = {
102         .name = "CALLCOMPLETION",
103         .read = acf_cc_read,
104         .write = acf_cc_write,
105 };
106
107 static int unload_module(void)
108 {
109         return ast_custom_function_unregister(&cc_function);
110 }
111
112 static int load_module(void)
113 {
114         return ast_custom_function_register(&cc_function) == 0 ? AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE;
115 }
116
117 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Control Configuration Function");