[asterisk-commits] qwell: trunk r78179 - in /trunk: channels/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 6 11:08:11 CDT 2007


Author: qwell
Date: Mon Aug  6 11:08:11 2007
New Revision: 78179

URL: http://svn.digium.com/view/asterisk?view=rev&rev=78179
Log:
Implement setvar functionality in chan_skinny

Closes issue #10379, patch by mvanbaak.

Modified:
    trunk/channels/chan_skinny.c
    trunk/configs/skinny.conf.sample

Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=78179&r1=78178&r2=78179
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Mon Aug  6 11:08:11 2007
@@ -1020,6 +1020,7 @@
 	struct skinny_subchannel *sub;
 	struct skinny_line *next;
 	struct skinny_device *parent;
+	struct ast_variable *chanvars;		/*!< Channel variables to set for inbound call */
 };
 
 struct skinny_speeddial {
@@ -1316,6 +1317,24 @@
 	return tmpl;
 }
 
+/*!
+ * implement the setvar config line
+ */
+static struct ast_variable *add_var(const char *buf, struct ast_variable *list)
+{
+	struct ast_variable *tmpvar = NULL;
+	char *varname = ast_strdupa(buf), *varval = NULL;
+
+	if ((varval = strchr(varname,'='))) {
+		*varval++ = '\0';
+		if ((tmpvar = ast_variable_new(varname, varval))) {
+			tmpvar->next = list;
+			list = tmpvar;
+		}
+	}
+	return list;
+}
+
 /* It's quicker/easier to find the subchannel when we know the instance number too */
 static struct skinny_subchannel *find_subchannel_by_instance_reference(struct skinny_device *d, int instance, int reference)
 {
@@ -2279,6 +2298,7 @@
 	struct skinny_speeddial *sd;
 	struct skinny_addon *a;
 	char device_vmexten[AST_MAX_EXTENSION];
+	struct ast_variable *chanvars = NULL;
 	int lineInstance = 1;
 	int speeddialInstance = 1;
 	int y = 0;
@@ -2362,6 +2382,8 @@
 				mwiblink = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "linelabel")) {
 				ast_copy_string(linelabel, v->value, sizeof(linelabel));
+			} else if (!strcasecmp(v->name, "setvar")) {
+				chanvars = add_var(v->value, chanvars);
 			} else if (!strcasecmp(v->name, "speeddial")) {
 				if (!(sd = ast_calloc(1, sizeof(*sd)))) {
 					return NULL;
@@ -2422,6 +2444,7 @@
 						ast_verb(3, "Setting mailbox '%s' on %s@%s\n", mailbox, d->name, l->name);
 					if (!ast_strlen_zero(device_vmexten))
 						ast_copy_string(l->vmexten, device_vmexten, sizeof(vmexten));
+					l->chanvars = chanvars;
 					l->msgstate = -1;
 					l->capability = d->capability;
 					l->prefs = d->prefs;
@@ -3009,6 +3032,7 @@
 	struct ast_channel *tmp;
 	struct skinny_subchannel *sub;
 	struct skinny_device *d = l->parent;
+	struct ast_variable *v = NULL;
 	int fmt;
 
 	tmp = ast_channel_alloc(1, state, l->cid_num, l->cid_name, l->accountcode, l->exten, l->context, l->amaflags, "Skinny/%s@%s-%d", l->name, d->name, callnums);
@@ -3078,6 +3102,10 @@
 
 		if (sub->rtp)
 			ast_jb_configure(tmp, &global_jbconf);
+
+		/* Set channel variables for this call from configuration */
+		for (v = l->chanvars ; v ; v = v->next)
+			pbx_builtin_setvar_helper(tmp, v->name, v->value);
 
 		if (state != AST_STATE_DOWN) {
 			if (ast_pbx_start(tmp)) {

Modified: trunk/configs/skinny.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/skinny.conf.sample?view=diff&rev=78179&r1=78178&r2=78179
==============================================================================
--- trunk/configs/skinny.conf.sample (original)
+++ trunk/configs/skinny.conf.sample Mon Aug  6 11:08:11 2007
@@ -72,6 +72,7 @@
 ;permit=192.168.0/24	; Optional, used for authentication
 ;nat=yes
 ;callerid="George W. Bush" <202-456-1414>
+;setvar=CUSTID=5678	; Channel variable to be set for all calls from this device
 ;mailbox=500
 ;callwaiting=yes
 ;transfer=yes




More information about the asterisk-commits mailing list