Asterisk - The Open Source Telephony Project  18.5.0
func_callcompletion.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2010, Digium, Inc.
5  *
6  * Mark Michelson <[email protected]>
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 <[email protected]>
22  */
23 
24 /*** MODULEINFO
25  <support_level>core</support_level>
26  ***/
27 
28 #include "asterisk.h"
29 
30 #include "asterisk/module.h"
31 #include "asterisk/channel.h"
32 #include "asterisk/ccss.h"
33 #include "asterisk/pbx.h"
34 
35 /*** DOCUMENTATION
36  <function name="CALLCOMPLETION" language="en_US">
37  <synopsis>
38  Get or set a call completion configuration parameter for a channel.
39  </synopsis>
40  <syntax>
41  <parameter name="option" required="true">
42  <para>The allowable options are:</para>
43  <enumlist>
44  <enum name="cc_agent_policy" />
45  <enum name="cc_monitor_policy" />
46  <enum name="cc_offer_timer" />
47  <enum name="ccnr_available_timer" />
48  <enum name="ccbs_available_timer" />
49  <enum name="cc_recall_timer" />
50  <enum name="cc_max_agents" />
51  <enum name="cc_max_monitors" />
52  <enum name="cc_callback_macro" />
53  <enum name="cc_agent_dialstring" />
54  </enumlist>
55  </parameter>
56  </syntax>
57  <description>
58  <para>The CALLCOMPLETION function can be used to get or set a call
59  completion configuration parameter for a channel. Note that setting
60  a configuration parameter will only change the parameter for the
61  duration of the call.
62 
63  For more information see <filename>doc/AST.pdf</filename>.
64  For more information on call completion parameters, see <filename>configs/ccss.conf.sample</filename>.</para>
65  </description>
66  </function>
67  ***/
68 
69 static int acf_cc_read(struct ast_channel *chan, const char *name, char *data,
70  char *buf, size_t buf_len)
71 {
72  struct ast_cc_config_params *cc_params;
73  int res;
74 
75  if (!chan) {
76  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", name);
77  return -1;
78  }
79 
80  ast_channel_lock(chan);
81  if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
82  ast_channel_unlock(chan);
83  return -1;
84  }
85 
86  res = ast_cc_get_param(cc_params, data, buf, buf_len);
87  ast_channel_unlock(chan);
88  return res;
89 }
90 
91 static int acf_cc_write(struct ast_channel *chan, const char *cmd, char *data,
92  const char *value)
93 {
94  struct ast_cc_config_params *cc_params;
95  int res;
96 
97  if (!chan) {
98  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
99  return -1;
100  }
101 
102  ast_channel_lock(chan);
103  if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
104  ast_channel_unlock(chan);
105  return -1;
106  }
107 
108  res = ast_cc_set_param(cc_params, data, value);
109  ast_channel_unlock(chan);
110  return res;
111 }
112 
114  .name = "CALLCOMPLETION",
115  .read = acf_cc_read,
116  .write = acf_cc_write,
117 };
118 
119 static int unload_module(void)
120 {
121  return ast_custom_function_unregister(&cc_function);
122 }
123 
124 static int load_module(void)
125 {
127 }
128 
129 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Call Control Configuration Function",
130  .support_level = AST_MODULE_SUPPORT_CORE,
131  .load = load_module,
132  .unload = unload_module,
133  .requires = "ccss",
134 );
const char * name
Definition: pbx.h:119
static int load_module(void)
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
int value
Definition: syslog.c:37
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
struct ast_cc_config_params * ast_channel_get_cc_config_params(struct ast_channel *chan)
Get the CCSS parameters from a channel.
Definition: channel.c:10675
#define ast_log
Definition: astobj2.c:42
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
Definition: pbx.h:118
int ast_cc_get_param(struct ast_cc_config_params *params, const char *const name, char *buf, size_t buf_len)
get a CCSS configuration parameter, given its name
Definition: ccss.c:759
int ast_cc_set_param(struct ast_cc_config_params *params, const char *const name, const char *value)
set a CCSS configuration parameter, given its name
Definition: ccss.c:804
Core PBX routines and definitions.
static int unload_module(void)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
static const char name[]
Definition: cdr_mysql.c:74
static int acf_cc_read(struct ast_channel *chan, const char *name, char *data, char *buf, size_t buf_len)
Call Completion Supplementary Services API.
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static struct ast_custom_function cc_function
static int acf_cc_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
Asterisk module definitions.
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1508