[asterisk-commits] russell: branch oej/bug8824-temp r136851 - /team/oej/bug8824-temp/funcs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 8 15:25:31 CDT 2008


Author: russell
Date: Fri Aug  8 15:25:31 2008
New Revision: 136851

URL: http://svn.digium.com/view/asterisk?view=rev&rev=136851
Log:
Add missing funcs/func_connectedline.c (issue #8824)

Added:
    team/oej/bug8824-temp/funcs/func_connectedline.c   (with props)

Added: team/oej/bug8824-temp/funcs/func_connectedline.c
URL: http://svn.digium.com/view/asterisk/team/oej/bug8824-temp/funcs/func_connectedline.c?view=auto&rev=136851
==============================================================================
--- team/oej/bug8824-temp/funcs/func_connectedline.c (added)
+++ team/oej/bug8824-temp/funcs/func_connectedline.c Fri Aug  8 15:25:31 2008
@@ -1,0 +1,131 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2007, Gareth Palmer
+ *
+ * Gareth Palmer <gareth at acsdata.co.nz>
+ *
+ * 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 Connected Line dialplan function
+ * 
+ * \ingroup functions
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "asterisk/module.h"
+#include "asterisk/channel.h"
+#include "asterisk/pbx.h"
+#include "asterisk/logger.h"
+#include "asterisk/utils.h"
+#include "asterisk/app.h"
+#include "asterisk/options.h"
+#include "asterisk/callerid.h"
+
+static int connectedline_read(struct ast_channel *chan, const char *cmd, char *data,
+			      char *buf, size_t len)
+{
+	if (!chan)
+		return -1;
+
+	if (!strncasecmp("all", data, 3)) {
+		snprintf(buf, len, "\"%s\" <%s>",
+			 S_OR(chan->lid.lid_name, ""),
+			 S_OR(chan->lid.lid_num, ""));
+	} else if (!strncasecmp("name", data, 4)) {
+		if (chan->lid.lid_name) {
+			ast_copy_string(buf, chan->lid.lid_name, len);
+		}
+	} else if (!strncasecmp("num", data, 3)) {
+		if (chan->lid.lid_num) {
+			ast_copy_string(buf, chan->lid.lid_num, len);
+		}
+	} else if (!strncasecmp("pres", data, 4)) {
+		ast_copy_string(buf, ast_named_caller_presentation(chan->lid.lid_pres), len);
+	} else {
+		ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
+	}
+
+	return 0;
+}
+
+static int connectedline_write(struct ast_channel *chan, const char *cmd, char *data,
+			       const char *value)
+{
+	if (!value || !chan)
+		return -1;
+
+	if (!strncasecmp("all", data, 3)) {
+		char name[256];
+		char num[256];
+
+		if (!ast_callerid_split(value, name, sizeof(name), num, sizeof(num))) 
+			ast_connectedline_update(chan, num, name, chan->lid.lid_pres);
+	} else if (!strncasecmp("name", data, 4)) {
+		ast_connectedline_update(chan, chan->lid.lid_num, value, chan->lid.lid_pres);
+	} else if (!strncasecmp("num", data, 3)) { 
+		ast_connectedline_update(chan, value, chan->lid.lid_name, chan->lid.lid_pres);
+	} else if (!strncasecmp("pres", data, 4)) {
+		char *tmp;
+		int pres;
+
+		tmp = ast_strdupa(value);
+		ast_trim_blanks(tmp);
+
+		if ((tmp[0] >= '0') && (tmp[0] <= '9'))
+			pres = atoi(tmp);
+		else
+			pres = ast_parse_caller_presentation(tmp);
+
+		if (pres < 0)
+			ast_log(LOG_ERROR, "Unknown called number presentation '%s', value unchanged\n", tmp);
+		else
+			ast_connectedline_update(chan, chan->lid.lid_num, chan->lid.lid_name, pres);
+	} else {
+		ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
+	}
+
+	return 0;
+}
+
+static struct ast_custom_function connectedline_function = {
+	.name = "CONNECTEDLINE",
+	.synopsis = "Gets or sets Connected Line data on the channel.",
+	.syntax = "CONNECTEDLINE(datatype)",
+	.desc =
+		"Gets or sets Connected Line data on the channel. The allowable\n"
+		"datatypes are \"all\", \"name\", \"num\" and \"pres\"\n",
+	.read = connectedline_read,
+	.write = connectedline_write,
+};
+
+static int unload_module(void)
+{
+	return ast_custom_function_unregister(&connectedline_function);
+}
+
+static int load_module(void)
+{
+	return ast_custom_function_register(&connectedline_function);
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Connected Line dialplan function");

Propchange: team/oej/bug8824-temp/funcs/func_connectedline.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/oej/bug8824-temp/funcs/func_connectedline.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/oej/bug8824-temp/funcs/func_connectedline.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list