[asterisk-commits] ParkAndAnnounce: Add variable inheritance (asterisk[certified/13.1])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 10 07:25:11 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: ParkAndAnnounce: Add variable inheritance
......................................................................


ParkAndAnnounce: Add variable inheritance

In Asterisk 11, the announcer channel would receive channel variables
from the channel being parked by means of normal channel inheritance.
This functionality was lost during the big res_parking project in
Asterisk 12. This patch restores that functionality.

ASTERISK-25369 #close
Review: https://gerrit.asterisk.org/#/c/1180/

Change-Id: Ie47e618330114ad2ea91e2edcef1cb6f341eed6e
---
M res/parking/parking_applications.c
1 file changed, 65 insertions(+), 0 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/res/parking/parking_applications.c b/res/parking/parking_applications.c
index 89c5e99..36b9a24 100644
--- a/res/parking/parking_applications.c
+++ b/res/parking/parking_applications.c
@@ -689,6 +689,68 @@
 	return pa_data;
 }
 
+/*! \internal
+ * \brief Gathers inheritable channel variables from a channel by name.
+ *
+ * \param oh outgoing helper struct we are bestowing inheritable variables to
+ * \param channel_id name or uniqueID of the channel to inherit variables from
+ *
+ * \return Nothing
+ */
+static void inherit_channel_vars_from_id(struct outgoing_helper *oh, const char *channel_id)
+{
+	struct ast_channel *chan = ast_channel_get_by_name(channel_id);
+	struct ast_var_t *current;
+	struct ast_variable *newvar;
+	const char *varname;
+	int vartype;
+
+
+	if (!chan) {
+		/* Already gone */
+		return;
+	}
+
+	ast_channel_lock(chan);
+
+	AST_LIST_TRAVERSE(ast_channel_varshead((struct ast_channel *) chan), current, entries) {
+		varname = ast_var_full_name(current);
+		if (!varname) {
+			continue;
+		}
+
+		vartype = 0;
+		if (varname[0] == '_') {
+			vartype = 1;
+			if (varname[1] == '_') {
+				vartype = 2;
+			}
+		}
+
+		switch (vartype) {
+		case 1:
+			newvar = ast_variable_new(&varname[1], ast_var_value(current), "");
+			break;
+		case 2:
+			newvar = ast_variable_new(varname, ast_var_value(current), "");
+			break;
+		default:
+			continue;
+		}
+		if (newvar) {
+			ast_debug(1, "Inheriting variable %s from %s.\n",
+				newvar->name, ast_channel_name(chan));
+			if (oh->vars) {
+				newvar->next = oh->vars;
+				oh->vars = newvar;
+			}
+		}
+	}
+
+	ast_channel_unlock(chan);
+	ast_channel_cleanup(chan);
+}
+
 static void announce_to_dial(char *dial_string, char *announce_string, int parkingspace, struct ast_channel_snapshot *parkee_snapshot)
 {
 	struct ast_channel *dchan;
@@ -710,6 +772,9 @@
 
 	snprintf(buf, sizeof(buf), "%d", parkingspace);
 	oh.vars = ast_variable_new("_PARKEDAT", buf, "");
+
+	inherit_channel_vars_from_id(&oh, parkee_snapshot->uniqueid);
+
 	dchan = __ast_request_and_dial(dial_tech, cap_slin, NULL, NULL, dial_string, 30000,
 		&outstate,
 		parkee_snapshot->caller_number,

-- 
To view, visit https://gerrit.asterisk.org/1227
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie47e618330114ad2ea91e2edcef1cb6f341eed6e
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: certified/13.1
Gerrit-Owner: Jonathan Rose <jrose at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list