Wed Jan 8 2020 09:49:47

Asterisk developer's documentation


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 <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 /*** MODULEINFO
25  <support_level>core</support_level>
26  ***/
27 
28 #include "asterisk.h"
29 
30 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 411313 $")
31 
32 #include "asterisk/module.h"
33 #include "asterisk/channel.h"
34 #include "asterisk/ccss.h"
35 #include "asterisk/pbx.h"
36 
37 /*** DOCUMENTATION
38  <function name="CALLCOMPLETION" language="en_US">
39  <synopsis>
40  Get or set a call completion configuration parameter for a channel.
41  </synopsis>
42  <syntax>
43  <parameter name="option" required="true">
44  <para>The allowable options are:</para>
45  <enumlist>
46  <enum name="cc_agent_policy" />
47  <enum name="cc_monitor_policy" />
48  <enum name="cc_offer_timer" />
49  <enum name="ccnr_available_timer" />
50  <enum name="ccbs_available_timer" />
51  <enum name="cc_recall_timer" />
52  <enum name="cc_max_agents" />
53  <enum name="cc_max_monitors" />
54  <enum name="cc_callback_macro" />
55  <enum name="cc_agent_dialstring" />
56  </enumlist>
57  </parameter>
58  </syntax>
59  <description>
60  <para>The CALLCOMPLETION function can be used to get or set a call
61  completion configuration parameter for a channel. Note that setting
62  a configuration parameter will only change the parameter for the
63  duration of the call.
64 
65  For more information see <filename>doc/AST.pdf</filename>.
66  For more information on call completion parameters, see <filename>configs/ccss.conf.sample</filename>.</para>
67  </description>
68  </function>
69  ***/
70 
71 static int acf_cc_read(struct ast_channel *chan, const char *name, char *data,
72  char *buf, size_t buf_len)
73 {
74  struct ast_cc_config_params *cc_params;
75  int res;
76 
77  if (!chan) {
78  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", name);
79  return -1;
80  }
81 
82  ast_channel_lock(chan);
83  if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
84  ast_channel_unlock(chan);
85  return -1;
86  }
87 
88  res = ast_cc_get_param(cc_params, data, buf, buf_len);
89  ast_channel_unlock(chan);
90  return res;
91 }
92 
93 static int acf_cc_write(struct ast_channel *chan, const char *cmd, char *data,
94  const char *value)
95 {
96  struct ast_cc_config_params *cc_params;
97  int res;
98 
99  if (!chan) {
100  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
101  return -1;
102  }
103 
104  ast_channel_lock(chan);
105  if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
106  ast_channel_unlock(chan);
107  return -1;
108  }
109 
110  res = ast_cc_set_param(cc_params, data, value);
111  ast_channel_unlock(chan);
112  return res;
113 }
114 
116  .name = "CALLCOMPLETION",
117  .read = acf_cc_read,
118  .write = acf_cc_write,
119 };
120 
121 static int unload_module(void)
122 {
123  return ast_custom_function_unregister(&cc_function);
124 }
125 
126 static int load_module(void)
127 {
129 }
130 
131 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Control Configuration Function");
static int load_module(void)
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:396
Asterisk main include file. File version handling, generic pbx functions.
#define LOG_WARNING
Definition: logger.h:144
int value
Definition: syslog.c:39
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
Definition: pbx.c:3814
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:9754
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
Definition: pbx.h:95
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:645
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:688
Core PBX routines and definitions.
static int unload_module(void)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static const char name[]
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.
static struct ast_custom_function cc_function
const char * name
Definition: pbx.h:96
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:38
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1164
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180