[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r300881 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 6 23:11:28 UTC 2011


Author: dvossel
Date: Thu Jan  6 17:11:23 2011
New Revision: 300881

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=300881
Log:
update pbx.c and manager.c for ast_format conversion

Modified:
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h
    team/dvossel/fixtheworld_phase1_step3/main/manager.c
    team/dvossel/fixtheworld_phase1_step3/main/pbx.c

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h?view=diff&rev=300881&r1=300880&r2=300881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h Thu Jan  6 17:11:23 2011
@@ -887,11 +887,11 @@
 
 /*! Synchronously or asynchronously make an outbound call and send it to a
    particular extension */
-int ast_pbx_outgoing_exten(const char *type, struct ast_format *format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_exten(const char *type, struct ast_cap *cap, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
 
 /*! Synchronously or asynchronously make an outbound call and send it to a
    particular application with given extension */
-int ast_pbx_outgoing_app(const char *type, struct ast_format *format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_app(const char *type, struct ast_cap *cap, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
 
 /*!
  * \brief Evaluate a condition

Modified: team/dvossel/fixtheworld_phase1_step3/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/manager.c?view=diff&rev=300881&r1=300880&r2=300881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/manager.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/manager.c Thu Jan  6 17:11:23 2011
@@ -3509,7 +3509,7 @@
 	/*! data can contain a channel name, extension number, username, password, etc. */
 	char data[512];
 	int timeout;
-	format_t format;				/*!< Codecs used for a call */
+	struct ast_cap *cap;				/*!< Codecs used for a call */
 	char app[AST_MAX_APP];
 	char appdata[AST_MAX_EXTENSION];
 	char cid_name[AST_MAX_EXTENSION];
@@ -3531,12 +3531,12 @@
 	char requested_channel[AST_CHANNEL_NAME];
 
 	if (!ast_strlen_zero(in->app)) {
-		res = ast_pbx_outgoing_app(in->tech, in->format, in->data, in->timeout, in->app, in->appdata, &reason, 1,
+		res = ast_pbx_outgoing_app(in->tech, in->cap, in->data, in->timeout, in->app, in->appdata, &reason, 1,
 			S_OR(in->cid_num, NULL),
 			S_OR(in->cid_name, NULL),
 			in->vars, in->account, &chan);
 	} else {
-		res = ast_pbx_outgoing_exten(in->tech, in->format, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
+		res = ast_pbx_outgoing_exten(in->tech, in->cap, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
 			S_OR(in->cid_num, NULL),
 			S_OR(in->cid_name, NULL),
 			in->vars, in->account, &chan);
@@ -3568,6 +3568,7 @@
 	if (chan) {
 		ast_channel_unlock(chan);
 	}
+	in->cap = ast_cap_destroy(in->cap);
 	ast_free(in);
 	return NULL;
 }
@@ -3825,29 +3826,39 @@
 	int reason = 0;
 	char tmp[256];
 	char tmp2[256];
-	format_t format = AST_FORMAT_SLINEAR;
-
+	struct ast_cap *cap = ast_cap_alloc();
+	struct ast_format tmp_fmt;
 	pthread_t th;
+
+	if (!cap) {
+		astman_send_error(s, m, "Internal Error. Memory allocation failure.");
+	}
+	ast_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_SLINEAR, 0));
+
 	if (ast_strlen_zero(name)) {
 		astman_send_error(s, m, "Channel not specified");
-		return 0;
+		res = 0;
+		goto fast_orig_cleanup;
 	}
 	if (!ast_strlen_zero(priority) && (sscanf(priority, "%30d", &pi) != 1)) {
 		if ((pi = ast_findlabel_extension(NULL, context, exten, priority, NULL)) < 1) {
 			astman_send_error(s, m, "Invalid priority");
-			return 0;
+			res = 0;
+			goto fast_orig_cleanup;
 		}
 	}
 	if (!ast_strlen_zero(timeout) && (sscanf(timeout, "%30d", &to) != 1)) {
 		astman_send_error(s, m, "Invalid timeout");
-		return 0;
+		res = 0;
+		goto fast_orig_cleanup;
 	}
 	ast_copy_string(tmp, name, sizeof(tmp));
 	tech = tmp;
 	data = strchr(tmp, '/');
 	if (!data) {
 		astman_send_error(s, m, "Invalid channel");
-		return 0;
+		res = 0;
+		goto fast_orig_cleanup;
 	}
 	*data++ = '\0';
 	ast_copy_string(tmp2, callerid, sizeof(tmp2));
@@ -3864,8 +3875,8 @@
 		}
 	}
 	if (!ast_strlen_zero(codecs)) {
-		format = 0;
-		ast_parse_allow_disallow(NULL, &format, codecs, 1);
+		ast_cap_remove_all(cap);
+		ast_parse_allow_disallow(NULL, cap, codecs, 1);
 	}
 	/* Allocate requested channel variables */
 	vars = astman_get_variables(m);
@@ -3891,10 +3902,12 @@
 			ast_copy_string(fast->context, context, sizeof(fast->context));
 			ast_copy_string(fast->exten, exten, sizeof(fast->exten));
 			ast_copy_string(fast->account, account, sizeof(fast->account));
-			fast->format = format;
+			fast->cap = cap;
+			cap = NULL; /* transfered originate helper the capabilities structure.  It is now responsible for freeing it. */
 			fast->timeout = to;
 			fast->priority = pi;
 			if (ast_pthread_create_detached(&th, NULL, fast_originate, fast)) {
+				ast_cap_destroy(fast->cap);
 				ast_free(fast);
 				res = -1;
 			} else {
@@ -3915,18 +3928,20 @@
 				strstr(appdata, "EVAL")           /* NoOp(${EVAL(${some_var_containing_SHELL})}) */
 				)) {
 			astman_send_error(s, m, "Originate with certain 'Application' arguments requires the additional System privilege, which you do not have.");
-			return 0;
-		}
-		res = ast_pbx_outgoing_app(tech, format, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
+			res = 0;
+			goto fast_orig_cleanup;
+		}
+		res = ast_pbx_outgoing_app(tech, cap, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
 	} else {
 		if (exten && context && pi) {
-			res = ast_pbx_outgoing_exten(tech, format, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
+			res = ast_pbx_outgoing_exten(tech, cap, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
 		} else {
 			astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
 			if (vars) {
 				ast_variables_destroy(vars);
 			}
-			return 0;
+			res = 0;
+			goto fast_orig_cleanup;
 		}
 	}
 	if (!res) {
@@ -3934,6 +3949,9 @@
 	} else {
 		astman_send_error(s, m, "Originate failed");
 	}
+
+fast_orig_cleanup:
+	ast_cap_destroy(cap);
 	return 0;
 }
 

Modified: team/dvossel/fixtheworld_phase1_step3/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/pbx.c?view=diff&rev=300881&r1=300880&r2=300881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/pbx.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/pbx.c Thu Jan  6 17:11:23 2011
@@ -8479,7 +8479,7 @@
 	return 0;  /* success */
 }
 
-int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
+int ast_pbx_outgoing_exten(const char *type, struct ast_cap *cap, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
 {
 	struct ast_channel *chan;
 	struct async_stat *as;
@@ -8496,7 +8496,7 @@
 		oh.vars = vars;
 		oh.parent_channel = NULL;
 
-		chan = __ast_request_and_dial(type, format, NULL, data, timeout, reason, cid_num, cid_name, &oh);
+		chan = __ast_request_and_dial(type, cap, NULL, data, timeout, reason, cid_num, cid_name, &oh);
 		if (channel) {
 			*channel = chan;
 			if (chan)
@@ -8586,7 +8586,7 @@
 			res = -1;
 			goto outgoing_exten_cleanup;
 		}
-		chan = ast_request_and_dial(type, format, NULL, data, timeout, reason, cid_num, cid_name);
+		chan = ast_request_and_dial(type, cap, NULL, data, timeout, reason, cid_num, cid_name);
 		if (channel) {
 			*channel = chan;
 			if (chan)
@@ -8645,7 +8645,7 @@
 	return NULL;
 }
 
-int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
+int ast_pbx_outgoing_app(const char *type, struct ast_cap *cap, void *data, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
 {
 	struct ast_channel *chan;
 	struct app_tmp *tmp;
@@ -8663,7 +8663,7 @@
 		goto outgoing_app_cleanup;
 	}
 	if (synchronous) {
-		chan = __ast_request_and_dial(type, format, NULL, data, timeout, reason, cid_num, cid_name, &oh);
+		chan = __ast_request_and_dial(type, cap, NULL, data, timeout, reason, cid_num, cid_name, &oh);
 		if (chan) {
 			ast_set_variables(chan, vars);
 			if (account)
@@ -8728,7 +8728,7 @@
 			res = -1;
 			goto outgoing_app_cleanup;
 		}
-		chan = __ast_request_and_dial(type, format, NULL, data, timeout, reason, cid_num, cid_name, &oh);
+		chan = __ast_request_and_dial(type, cap, NULL, data, timeout, reason, cid_num, cid_name, &oh);
 		if (!chan) {
 			ast_free(as);
 			res = -1;




More information about the asterisk-commits mailing list