[asterisk-commits] mmichelson: branch mmichelson/features_config r389956 - in /team/mmichelson/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 28 15:01:28 CDT 2013


Author: mmichelson
Date: Tue May 28 15:01:24 2013
New Revision: 389956

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389956
Log:
Adjust the way that the pickup extension is queried in channel drivers.


Modified:
    team/mmichelson/features_config/channels/chan_dahdi.c
    team/mmichelson/features_config/channels/chan_mgcp.c
    team/mmichelson/features_config/channels/chan_misdn.c
    team/mmichelson/features_config/channels/chan_unistim.c
    team/mmichelson/features_config/channels/sig_analog.c
    team/mmichelson/features_config/include/asterisk/features.h
    team/mmichelson/features_config/main/features.c

Modified: team/mmichelson/features_config/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/channels/chan_dahdi.c?view=diff&rev=389956&r1=389955&r2=389956
==============================================================================
--- team/mmichelson/features_config/channels/chan_dahdi.c (original)
+++ team/mmichelson/features_config/channels/chan_dahdi.c Tue May 28 15:01:24 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(struct ast_features_pickup_config *pickup_cfg, 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(pickup_cfg->pickupexten) && !strncmp(pickup_cfg->pickupexten, exten, extlen)) {
 		return 1;
 	}
 	/* hardcoded features are *60, *67, *69, *70, *72, *73, *78, *79, *82, *0 */
@@ -10190,6 +10191,7 @@
 	int res;
 	int idx;
 	struct ast_format tmpfmt;
+	RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
 
 	ast_mutex_lock(&ss_thread_lock);
 	ss_thread_count++;
@@ -10209,6 +10211,9 @@
 		ast_hangup(chan);
 		goto quit;
 	}
+	ast_channel_lock(chan);
+	pickup_cfg = ast_get_chan_features_pickup_config(chan);
+	ast_channel_unlock(chan);
 	if (p->dsp)
 		ast_dsp_digitreset(p->dsp);
 	switch (p->sig) {
@@ -10575,7 +10580,7 @@
 				memset(exten, 0, sizeof(exten));
 				timeout = firstdigittimeout;
 
-			} else if (!strcmp(exten,ast_pickup_ext())) {
+			} else if (!strcmp(exten, pickup_cfg->pickupexten)) {
 				/* Scan all channels and see if there are any
 				 * ringing channels that have call groups
 				 * that equal this channels pickup group
@@ -10707,7 +10712,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(pickup_cfg, 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/features_config/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/channels/chan_mgcp.c?view=diff&rev=389956&r1=389955&r2=389956
==============================================================================
--- team/mmichelson/features_config/channels/chan_mgcp.c (original)
+++ team/mmichelson/features_config/channels/chan_mgcp.c Tue May 28 15:01:24 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,13 @@
 	int res= 0;
 	int getforward = 0;
 	int loop_pause = 100;
+	RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
 
 	len = strlen(p->dtmf_buf);
+
+	ast_channel_lock(chan);
+	pickup_cfg = ast_get_chan_features_pickup_config(chan);
+	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 +3071,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, pickup_cfg->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/features_config/channels/chan_misdn.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/channels/chan_misdn.c?view=diff&rev=389956&r1=389955&r2=389956
==============================================================================
--- team/mmichelson/features_config/channels/chan_misdn.c (original)
+++ team/mmichelson/features_config/channels/chan_misdn.c Tue May 28 15:01:24 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,7 @@
 		}
 
 		if (ch->state == MISDN_WAITING4DIGS) {
+			RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
 			/*  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 +10082,12 @@
 			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);
+			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), pickup_cfg->pickupexten)) {
 				if (ast_pickup_call(ch->ast)) {
 					hangup_chan(ch, bc);
 				} else {
@@ -10169,6 +10175,7 @@
 		int ai;
 		int im;
 		int append_msn = 0;
+		RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
 
 		if (ch) {
 			switch (ch->state) {
@@ -10223,6 +10230,10 @@
 			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);
+		ast_channel_unlock(chan);
 
 		if ((exceed = add_in_calls(bc->port))) {
 			char tmp[16];
@@ -10315,7 +10326,7 @@
 		}
 
 		/* Check for Pickup Request first */
-		if (!strcmp(ast_channel_exten(chan), ast_pickup_ext())) {
+		if (!strcmp(ast_channel_exten(chan), pickup_cfg->pickupexten)) {
 			if (!ch->noautorespond_on_setup) {
 				/* Sending SETUP_ACK */
 				misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE);

Modified: team/mmichelson/features_config/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/channels/chan_unistim.c?view=diff&rev=389956&r1=389955&r2=389956
==============================================================================
--- team/mmichelson/features_config/channels/chan_unistim.c (original)
+++ team/mmichelson/features_config/channels/chan_unistim.c Tue May 28 15:01:24 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,19 @@
 	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);
 		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);
+			ast_channel_unlock(c);
+		} else {
+			pickup_cfg = ast_get_chan_features_pickup_config(NULL);
+		}
+		if (c && !strcmp(s->device->phone_number, pickup_cfg->pickupexten)) {
 			if (unistimdebug) {
 				ast_verb(0, "Try to pickup in unistim_new\n");
 			}
@@ -4099,8 +4108,12 @@
 			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);
+
 			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/features_config/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/channels/sig_analog.c?view=diff&rev=389956&r1=389955&r2=389956
==============================================================================
--- team/mmichelson/features_config/channels/sig_analog.c (original)
+++ team/mmichelson/features_config/channels/sig_analog.c Tue May 28 15:01:24 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(struct ast_features_pickup_config *pickup_cfg, 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(pickup_cfg->pickupexten) && !strncmp(pickup_cfg->pickupexten, exten, extlen)) {
 		return 1;
 	}
 	/* hardcoded features are *60, *67, *69, *70, *72, *73, *78, *79, *82, *0 */
@@ -1756,6 +1755,7 @@
 	int res;
 	int idx;
 	struct ast_callid *callid;
+	RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
 
 	analog_increase_ss_count();
 
@@ -1786,6 +1786,11 @@
 		ast_hangup(chan);
 		goto quit;
 	}
+
+	ast_channel_lock(chan);
+	pickup_cfg = ast_get_chan_features_pickup_config(chan);
+	ast_channel_unlock(chan);
+
 	analog_dsp_reset_and_flush_digits(p);
 	switch (p->sig) {
 	case ANALOG_SIG_FEATD:
@@ -2190,7 +2195,7 @@
 				memset(exten, 0, sizeof(exten));
 				timeout = analog_firstdigittimeout;
 
-			} else if (!strcmp(exten,ast_pickup_ext())) {
+			} else if (!strcmp(exten, pickup_cfg->pickupexten)) {
 				/* Scan all channels and see if there are any
 				 * ringing channels that have call groups
 				 * that equal this channels pickup group
@@ -2334,7 +2339,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(pickup_cfg, 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/features_config/include/asterisk/features.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/include/asterisk/features.h?view=diff&rev=389956&r1=389955&r2=389956
==============================================================================
--- team/mmichelson/features_config/include/asterisk/features.h (original)
+++ team/mmichelson/features_config/include/asterisk/features.h Tue May 28 15:01:24 2013
@@ -166,9 +166,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.
  *

Modified: team/mmichelson/features_config/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/main/features.c?view=diff&rev=389956&r1=389955&r2=389956
==============================================================================
--- team/mmichelson/features_config/main/features.c (original)
+++ team/mmichelson/features_config/main/features.c Tue May 28 15:01:24 2013
@@ -829,12 +829,6 @@
 	return get_parking_exten(exten_str, chan, context) ? 1 : 0;
 }
 
-const char *ast_pickup_ext(void)
-{
-	/* XXX Heh, this is WAY wrong */
-	return "";
-}
-
 struct ast_bridge_thread_obj
 {
 	struct ast_bridge_config bconfig;
@@ -6267,6 +6261,7 @@
 {
 	int i;
 	struct ast_call_feature *feature;
+	RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, ast_get_chan_features_pickup_config(NULL), ao2_cleanup);
 #define HFS_FORMAT "%-25s %-7s %-7s\n"
 
 	switch (cmd) {
@@ -6284,7 +6279,7 @@
 	ast_cli(a->fd, HFS_FORMAT, "Builtin Feature", "Default", "Current");
 	ast_cli(a->fd, HFS_FORMAT, "---------------", "-------", "-------");
 
-	ast_cli(a->fd, HFS_FORMAT, "Pickup", "*8", ast_pickup_ext());          /* default hardcoded above, so we'll hardcode it here */
+	ast_cli(a->fd, HFS_FORMAT, "Pickup", "*8", pickup_cfg->pickupexten);          /* default hardcoded above, so we'll hardcode it here */
 
 	ast_rdlock_call_features();
 	for (i = 0; i < FEATURES_COUNT; i++)




More information about the asterisk-commits mailing list