func_callcompletion.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2010, Digium, Inc.
00005  *
00006  * Mark Michelson <mmichelson@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  * \brief Call Completion Supplementary Services implementation
00021  * \author Mark Michelson <mmichelson@digium.com>
00022  */
00023 
00024 /*** MODULEINFO
00025    <support_level>core</support_level>
00026  ***/
00027 
00028 #include "asterisk.h"
00029 
00030 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 411328 $")
00031 
00032 #include "asterisk/module.h"
00033 #include "asterisk/channel.h"
00034 #include "asterisk/ccss.h"
00035 #include "asterisk/pbx.h"
00036 
00037 /*** DOCUMENTATION
00038    <function name="CALLCOMPLETION" language="en_US">
00039       <synopsis>
00040          Get or set a call completion configuration parameter for a channel.
00041       </synopsis>
00042       <syntax>
00043          <parameter name="option" required="true">
00044             <para>The allowable options are:</para>
00045             <enumlist>
00046                <enum name="cc_agent_policy" />
00047                <enum name="cc_monitor_policy" />
00048                <enum name="cc_offer_timer" />
00049                <enum name="ccnr_available_timer" />
00050                <enum name="ccbs_available_timer" />
00051                <enum name="cc_recall_timer" />
00052                <enum name="cc_max_agents" />
00053                <enum name="cc_max_monitors" />
00054                <enum name="cc_callback_macro" />
00055                <enum name="cc_agent_dialstring" />
00056             </enumlist>
00057          </parameter>
00058       </syntax>
00059       <description>
00060          <para>The CALLCOMPLETION function can be used to get or set a call
00061          completion configuration parameter for a channel. Note that setting
00062          a configuration parameter will only change the parameter for the
00063          duration of the call.
00064 
00065          For more information see <filename>doc/AST.pdf</filename>.
00066          For more information on call completion parameters, see <filename>configs/ccss.conf.sample</filename>.</para>
00067       </description>
00068    </function>
00069  ***/
00070 
00071 static int acf_cc_read(struct ast_channel *chan, const char *name, char *data,
00072       char *buf, size_t buf_len)
00073 {
00074    struct ast_cc_config_params *cc_params;
00075    int res;
00076 
00077    if (!chan) {
00078       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", name);
00079       return -1;
00080    }
00081 
00082    ast_channel_lock(chan);
00083    if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
00084       ast_channel_unlock(chan);
00085       return -1;
00086    }
00087 
00088    res = ast_cc_get_param(cc_params, data, buf, buf_len);
00089    ast_channel_unlock(chan);
00090    return res;
00091 }
00092 
00093 static int acf_cc_write(struct ast_channel *chan, const char *cmd, char *data,
00094       const char *value)
00095 {
00096    struct ast_cc_config_params *cc_params;
00097    int res;
00098 
00099    if (!chan) {
00100       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
00101       return -1;
00102    }
00103 
00104    ast_channel_lock(chan);
00105    if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
00106       ast_channel_unlock(chan);
00107       return -1;
00108    }
00109 
00110    res = ast_cc_set_param(cc_params, data, value);
00111    ast_channel_unlock(chan);
00112    return res;
00113 }
00114 
00115 static struct ast_custom_function cc_function = {
00116    .name = "CALLCOMPLETION",
00117    .read = acf_cc_read,
00118    .write = acf_cc_write,
00119 };
00120 
00121 static int unload_module(void)
00122 {
00123    return ast_custom_function_unregister(&cc_function);
00124 }
00125 
00126 static int load_module(void)
00127 {
00128    return ast_custom_function_register(&cc_function) == 0 ? AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE;
00129 }
00130 
00131 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Control Configuration Function");

Generated on Thu Apr 16 06:27:35 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6