[asterisk-commits] mmichelson: branch group/CCSS r213092 - in /team/group/CCSS: funcs/ include/a...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Aug 19 15:15:50 CDT 2009
Author: mmichelson
Date: Wed Aug 19 15:15:47 2009
New Revision: 213092
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=213092
Log:
Add func_callcompletion.c and necessary helper routines.
At this point, I can actually test that configuration
parameters are set properly and that I can retrieve and
set them properly from the dialplan. Such testing is my
next step.
Added:
team/group/CCSS/funcs/func_callcompletion.c (with props)
Modified:
team/group/CCSS/include/asterisk/ccss.h
team/group/CCSS/include/asterisk/channel.h
team/group/CCSS/main/ccss.c
team/group/CCSS/main/channel.c
Added: team/group/CCSS/funcs/func_callcompletion.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/funcs/func_callcompletion.c?view=auto&rev=213092
==============================================================================
--- team/group/CCSS/funcs/func_callcompletion.c (added)
+++ team/group/CCSS/funcs/func_callcompletion.c Wed Aug 19 15:15:47 2009
@@ -1,0 +1,109 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2009, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief Call Completion Supplementary Services implementation
+ * \author Mark Michelson <mmichelson at digium.com>
+ */
+
+#include "asterisk.h"
+#include "asterisk/module.h"
+#include "asterisk/channel.h"
+#include "asterisk/ccss.h"
+#include "asterisk/pbx.h"
+
+/*** DOCUMENTATION
+ <function name="CALLCOMPLETION" language="en_US">
+ <synopsis>
+ Get or set a call completion configuration parameter for a channel.
+ </synopsis>
+ <syntax>
+ <parameter name="option" required="true">
+ <para>The allowable options are:</para>
+ <enumlist>
+ <enum name="cc_agent_policy" />
+ <enum name="cc_monitor_policy" />
+ <enum name="cc_offer_timer" />
+ <enum name="ccnr_available_timer" />
+ <enum name="ccbs_available_timer" />
+ <enum name="cc_max_agents" />
+ <enum name="cc_max_monitors" />
+ <enum name="cc_callback_macro" />
+ </enumlist>
+ </parameter>
+ </syntax>
+ <description>
+ <para>The CALLCOMPLETION function can be used to get or set a call
+ completion configuration parameter for a channel. Note that setting
+ a configuration parameter will only change the parameter for the
+ duration of the call.</para>
+ </description>
+ </function>
+ ***/
+
+static int acf_cc_read(struct ast_channel *chan, const char *name, char *data,
+ char *buf, size_t buf_len)
+{
+ struct ast_cc_config_params *cc_params;
+ int res;
+
+ ast_channel_lock(chan);
+ if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
+ ast_channel_unlock(chan);
+ return -1;
+ }
+
+ res = ast_cc_get_param(cc_params, name, buf, buf_len);
+ ast_channel_unlock(chan);
+ return res;
+}
+
+static int acf_cc_write(struct ast_channel *chan, const char *cmd, char *data,
+ const char *value)
+{
+ struct ast_cc_config_params *cc_params;
+ int res;
+
+ ast_channel_lock(chan);
+ if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
+ ast_channel_unlock(chan);
+ return -1;
+ }
+
+ res = ast_cc_set_param(cc_params, data, value);
+ ast_channel_unlock(chan);
+ return res;
+}
+
+static struct ast_custom_function cc_function = {
+ .name = "CALLCOMPLETION",
+ .read = acf_cc_read,
+ .write = acf_cc_write,
+};
+
+static int unload_module(void)
+{
+ return ast_custom_function_unregister(&cc_function);
+}
+
+static int load_module(void)
+{
+ return ast_custom_function_register(&cc_function);
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Control Configuration Function");
Propchange: team/group/CCSS/funcs/func_callcompletion.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/group/CCSS/funcs/func_callcompletion.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/group/CCSS/funcs/func_callcompletion.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=213092&r1=213091&r2=213092
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Wed Aug 19 15:15:47 2009
@@ -138,17 +138,35 @@
void ast_cc_config_params_destroy(struct ast_cc_config_params *params);
/*!
- * \brief set a CCSS configuration parameter
+ * \brief set a CCSS configuration parameter, given its name
*
* Useful when parsing config files when used in conjunction
* with ast_ccss_is_cc_config_param.
*
+ * \param params The parameter structure to set the value on
* \param name The name of the cc parameter
* \param value The value of the parameter
* \retval 0 Success
* \retval -1 Failure
*/
-int ast_cc_set_param(struct ast_cc_config_params *params, const char * const name, const char * value);
+int ast_cc_set_param(struct ast_cc_config_params *params, const char * const name,
+ const char * value);
+
+/*!
+ * \brief get a CCSS configuration parameter, given its name
+ *
+ * Useful when reading input as a string, like from dialplan or
+ * manager.
+ *
+ * \param params The CCSS configuration from which to get the value
+ * \param name The name of the CCSS parameter we want
+ * \param buf A preallocated buffer to hold the value
+ * \param buf_len The size of buf
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_cc_get_param(struct ast_cc_config_params *params, const char * const name,
+ char *buf, size_t buf_len);
/*!
* \since 1.6.4
@@ -493,4 +511,18 @@
*/
int ast_cc_request_state_change(enum ast_cc_state state, const unsigned int core_id, const char *debug);
+#if 0
+Commented out for now, but will be necessary when taskprocessor is added later
+/*!
+ * \since 1.6.4
+ * \brief Initialize CCSS
+ *
+ * Registers applications, custom functions, and manager actions.
+ * Creates core task processor
+ * \retval 0 Success
+ * \retval nonzero Failure
+ */
+int ast_cc_init(void);
+#endif
+
#endif /* _ASTERISK_CCSS_H */
Modified: team/group/CCSS/include/asterisk/channel.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/include/asterisk/channel.h?view=diff&rev=213092&r1=213091&r2=213092
==============================================================================
--- team/group/CCSS/include/asterisk/channel.h (original)
+++ team/group/CCSS/include/asterisk/channel.h Wed Aug 19 15:15:47 2009
@@ -2687,6 +2687,19 @@
int ast_channel_cc_params_init(struct ast_channel *chan,
const struct ast_cc_config_params *base_params);
+/*!
+ * \since 1.6.4
+ * \brief Get the CCSS parameters from a channel
+ *
+ * This function makes use of datastore operations on the channel, so
+ * it is important to lock the channel before calling this function.
+ *
+ * \param chan Channel to retrieve parameters from
+ * \retval NULL Failure
+ * \retval non-NULL The parameters desired
+ */
+struct ast_cc_config_params *ast_channel_get_cc_config_params(struct ast_channel *chan);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=213092&r1=213091&r2=213092
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Aug 19 15:15:47 2009
@@ -25,6 +25,7 @@
#include "asterisk/strings.h"
#include "asterisk/ccss.h"
#include "asterisk/channel.h"
+#include "asterisk/pbx.h"
/*!
* \since 1.6.4
@@ -39,13 +40,6 @@
unsigned int ccbs_available_timer;
unsigned int cc_max_agents;
unsigned int cc_max_monitors;
- /*XXX callback_macro only applies to generic agents. Should this
- * be part of the generic agent's private_data field? My initial
- * thinking is no, since it makes sense that someone might wish
- * to modify this the same way that they would modify any other
- * CCSS configuration value. If someone sets a callback_macro and
- * we use a native CCSS agent, then we'll just ignore the param...
- */
char cc_callback_macro[AST_MAX_EXTENSION];
};
@@ -115,7 +109,42 @@
}
}
-int ast_cc_set_param(struct ast_cc_config_params *params, const char * const name, const char * const value)
+int ast_cc_get_param(struct ast_cc_config_params *params, const char * const name,
+ char *buf, size_t buf_len)
+{
+ if (!strcasecmp(name, "cc_callback_macro")) {
+ ast_copy_string(buf, ast_get_cc_callback_macro(params), buf_len);
+ return 0;
+ }
+
+ /* The rest of these are all ints of some sort and require some
+ * snprintf-itude
+ */
+
+ if (!strcasecmp(name, "cc_agent_policy")) {
+ snprintf(buf, buf_len, "%d", ast_get_cc_agent_policy(params));
+ } else if (!strcasecmp(name, "cc_monitor_policy")) {
+ snprintf(buf, buf_len, "%d", ast_get_cc_monitor_policy(params));
+ } else if (!strcasecmp(name, "cc_offer_timer")) {
+ snprintf(buf, buf_len, "%u", ast_get_cc_offer_timer(params));
+ } else if (!strcasecmp(name, "ccnr_available_timer")) {
+ snprintf(buf, buf_len, "%u", ast_get_ccnr_available_timer(params));
+ } else if (!strcasecmp(name, "ccbs_available_timer")) {
+ snprintf(buf, buf_len, "%u", ast_get_ccbs_available_timer(params));
+ } else if (!strcasecmp(name, "cc_max_agents")) {
+ snprintf(buf, buf_len, "%u", ast_get_cc_max_agents(params));
+ } else if (!strcasecmp(name, "cc_max_monitors")) {
+ snprintf(buf, buf_len, "%u", ast_get_cc_max_monitors(params));
+ } else {
+ ast_log(LOG_WARNING, "%s is not a valid CC parameter. Ignoring.\n", name);
+ return -1;
+ }
+
+ return 0;
+}
+
+int ast_cc_set_param(struct ast_cc_config_params *params, const char * const name,
+ const char * const value)
{
unsigned int value_as_uint;
if (!strcasecmp(name, "cc_agent_policy")) {
@@ -143,6 +172,7 @@
ast_set_cc_max_monitors(params, value_as_uint);
} else {
ast_log(LOG_WARNING, "%s is not a valid CC parameter. Ignoring.\n", name);
+ return -1;
}
return 0;
Modified: team/group/CCSS/main/channel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/channel.c?view=diff&rev=213092&r1=213091&r2=213092
==============================================================================
--- team/group/CCSS/main/channel.c (original)
+++ team/group/CCSS/main/channel.c Wed Aug 19 15:15:47 2009
@@ -7108,6 +7108,18 @@
return 0;
}
+struct ast_cc_config_params *ast_channel_get_cc_config_params(struct ast_channel *chan)
+{
+ struct ast_datastore *cc_datastore;
+
+ if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
+ return NULL;
+ }
+
+ ast_assert(cc_datastore->data != NULL);
+ return cc_datastore->data;
+}
+
/* DO NOT PUT ADDITIONAL FUNCTIONS BELOW THIS BOUNDARY
*
* ONLY FUNCTIONS FOR PROVIDING BACKWARDS ABI COMPATIBILITY BELONG HERE
More information about the asterisk-commits
mailing list