[asterisk-commits] kmoore: branch kmoore/event_system_strip r396486 - in /team/kmoore/event_syst...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 9 08:24:06 CDT 2013


Author: kmoore
Date: Fri Aug  9 08:23:42 2013
New Revision: 396486

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396486
Log:
Resolve merge conflict and enable automerge

Added:
    team/kmoore/event_system_strip/res/parking/parking_tests.c
      - copied unchanged from r396480, trunk/res/parking/parking_tests.c
    team/kmoore/event_system_strip/rest-api-templates/param_cleanup.mustache
      - copied unchanged from r396480, trunk/rest-api-templates/param_cleanup.mustache
Modified:
    team/kmoore/event_system_strip/   (props changed)
    team/kmoore/event_system_strip/UPGRADE-11.txt
    team/kmoore/event_system_strip/apps/app_meetme.c
    team/kmoore/event_system_strip/apps/app_minivm.c
    team/kmoore/event_system_strip/apps/app_playback.c
    team/kmoore/event_system_strip/apps/app_queue.c
    team/kmoore/event_system_strip/apps/app_stack.c
    team/kmoore/event_system_strip/apps/app_voicemail.c
    team/kmoore/event_system_strip/apps/confbridge/conf_chan_announce.c
    team/kmoore/event_system_strip/apps/confbridge/conf_chan_record.c
    team/kmoore/event_system_strip/apps/confbridge/confbridge_manager.c
    team/kmoore/event_system_strip/bridges/bridge_holding.c
    team/kmoore/event_system_strip/channels/chan_bridge_media.c
    team/kmoore/event_system_strip/channels/chan_dahdi.c
    team/kmoore/event_system_strip/channels/chan_sip.c
    team/kmoore/event_system_strip/channels/chan_unistim.c
    team/kmoore/event_system_strip/channels/sig_pri.c
    team/kmoore/event_system_strip/formats/format_wav_gsm.c
    team/kmoore/event_system_strip/funcs/func_frame_trace.c
    team/kmoore/event_system_strip/funcs/func_global.c
    team/kmoore/event_system_strip/funcs/func_strings.c
    team/kmoore/event_system_strip/include/asterisk/app.h
    team/kmoore/event_system_strip/include/asterisk/bridge_basic.h
    team/kmoore/event_system_strip/include/asterisk/bridge_features.h
    team/kmoore/event_system_strip/include/asterisk/bridge_roles.h
    team/kmoore/event_system_strip/include/asterisk/channel.h
    team/kmoore/event_system_strip/include/asterisk/frame.h
    team/kmoore/event_system_strip/include/asterisk/json.h
    team/kmoore/event_system_strip/include/asterisk/manager.h
    team/kmoore/event_system_strip/include/asterisk/options.h
    team/kmoore/event_system_strip/include/asterisk/stasis.h
    team/kmoore/event_system_strip/include/asterisk/stasis_app.h
    team/kmoore/event_system_strip/include/asterisk/stasis_app_recording.h
    team/kmoore/event_system_strip/main/app.c
    team/kmoore/event_system_strip/main/asterisk.c
    team/kmoore/event_system_strip/main/bridge.c
    team/kmoore/event_system_strip/main/bridge_basic.c
    team/kmoore/event_system_strip/main/bridge_roles.c
    team/kmoore/event_system_strip/main/cdr.c
    team/kmoore/event_system_strip/main/cel.c
    team/kmoore/event_system_strip/main/channel.c
    team/kmoore/event_system_strip/main/channel_internal_api.c
    team/kmoore/event_system_strip/main/cli.c
    team/kmoore/event_system_strip/main/features.c
    team/kmoore/event_system_strip/main/json.c
    team/kmoore/event_system_strip/main/manager.c
    team/kmoore/event_system_strip/main/manager_bridges.c
    team/kmoore/event_system_strip/main/manager_channels.c
    team/kmoore/event_system_strip/main/pbx.c
    team/kmoore/event_system_strip/main/stasis_bridges.c
    team/kmoore/event_system_strip/main/stasis_cache.c
    team/kmoore/event_system_strip/main/stasis_cache_pattern.c
    team/kmoore/event_system_strip/main/utils.c
    team/kmoore/event_system_strip/pbx/pbx_dundi.c
    team/kmoore/event_system_strip/pbx/pbx_loopback.c
    team/kmoore/event_system_strip/res/ari/ari_model_validators.c
    team/kmoore/event_system_strip/res/ari/ari_model_validators.h
    team/kmoore/event_system_strip/res/ari/ari_websockets.c
    team/kmoore/event_system_strip/res/ari/resource_asterisk.c
    team/kmoore/event_system_strip/res/ari/resource_asterisk.h
    team/kmoore/event_system_strip/res/ari/resource_bridges.c
    team/kmoore/event_system_strip/res/ari/resource_bridges.h
    team/kmoore/event_system_strip/res/ari/resource_events.c
    team/kmoore/event_system_strip/res/ari/resource_events.h
    team/kmoore/event_system_strip/res/ari/resource_recordings.c
    team/kmoore/event_system_strip/res/ari/resource_recordings.h
    team/kmoore/event_system_strip/res/ari/resource_sounds.h
    team/kmoore/event_system_strip/res/parking/parking_bridge.c
    team/kmoore/event_system_strip/res/parking/res_parking.h
    team/kmoore/event_system_strip/res/res_ari_asterisk.c
    team/kmoore/event_system_strip/res/res_ari_bridges.c
    team/kmoore/event_system_strip/res/res_ari_channels.c
    team/kmoore/event_system_strip/res/res_ari_endpoints.c
    team/kmoore/event_system_strip/res/res_ari_events.c
    team/kmoore/event_system_strip/res/res_ari_playback.c
    team/kmoore/event_system_strip/res/res_ari_recordings.c
    team/kmoore/event_system_strip/res/res_ari_sounds.c
    team/kmoore/event_system_strip/res/res_parking.c
    team/kmoore/event_system_strip/res/res_pjsip.c
    team/kmoore/event_system_strip/res/res_pjsip/config_system.c
    team/kmoore/event_system_strip/res/res_pjsip/include/res_pjsip_private.h
    team/kmoore/event_system_strip/res/res_pjsip_exten_state.c
    team/kmoore/event_system_strip/res/res_pjsip_messaging.c
    team/kmoore/event_system_strip/res/res_pjsip_notify.c
    team/kmoore/event_system_strip/res/res_pjsip_outbound_registration.c
    team/kmoore/event_system_strip/res/res_sorcery_astdb.c
    team/kmoore/event_system_strip/res/res_stasis_recording.c
    team/kmoore/event_system_strip/res/snmp/agent.c
    team/kmoore/event_system_strip/res/stasis/control.c
    team/kmoore/event_system_strip/rest-api-templates/ari_resource.h.mustache
    team/kmoore/event_system_strip/rest-api-templates/param_parsing.mustache
    team/kmoore/event_system_strip/rest-api-templates/res_ari_resource.c.mustache
    team/kmoore/event_system_strip/rest-api/api-docs/asterisk.json
    team/kmoore/event_system_strip/rest-api/api-docs/bridges.json
    team/kmoore/event_system_strip/rest-api/api-docs/channels.json
    team/kmoore/event_system_strip/rest-api/api-docs/events.json
    team/kmoore/event_system_strip/rest-api/api-docs/recordings.json
    team/kmoore/event_system_strip/rest-api/api-docs/sounds.json
    team/kmoore/event_system_strip/tests/test_json.c
    team/kmoore/event_system_strip/tests/test_stasis.c
    team/kmoore/event_system_strip/utils/extconf.c

Propchange: team/kmoore/event_system_strip/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/kmoore/event_system_strip/
------------------------------------------------------------------------------
--- branch-11-blocked (original)
+++ branch-11-blocked Fri Aug  9 08:23:42 2013
@@ -1,1 +1,1 @@
-/branches/11:373240,375247,375702,385356,395020
+/branches/11:373240,375247,375702,385356,395020,396441

Propchange: team/kmoore/event_system_strip/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/kmoore/event_system_strip/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Aug  9 08:23:42 2013
@@ -1,1 +1,1 @@
-/trunk:1-396107
+/trunk:1-396485

Modified: team/kmoore/event_system_strip/UPGRADE-11.txt
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/UPGRADE-11.txt?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/UPGRADE-11.txt (original)
+++ team/kmoore/event_system_strip/UPGRADE-11.txt Fri Aug  9 08:23:42 2013
@@ -19,6 +19,11 @@
 === UPGRADE-10.txt -- Upgrade info for 1.8 to 10
 ===
 ===========================================================
+From 11.5 to 11.6:
+* res_agi will now properly indicate if there was an error in streaming an
+  audio file.  The result code will be -1 and the result returned from the
+  the function will be RESULT_FAILURE instead of the prior behavior of always
+  returning RESULT_SUCCESS even if there was an error.
 
 From 11.4 to 11.5:
 * The default settings for chan_sip are now overriden properly by the general

Modified: team/kmoore/event_system_strip/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/apps/app_meetme.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/apps/app_meetme.c (original)
+++ team/kmoore/event_system_strip/apps/app_meetme.c Fri Aug  9 08:23:42 2013
@@ -1167,7 +1167,7 @@
 	STASIS_MESSAGE_TYPE_INIT(meetme_talk_request_type);
 
 	meetme_event_message_router = stasis_message_router_create(
-		ast_channel_cache());
+		ast_channel_topic_all_cached());
 
 	if (!meetme_event_message_router) {
 		meetme_stasis_cleanup();

Modified: team/kmoore/event_system_strip/apps/app_minivm.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/apps/app_minivm.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/apps/app_minivm.c (original)
+++ team/kmoore/event_system_strip/apps/app_minivm.c Fri Aug  9 08:23:42 2013
@@ -1674,7 +1674,7 @@
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
 			if (ast_test_flag(vmu, MVM_OPERATOR))
 				canceldtmf = "0";
-			cmd = ast_play_and_record_full(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, global_silencethreshold, global_maxsilence, unlockdir, acceptdtmf, canceldtmf, 0, AST_RECORD_IF_EXISTS_OVERWRITE);
+			cmd = ast_play_and_record_full(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, global_silencethreshold, global_maxsilence, unlockdir, acceptdtmf, canceldtmf, 0, AST_RECORD_IF_EXISTS_OVERWRITE);
 			if (record_gain)
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0);
 			if (cmd == -1) /* User has hung up, no options to give */

Modified: team/kmoore/event_system_strip/apps/app_playback.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/apps/app_playback.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/apps/app_playback.c (original)
+++ team/kmoore/event_system_strip/apps/app_playback.c Fri Aug  9 08:23:42 2013
@@ -220,6 +220,10 @@
 		s = x + 1;
 	ast_debug(2, "value is <%s>\n", s);
 	n = ast_var_assign("SAY", s);
+	if (!n) {
+		ast_log(LOG_ERROR, "Memory allocation error in do_say\n");
+		return -1;
+	}
 	AST_LIST_INSERT_HEAD(&head, n, entries);
 
 	/* scan the body, one piece at a time */

Modified: team/kmoore/event_system_strip/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/apps/app_queue.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/apps/app_queue.c (original)
+++ team/kmoore/event_system_strip/apps/app_queue.c Fri Aug  9 08:23:42 2013
@@ -4583,10 +4583,10 @@
 						case AST_CONTROL_BUSY:
 							ast_verb(3, "%s is busy\n", ochan_name);
 							ast_channel_publish_dial(qe->chan, o->chan, on, "BUSY");
-							do_hang(o);
 							endtime = (long) time(NULL);
 							endtime -= starttime;
 							rna(endtime * 1000, qe, o->chan, on, membername, qe->parent->autopausebusy);
+							do_hang(o);
 							if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
 								if (qe->parent->timeoutrestart) {
 									start_time_tv = ast_tvnow();

Modified: team/kmoore/event_system_strip/apps/app_stack.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/apps/app_stack.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/apps/app_stack.c (original)
+++ team/kmoore/event_system_strip/apps/app_stack.c Fri Aug  9 08:23:42 2013
@@ -273,8 +273,9 @@
 	}
 
 	if (!found) {
-		variables = ast_var_assign(var, "");
-		AST_LIST_INSERT_HEAD(&frame->varshead, variables, entries);
+		if ((variables = ast_var_assign(var, ""))) {
+			AST_LIST_INSERT_HEAD(&frame->varshead, variables, entries);
+		}
 		pbx_builtin_pushvar_helper(chan, var, value);
 	} else {
 		pbx_builtin_setvar_helper(chan, var, value);

Modified: team/kmoore/event_system_strip/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/apps/app_voicemail.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/apps/app_voicemail.c (original)
+++ team/kmoore/event_system_strip/apps/app_voicemail.c Fri Aug  9 08:23:42 2013
@@ -14681,7 +14681,7 @@
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
 			if (ast_test_flag(vmu, VM_OPERATOR))
 				canceldtmf = "0";
-			cmd = ast_play_and_record_full(chan, playfile, tempfile, maxtime, fmt, duration, sound_duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf, 0, AST_RECORD_IF_EXISTS_OVERWRITE);
+			cmd = ast_play_and_record_full(chan, playfile, tempfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf, 0, AST_RECORD_IF_EXISTS_OVERWRITE);
 			if (strchr(canceldtmf, cmd)) {
 			/* need this flag here to distinguish between pressing '0' during message recording or after */
 				canceleddtmf = 1;

Modified: team/kmoore/event_system_strip/apps/confbridge/conf_chan_announce.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/apps/confbridge/conf_chan_announce.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/apps/confbridge/conf_chan_announce.c (original)
+++ team/kmoore/event_system_strip/apps/confbridge/conf_chan_announce.c Fri Aug  9 08:23:42 2013
@@ -134,7 +134,7 @@
 	.send_text = ast_unreal_sendtext,
 	.queryoption = ast_unreal_queryoption,
 	.setoption = ast_unreal_setoption,
-	.properties = AST_CHAN_TP_ANNOUNCER,
+	.properties = AST_CHAN_TP_INTERNAL,
 };
 
 struct ast_channel_tech *conf_announce_get_tech(void)

Modified: team/kmoore/event_system_strip/apps/confbridge/conf_chan_record.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/apps/confbridge/conf_chan_record.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/apps/confbridge/conf_chan_record.c (original)
+++ team/kmoore/event_system_strip/apps/confbridge/conf_chan_record.c Fri Aug  9 08:23:42 2013
@@ -86,7 +86,7 @@
 	.call = rec_call,
 	.read = rec_read,
 	.write = rec_write,
-	.properties = AST_CHAN_TP_RECORDER,
+	.properties = AST_CHAN_TP_INTERNAL,
 };
 
 struct ast_channel_tech *conf_record_get_tech(void)

Modified: team/kmoore/event_system_strip/apps/confbridge/confbridge_manager.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/apps/confbridge/confbridge_manager.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/apps/confbridge/confbridge_manager.c (original)
+++ team/kmoore/event_system_strip/apps/confbridge/confbridge_manager.c Fri Aug  9 08:23:42 2013
@@ -200,7 +200,7 @@
 	ast_assert(blob != NULL);
 	ast_assert(event != NULL);
 
-	bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
+	bridge_text = ast_manager_build_bridge_state_string(blob->bridge);
 	if (!bridge_text) {
 		return;
 	}

Modified: team/kmoore/event_system_strip/bridges/bridge_holding.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/bridges/bridge_holding.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/bridges/bridge_holding.c (original)
+++ team/kmoore/event_system_strip/bridges/bridge_holding.c Fri Aug  9 08:23:42 2013
@@ -81,7 +81,7 @@
 		ast_moh_stop(bridge_channel->chan);
 		break;
 	case IDLE_MODE_RINGING:
-		ast_indicate(bridge_channel->chan, -1);
+		ast_bridge_channel_queue_control_data(bridge_channel, -1, NULL, 0);
 		break;
 	case IDLE_MODE_NONE:
 		break;
@@ -124,7 +124,7 @@
 		ast_moh_start(bridge_channel->chan, ast_strlen_zero(moh_class) ? NULL : moh_class, NULL);
 		break;
 	case IDLE_MODE_RINGING:
-		ast_indicate(bridge_channel->chan, AST_CONTROL_RINGING);
+		ast_bridge_channel_queue_control_data(bridge_channel, AST_CONTROL_RINGING, NULL, 0);
 		break;
 	case IDLE_MODE_NONE:
 		break;
@@ -302,6 +302,44 @@
 	return 0;
 }
 
+static void holding_bridge_suspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	struct holding_channel *hc = bridge_channel ? bridge_channel->tech_pvt : NULL;
+
+	if (!hc) {
+		return;
+	}
+
+	if (!ast_test_flag(&hc->holding_roles, HOLDING_ROLE_PARTICIPANT)) {
+		return;
+	}
+
+	participant_stop_hold_audio(bridge_channel);
+}
+
+static void holding_bridge_unsuspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	struct holding_channel *hc = bridge_channel ? bridge_channel->tech_pvt : NULL;
+	struct ast_bridge_channel *announcer_channel = bridge->tech_pvt;
+
+	if (!hc) {
+		return;
+	}
+
+	/* If the bridge channel being unsuspended is not a participant, no need to do anything. */
+	if (!ast_test_flag(&hc->holding_roles, HOLDING_ROLE_PARTICIPANT)) {
+		return;
+	}
+
+	/* If there is currently an announcer channel in the bridge, there is also no need to do anything. */
+	if (announcer_channel) {
+		return;
+	}
+
+	/* Otherwise we need to resume the entertainment. */
+	participant_start_hold_audio(bridge_channel);
+}
+
 static struct ast_bridge_technology holding_bridge = {
 	.name = "holding_bridge",
 	.capabilities = AST_BRIDGE_CAPABILITY_HOLDING,
@@ -309,6 +347,8 @@
 	.write = holding_bridge_write,
 	.join = holding_bridge_join,
 	.leave = holding_bridge_leave,
+	.suspend = holding_bridge_suspend,
+	.unsuspend = holding_bridge_unsuspend,
 };
 
 static int unload_module(void)

Modified: team/kmoore/event_system_strip/channels/chan_bridge_media.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/channels/chan_bridge_media.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/channels/chan_bridge_media.c (original)
+++ team/kmoore/event_system_strip/channels/chan_bridge_media.c Fri Aug  9 08:23:42 2013
@@ -89,7 +89,7 @@
 	.send_text = ast_unreal_sendtext,
 	.queryoption = ast_unreal_queryoption,
 	.setoption = ast_unreal_setoption,
-	.properties = AST_CHAN_TP_ANNOUNCER,
+	.properties = AST_CHAN_TP_INTERNAL,
 };
 
 static struct ast_channel_tech record_tech = {
@@ -111,7 +111,7 @@
 	.send_text = ast_unreal_sendtext,
 	.queryoption = ast_unreal_queryoption,
 	.setoption = ast_unreal_setoption,
-	.properties = AST_CHAN_TP_RECORDER,
+	.properties = AST_CHAN_TP_INTERNAL,
 };
 
 static struct ast_channel *media_request_helper(struct ast_format_cap *cap,

Modified: team/kmoore/event_system_strip/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/channels/chan_dahdi.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/channels/chan_dahdi.c (original)
+++ team/kmoore/event_system_strip/channels/chan_dahdi.c Fri Aug  9 08:23:42 2013
@@ -460,6 +460,8 @@
 static int num_cadence = 4;
 static int user_has_defined_cadences = 0;
 
+static int has_pseudo;
+
 static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX] = {
 	{ { 125, 125, 2000, 4000 } },			/*!< Quick chirp followed by normal ring */
 	{ { 250, 250, 500, 1000, 250, 250, 500, 4000 } }, /*!< British style ring */
@@ -816,6 +818,18 @@
 	 * \note Set from the "smdiport" string read in from chan_dahdi.conf
 	 */
 	char smdi_port[SMDI_MAX_FILENAME_LEN];
+
+	/*!
+	 * \brief Don't create channels below this number
+	 * \note by default is 0 (no limit)
+	 */
+	int wanted_channels_start;
+
+	/*!
+	 * \brief Don't create channels above this number (infinity by default)
+	 * \note by default is 0 (special value that means "no limit").
+	 */
+	int wanted_channels_end;
 };
 
 /*! returns a new dahdi_chan_conf with default values (by-value) */
@@ -2632,7 +2646,7 @@
 #endif	/* defined(HAVE_PRI) */
 
 #if defined(HAVE_PRI)
-static int pri_destroy_dchan(struct sig_pri_span *pri);
+static void pri_destroy_span(struct sig_pri_span *pri);
 
 static void my_handle_dchan_exception(struct sig_pri_span *pri, int index)
 {
@@ -2662,7 +2676,7 @@
 		pri_event_noalarm(pri, index, 0);
 		break;
 	case DAHDI_EVENT_REMOVED:
-		pri_destroy_dchan(pri);
+		pri_destroy_span(pri);
 		break;
 	default:
 		break;
@@ -10735,28 +10749,120 @@
 	return handled;
 }
 
-/* destroy a DAHDI channel, identified by its number */
-static int dahdi_destroy_channel_bynum(int channel)
+/* destroy a range DAHDI channels, identified by their number */
+static void dahdi_destroy_channel_range(int start, int end)
 {
 	struct dahdi_pvt *cur;
-
+	struct dahdi_pvt *next;
+	int destroyed_first = 0;
+	int destroyed_last = 0;
+
+	ast_mutex_lock(&iflock);
+	ast_debug(1, "range: %d-%d\n", start, end);
+	for (cur = iflist; cur; cur = next) {
+		next = cur->next;
+		if (cur->channel >= start && cur->channel <= end) {
+			int x = DAHDI_FLASH;
+
+			if (cur->channel > destroyed_last) {
+				destroyed_last = cur->channel;
+			}
+			if (destroyed_first < 1 || cur->channel < destroyed_first) {
+				destroyed_first = cur->channel;
+			}
+			ast_debug(3, "Destroying %d\n", cur->channel);
+			/* important to create an event for dahdi_wait_event to register so that all analog_ss_threads terminate */
+			ioctl(cur->subs[SUB_REAL].dfd, DAHDI_HOOK, &x);
+
+			destroy_channel(cur, 1);
+			ast_module_unref(ast_module_info->self);
+		}
+	}
+	ast_mutex_unlock(&iflock);
+	if (destroyed_first > start || destroyed_last < end) {
+		ast_debug(1, "Asked to destroy %d-%d, destroyed %d-%d,\n",
+			start, end, destroyed_first, destroyed_last);
+	}
+}
+
+static int setup_dahdi(int reload);
+static int setup_dahdi_int(int reload, struct dahdi_chan_conf *default_conf, struct dahdi_chan_conf *base_conf, struct dahdi_chan_conf *conf);
+
+/*!
+ * \internal
+ * \brief create a range of new DAHDI channels
+ *
+ * \param start first channel in the range
+ * \param end last channel in the range
+ *
+ * \retval RESULT_SUCCESS on success.
+ * \retval RESULT_FAILURE on error.
+ */
+static int dahdi_create_channel_range(int start, int end)
+{
+	struct dahdi_pvt *cur;
+	struct dahdi_chan_conf default_conf = dahdi_chan_conf_default();
+	struct dahdi_chan_conf base_conf = dahdi_chan_conf_default();
+	struct dahdi_chan_conf conf = dahdi_chan_conf_default();
+	int i, x;
+	int ret = RESULT_FAILURE; /* be pessimistic */
+
+	ast_debug(1, "channel range caps: %d - %d\n", start, end);
 	ast_mutex_lock(&iflock);
 	for (cur = iflist; cur; cur = cur->next) {
-		if (cur->channel == channel) {
-			int x = DAHDI_FLASH;
-
-			/* important to create an event for dahdi_wait_event to register so that all analog_ss_threads terminate */
-			ioctl(cur->subs[SUB_REAL].dfd, DAHDI_HOOK, &x);
-
-			destroy_channel(cur, 1);
-			ast_mutex_unlock(&iflock);
-			ast_module_unref(ast_module_info->self);
-			return RESULT_SUCCESS;
-		}
-	}
+		if (cur->channel >= start && cur->channel <= end) {
+			ast_log(LOG_ERROR,
+				"channel range %d-%d is occupied\n",
+				start, end);
+			goto out;
+		}
+	}
+	for (x = 0; x < NUM_SPANS; x++) {
+#ifdef HAVE_PRI
+		struct dahdi_pri *pri = pris + x;
+
+		if (!pris[x].pri.pvts[0]) {
+			break;
+		}
+		for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) {
+			int channo = pri->dchannels[i];
+
+			if (!channo) {
+				break;
+			}
+			if (!pri->pri.fds[i]) {
+				break;
+			}
+			if (channo >= start && channo <= end) {
+				ast_log(LOG_ERROR,
+						"channel range %d-%d is occupied by span %d\n",
+						start, end, x + 1);
+				goto out;
+			}
+		}
+#endif
+	}
+	if (!default_conf.chan.cc_params || !base_conf.chan.cc_params ||
+		!conf.chan.cc_params) {
+		goto out;
+	}
+	default_conf.wanted_channels_start = start;
+	base_conf.wanted_channels_start = start;
+	conf.wanted_channels_start = start;
+	default_conf.wanted_channels_end = end;
+	base_conf.wanted_channels_end = end;
+	conf.wanted_channels_end = end;
+	if (setup_dahdi_int(0, &default_conf, &base_conf, &conf) == 0) {
+		ret = RESULT_SUCCESS;
+	}
+out:
+	ast_cc_config_params_destroy(default_conf.chan.cc_params);
+	ast_cc_config_params_destroy(base_conf.chan.cc_params);
+	ast_cc_config_params_destroy(conf.chan.cc_params);
 	ast_mutex_unlock(&iflock);
-	return RESULT_FAILURE;
-}
+	return ret;
+}
+
 
 static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
 {
@@ -11123,11 +11229,7 @@
 		doomed = NULL;
 		for (i = iflist;; i = i->next) {
 			if (doomed) {
-				int res;
-				res = dahdi_destroy_channel_bynum(doomed->channel);
-				if (res != RESULT_SUCCESS) {
-					ast_log(LOG_WARNING, "Couldn't find channel to destroy, hopefully another destroy operation just happened.\n");
-				}
+				dahdi_destroy_channel_range(doomed->channel, doomed->channel);
 				doomed = NULL;
 			}
 			if (!i) {
@@ -13573,10 +13675,21 @@
 	for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) {
 		if (!pri->dchannels[i])
 			break;
+		if (pri->pri.fds[i] >= 0) {
+			/* A partial range addition. Not a complete setup. */
+			break;
+		}
 		pri->pri.fds[i] = open("/dev/dahdi/channel", O_RDWR);
+		if ((pri->pri.fds[i] < 0)) {
+			ast_log(LOG_ERROR, "Unable to open D-channel (fd=%d) (%s)\n",
+				pri->pri.fds[i], strerror(errno));
+			return -1;
+		}
 		x = pri->dchannels[i];
-		if ((pri->pri.fds[i] < 0) || (ioctl(pri->pri.fds[i],DAHDI_SPECIFY,&x) == -1)) {
-			ast_log(LOG_ERROR, "Unable to open D-channel %d (%s)\n", x, strerror(errno));
+		res = ioctl(pri->pri.fds[i], DAHDI_SPECIFY, &x);
+		if (res) {
+			dahdi_close_pri_fd(pri, i);
+			ast_log(LOG_ERROR, "Unable to SPECIFY channel %d (%s)\n", x, strerror(errno));
 			return -1;
 		}
 		memset(&p, 0, sizeof(p));
@@ -13977,22 +14090,44 @@
  *
  * \param pri the pri span
  *
- * \return TRUE if the span was valid and we attempted destroying.
- *
  * Shuts down a span and destroys its D-Channel. Further destruction
  * of the B-channels using dahdi_destroy_channel() would probably be required
  * for the B-Channels.
  */
-static int pri_destroy_dchan(struct sig_pri_span *pri)
+static void pri_destroy_span(struct sig_pri_span *pri)
 {
 	int i;
+	int res;
+	int cancel_code;
 	struct dahdi_pri* dahdi_pri;
-
-	if (!pri->master || (pri->master == AST_PTHREADT_NULL)) {
-		return 0;
-	}
-	pthread_cancel(pri->master);
-	pthread_join(pri->master, NULL);
+	pthread_t master = pri->master;
+
+	if (!master || (master == AST_PTHREADT_NULL)) {
+		return;
+	}
+	ast_debug(2, "About to destroy DAHDI channels of span %d.\n", pri->span);
+	for (i = 0; i < pri->numchans; i++) {
+		int channel;
+		struct sig_pri_chan *pvt = pri->pvts[i];
+
+		if (!pvt) {
+			continue;
+		}
+		channel = pvt->channel;
+		ast_debug(2, "About to destroy B-channel %d.\n", channel);
+		dahdi_destroy_channel_range(channel, channel);
+	}
+
+	cancel_code = pthread_cancel(master);
+	ast_debug(4,
+		"Waiting to join thread of span %d "
+		"with pid=%p cancel_code=%d\n",
+		pri->span, (void *)master, cancel_code);
+	res = pthread_join(master, NULL);
+	if (res != 0) {
+		ast_log(LOG_NOTICE, "pthread_join failed: %d\n", res);
+	}
+	pri->master = AST_PTHREADT_NULL;
 
 	/* The 'struct dahdi_pri' that contains our 'struct sig_pri_span' */
 	dahdi_pri = container_of(pri, struct dahdi_pri, pri);
@@ -14000,17 +14135,16 @@
 		ast_debug(4, "closing pri_fd %d\n", i);
 		dahdi_close_pri_fd(dahdi_pri, i);
 	}
-	pri->pri = NULL;
+	sig_pri_init_pri(pri);
 	ast_debug(1, "PRI span %d destroyed\n", pri->span);
-	return 1;
 }
 
 static char *handle_pri_destroy_span(struct ast_cli_entry *e, int cmd,
 		struct ast_cli_args *a)
 {
 	int span;
-	int i;
 	int res;
+	struct sig_pri_span *pri;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -14034,25 +14168,13 @@
 			a->argv[3], 1, NUM_SPANS);
 		return CLI_SUCCESS;
 	}
-	if (!pris[span - 1].pri.pri) {
+	pri = &pris[span - 1].pri;
+	if (!pri->pri) {
 		ast_cli(a->fd, "No PRI running on span %d\n", span);
 		return CLI_SUCCESS;
 	}
 
-	for (i = 0; i < pris[span - 1].pri.numchans; i++) {
-		int channel;
-		struct sig_pri_chan *pvt = pris[span - 1].pri.pvts[i];
-
-		if (!pvt) {
-			continue;
-		}
-		channel = pvt->channel;
-		ast_debug(2, "About to destroy B-channel %d.\n", channel);
-		dahdi_destroy_channel_bynum(channel);
-	}
-	ast_debug(2, "About to destroy D-channel of span %d.\n", span);
-	pri_destroy_dchan(&pris[span - 1].pri);
-
+	pri_destroy_span(pri);
 	return CLI_SUCCESS;
 }
 
@@ -14504,26 +14626,97 @@
 
 #endif /* HAVE_OPENR2 */
 
-static char *dahdi_destroy_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	int channel;
-	int ret;
+static char *dahdi_destroy_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	int start;
+	int end;
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "dahdi destroy channel";
+		e->command = "dahdi destroy channels";
 		e->usage =
-			"Usage: dahdi destroy channel <chan num>\n"
+			"Usage: dahdi destroy channels <from_channel> [<to_channel>]\n"
 			"	DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.  Immediately removes a given channel, whether it is in use or not\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
 	}
-	if (a->argc != 4)
+	if ((a->argc < 4) || a->argc > 5) {
 		return CLI_SHOWUSAGE;
-
-	channel = atoi(a->argv[3]);
-	ret = dahdi_destroy_channel_bynum(channel);
-	return ( RESULT_SUCCESS == ret ) ? CLI_SUCCESS : CLI_FAILURE;
+	}
+	start = atoi(a->argv[3]);
+	if (start < 1) {
+		ast_cli(a->fd, "Invalid starting channel number %s.\n",
+				a->argv[4]);
+		return CLI_FAILURE;
+	}
+	if (a->argc == 5) {
+		end = atoi(a->argv[4]);
+		if (end < 1) {
+			ast_cli(a->fd, "Invalid ending channel number %s.\n",
+					a->argv[4]);
+			return CLI_FAILURE;
+		}
+	} else {
+		end = start;
+	}
+
+	if (end < start) {
+		ast_cli(a->fd,
+			"range end (%d) is smaller than range start (%d)\n",
+			end, start);
+		return CLI_FAILURE;
+	}
+	dahdi_destroy_channel_range(start, end);
+	return CLI_SUCCESS;
+}
+
+static char *dahdi_create_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	int start;
+	int end;
+	int ret;
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "dahdi create channels";
+		e->usage = "Usage: dahdi create channels <from> [<to>] - a range of channels\n"
+			   "       dahdi create channels new           - add channels not yet created\n"
+			   "For ISDN  and SS7 the range should include complete spans.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+	if ((a->argc < 4) || a->argc > 5) {
+		return CLI_SHOWUSAGE;
+	}
+	if (a->argc == 4 && !strcmp(a->argv[3], "new")) {
+		ret = dahdi_create_channel_range(0, 0);
+		return (RESULT_SUCCESS == ret) ? CLI_SUCCESS : CLI_FAILURE;
+	}
+	start = atoi(a->argv[3]);
+	if (start <= 0) {
+		ast_cli(a->fd, "Invalid starting channel number '%s'.\n",
+				a->argv[3]);
+		return CLI_FAILURE;
+	}
+	if (a->argc == 5) {
+		end = atoi(a->argv[4]);
+		if (end <= 0) {
+			ast_cli(a->fd, "Invalid ending channel number '%s'.\n",
+					a->argv[4]);
+			return CLI_FAILURE;
+		}
+	} else {
+		end = start;
+	}
+	if (end < start) {
+		ast_cli(a->fd,
+			"range end (%d) is smaller than range start (%d)\n",
+			end, start);
+		return CLI_FAILURE;
+	}
+	ret = dahdi_create_channel_range(start, end);
+	return (RESULT_SUCCESS == ret) ? CLI_SUCCESS : CLI_FAILURE;
 }
 
 static void dahdi_softhangup_all(void)
@@ -14554,7 +14747,6 @@
 	ast_mutex_unlock(&iflock);
 }
 
-static int setup_dahdi(int reload);
 static int dahdi_restart(void)
 {
 #if defined(HAVE_PRI) || defined(HAVE_SS7)
@@ -15331,7 +15523,8 @@
 	AST_CLI_DEFINE(handle_dahdi_show_cadences, "List cadences"),
 	AST_CLI_DEFINE(dahdi_show_channels, "Show active DAHDI channels"),
 	AST_CLI_DEFINE(dahdi_show_channel, "Show information on a channel"),
-	AST_CLI_DEFINE(dahdi_destroy_channel, "Destroy a channel"),
+	AST_CLI_DEFINE(dahdi_destroy_channels, "Destroy channels"),
+	AST_CLI_DEFINE(dahdi_create_channels, "Create channels"),
 	AST_CLI_DEFINE(dahdi_restart_cmd, "Fully restart DAHDI channels"),
 	AST_CLI_DEFINE(dahdi_show_status, "Show all DAHDI cards status"),
 	AST_CLI_DEFINE(dahdi_show_version, "Show the DAHDI version in use"),
@@ -16358,7 +16551,7 @@
 	return p;
 }
 
-static int build_channels(struct dahdi_chan_conf *conf, const char *value, int reload, int lineno, int *found_pseudo)
+static int build_channels(struct dahdi_chan_conf *conf, const char *value, int reload, int lineno)
 {
 	char *c, *chan;
 	char *subdir;
@@ -16381,8 +16574,6 @@
 			finish = start;
 		} else if (!strcasecmp(chan, "pseudo")) {
 			finish = start = CHAN_PSEUDO;
-			if (found_pseudo)
-				*found_pseudo = 1;
 		} else {
 			ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", value, chan);
 			return -1;
@@ -16412,6 +16603,12 @@
 					}
 				}
 			}
+			if (conf->wanted_channels_start &&
+				(real_channel < conf->wanted_channels_start ||
+				 real_channel > conf->wanted_channels_end)
+			   ) {
+				continue;
+			}
 			tmp = mkintf(real_channel, conf, reload);
 
 			if (tmp) {
@@ -16420,6 +16617,9 @@
 				ast_log(LOG_ERROR, "Unable to %s channel '%s'\n",
 						(reload == 1) ? "reconfigure" : "register", value);
 				return -1;
+			}
+			if (real_channel == CHAN_PSEUDO) {
+				has_pseudo = 1;
 			}
 		}
 	}
@@ -16607,7 +16807,6 @@
 {
 	struct dahdi_pvt *tmp;
 	int y;
-	int found_pseudo = 0;
 	struct ast_variable *dahdichan = NULL;
 
 	for (; v; v = v->next) {
@@ -16620,7 +16819,7 @@
 				ast_log(LOG_WARNING, "Channel '%s' ignored.\n", v->value);
 				continue;
 			}
-			if (build_channels(confp, v->value, reload, v->lineno, &found_pseudo)) {
+			if (build_channels(confp, v->value, reload, v->lineno)) {
 				if (confp->ignore_failed_channels) {
 					ast_log(LOG_WARNING, "Channel '%s' failure ignored: ignore_failed_channels.\n", v->value);
 					continue;
@@ -17753,8 +17952,7 @@
 
 	if (dahdichan) {
 		/* Process the deferred dahdichan value. */
-		if (build_channels(confp, dahdichan->value, reload, dahdichan->lineno,
-			&found_pseudo)) {
+		if (build_channels(confp, dahdichan->value, reload, dahdichan->lineno)) {
 			if (confp->ignore_failed_channels) {
 				ast_log(LOG_WARNING,
 					"Dahdichan '%s' failure ignored: ignore_failed_channels.\n",
@@ -17777,7 +17975,7 @@
 
 	/*< \todo why check for the pseudo in the per-channel section.
 	 * Any actual use for manual setup of the pseudo channel? */
-	if (!found_pseudo && reload != 1 && !(options & PROC_DAHDI_OPT_NOCHAN)) {
+	if (!has_pseudo && reload != 1 && !(options & PROC_DAHDI_OPT_NOCHAN)) {
 		/* use the default configuration for a channel, so
 		   that any settings from real configured channels
 		   don't "leak" into the pseudo channel config
@@ -17791,6 +17989,7 @@
 		}
 		if (tmp) {
 			ast_verb(3, "Automatically generated pseudo channel\n");
+			has_pseudo = 1;
 		} else {
 			ast_log(LOG_WARNING, "Unable to register pseudo channel!\n");
 		}
@@ -18070,7 +18269,8 @@
 	if (reload != 1) {
 		int x;
 		for (x = 0; x < NUM_SPANS; x++) {
-			if (pris[x].pri.pvts[0]) {
+			if (pris[x].pri.pvts[0] &&
+					pris[x].pri.master == AST_PTHREADT_NULL) {
 				prepare_pri(pris + x);
 				if (sig_pri_start_pri(&pris[x].pri)) {
 					ast_log(LOG_ERROR, "Unable to start D-channel on span %d\n", x + 1);

Modified: team/kmoore/event_system_strip/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/channels/chan_sip.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/channels/chan_sip.c (original)
+++ team/kmoore/event_system_strip/channels/chan_sip.c Fri Aug  9 08:23:42 2013
@@ -15271,6 +15271,8 @@
 			append_history(p, "RegistryInit", "Account: %s@%s", r->username, r->hostname);
 		}
 
+		p->socket.type = r->transport;
+
 		/* Use port number specified if no SRV record was found */
 		if (!ast_sockaddr_isnull(&r->us)) {
 			if (!ast_sockaddr_port(&r->us) && r->portno) {

Modified: team/kmoore/event_system_strip/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/channels/chan_unistim.c?view=diff&rev=396486&r1=396485&r2=396486
==============================================================================
--- team/kmoore/event_system_strip/channels/chan_unistim.c (original)
+++ team/kmoore/event_system_strip/channels/chan_unistim.c Fri Aug  9 08:23:42 2013
@@ -2870,7 +2870,11 @@
 			send_text(TEXT_LINE0, TEXT_NORMAL, pte, ustmtext("Enter the number to dial", pte));
 			send_text(TEXT_LINE1, TEXT_NORMAL, pte, ustmtext("and press Call", pte));
 		}
-		send_text_status(pte, ustmtext("Call   Redial BackSp Erase", pte));
+		if (ast_strlen_zero(pte->device->redial_number)) {
+			send_text_status(pte, ustmtext("Call          BackSp Erase", pte));
+		} else {
+			send_text_status(pte, ustmtext("Call   Redial BackSp Erase", pte));
+		}
 	}
 
 	pte->device->size_phone_number = 0;
@@ -3273,6 +3277,8 @@
 static void key_call(struct unistimsession *pte, char keycode)
 {
 	struct unistim_subchannel *sub = get_sub(pte->device, SUB_REAL);
+	struct unistim_subchannel *sub_3way = get_sub(pte->device, SUB_THREEWAY);
+
 	if ((keycode >= KEY_0) && (keycode <= KEY_SHARP)) {
 		if (keycode == KEY_SHARP) {
 			keycode = '#';
@@ -3287,22 +3293,21 @@
 	switch (keycode) {
 	case KEY_FUNC1:
 		if (ast_channel_state(sub->owner) == AST_STATE_UP) {
-			if (get_sub(pte->device, SUB_THREEWAY)) {
+			if (sub_3way) {
 				close_call(pte);
 			}
 		}
 		break;
 	case KEY_FUNC2:
-		if (ast_channel_state(sub->owner) == AST_STATE_RING) {
+		if (sub_3way) {
 			transfer_cancel_step2(pte);
-		}
-		if (ast_channel_state(sub->owner) == AST_STATE_UP) {
+		} else if (ast_channel_state(sub->owner) == AST_STATE_UP) {
 			transfer_call_step1(pte);
 		}
 		break;
 	case KEY_HANGUP:
 	case KEY_FUNC4:
-		if (!get_sub(pte->device, SUB_THREEWAY)) {
+		if (!sub_3way) {
 			close_call(pte);
 		}
 		break;
@@ -3980,13 +3985,24 @@
 			send_text(TEXT_LINE1, TEXT_NORMAL, pte, pte->device->call_forward);
 		}
 		send_icon(TEXT_LINE0, FAV_ICON_REFLECT + FAV_BLINK_SLOW, pte);
-		send_text_status(pte, ustmtext("Dial   Redial NoFwd  ", pte));
+		if (ast_strlen_zero(pte->device->redial_number)) {
+			send_text_status(pte, ustmtext("Dial          NoFwd  ", pte));
+		} else {
+			send_text_status(pte, ustmtext("Dial   Redial NoFwd  ", pte));
+		}
 	} else {
-		if ((pte->device->extension == EXTENSION_ASK) ||
-			(pte->device->extension == EXTENSION_TN)) {
-			send_text_status(pte, ustmtext("Dial   Redial Fwd    Unregis", pte));
+		if ((pte->device->extension == EXTENSION_ASK) || (pte->device->extension == EXTENSION_TN)) {
+			if (ast_strlen_zero(pte->device->redial_number)) {
+				send_text_status(pte, ustmtext("Dial          Fwd    Unregis", pte));
+			} else {
+				send_text_status(pte, ustmtext("Dial   Redial Fwd    Unregis", pte));
+			}
 		} else {
-			send_text_status(pte, ustmtext("Dial   Redial Fwd    Pickup", pte));
+			if (ast_strlen_zero(pte->device->redial_number)) {
+				send_text_status(pte, ustmtext("Dial          Fwd    Pickup", pte));
+			} else {

[... 6582 lines stripped ...]



More information about the asterisk-commits mailing list