[svn-commits] oej: branch group/bufo-manager-setvar-trunk r336090 - in /team/group/bufo-man...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Sep 15 09:22:46 CDT 2011


Author: oej
Date: Thu Sep 15 09:22:44 2011
New Revision: 336090

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=336090
Log:
Updating branch according to mjordan's excellent review in reviewboard

Modified:
    team/group/bufo-manager-setvar-trunk/CHANGES
    team/group/bufo-manager-setvar-trunk/configs/manager.conf.sample
    team/group/bufo-manager-setvar-trunk/include/asterisk/config.h
    team/group/bufo-manager-setvar-trunk/main/config.c
    team/group/bufo-manager-setvar-trunk/main/manager.c

Modified: team/group/bufo-manager-setvar-trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/group/bufo-manager-setvar-trunk/CHANGES?view=diff&rev=336090&r1=336089&r2=336090
==============================================================================
--- team/group/bufo-manager-setvar-trunk/CHANGES (original)
+++ team/group/bufo-manager-setvar-trunk/CHANGES Thu Sep 15 09:22:44 2011
@@ -30,6 +30,10 @@
    specification of a list of codecs allowed and disallowed, without the
    requirement to use two different keywords.  For example, to specify all
    codecs except g729 and g723, one need only specify allow=all,!g729,!g723.
+
+AMI - Manager
+-------------
+ * Added setvar= option to manager accounts (much like sip.conf) 
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.8 to Asterisk 10 -------------------

Modified: team/group/bufo-manager-setvar-trunk/configs/manager.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/group/bufo-manager-setvar-trunk/configs/manager.conf.sample?view=diff&rev=336090&r1=336089&r2=336090
==============================================================================
--- team/group/bufo-manager-setvar-trunk/configs/manager.conf.sample (original)
+++ team/group/bufo-manager-setvar-trunk/configs/manager.conf.sample Thu Sep 15 09:22:44 2011
@@ -86,6 +86,12 @@
 ;secret = mysecret
 ;deny=0.0.0.0/0.0.0.0
 ;permit=209.16.236.73/255.255.255.0
+
+; 
+;setvar=PBXACCOUNT=edvina	
+; The setvar option defines channel variables that will be set when this account
+; originates a call. You can define multiple setvar= commands for one manager
+; user.
 ;
 ;eventfilter=Event: Newchannel
 ;eventfilter=!Channel: DAHDI*

Modified: team/group/bufo-manager-setvar-trunk/include/asterisk/config.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bufo-manager-setvar-trunk/include/asterisk/config.h?view=diff&rev=336090&r1=336089&r2=336090
==============================================================================
--- team/group/bufo-manager-setvar-trunk/include/asterisk/config.h (original)
+++ team/group/bufo-manager-setvar-trunk/include/asterisk/config.h Thu Sep 15 09:22:44 2011
@@ -446,10 +446,11 @@
 /*! \brief Check if there's any realtime engines loaded */
 int ast_realtime_enabled(void);
 
-/*! \brief copy variables, preserving order 
- *  \param in the linked list of variables to copy
- */
-struct ast_variable *ast_variable_copy(struct ast_variable *in);
+/*! \brief copy variables, preserving order
+ *  \param in the linked list of variables 
+    \note This function is not copying the comment pointers
+*/
+struct ast_variable *ast_variable_copy(const struct ast_variable *in);
 
 /*!
  * \brief Free variable list

Modified: team/group/bufo-manager-setvar-trunk/main/config.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bufo-manager-setvar-trunk/main/config.c?view=diff&rev=336090&r1=336089&r2=336090
==============================================================================
--- team/group/bufo-manager-setvar-trunk/main/config.c (original)
+++ team/group/bufo-manager-setvar-trunk/main/config.c Thu Sep 15 09:22:44 2011
@@ -517,20 +517,23 @@
 	*comment = NULL;
 }
 
-/*! \brief copy variables, preserving order */
-struct ast_variable *ast_variable_copy(struct ast_variable *in)
-{
-	/* This really belongs in config.c, and will move there in non-releases */
-
+/*! \brief copy variables, preserving order 
+    \note This function is not copying the comment pointers
+*/
+struct ast_variable *ast_variable_copy(const struct ast_variable *in)
+{
 	struct ast_variable *out = NULL, *tmp, *v, *prev = NULL;
 
-	for (v = in ; v ; v = v->next) {
-		if ((tmp = ast_variable_new(v->name, v->value, ""))) {
+	for (v = in; v; v = v->next) {
+		if ((tmp = ast_variable_new(v->name, v->value, v->filename))) {
+			tmp->lineno = v->lineno;
+			tmp->object = v->object;
+			tmp->blanklines = v->blanklines;
 			if (!out) {
 				out = tmp;	/* The first record */
 			}
 			if (prev) {
-				prev->next = tmp; 
+				prev->next = tmp;
 			}
 			prev = tmp;
 		}

Modified: team/group/bufo-manager-setvar-trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bufo-manager-setvar-trunk/main/manager.c?view=diff&rev=336090&r1=336089&r2=336090
==============================================================================
--- team/group/bufo-manager-setvar-trunk/main/manager.c (original)
+++ team/group/bufo-manager-setvar-trunk/main/manager.c Thu Sep 15 09:22:44 2011
@@ -1577,13 +1577,16 @@
 		"      read perm: %s\n"
 		"     write perm: %s\n"
 		"displayconnects: %s\n",
-/* XXX Add setvar channel variables */
 		(user->username ? user->username : "(N/A)"),
 		(user->secret ? "<Set>" : "(N/A)"),
 		(user->ha ? "yes" : "no"),
 		authority_to_str(user->readperm, &rauthority),
 		authority_to_str(user->writeperm, &wauthority),
 		(user->displayconnects ? "yes" : "no"));
+	ast_cli(a->fd, "      Variables: \n");
+		for (v = user->chanvars ; v ; v = v->next) {
+			ast_cli(fd, "                 %s = %s\n", v->name, v->value);
+		}
 
 	AST_RWLIST_UNLOCK(&users);
 
@@ -4005,26 +4008,19 @@
 	}
 
 	/* Allocate requested channel variables */
-	/* read variables from manager command and allocate memory now */
 	vars = astman_get_variables(m);
 	if (s->session->chanvars) {
 		struct ast_variable *v, *old;
 		old = vars;
 		vars = NULL;
 
-		/* The variables in the originate command is appended at the
-			end of the list, to override */
+		/* The variables in the AMI originate action are appended at the end of the list, to override any user variables that apply*/
 
 		vars = ast_variable_copy(s->session->chanvars);
-		/* copy channel vars */
 		if (old ) {
-			for (v = vars ; v ; ) {
-				if (!v->next) {
-					v->next = old;	/* Append originate variables at end of list */
-					v = NULL;
-				} else {
-					v = v->next;	/* Loop */
-				}
+			for (v = vars; v->next; v = v->next );
+			if (v->next) {
+				v->next = old;	/* Append originate variables at end of list */
 			}
 		}
 	}




More information about the svn-commits mailing list