[asterisk-commits] mmichelson: branch mmichelson/atxfer_features r390469 - in /team/mmichelson/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 5 09:04:53 CDT 2013


Author: mmichelson
Date: Wed Jun  5 09:04:50 2013
New Revision: 390469

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390469
Log:
Add features configuration diff to working copy.

This may be a bad idea since features configuration has
not yet been approved on reviewboard. However, I need the
changes here in order to continue with this task, so I'm
putting this in tentatively. Once the final version of
features configuration is merged to trunk, I'll work on
getting any potential conflicts sorted out here.


Modified:
    team/mmichelson/atxfer_features/apps/app_dial.c
    team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c
    team/mmichelson/atxfer_features/channels/chan_dahdi.c
    team/mmichelson/atxfer_features/channels/chan_mgcp.c
    team/mmichelson/atxfer_features/channels/chan_misdn.c
    team/mmichelson/atxfer_features/channels/chan_sip.c
    team/mmichelson/atxfer_features/channels/chan_unistim.c
    team/mmichelson/atxfer_features/channels/sig_analog.c
    team/mmichelson/atxfer_features/channels/sip/include/sip.h
    team/mmichelson/atxfer_features/include/asterisk/channel.h
    team/mmichelson/atxfer_features/include/asterisk/features.h
    team/mmichelson/atxfer_features/main/bridging.c
    team/mmichelson/atxfer_features/main/features.c
    team/mmichelson/atxfer_features/main/manager.c

Modified: team/mmichelson/atxfer_features/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/apps/app_dial.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/apps/app_dial.c (original)
+++ team/mmichelson/atxfer_features/apps/app_dial.c Wed Jun  5 09:04:50 2013
@@ -69,6 +69,7 @@
 #include "asterisk/dial.h"
 #include "asterisk/stasis_channels.h"
 #include "asterisk/bridging.h"
+#include "asterisk/features_config.h"
 
 /*** DOCUMENTATION
 	<application name="Dial" language="en_US">
@@ -1074,7 +1075,7 @@
 	int caller_entertained = outgoing
 		&& ast_test_flag64(outgoing, OPT_MUSICBACK | OPT_RINGBACK);
 	struct ast_party_connected_line connected_caller;
-	struct ast_str *featurecode = ast_str_alloca(FEATURE_MAX_LEN + 1);
+	struct ast_str *featurecode = ast_str_alloca(AST_FEATURE_MAX_LEN + 1);
 	int cc_recall_core_id;
 	int is_cc_recall;
 	int cc_frame_received = 0;
@@ -1701,22 +1702,31 @@
 
 static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str **featurecode)
 {
-	struct ast_flags features = { AST_FEATURE_DISCONNECT }; /* only concerned with disconnect feature */
-	struct ast_call_feature feature = { 0, };
+	char disconnect_code[AST_FEATURE_MAX_LEN];
 	int res;
 
 	ast_str_append(featurecode, 1, "%c", code);
 
-	res = ast_feature_detect(chan, &features, ast_str_buffer(*featurecode), &feature);
-
-	if (res != AST_FEATURE_RETURN_STOREDIGITS) {
+	res = ast_get_builtin_feature(chan, "disconnect", disconnect_code, sizeof(disconnect_code));
+	if (res) {
 		ast_str_reset(*featurecode);
-	}
-	if (feature.feature_mask & AST_FEATURE_DISCONNECT) {
-		return 1;
-	}
-
-	return 0;
+		return 0;
+	}
+
+	if (strlen(disconnect_code) > ast_str_strlen(*featurecode)) {
+		/* Could be a partial match, anyway */
+		if (strncmp(disconnect_code, ast_str_buffer(*featurecode), ast_str_strlen(*featurecode))) {
+			ast_str_reset(*featurecode);
+		}
+		return 0;
+	}
+
+	if (strcmp(disconnect_code, ast_str_buffer(*featurecode))) {
+		ast_str_reset(*featurecode);
+		return 0;
+	}
+
+	return 1;
 }
 
 /* returns true if there is a valid privacy reply */

Modified: team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c (original)
+++ team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c Wed Jun  5 09:04:50 2013
@@ -49,6 +49,7 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/pbx.h"
 #include "asterisk/parking.h"
+#include "asterisk/features_config.h"
 
 /*!
  * \brief Helper function that presents dialtone and grabs extension
@@ -59,6 +60,18 @@
 static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len, const char *context)
 {
 	int res;
+	int digit_timeout;
+	RAII_VAR(struct ast_features_xfer_config *, xfer_cfg, NULL, ao2_cleanup);
+
+	ast_channel_lock(chan);
+	xfer_cfg = ast_get_chan_features_xfer_config(chan);
+	if (!xfer_cfg) {
+		ast_log(LOG_ERROR, "Unable to get transfer configuration\n");
+		ast_channel_unlock(chan);
+		return -1;
+	}
+	digit_timeout = xfer_cfg->transferdigittimeout;
+	ast_channel_unlock(chan);
 
 	/* Play the simple "transfer" prompt out and wait */
 	res = ast_stream_and_wait(chan, "pbx-transfer", AST_DIGIT_ANY);
@@ -73,8 +86,7 @@
 	}
 
 	/* Drop to dialtone so they can enter the extension they want to transfer to */
-/* BUGBUG the timeout needs to be configurable from features.conf. */
-	res = ast_app_dtget(chan, context, exten, exten_len, exten_len - 1, 3000);
+	res = ast_app_dtget(chan, context, exten, exten_len, exten_len - 1, digit_timeout);
 	if (res < 0) {
 		/* Hangup or error */
 		res = -1;
@@ -265,6 +277,11 @@
 	struct ast_bridge_features_attended_transfer *attended_transfer = hook_pvt;
 	const char *context;
 	enum atxfer_code transfer_code = ATXFER_INCOMPLETE;
+	const char *atxfer_abort;
+	const char *atxfer_threeway;
+	const char *atxfer_complete;
+	const char *fail_sound;
+	RAII_VAR(struct ast_features_xfer_config *, xfer_cfg, NULL, ao2_cleanup);
 
 	ast_bridge_channel_write_hold(bridge_channel, NULL);
 
@@ -273,6 +290,22 @@
 	ast_channel_lock(bridge_channel->chan);
 	context = ast_strdupa(get_transfer_context(bridge_channel->chan,
 		attended_transfer ? attended_transfer->context : NULL));
+	xfer_cfg = ast_get_chan_features_xfer_config(bridge_channel->chan);
+	if (!xfer_cfg) {
+		ast_log(LOG_ERROR, "Unable to get transfer configuration options\n");
+		ast_channel_unlock(bridge_channel->chan);
+		return 0;
+	}
+	if (attended_transfer) {
+		atxfer_abort = ast_strdupa(S_OR(attended_transfer->abort, xfer_cfg->atxferabort));
+		atxfer_threeway = ast_strdupa(S_OR(attended_transfer->threeway, xfer_cfg->atxferthreeway));
+		atxfer_complete = ast_strdupa(S_OR(attended_transfer->complete, xfer_cfg->atxfercomplete));
+	} else {
+		atxfer_abort = ast_strdupa(xfer_cfg->atxferabort);
+		atxfer_threeway = ast_strdupa(xfer_cfg->atxferthreeway);
+		atxfer_complete = ast_strdupa(xfer_cfg->atxfercomplete);
+	}
+	fail_sound = ast_strdupa(xfer_cfg->xferfailsound);
 	ast_channel_unlock(bridge_channel->chan);
 
 	/* Grab the extension to transfer to */
@@ -288,36 +321,27 @@
 	if (!peer) {
 		ast_bridge_merge_inhibit(bridge, -1);
 		ao2_ref(bridge, -1);
-/* BUGBUG beeperr needs to be configurable from features.conf */
-		ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_NONE);
-		ast_bridge_channel_write_unhold(bridge_channel);
-		return 0;
-	}
-
-/* BUGBUG bridging API features does not support features.conf featuremap */
+		ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
+		ast_bridge_channel_write_unhold(bridge_channel);
+		return 0;
+	}
+
 /* BUGBUG bridging API features does not support the features.conf atxfer bounce between C & B channels */
 	/* Setup a DTMF menu to control the transfer. */
 	if (ast_bridge_features_init(&caller_features)
 		|| ast_bridge_hangup_hook(&caller_features,
 			attended_transfer_complete, &transfer_code, NULL, 0)
-		|| ast_bridge_dtmf_hook(&caller_features,
-			attended_transfer && !ast_strlen_zero(attended_transfer->abort)
-				? attended_transfer->abort : "*1",
+		|| ast_bridge_dtmf_hook(&caller_features, atxfer_abort,
 			attended_transfer_abort, &transfer_code, NULL, 0)
-		|| ast_bridge_dtmf_hook(&caller_features,
-			attended_transfer && !ast_strlen_zero(attended_transfer->complete)
-				? attended_transfer->complete : "*2",
+		|| ast_bridge_dtmf_hook(&caller_features, atxfer_complete,
 			attended_transfer_complete, &transfer_code, NULL, 0)
-		|| ast_bridge_dtmf_hook(&caller_features,
-			attended_transfer && !ast_strlen_zero(attended_transfer->threeway)
-				? attended_transfer->threeway : "*3",
+		|| ast_bridge_dtmf_hook(&caller_features, atxfer_threeway,
 			attended_transfer_threeway, &transfer_code, NULL, 0)) {
 		ast_bridge_features_cleanup(&caller_features);
 		ast_hangup(peer);
 		ast_bridge_merge_inhibit(bridge, -1);
 		ao2_ref(bridge, -1);
-/* BUGBUG beeperr needs to be configurable from features.conf */
-		ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_NONE);
+		ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
 		ast_bridge_channel_write_unhold(bridge_channel);
 		return 0;
 	}
@@ -330,8 +354,7 @@
 		ast_hangup(peer);
 		ast_bridge_merge_inhibit(bridge, -1);
 		ao2_ref(bridge, -1);
-/* BUGBUG beeperr needs to be configurable from features.conf */
-		ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_NONE);
+		ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
 		ast_bridge_channel_write_unhold(bridge_channel);
 		return 0;
 	}
@@ -345,8 +368,7 @@
 		ast_hangup(peer);
 		ast_bridge_merge_inhibit(bridge, -1);
 		ao2_ref(bridge, -1);
-/* BUGBUG beeperr needs to be configurable from features.conf */
-		ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_NONE);
+		ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
 		ast_bridge_channel_write_unhold(bridge_channel);
 		return 0;
 	}
@@ -415,7 +437,7 @@
 	if (xfer_failed) {
 		ast_hangup(peer);
 		if (!ast_check_hangup_locked(bridge_channel->chan)) {
-			ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_NONE);
+			ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
 		}
 		ast_bridge_channel_write_unhold(bridge_channel);
 	}

Modified: team/mmichelson/atxfer_features/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/channels/chan_dahdi.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/channels/chan_dahdi.c (original)
+++ team/mmichelson/atxfer_features/channels/chan_dahdi.c Wed Jun  5 09:04:50 2013
@@ -130,6 +130,7 @@
 #include "asterisk/paths.h"
 #include "asterisk/ccss.h"
 #include "asterisk/data.h"
+#include "asterisk/features_config.h"
 
 /*** DOCUMENTATION
 	<application name="DAHDISendKeypadFacility" language="en_US">
@@ -10136,15 +10137,15 @@
 	return 0;
 }
 
-static int canmatch_featurecode(const char *exten)
+static int canmatch_featurecode(const char *pickupexten, const char *exten)
 {
 	int extlen = strlen(exten);
-	const char *pickup_ext;
+
 	if (!extlen) {
 		return 1;
 	}
-	pickup_ext = ast_pickup_ext();
-	if (extlen < strlen(pickup_ext) && !strncmp(pickup_ext, exten, extlen)) {
+
+	if (extlen < strlen(pickupexten) && !strncmp(pickupexten, exten, extlen)) {
 		return 1;
 	}
 	/* hardcoded features are *60, *67, *69, *70, *72, *73, *78, *79, *82, *0 */
@@ -10190,6 +10191,8 @@
 	int res;
 	int idx;
 	struct ast_format tmpfmt;
+	RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
+	const char *pickupexten;
 
 	ast_mutex_lock(&ss_thread_lock);
 	ss_thread_count++;
@@ -10209,6 +10212,17 @@
 		ast_hangup(chan);
 		goto quit;
 	}
+
+	ast_channel_lock(chan);
+	pickup_cfg = ast_get_chan_features_pickup_config(chan);
+	if (!pickup_cfg) {
+		ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
+		pickupexten = "";
+	} else {
+		pickupexten = ast_strdupa(pickup_cfg->pickupexten);
+	}
+	ast_channel_unlock(chan);
+
 	if (p->dsp)
 		ast_dsp_digitreset(p->dsp);
 	switch (p->sig) {
@@ -10575,7 +10589,7 @@
 				memset(exten, 0, sizeof(exten));
 				timeout = firstdigittimeout;
 
-			} else if (!strcmp(exten,ast_pickup_ext())) {
+			} else if (!strcmp(exten, pickupexten)) {
 				/* Scan all channels and see if there are any
 				 * ringing channels that have call groups
 				 * that equal this channels pickup group
@@ -10707,7 +10721,7 @@
 				}
 			} else if (!ast_canmatch_extension(chan, ast_channel_context(chan), exten, 1,
 				S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))
-				&& !canmatch_featurecode(exten)) {
+				&& !canmatch_featurecode(pickupexten, exten)) {
 				ast_debug(1, "Can't match %s from '%s' in context %s\n", exten,
 					S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, "<Unknown Caller>"),
 					ast_channel_context(chan));

Modified: team/mmichelson/atxfer_features/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/channels/chan_mgcp.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/channels/chan_mgcp.c (original)
+++ team/mmichelson/atxfer_features/channels/chan_mgcp.c Wed Jun  5 09:04:50 2013
@@ -84,6 +84,7 @@
 #include "asterisk/pktccops.h"
 #include "asterisk/stasis.h"
 #include "asterisk/bridging.h"
+#include "asterisk/features_config.h"
 
 /*
  * Define to work around buggy dlink MGCP phone firmware which
@@ -2971,8 +2972,20 @@
 	int res= 0;
 	int getforward = 0;
 	int loop_pause = 100;
+	RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
+	const char *pickupexten;
 
 	len = strlen(p->dtmf_buf);
+
+	ast_channel_lock(chan);
+	pickup_cfg = ast_get_chan_features_pickup_config(chan);
+	if (!pickup_cfg) {
+		ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
+		pickupexten = "";
+	} else {
+		pickupexten = ast_strdupa(pickup_cfg->pickupexten);
+	}
+	ast_channel_unlock(chan);
 
 	while (len < AST_MAX_EXTENSION - 1) {
 		ast_debug(1, "Dtmf buffer '%s' for '%s@%s'\n", p->dtmf_buf, p->name, p->parent->name);
@@ -3065,7 +3078,7 @@
 			len = 0;
 			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			timeout = firstdigittimeout;
-		} else if (!strcmp(p->dtmf_buf,ast_pickup_ext())) {
+		} else if (!strcmp(p->dtmf_buf, pickupexten)) {
 			/* Scan all channels and see if any there
 			 * ringing channqels with that have call groups
 			 * that equal this channels pickup group

Modified: team/mmichelson/atxfer_features/channels/chan_misdn.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/channels/chan_misdn.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/channels/chan_misdn.c (original)
+++ team/mmichelson/atxfer_features/channels/chan_misdn.c Wed Jun  5 09:04:50 2013
@@ -102,6 +102,7 @@
 #include "asterisk/causes.h"
 #include "asterisk/format.h"
 #include "asterisk/format_cap.h"
+#include "asterisk/features_config.h"
 
 #include "chan_misdn_config.h"
 #include "isdn_lib.h"
@@ -10071,6 +10072,9 @@
 		}
 
 		if (ch->state == MISDN_WAITING4DIGS) {
+			RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
+			const char *pickupexten;
+
 			/*  Ok, incomplete Setup, waiting till extension exists */
 			if (ast_strlen_zero(bc->info_dad) && ! ast_strlen_zero(bc->keypad)) {
 				chan_misdn_log(1, bc->port, " --> using keypad as info\n");
@@ -10080,8 +10084,18 @@
 			strncat(bc->dialed.number, bc->info_dad, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
 			ast_channel_exten_set(ch->ast, bc->dialed.number);
 
+			ast_channel_lock(ch->ast);
+			pickup_cfg = ast_get_chan_features_pickup_config(ch->ast);
+			if (!pickup_cfg) {
+				ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
+				pickupexten = "";
+			} else {
+				pickupexten = ast_strdupa(pickup_cfg->pickupexten);
+			}
+			ast_channel_unlock(ch->ast);
+
 			/* Check for Pickup Request first */
-			if (!strcmp(ast_channel_exten(ch->ast), ast_pickup_ext())) {
+			if (!strcmp(ast_channel_exten(ch->ast), pickupexten)) {
 				if (ast_pickup_call(ch->ast)) {
 					hangup_chan(ch, bc);
 				} else {
@@ -10169,6 +10183,8 @@
 		int ai;
 		int im;
 		int append_msn = 0;
+		RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
+		const char *pickupexten;
 
 		if (ch) {
 			switch (ch->state) {
@@ -10223,6 +10239,16 @@
 			ast_log(LOG_ERROR, "cb_events: misdn_new failed!\n");
 			return RESPONSE_RELEASE_SETUP;
 		}
+
+		ast_channel_lock(chan);
+		pickup_cfg = ast_get_chan_features_pickup_config(chan);
+		if (!pickup_cfg) {
+			ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
+			pickupexten = "";
+		} else {
+			pickupexten = ast_strdupa(pickup_cfg->pickupexten);
+		}
+		ast_channel_unlock(chan);
 
 		if ((exceed = add_in_calls(bc->port))) {
 			char tmp[16];
@@ -10315,7 +10341,7 @@
 		}
 
 		/* Check for Pickup Request first */
-		if (!strcmp(ast_channel_exten(chan), ast_pickup_ext())) {
+		if (!strcmp(ast_channel_exten(chan), pickupexten)) {
 			if (!ch->noautorespond_on_setup) {
 				/* Sending SETUP_ACK */
 				misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE);

Modified: team/mmichelson/atxfer_features/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/channels/chan_sip.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/channels/chan_sip.c (original)
+++ team/mmichelson/atxfer_features/channels/chan_sip.c Wed Jun  5 09:04:50 2013
@@ -296,6 +296,7 @@
 #include "asterisk/app.h"
 #include "asterisk/bridging.h"
 #include "asterisk/stasis_endpoints.h"
+#include "asterisk/features_config.h"
 
 /*** DOCUMENTATION
 	<application name="SIPDtmfMode" language="en_US">
@@ -17662,6 +17663,16 @@
 	char tmpf[256] = "", *from = NULL;
 	struct sip_request *req;
 	char *decoded_uri;
+	RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, ast_get_chan_features_pickup_config(p->owner), ao2_cleanup);
+	const char *pickupexten;
+
+	if (!pickup_cfg) {
+		ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
+		pickupexten = "";
+	} else {
+		/* Don't need to duplicate since channel is locked for the duration of this function */
+		pickupexten = pickup_cfg->pickupexten;
+	}
 
 	req = oreq;
 	if (!req) {
@@ -17772,7 +17783,7 @@
 			return SIP_GET_DEST_EXTEN_FOUND;
 		}
 		if (ast_exists_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from))
-			|| !strcmp(decoded_uri, ast_pickup_ext())) {
+			|| !strcmp(decoded_uri, pickupexten)) {
 			if (!oreq) {
 				ast_string_field_set(p, exten, decoded_uri);
 			}
@@ -17800,7 +17811,7 @@
 	if (ast_test_flag(&global_flags[1], SIP_PAGE2_ALLOWOVERLAP)
 		&& (ast_canmatch_extension(NULL, p->context, uri, 1, S_OR(p->cid_num, from))
 			|| ast_canmatch_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from))
-			|| !strncmp(decoded_uri, ast_pickup_ext(), strlen(decoded_uri)))) {
+			|| !strncmp(decoded_uri, pickupexten, strlen(decoded_uri)))) {
 		/* Overlap dialing is enabled and we need more digits to match an extension. */
 		return SIP_GET_DEST_EXTEN_MATCHMORE;
 	}
@@ -21699,7 +21710,8 @@
 		 * on phone calls.
 		 */
 
-		struct ast_call_feature *feat = NULL;
+		char feat[AST_FEATURE_MAX_LEN];
+		int feat_res = -1;
 		int j;
 		struct ast_frame f = { AST_FRAME_DTMF, };
 		int suppress_warning = 0; /* Supress warning if the feature is blank */
@@ -21711,43 +21723,40 @@
 		}
 
 		/* first, get the feature string, if it exists */
-		ast_rdlock_call_features();
 		if (p->relatedpeer) {
 			if (!strcasecmp(c, "on")) {
 				if (ast_strlen_zero(p->relatedpeer->record_on_feature)) {
 					suppress_warning = 1;
 				} else {
-					feat = ast_find_call_feature(p->relatedpeer->record_on_feature);
+					feat_res = ast_get_feature(p->owner, p->relatedpeer->record_on_feature, feat, sizeof(feat));
 				}
 			} else if (!strcasecmp(c, "off")) {
 				if (ast_strlen_zero(p->relatedpeer->record_off_feature)) {
 					suppress_warning = 1;
 				} else {
-					feat = ast_find_call_feature(p->relatedpeer->record_off_feature);
+					feat_res = ast_get_feature(p->owner, p->relatedpeer->record_off_feature, feat, sizeof(feat));
 				}
 			} else {
 				ast_log(LOG_ERROR, "Received INFO requesting to record with invalid value: %s\n", c);
 			}
 		}
-		if (!feat || ast_strlen_zero(feat->exten)) {
+		if (feat_res || ast_strlen_zero(feat)) {
 			if (!suppress_warning) {
 				ast_log(LOG_WARNING, "Recording requested, but no One Touch Monitor registered. (See features.conf)\n");
 			}
 			/* 403 means that we don't support this feature, so don't request it again */
 			transmit_response(p, "403 Forbidden", req);
-			ast_unlock_call_features();
 			return;
 		}
 		/* Send the feature code to the PBX as DTMF, just like the handset had sent it */
 		f.len = 100;
-		for (j = 0; j < strlen(feat->exten); j++) {
-			f.subclass.integer = feat->exten[j];
+		for (j = 0; j < strlen(feat); j++) {
+			f.subclass.integer = feat[j];
 			ast_queue_frame(p->owner, &f);
 			if (sipdebug) {
 				ast_verbose("* DTMF-relay event faked: %c\n", f.subclass.integer);
 			}
 		}
-		ast_unlock_call_features();
 
 		ast_debug(1, "Got a Request to Record the channel, state %s\n", c);
 		transmit_response(p, "200 OK", req);
@@ -25650,6 +25659,15 @@
 
 	if (c) {	/* We have a call  -either a new call or an old one (RE-INVITE) */
 		enum ast_channel_state c_state = ast_channel_state(c);
+		RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, ast_get_chan_features_pickup_config(c), ao2_cleanup);
+		const char *pickupexten;
+		
+		if (!pickup_cfg) {
+			ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
+			pickupexten = "";
+		} else {
+			pickupexten = ast_strdupa(pickup_cfg->pickupexten);
+		}
 
 		if (c_state != AST_STATE_UP && reinvite &&
 			(p->invitestate == INV_TERMINATED || p->invitestate == INV_CONFIRMED)) {
@@ -25671,7 +25689,7 @@
 			transmit_provisional_response(p, "100 Trying", req, 0);
 			p->invitestate = INV_PROCEEDING;
 			ast_setstate(c, AST_STATE_RING);
-			if (strcmp(p->exten, ast_pickup_ext())) {	/* Call to extension -start pbx on this call */
+			if (strcmp(p->exten, pickupexten)) {	/* Call to extension -start pbx on this call */
 				enum ast_pbx_result result;
 
 				result = ast_pbx_start(c);

Modified: team/mmichelson/atxfer_features/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/channels/chan_unistim.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/channels/chan_unistim.c (original)
+++ team/mmichelson/atxfer_features/channels/chan_unistim.c Wed Jun  5 09:04:50 2013
@@ -76,6 +76,7 @@
 #include "asterisk/features.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/astdb.h"
+#include "asterisk/features_config.h"
 
 
 #define DEFAULTCONTEXT	  "default"
@@ -3086,11 +3087,25 @@
 	send_favorite_short(sub->softkey, FAV_ICON_OFFHOOK_BLACK, s);
 	s->device->selected = -1;
 	if (!sub->owner) {		      /* A call is already in progress ? */
+		RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
+		const char *pickupexten;
+
 		c = unistim_new(sub, AST_STATE_DOWN, NULL);   /* No, starting a new one */
 		if (!sub->rtp) { /* Need to start RTP before calling ast_pbx_run */
 			start_rtp(sub);
 		}
-		if (c && !strcmp(s->device->phone_number, ast_pickup_ext())) {
+		if (c) {
+			ast_channel_lock(c);
+			pickup_cfg = ast_get_chan_features_pickup_config(c);
+			if (!pickup_cfg) {
+				ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
+				pickupexten = "";
+			} else {
+				pickupexten = ast_strdupa(pickup_cfg->pickupexten);
+			}
+			ast_channel_unlock(c);
+		}
+		if (c && !strcmp(s->device->phone_number, pickupexten)) {
 			if (unistimdebug) {
 				ast_verb(0, "Try to pickup in unistim_new\n");
 			}
@@ -4099,8 +4114,17 @@
 			ast_mutex_unlock(&devicelock);
 			show_extension_page(pte);
 		} else { /* Pickup function */
+			/* XXX Is there a way to get a specific channel here? */
+			RAII_VAR(struct ast_features_pickup_config *, pickup_cfg,
+					ast_get_chan_features_pickup_config(NULL), ao2_cleanup);
+
+			if (!pickup_cfg) {
+				ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
+				break;
+			}
+
 			pte->device->selected = -1;
-			ast_copy_string(pte->device->phone_number, ast_pickup_ext(),
+			ast_copy_string(pte->device->phone_number, pickup_cfg->pickupexten,
 						sizeof(pte->device->phone_number));
 			handle_call_outgoing(pte);
                 }

Modified: team/mmichelson/atxfer_features/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/channels/sig_analog.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/channels/sig_analog.c (original)
+++ team/mmichelson/atxfer_features/channels/sig_analog.c Wed Jun  5 09:04:50 2013
@@ -43,6 +43,7 @@
 #include "asterisk/features.h"
 #include "asterisk/cel.h"
 #include "asterisk/causes.h"
+#include "asterisk/features_config.h"
 
 #include "sig_analog.h"
 
@@ -1708,15 +1709,13 @@
 
 #define ANALOG_NEED_MFDETECT(p) (((p)->sig == ANALOG_SIG_FEATDMF) || ((p)->sig == ANALOG_SIG_FEATDMF_TA) || ((p)->sig == ANALOG_SIG_E911) || ((p)->sig == ANALOG_SIG_FGC_CAMA) || ((p)->sig == ANALOG_SIG_FGC_CAMAMF) || ((p)->sig == ANALOG_SIG_FEATB))
 
-static int analog_canmatch_featurecode(const char *exten)
+static int analog_canmatch_featurecode(const char *pickupexten, const char *exten)
 {
 	int extlen = strlen(exten);
-	const char *pickup_ext;
 	if (!extlen) {
 		return 1;
 	}
-	pickup_ext = ast_pickup_ext();
-	if (extlen < strlen(pickup_ext) && !strncmp(pickup_ext, exten, extlen)) {
+	if (extlen < strlen(pickupexten) && !strncmp(pickupexten, exten, extlen)) {
 		return 1;
 	}
 	/* hardcoded features are *60, *67, *69, *70, *72, *73, *78, *79, *82, *0 */
@@ -1756,6 +1755,8 @@
 	int res;
 	int idx;
 	struct ast_callid *callid;
+	RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
+	const char *pickupexten;
 
 	analog_increase_ss_count();
 
@@ -1786,6 +1787,17 @@
 		ast_hangup(chan);
 		goto quit;
 	}
+
+	ast_channel_lock(chan);
+	pickup_cfg = ast_get_chan_features_pickup_config(chan);
+	if (!pickup_cfg) {
+		ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
+		pickupexten = "";
+	} else {
+		pickupexten = ast_strdupa(pickup_cfg->pickupexten);
+	}
+	ast_channel_unlock(chan);
+
 	analog_dsp_reset_and_flush_digits(p);
 	switch (p->sig) {
 	case ANALOG_SIG_FEATD:
@@ -2190,7 +2202,7 @@
 				memset(exten, 0, sizeof(exten));
 				timeout = analog_firstdigittimeout;
 
-			} else if (!strcmp(exten,ast_pickup_ext())) {
+			} else if (!strcmp(exten, pickupexten)) {
 				/* Scan all channels and see if there are any
 				 * ringing channels that have call groups
 				 * that equal this channels pickup group
@@ -2334,7 +2346,7 @@
 				}
 			} else if (!ast_canmatch_extension(chan, ast_channel_context(chan), exten, 1,
 				ast_channel_caller(chan)->id.number.valid ? ast_channel_caller(chan)->id.number.str : NULL)
-				&& !analog_canmatch_featurecode(exten)) {
+				&& !analog_canmatch_featurecode(pickupexten, exten)) {
 				ast_debug(1, "Can't match %s from '%s' in context %s\n", exten,
 					ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str
 						? ast_channel_caller(chan)->id.number.str : "<Unknown Caller>",

Modified: team/mmichelson/atxfer_features/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/channels/sip/include/sip.h?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/channels/sip/include/sip.h (original)
+++ team/mmichelson/atxfer_features/channels/sip/include/sip.h Wed Jun  5 09:04:50 2013
@@ -38,6 +38,7 @@
 #include "asterisk/http_websocket.h"
 #include "asterisk/rtp_engine.h"
 #include "asterisk/netsock2.h"
+#include "asterisk/features_config.h"
 
 #ifndef FALSE
 #define FALSE    0
@@ -762,8 +763,8 @@
 	struct sip_proxy outboundproxy; /*!< Outbound proxy */
 	char default_context[AST_MAX_CONTEXT];
 	char default_subscribecontext[AST_MAX_CONTEXT];
-	char default_record_on_feature[FEATURE_MAX_LEN];
-	char default_record_off_feature[FEATURE_MAX_LEN];
+	char default_record_on_feature[AST_FEATURE_MAX_LEN];
+	char default_record_off_feature[AST_FEATURE_MAX_LEN];
 	struct ast_acl_list *contact_acl;  /*! \brief Global list of addresses dynamic peers are not allowed to use */
 	struct ast_format_cap *caps; /*!< Supported codecs */
 	int tcp_enabled;

Modified: team/mmichelson/atxfer_features/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/channel.h?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/channel.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/channel.h Wed Jun  5 09:04:50 2013
@@ -926,6 +926,9 @@
 	AST_FEATURE_PARKCALL =     (1 << 5),
 	AST_FEATURE_AUTOMIXMON =   (1 << 6),
 };
+
+#define AST_FEATURE_DTMF_MASK (AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |\
+	AST_FEATURE_ATXFER | AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON)
 
 /*! \brief bridge configuration */
 struct ast_bridge_config {

Modified: team/mmichelson/atxfer_features/include/asterisk/features.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/features.h?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/features.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/features.h Wed Jun  5 09:04:50 2013
@@ -62,20 +62,6 @@
 	AST_FEATURE_FLAG_BYBOTH	 =   (3 << 3),
 };
 
-struct ast_call_feature {
-	int feature_mask;
-	char *fname;
-	char sname[FEATURE_SNAME_LEN];
-	char exten[FEATURE_MAX_LEN];
-	char default_exten[FEATURE_MAX_LEN];
-	ast_feature_operation operation;
-	unsigned int flags;
-	char app[FEATURE_APP_LEN];		
-	char app_args[FEATURE_APP_ARGS_LEN];
-	char moh_class[FEATURE_MOH_LEN];
-	AST_LIST_ENTRY(ast_call_feature) feature_entry;
-};
-
 /*!
  * \brief Park a call and read back parked location
  *
@@ -166,9 +152,6 @@
 */
 int ast_parking_ext_valid(const char *exten_str, struct ast_channel *chan, const char *context);
 
-/*! \brief Determine system call pickup extension */
-const char *ast_pickup_ext(void);
-
 /*!
  * \brief Simulate a DTMF end on a broken bridge channel.
  *
@@ -221,39 +204,6 @@
  */
 int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target);
 
-/*! 
- * \brief register new feature into feature_set 
- * \param feature an ast_call_feature object which contains a keysequence
- * and a callback function which is called when this keysequence is pressed
- * during a call. 
-*/
-void ast_register_feature(struct ast_call_feature *feature);
-
-/*! 
- * \brief unregister feature from feature_set
- * \param feature the ast_call_feature object which was registered before
-*/
-void ast_unregister_feature(struct ast_call_feature *feature);
-
-/*! 
- * \brief detect a feature before bridging 
- * \param chan
- * \param features an ast_flags ptr
- * \param code ptr of input code
- * \param feature
- * \retval ast_call_feature ptr to be set if found 
-*/
-int ast_feature_detect(struct ast_channel *chan, struct ast_flags *features, const char *code, struct ast_call_feature *feature);
-
-/*! 
- * \brief look for a call feature entry by its sname
- * \param name a string ptr, should match "automon", "blindxfer", "atxfer", etc. 
-*/
-struct ast_call_feature *ast_find_call_feature(const char *name);
-
-void ast_rdlock_call_features(void);
-void ast_unlock_call_features(void);
-
 /*! \brief Reload call features from features.conf */
 int ast_features_reload(void);
 

Modified: team/mmichelson/atxfer_features/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging.c (original)
+++ team/mmichelson/atxfer_features/main/bridging.c Wed Jun  5 09:04:50 2013
@@ -61,6 +61,7 @@
 #include "asterisk/cli.h"
 #include "asterisk/parking.h"
 #include "asterisk/core_local.h"
+#include "asterisk/features_config.h"
 
 /*! All bridges container. */
 static struct ao2_container *bridges;
@@ -1914,6 +1915,17 @@
 	struct ast_bridge_hook *hook = NULL;
 	char dtmf[MAXIMUM_DTMF_FEATURE_STRING] = "";
 	size_t dtmf_len = 0;
+	unsigned int digit_timeout;
+	RAII_VAR(struct ast_features_general_config *, gen_cfg, NULL, ao2_cleanup);
+
+	ast_channel_lock(bridge_channel->chan);
+	gen_cfg = ast_get_chan_features_general_config(bridge_channel->chan);
+	if (!gen_cfg) {
+		ast_log(LOG_ERROR, "Unable to retrieve features configuration.\n");
+		return;
+	}
+	digit_timeout = gen_cfg->featuredigittimeout;
+	ast_channel_unlock(bridge_channel->chan);
 
 	/* The channel is now under our control and we don't really want any begin frames to do our DTMF matching so disable 'em at the core level */
 	ast_set_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_END_DTMF_ONLY);
@@ -1923,7 +1935,7 @@
 		int res;
 
 		/* If the above timed out simply exit */
-		res = ast_waitfordigit(bridge_channel->chan, 3000);
+		res = ast_waitfordigit(bridge_channel->chan, digit_timeout);
 		if (!res) {
 			ast_debug(1, "DTMF feature string collection on %p(%s) timed out\n",
 				bridge_channel, ast_channel_name(bridge_channel->chan));

Modified: team/mmichelson/atxfer_features/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/features.c?view=diff&rev=390469&r1=390468&r2=390469
==============================================================================
--- team/mmichelson/atxfer_features/main/features.c (original)
+++ team/mmichelson/atxfer_features/main/features.c Wed Jun  5 09:04:50 2013
@@ -74,6 +74,9 @@
 #include "asterisk/test.h"
 #include "asterisk/bridging.h"
 #include "asterisk/bridging_basic.h"
+#include "asterisk/features_config.h"
+
+#undef TEST_FRAMEWORK
 
 /*
  * Party A - transferee
@@ -299,58 +302,6 @@
 			<para>Bridge together two channels already in the PBX.</para>
 		</description>
 	</manager>
-	<function name="FEATURE" language="en_US">
-		<synopsis>
-			Get or set a feature option on a channel.
-		</synopsis>
-		<syntax>
-			<parameter name="option_name" required="true">
-				<para>The allowed values are:</para>
-				<enumlist>
-					<enum name="parkingtime"><para>Specified in seconds.</para></enum>
-					<enum name="inherit"><para>Inherit feature settings made in FEATURE or FEATUREMAP to child channels.</para></enum>
-				</enumlist>
-			</parameter>
-		</syntax>
-		<description>
-			<para>When this function is used as a read, it will get the current
-			value of the specified feature option for this channel.  It will be
-			the value of this option configured in features.conf if a channel specific
-			value has not been set.  This function can also be used to set a channel
-			specific value for the supported feature options.</para>
-		</description>
-		<see-also>
-			<ref type="function">FEATUREMAP</ref>
-		</see-also>
-	</function>
-	<function name="FEATUREMAP" language="en_US">
-		<synopsis>
-			Get or set a feature map to a given value on a specific channel.
-		</synopsis>
-		<syntax>
-			<parameter name="feature_name" required="true">
-				<para>The allowed values are:</para>
-				<enumlist>
-					<enum name="atxfer"><para>Attended Transfer</para></enum>
-					<enum name="blindxfer"><para>Blind Transfer</para></enum>
-					<enum name="automon"><para>Auto Monitor</para></enum>
-					<enum name="disconnect"><para>Call Disconnect</para></enum>
-					<enum name="parkcall"><para>Park Call</para></enum>
-					<enum name="automixmon"><para>Auto MixMonitor</para></enum>
-				</enumlist>
-			</parameter>
-		</syntax>
-		<description>
-			<para>When this function is used as a read, it will get the current
-			digit sequence mapped to the specified feature for this channel.  This
-			value will be the one configured in features.conf if a channel specific
-			value has not been set.  This function can also be used to set a channel
-			specific value for a feature mapping.</para>
-		</description>
-		<see-also>
-			<ref type="function">FEATURE</ref>
-		</see-also>
-	</function>
 	<managerEvent language="en_US" name="ParkedCallTimeOut">
 		<managerEventInstance class="EVENT_FLAG_CALL">
 			<synopsis>Raised when a parked call times out.</synopsis>
@@ -395,12 +346,6 @@
 
 #define DEFAULT_PARK_TIME							45000	/*!< ms */
 #define DEFAULT_PARK_EXTENSION						"700"
-#define DEFAULT_TRANSFER_DIGIT_TIMEOUT				3000	/*!< ms */
-#define DEFAULT_FEATURE_DIGIT_TIMEOUT				1000	/*!< ms */
-#define DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER	15000	/*!< ms */
-#define DEFAULT_ATXFER_DROP_CALL					0		/*!< Do not drop call. */
-#define DEFAULT_ATXFER_LOOP_DELAY					10000	/*!< ms */
-#define DEFAULT_ATXFER_CALLBACK_RETRIES				2
 #define DEFAULT_COMEBACK_CONTEXT					"parkedcallstimeout"
 #define DEFAULT_COMEBACK_TO_ORIGIN					1
 #define DEFAULT_COMEBACK_DIAL_TIME					30
@@ -409,24 +354,6 @@
 #define MAX_DIAL_FEATURE_OPTIONS 30
 
 /* TODO Scrape all of the parking stuff out of features.c */
-
-struct feature_group_exten {
-	AST_LIST_ENTRY(feature_group_exten) entry;
-	AST_DECLARE_STRING_FIELDS(
-		AST_STRING_FIELD(exten);
-	);
-	struct ast_call_feature *feature;
-};
-
-struct feature_group {
-	AST_LIST_ENTRY(feature_group) entry;
-	AST_DECLARE_STRING_FIELDS(
-		AST_STRING_FIELD(gname);
-	);
-	AST_LIST_HEAD_NOLOCK(, feature_group_exten) features;
-};
-
-static AST_RWLIST_HEAD_STATIC(feature_groups, feature_group);
 
 typedef enum {
 	FEATURE_INTERPRET_DETECT, /* Used by ast_feature_detect */
@@ -435,8 +362,6 @@
 } feature_interpret_op;
 
 static const char *parkedcall = "ParkedCall";
-
-static char pickup_ext[AST_MAX_EXTENSION];                 /*!< Call pickup extension */
 
 /*! Parking lot access ramp dialplan usage entry. */
 struct parking_dp_ramp {
@@ -606,15 +531,11 @@
 static struct ast_parkinglot *default_parkinglot;
 
 /*! Force a config reload to reload regardless of config file timestamp. */
+#ifdef TEST_FRAMEWORK
 static int force_reload_load;
-
-static int parkedplay = 0;                                 /*!< Who to play courtesytone to when someone picks up a parked call. */
+#endif
+
 static int parkeddynamic = 0;                              /*!< Enable creation of parkinglots dynamically */
-static char courtesytone[256];                             /*!< Courtesy tone used to pickup parked calls and on-touch-record */
-static char xfersound[256];                                /*!< Call transfer sound */
-static char xferfailsound[256];                            /*!< Call transfer failure sound */
-static char pickupsound[256];                              /*!< Pickup sound */
-static char pickupfailsound[256];                          /*!< Pickup failure sound */
 
 /*!

[... 3237 lines stripped ...]



More information about the asterisk-commits mailing list