[svn-commits] rmudgett: branch rmudgett/cid r266785 - /team/rmudgett/cid/funcs/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Jun 1 15:30:18 CDT 2010
Author: rmudgett
Date: Tue Jun 1 15:30:16 2010
New Revision: 266785
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=266785
Log:
Consolidate CONNECTEDLINE() and REDIRECTING() into func_callerid.c.
Removed:
team/rmudgett/cid/funcs/func_connectedline.c
team/rmudgett/cid/funcs/func_redirecting.c
Modified:
team/rmudgett/cid/funcs/func_callerid.c
Modified: team/rmudgett/cid/funcs/func_callerid.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/funcs/func_callerid.c?view=diff&rev=266785&r1=266784&r2=266785
==============================================================================
--- team/rmudgett/cid/funcs/func_callerid.c (original)
+++ team/rmudgett/cid/funcs/func_callerid.c Tue Jun 1 15:30:16 2010
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999-2006, Digium, Inc.
+ * Copyright (C) 1999-2010, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
@@ -16,9 +16,12 @@
/*! \file
*
- * \brief Caller ID related dialplan functions
+ * \brief Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting)
*
* \ingroup functions
+ *
+ * See Also:
+ * \arg \ref AstCREDITS
*/
#include "asterisk.h"
@@ -40,6 +43,32 @@
*
* Do not document the CALLERID(ton) datatype.
* It is an alias for num-plan.
+ *
+ * Do not document the CONNECTEDLINE(source) datatype.
+ * It has turned out to not be needed. The source value is really
+ * only useful as a possible tracing aid.
+ *
+ * Do not document the CONNECTEDLINE(pres) datatype.
+ * The name and number now have their own presentation value. The pres
+ * option will simply live on as a historical relic with as best
+ * as can be managed backward compatible meaning.
+ *
+ * Do not document the CONNECTEDLINE(ton) datatype.
+ * It is an alias for num-plan.
+ *
+ * Do not document the REDIRECTING(pres) datatype.
+ * It has turned out that the from-pres and to-pres values must be kept
+ * separate. They represent two different parties and there is a case when
+ * they are active at the same time. The plain pres option will simply
+ * live on as a historical relic.
+ *
+ * Do not document the REDIRECTING(from-pres) or REDIRECTING(to-pres) datatypes.
+ * The name and number now have their own presentation value. The from-pres
+ * and to-pres options will simply live on as a historical relic with as best
+ * as can be managed backward compatible meaning.
+ *
+ * Do not document the REDIRECTING(from-ton) or REDIRECTING(to-ton) datatypes.
+ * They are aliases for from-num-plan and to-num-plan respectively.
*/
/*** DOCUMENTATION
<function name="CALLERID" language="en_US">
@@ -138,6 +167,132 @@
</enumlist>
</description>
</function>
+ <function name="CONNECTEDLINE" language="en_US">
+ <synopsis>
+ Gets or sets Connected Line data on the channel.
+ </synopsis>
+ <syntax>
+ <parameter name="datatype" required="true">
+ <para>The allowable datatypes are:</para>
+ <enumlist>
+ <enum name = "all" />
+ <enum name = "name" />
+ <enum name = "name-valid" />
+ <enum name = "name-charset" />
+ <enum name = "name-pres" />
+ <enum name = "num" />
+ <enum name = "num-valid" />
+ <enum name = "num-plan" />
+ <enum name = "num-pres" />
+ <enum name = "subaddr" />
+ <enum name = "subaddr-valid" />
+ <enum name = "subaddr-type" />
+ <enum name = "subaddr-odd" />
+ <enum name = "tag" />
+ </enumlist>
+ </parameter>
+ <parameter name="i">
+ <para>If set, this will prevent the channel from sending out protocol
+ messages because of the value being set</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>Gets or sets Connected Line data on the channel.</para>
+ <para>The allowable values for the <replaceable>name-charset</replaceable>
+ field are the following:</para>
+ <enumlist>
+ <enum name = "unknown"><para>Unknown</para></enum>
+ <enum name = "iso8859-1"><para>ISO8859-1</para></enum>
+ <enum name = "withdrawn"><para>Withdrawn</para></enum>
+ <enum name = "iso8859-2"><para>ISO8859-2</para></enum>
+ <enum name = "iso8859-3"><para>ISO8859-3</para></enum>
+ <enum name = "iso8859-4"><para>ISO8859-4</para></enum>
+ <enum name = "iso8859-5"><para>ISO8859-5</para></enum>
+ <enum name = "iso8859-7"><para>ISO8859-7</para></enum>
+ <enum name = "bmp"><para>ISO10646 Bmp String</para></enum>
+ <enum name = "utf8"><para>ISO10646 UTF-8 String</para></enum>
+ </enumlist>
+ </description>
+ </function>
+ <function name="REDIRECTING" language="en_US">
+ <synopsis>
+ Gets or sets Redirecting data on the channel.
+ </synopsis>
+ <syntax>
+ <parameter name="datatype" required="true">
+ <para>The allowable datatypes are:</para>
+ <enumlist>
+ <enum name = "from-all" />
+ <enum name = "from-name" />
+ <enum name = "from-name-valid" />
+ <enum name = "from-name-charset" />
+ <enum name = "from-name-pres" />
+ <enum name = "from-num" />
+ <enum name = "from-num-valid" />
+ <enum name = "from-num-plan" />
+ <enum name = "from-num-pres" />
+ <enum name = "from-subaddr" />
+ <enum name = "from-subaddr-valid" />
+ <enum name = "from-subaddr-type" />
+ <enum name = "from-subaddr-odd" />
+ <enum name = "from-tag" />
+ <enum name = "to-all" />
+ <enum name = "to-name" />
+ <enum name = "to-name-valid" />
+ <enum name = "to-name-charset" />
+ <enum name = "to-name-pres" />
+ <enum name = "to-num" />
+ <enum name = "to-num-valid" />
+ <enum name = "to-num-plan" />
+ <enum name = "to-num-pres" />
+ <enum name = "to-subaddr" />
+ <enum name = "to-subaddr-valid" />
+ <enum name = "to-subaddr-type" />
+ <enum name = "to-subaddr-odd" />
+ <enum name = "to-tag" />
+ <enum name = "reason" />
+ <enum name = "count" />
+ </enumlist>
+ </parameter>
+ <parameter name="i">
+ <para>If set, this will prevent the channel from sending out protocol
+ messages because of the value being set</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>Gets or sets Redirecting data on the channel.</para>
+ <para>The allowable values for the <replaceable>reason</replaceable>
+ field are the following:</para>
+ <enumlist>
+ <enum name = "unknown"><para>Unknown</para></enum>
+ <enum name = "cfb"><para>Call Forwarding Busy</para></enum>
+ <enum name = "cfnr"><para>Call Forwarding No Reply</para></enum>
+ <enum name = "unavailable"><para>Callee is Unavailable</para></enum>
+ <enum name = "time_of_day"><para>Time of Day</para></enum>
+ <enum name = "dnd"><para>Do Not Disturb</para></enum>
+ <enum name = "deflection"><para>Call Deflection</para></enum>
+ <enum name = "follow_me"><para>Follow Me</para></enum>
+ <enum name = "out_of_order"><para>Called DTE Out-Of-Order</para></enum>
+ <enum name = "away"><para>Callee is Away</para></enum>
+ <enum name = "cf_dte"><para>Call Forwarding By The Called DTE</para></enum>
+ <enum name = "cfu"><para>Call Forwarding Unconditional</para></enum>
+ </enumlist>
+ <para>The allowable values for the <replaceable>xxx-name-charset</replaceable>
+ field are the following:</para>
+ <enumlist>
+ <enum name = "unknown"><para>Unknown</para></enum>
+ <enum name = "iso8859-1"><para>ISO8859-1</para></enum>
+ <enum name = "withdrawn"><para>Withdrawn</para></enum>
+ <enum name = "iso8859-2"><para>ISO8859-2</para></enum>
+ <enum name = "iso8859-3"><para>ISO8859-3</para></enum>
+ <enum name = "iso8859-4"><para>ISO8859-4</para></enum>
+ <enum name = "iso8859-5"><para>ISO8859-5</para></enum>
+ <enum name = "iso8859-7"><para>ISO8859-7</para></enum>
+ <enum name = "bmp"><para>ISO10646 Bmp String</para></enum>
+ <enum name = "utf8"><para>ISO10646 UTF-8 String</para></enum>
+ </enumlist>
+ </description>
+ </function>
***/
enum ID_FIELD_STATUS {
@@ -155,6 +310,34 @@
AST_DEFINE_APP_ARGS_TYPE(ast_party_members,
AST_APP_ARG(subnames[10]); /* Option member subnames */
);
+
+enum CONNECTED_LINE_OPT_FLAGS {
+ CONNECTED_LINE_OPT_INHIBIT = (1 << 0),
+};
+enum CONNECTED_LINE_OPT_ARGS {
+ CONNECTED_LINE_OPT_DUMMY, /* Delete this if CONNECTED_LINE ever gets an option with parameters. */
+
+ /* note: this entry _MUST_ be the last one in the enum */
+ CONNECTED_LINE_OPT_ARG_ARRAY_SIZE
+};
+
+AST_APP_OPTIONS(connectedline_opts, BEGIN_OPTIONS
+ AST_APP_OPTION('i', CONNECTED_LINE_OPT_INHIBIT),
+END_OPTIONS);
+
+enum REDIRECTING_OPT_FLAGS {
+ REDIRECTING_OPT_INHIBIT = (1 << 0),
+};
+enum REDIRECTING_OPT_ARGS {
+ REDIRECTING_OPT_DUMMY, /* Delete this if REDIRECTING ever gets an option with parameters. */
+
+ /* note: this entry _MUST_ be the last one in the enum */
+ REDIRECTING_OPT_ARG_ARRAY_SIZE
+};
+
+AST_APP_OPTIONS(redirecting_opts, BEGIN_OPTIONS
+ AST_APP_OPTION('i', REDIRECTING_OPT_INHIBIT),
+END_OPTIONS);
/*!
* \internal
@@ -597,6 +780,19 @@
/*! TRUE if we have already notified about CALLERPRES being deprecated. */
static int callerpres_deprecate_notify;
+/*!
+ * \internal
+ * \brief Read values from the caller-id presentation information struct.
+ *
+ * \param chan Asterisk channel to read
+ * \param cmd Not used
+ * \param data Caller-id presentation function datatype string
+ * \param buf Buffer to fill with read value.
+ * \param len Length of the buffer
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
static int callerpres_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
if (!callerpres_deprecate_notify) {
@@ -609,6 +805,18 @@
return 0;
}
+/*!
+ * \internal
+ * \brief Write new values to the caller-id presentation information struct.
+ *
+ * \param chan Asterisk channel to update
+ * \param cmd Not used
+ * \param data Caller-id presentation function datatype string
+ * \param value Value to assign to the caller-id presentation information struct.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
static int callerpres_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
{
int pres;
@@ -629,6 +837,19 @@
return 0;
}
+/*!
+ * \internal
+ * \brief Read values from the caller-id information struct.
+ *
+ * \param chan Asterisk channel to read
+ * \param cmd Not used
+ * \param data Caller-id function datatype string
+ * \param buf Buffer to fill with read value.
+ * \param len Length of the buffer
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
enum ID_FIELD_STATUS status;
@@ -747,6 +968,18 @@
return 0;
}
+/*!
+ * \internal
+ * \brief Write new values to the caller-id information struct.
+ *
+ * \param chan Asterisk channel to update
+ * \param cmd Not used
+ * \param data Caller-id function datatype string
+ * \param value Value to assign to the caller-id information struct.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
{
struct ast_party_caller caller;
@@ -889,6 +1122,376 @@
return 0;
}
+/*!
+ * \internal
+ * \brief Read values from the connected line information struct.
+ *
+ * \param chan Asterisk channel to read
+ * \param cmd Not used
+ * \param data Connected line function datatype string
+ * \param buf Buffer to fill with read value.
+ * \param len Length of the buffer
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int connectedline_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ struct ast_party_members member;
+ char *read_what;
+ enum ID_FIELD_STATUS status;
+
+ /* Ensure that the buffer is empty */
+ *buf = 0;
+
+ if (!chan) {
+ return -1;
+ }
+
+ read_what = ast_strdupa(data);
+ AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
+ if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
+ /* Too few or too many subnames */
+ return -1;
+ }
+
+ ast_channel_lock(chan);
+
+ if (member.argc == 1 && !strcasecmp("source", member.argv[0])) {
+ ast_copy_string(buf, ast_connected_line_source_name(chan->connected.source), len);
+ } else {
+ status = party_id_read(buf, len, member.argc, member.argv, &chan->connected.id);
+ switch (status) {
+ case ID_FIELD_VALID:
+ case ID_FIELD_INVALID:
+ break;
+ default:
+ ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
+ break;
+ }
+ }
+
+ ast_channel_unlock(chan);
+
+ return 0;
+}
+
+/*!
+ * \internal
+ * \brief Write new values to the connected line information struct.
+ *
+ * \param chan Asterisk channel to update
+ * \param cmd Not used
+ * \param data Connected line function datatype string
+ * \param value Value to assign to the connected line information struct.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int connectedline_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
+{
+ struct ast_party_connected_line connected;
+ enum ID_FIELD_STATUS status;
+ char *val;
+ char *parms;
+ void (*set_it)(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
+ struct ast_party_func_args args;
+ struct ast_party_members member;
+ struct ast_flags opts;
+ char *opt_args[CONNECTED_LINE_OPT_ARG_ARRAY_SIZE];
+
+ if (!value || !chan) {
+ return -1;
+ }
+
+ parms = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parms);
+ if (args.argc == 0) {
+ /* Must have at least one argument. */
+ return -1;
+ }
+
+ AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
+ if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
+ /* Too few or too many subnames */
+ return -1;
+ }
+
+ if (ast_app_parse_options(connectedline_opts, &opts, opt_args, args.opts)) {
+ /* General invalid option syntax. */
+ return -1;
+ }
+
+ /* Determine if the update indication inhibit option is present */
+ if (ast_test_flag(&opts, CONNECTED_LINE_OPT_INHIBIT)) {
+ set_it = ast_channel_set_connected_line;
+ } else {
+ set_it = ast_channel_update_connected_line;
+ }
+
+ ast_channel_lock(chan);
+ ast_party_connected_line_set_init(&connected, &chan->connected);
+ ast_channel_unlock(chan);
+
+ value = ast_skip_blanks(value);
+
+ if (member.argc == 1 && !strcasecmp("source", member.argv[0])) {
+ int source;
+
+ val = ast_strdupa(value);
+ ast_trim_blanks(val);
+
+ if (('0' <= val[0]) && (val[0] <= '9')) {
+ source = atoi(val);
+ } else {
+ source = ast_connected_line_source_parse(val);
+ }
+
+ if (source < 0) {
+ ast_log(LOG_ERROR, "Unknown connectedline source '%s', value unchanged\n", val);
+ } else {
+ connected.source = source;
+ set_it(chan, &connected, NULL);
+ }
+ } else {
+ status = party_id_write(&connected.id, member.argc, member.argv, value);
+ switch (status) {
+ case ID_FIELD_VALID:
+ set_it(chan, &connected, NULL);
+ break;
+ case ID_FIELD_INVALID:
+ break;
+ default:
+ ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
+ break;
+ }
+ ast_party_connected_line_free(&connected);
+ }
+
+ return 0;
+}
+
+/*!
+ * \internal
+ * \brief Read values from the redirecting information struct.
+ *
+ * \param chan Asterisk channel to read
+ * \param cmd Not used
+ * \param data Redirecting function datatype string
+ * \param buf Buffer to fill with read value.
+ * \param len Length of the buffer
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int redirecting_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ struct ast_party_members member;
+ char *read_what;
+ enum ID_FIELD_STATUS status;
+
+ /* Ensure that the buffer is empty */
+ *buf = 0;
+
+ if (!chan) {
+ return -1;
+ }
+
+ read_what = ast_strdupa(data);
+ AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
+ if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
+ /* Too few or too many subnames */
+ return -1;
+ }
+
+ ast_channel_lock(chan);
+
+ if (!strcasecmp("from", member.argv[0])) {
+ status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
+ &chan->redirecting.from);
+ switch (status) {
+ case ID_FIELD_VALID:
+ case ID_FIELD_INVALID:
+ break;
+ default:
+ ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
+ break;
+ }
+ } else if (!strcasecmp("to", member.argv[0])) {
+ status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
+ &chan->redirecting.to);
+ switch (status) {
+ case ID_FIELD_VALID:
+ case ID_FIELD_INVALID:
+ break;
+ default:
+ ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
+ break;
+ }
+ } else if (member.argc == 1 && !strncasecmp("pres", member.argv[0], 4)) {
+ /*
+ * Accept pres[entation]
+ * This is the combined from name/number presentation.
+ */
+ ast_copy_string(buf,
+ ast_named_caller_presentation(
+ ast_party_id_presentation(&chan->redirecting.from)), len);
+ } else if (member.argc == 1 && !strcasecmp("reason", member.argv[0])) {
+ ast_copy_string(buf, ast_redirecting_reason_name(chan->redirecting.reason), len);
+ } else if (member.argc == 1 && !strcasecmp("count", member.argv[0])) {
+ snprintf(buf, len, "%d", chan->redirecting.count);
+ } else {
+ ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
+ }
+
+ ast_channel_unlock(chan);
+
+ return 0;
+}
+
+/*!
+ * \internal
+ * \brief Write new values to the redirecting information struct.
+ *
+ * \param chan Asterisk channel to update
+ * \param cmd Not used
+ * \param data Redirecting function datatype string
+ * \param value Value to assign to the redirecting information struct.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int redirecting_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
+{
+ struct ast_party_redirecting redirecting;
+ enum ID_FIELD_STATUS status;
+ char *val;
+ char *parms;
+ void (*set_it)(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
+ struct ast_party_func_args args;
+ struct ast_party_members member;
+ struct ast_flags opts;
+ char *opt_args[REDIRECTING_OPT_ARG_ARRAY_SIZE];
+
+ if (!value || !chan) {
+ return -1;
+ }
+
+ parms = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parms);
+ if (args.argc == 0) {
+ /* Must have at least one argument. */
+ return -1;
+ }
+
+ AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
+ if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
+ /* Too few or too many subnames */
+ return -1;
+ }
+
+ if (ast_app_parse_options(redirecting_opts, &opts, opt_args, args.opts)) {
+ /* General invalid option syntax. */
+ return -1;
+ }
+
+ /* Determine if the update indication inhibit option is present */
+ if (ast_test_flag(&opts, REDIRECTING_OPT_INHIBIT)) {
+ set_it = ast_channel_set_redirecting;
+ } else {
+ set_it = ast_channel_update_redirecting;
+ }
+
+ ast_channel_lock(chan);
+ ast_party_redirecting_set_init(&redirecting, &chan->redirecting);
+ ast_channel_unlock(chan);
+
+ value = ast_skip_blanks(value);
+
+ if (!strcasecmp("from", member.argv[0])) {
+ status = party_id_write(&redirecting.from, member.argc - 1, member.argv + 1,
+ value);
+ switch (status) {
+ case ID_FIELD_VALID:
+ set_it(chan, &redirecting, NULL);
+ break;
+ case ID_FIELD_INVALID:
+ break;
+ default:
+ ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
+ break;
+ }
+ ast_party_redirecting_free(&redirecting);
+ } else if (!strcasecmp("to", member.argv[0])) {
+ status = party_id_write(&redirecting.to, member.argc - 1, member.argv + 1, value);
+ switch (status) {
+ case ID_FIELD_VALID:
+ set_it(chan, &redirecting, NULL);
+ break;
+ case ID_FIELD_INVALID:
+ break;
+ default:
+ ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
+ break;
+ }
+ ast_party_redirecting_free(&redirecting);
+ } else if (member.argc == 1 && !strncasecmp("pres", member.argv[0], 4)) {
+ int pres;
+
+ val = ast_strdupa(value);
+ ast_trim_blanks(val);
+
+ if (('0' <= val[0]) && (val[0] <= '9')) {
+ pres = atoi(val);
+ } else {
+ pres = ast_parse_caller_presentation(val);
+ }
+
+ if (pres < 0) {
+ ast_log(LOG_ERROR,
+ "Unknown redirecting combined presentation '%s', value unchanged\n", val);
+ } else {
+ redirecting.from.XXX_name.presentation = pres;
+ redirecting.from.XXX_number.presentation = pres;
+ redirecting.to.XXX_name.presentation = pres;
+ redirecting.to.XXX_number.presentation = pres;
+ set_it(chan, &redirecting, NULL);
+ }
+ } else if (member.argc == 1 && !strcasecmp("reason", member.argv[0])) {
+ int reason;
+
+ val = ast_strdupa(value);
+ ast_trim_blanks(val);
+
+ if (('0' <= val[0]) && (val[0] <= '9')) {
+ reason = atoi(val);
+ } else {
+ reason = ast_redirecting_reason_parse(val);
+ }
+
+ if (reason < 0) {
+ ast_log(LOG_ERROR, "Unknown redirecting reason '%s', value unchanged\n", val);
+ } else {
+ redirecting.reason = reason;
+ set_it(chan, &redirecting, NULL);
+ }
+ } else if (member.argc == 1 && !strcasecmp("count", member.argv[0])) {
+ val = ast_strdupa(value);
+ ast_trim_blanks(val);
+
+ if (('0' <= val[0]) && (val[0] <= '9')) {
+ redirecting.count = atoi(val);
+ set_it(chan, &redirecting, NULL);
+ } else {
+ ast_log(LOG_ERROR, "Unknown redirecting count '%s', value unchanged\n", val);
+ }
+ } else {
+ ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
+ }
+
+ return 0;
+}
+
static struct ast_custom_function callerid_function = {
.name = "CALLERID",
.read = callerid_read,
@@ -903,18 +1506,53 @@
.write = callerpres_write,
};
+static struct ast_custom_function connectedline_function = {
+ .name = "CONNECTEDLINE",
+ .read = connectedline_read,
+ .write = connectedline_write,
+};
+
+static struct ast_custom_function redirecting_function = {
+ .name = "REDIRECTING",
+ .read = redirecting_read,
+ .write = redirecting_write,
+};
+
+/*!
+ * \internal
+ * \brief Unload the function module
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
static int unload_module(void)
{
- int res = ast_custom_function_unregister(&callerpres_function);
+ int res;
+
+ res = ast_custom_function_unregister(&callerpres_function);
res |= ast_custom_function_unregister(&callerid_function);
+ res |= ast_custom_function_unregister(&connectedline_function);
+ res |= ast_custom_function_unregister(&redirecting_function);
return res;
}
+/*!
+ * \internal
+ * \brief Load and initialize the function module.
+ *
+ * \retval AST_MODULE_LOAD_SUCCESS on success.
+ * \retval AST_MODULE_LOAD_DECLINE on error.
+ */
static int load_module(void)
{
- int res = ast_custom_function_register(&callerpres_function);
+ int res;
+
+ res = ast_custom_function_register(&callerpres_function);
res |= ast_custom_function_register(&callerid_function);
- return res;
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Caller ID related dialplan functions");
+ res |= ast_custom_function_register(&connectedline_function);
+ res |= ast_custom_function_register(&redirecting_function);
+ return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
+}
+
+/* Do not wrap the following line. */
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting)");
More information about the svn-commits
mailing list