[asterisk-commits] irroot: branch irroot/distrotech-customers-10 r350937 - in /team/irroot/distr...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 16 07:28:09 CST 2012


Author: irroot
Date: Mon Jan 16 07:27:54 2012
New Revision: 350937

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=350937
Log:
Update branch

Added:
    team/irroot/distrotech-customers-10/contrib/scripts/valgrind_compare
      - copied unchanged from r350936, branches/10/contrib/scripts/valgrind_compare
Modified:
    team/irroot/distrotech-customers-10/   (props changed)
    team/irroot/distrotech-customers-10/CHANGES
    team/irroot/distrotech-customers-10/addons/chan_mobile.c
    team/irroot/distrotech-customers-10/apps/app_authenticate.c
    team/irroot/distrotech-customers-10/apps/app_chanspy.c
    team/irroot/distrotech-customers-10/apps/app_confbridge.c
    team/irroot/distrotech-customers-10/apps/app_dial.c
    team/irroot/distrotech-customers-10/apps/app_followme.c
    team/irroot/distrotech-customers-10/apps/app_meetme.c
    team/irroot/distrotech-customers-10/apps/app_originate.c
    team/irroot/distrotech-customers-10/apps/app_parkandannounce.c
    team/irroot/distrotech-customers-10/apps/app_queue.c
    team/irroot/distrotech-customers-10/apps/confbridge/   (props changed)
    team/irroot/distrotech-customers-10/apps/confbridge/conf_config_parser.c
    team/irroot/distrotech-customers-10/autoconf/ast_gcc_attribute.m4
    team/irroot/distrotech-customers-10/autoconf/libcurl.m4
    team/irroot/distrotech-customers-10/bootstrap.sh
    team/irroot/distrotech-customers-10/bridges/bridge_builtin_features.c
    team/irroot/distrotech-customers-10/cel/cel_manager.c
    team/irroot/distrotech-customers-10/cel/cel_odbc.c
    team/irroot/distrotech-customers-10/cel/cel_pgsql.c
    team/irroot/distrotech-customers-10/cel/cel_sqlite3_custom.c
    team/irroot/distrotech-customers-10/channels/chan_bridge.c
    team/irroot/distrotech-customers-10/channels/chan_dahdi.c
    team/irroot/distrotech-customers-10/channels/chan_h323.c
    team/irroot/distrotech-customers-10/channels/chan_iax2.c
    team/irroot/distrotech-customers-10/channels/chan_sip.c
    team/irroot/distrotech-customers-10/channels/sip/config_parser.c
    team/irroot/distrotech-customers-10/codecs/speex/   (props changed)
    team/irroot/distrotech-customers-10/configs/cel.conf.sample
    team/irroot/distrotech-customers-10/configs/cel_custom.conf.sample
    team/irroot/distrotech-customers-10/configs/cel_odbc.conf.sample
    team/irroot/distrotech-customers-10/configs/cel_pgsql.conf.sample
    team/irroot/distrotech-customers-10/configs/cel_sqlite3_custom.conf.sample
    team/irroot/distrotech-customers-10/configs/sip.conf.sample
    team/irroot/distrotech-customers-10/configure
    team/irroot/distrotech-customers-10/configure.ac
    team/irroot/distrotech-customers-10/contrib/init.d/rc.debian.asterisk
    team/irroot/distrotech-customers-10/contrib/scripts/autosupport
    team/irroot/distrotech-customers-10/contrib/scripts/autosupport.8
    team/irroot/distrotech-customers-10/contrib/scripts/install_prereq
    team/irroot/distrotech-customers-10/funcs/func_cdr.c
    team/irroot/distrotech-customers-10/funcs/func_lock.c
    team/irroot/distrotech-customers-10/include/asterisk/autoconfig.h.in
    team/irroot/distrotech-customers-10/include/asterisk/bridging.h
    team/irroot/distrotech-customers-10/include/asterisk/cdr.h
    team/irroot/distrotech-customers-10/include/asterisk/dsp.h
    team/irroot/distrotech-customers-10/include/asterisk/format_pref.h
    team/irroot/distrotech-customers-10/include/asterisk/module.h
    team/irroot/distrotech-customers-10/include/asterisk/pbx.h
    team/irroot/distrotech-customers-10/include/asterisk/res_fax.h
    team/irroot/distrotech-customers-10/main/app.c
    team/irroot/distrotech-customers-10/main/asterisk.c
    team/irroot/distrotech-customers-10/main/audiohook.c
    team/irroot/distrotech-customers-10/main/bridging.c
    team/irroot/distrotech-customers-10/main/cel.c
    team/irroot/distrotech-customers-10/main/channel.c
    team/irroot/distrotech-customers-10/main/db.c
    team/irroot/distrotech-customers-10/main/dsp.c
    team/irroot/distrotech-customers-10/main/features.c
    team/irroot/distrotech-customers-10/main/file.c
    team/irroot/distrotech-customers-10/main/message.c
    team/irroot/distrotech-customers-10/main/pbx.c
    team/irroot/distrotech-customers-10/main/rtp_engine.c
    team/irroot/distrotech-customers-10/main/say.c
    team/irroot/distrotech-customers-10/pbx/pbx_lua.c
    team/irroot/distrotech-customers-10/res/res_fax.c
    team/irroot/distrotech-customers-10/res/res_fax_spandsp.c
    team/irroot/distrotech-customers-10/res/res_monitor.c
    team/irroot/distrotech-customers-10/res/res_musiconhold.c
    team/irroot/distrotech-customers-10/res/res_pktccops.c
    team/irroot/distrotech-customers-10/res/res_timing_dahdi.c
    team/irroot/distrotech-customers-10/res/res_timing_pthread.c
    team/irroot/distrotech-customers-10/res/res_timing_timerfd.c
    team/irroot/distrotech-customers-10/utils/   (props changed)
    team/irroot/distrotech-customers-10/utils/extconf.c

Propchange: team/irroot/distrotech-customers-10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Propchange: team/irroot/distrotech-customers-10/
            ('svn:mergeinfo' removed)

Propchange: team/irroot/distrotech-customers-10/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 16 07:27:54 2012
@@ -1,1 +1,1 @@
-/branches/10:1-348171
+/branches/10:1-350936

Modified: team/irroot/distrotech-customers-10/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/CHANGES?view=diff&rev=350937&r1=350936&r2=350937
==============================================================================
--- team/irroot/distrotech-customers-10/CHANGES (original)
+++ team/irroot/distrotech-customers-10/CHANGES Mon Jan 16 07:27:54 2012
@@ -7,6 +7,18 @@
 === and the other UPGRADE files for older releases.
 ===
 ==============================================================================
+
+------------------------------------------------------------------------------
+--- Functionality changes since Asterisk 10.1.0 ------------------------------
+------------------------------------------------------------------------------
+
+Followme changes
+-------------
+ * A new option, 'I' has been added to app_followme.
+   By setting this option, Asterisk will not update the caller with
+   connected line changes when they occur.  This is similar to app_dial
+   and app_queue.
+ * The 'N' option is now ignored if the call is already answered.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.8 to Asterisk 10 -------------------

Modified: team/irroot/distrotech-customers-10/addons/chan_mobile.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/addons/chan_mobile.c?view=diff&rev=350937&r1=350936&r2=350937
==============================================================================
--- team/irroot/distrotech-customers-10/addons/chan_mobile.c (original)
+++ team/irroot/distrotech-customers-10/addons/chan_mobile.c Mon Jan 16 07:27:54 2012
@@ -2273,14 +2273,13 @@
  */
 static char *hfp_parse_cusd(struct hfp_pvt *hfp, char *buf)
 {
-	int i, state, message_start, message_end;
+	int i, message_start, message_end;
 	char *cusd;
 	size_t s;
 
 	/* parse cusd message in the following format:
 	 * +CUSD: 0,"100,00 EURO, valid till 01.01.2010, you are using tariff "Mega Tariff". More informations *111#."
 	 */
-	state = 0;
 	message_start = 0;
 	message_end = 0;
 	s = strlen(buf);
@@ -2678,7 +2677,7 @@
 {
 	int i, state, group;
 	size_t s;
-	char *indicator = NULL, *values;
+	char *indicator = NULL;
 
 	hfp->nocallsetup = 1;
 
@@ -2717,7 +2716,6 @@
 			}
 			break;
 		case 5: /* mark the start of the value range */
-			values = &buf[i];
 			state++;
 			break;
 		case 6: /* find the end of the value range */
@@ -2989,7 +2987,6 @@
 	sdp_list_t  *l2cap_list = 0, *rfcomm_list = 0, *root_list = 0, *proto_list = 0, *access_proto_list = 0, *svc_uuid_list = 0;
 	sdp_data_t *channel = 0;
 
-	int err = 0;
 	sdp_session_t *session = 0;
 
 	sdp_record_t *record = sdp_record_alloc();
@@ -3026,7 +3023,7 @@
 	if (!(session = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY)))
 		ast_log(LOG_WARNING, "Failed to connect sdp and create session.\n");
 	else
-		err = sdp_record_register(session, record, 0);
+		sdp_record_register(session, record, 0);
 
 	sdp_data_free(channel);
 	sdp_list_free(rfcomm_list, 0);

Modified: team/irroot/distrotech-customers-10/apps/app_authenticate.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/apps/app_authenticate.c?view=diff&rev=350937&r1=350936&r2=350937
==============================================================================
--- team/irroot/distrotech-customers-10/apps/app_authenticate.c (original)
+++ team/irroot/distrotech-customers-10/apps/app_authenticate.c Mon Jan 16 07:27:54 2012
@@ -213,14 +213,20 @@
 						continue;
 					ast_md5_hash(md5passwd, passwd);
 					if (!strcmp(md5passwd, md5secret)) {
-						if (ast_test_flag(&flags,OPT_ACCOUNT))
+						if (ast_test_flag(&flags,OPT_ACCOUNT)) {
+							ast_channel_lock(chan);
 							ast_cdr_setaccount(chan, buf);
+							ast_channel_unlock(chan);
+						}
 						break;
 					}
 				} else {
 					if (!strcmp(passwd, buf)) {
-						if (ast_test_flag(&flags, OPT_ACCOUNT))
+						if (ast_test_flag(&flags, OPT_ACCOUNT)) {
+							ast_channel_lock(chan);
 							ast_cdr_setaccount(chan, buf);
+							ast_channel_unlock(chan);
+						}
 						break;
 					}
 				}
@@ -242,8 +248,11 @@
 	}
 
 	if ((retries < 3) && !res) {
-		if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE))
+		if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE)) {
+			ast_channel_lock(chan);
 			ast_cdr_setaccount(chan, passwd);
+			ast_channel_unlock(chan);
+		}
 		if (!(res = ast_streamfile(chan, "auth-thankyou", chan->language)))
 			res = ast_waitstream(chan, "");
 	} else {

Modified: team/irroot/distrotech-customers-10/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/apps/app_chanspy.c?view=diff&rev=350937&r1=350936&r2=350937
==============================================================================
--- team/irroot/distrotech-customers-10/apps/app_chanspy.c (original)
+++ team/irroot/distrotech-customers-10/apps/app_chanspy.c Mon Jan 16 07:27:54 2012
@@ -546,6 +546,9 @@
 	memset(&csth, 0, sizeof(csth));
 	ast_copy_flags(&csth.flags, flags, AST_FLAGS_ALL);
 
+	/* This is the audiohook which gives us the audio off the channel we are
+	   spying on.
+	*/
 	ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy", 0);
 
 	if (start_spying(spyee_autochan, spyer_name, &csth.spy_audiohook)) {
@@ -553,17 +556,30 @@
 		return 0;
 	}
 
-	ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy", 0);
-	ast_audiohook_init(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy", 0);
-	if (start_spying(spyee_autochan, spyer_name, &csth.whisper_audiohook)) {
-		ast_log(LOG_WARNING, "Unable to attach whisper audiohook to spyee %s. Whisper mode disabled!\n", name);
-	}
-	if ((spyee_bridge_autochan = ast_autochan_setup(ast_bridged_channel(spyee_autochan->chan)))) {
-		ast_channel_lock(spyee_bridge_autochan->chan);
-		if (start_spying(spyee_bridge_autochan, spyer_name, &csth.bridge_whisper_audiohook)) {
-			ast_log(LOG_WARNING, "Unable to attach barge audiohook on spyee %s. Barge mode disabled!\n", name);
-		}
-		ast_channel_unlock(spyee_bridge_autochan->chan);
+	if (ast_test_flag(flags, OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
+		/* This audiohook will let us inject audio from our channel into the
+		   channel we are currently spying on.
+		*/
+		ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy", 0);
+
+		if (start_spying(spyee_autochan, spyer_name, &csth.whisper_audiohook)) {
+			ast_log(LOG_WARNING, "Unable to attach whisper audiohook to spyee %s. Whisper mode disabled!\n", name);
+		}
+	}
+
+	if (ast_test_flag(flags, OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
+		/* And this hook lets us inject audio into the channel that the spied on
+		   channel is currently bridged with.
+		*/
+		ast_audiohook_init(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy", 0);
+
+		if ((spyee_bridge_autochan = ast_autochan_setup(ast_bridged_channel(spyee_autochan->chan)))) {
+			ast_channel_lock(spyee_bridge_autochan->chan);
+			if (start_spying(spyee_bridge_autochan, spyer_name, &csth.bridge_whisper_audiohook)) {
+				ast_log(LOG_WARNING, "Unable to attach barge audiohook on spyee %s. Barge mode disabled!\n", name);
+			}
+			ast_channel_unlock(spyee_bridge_autochan->chan);
+		}
 	}
 
 	ast_channel_lock(chan);
@@ -686,15 +702,19 @@
 	ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY);
 	ast_channel_unlock(chan);
 
-	ast_audiohook_lock(&csth.whisper_audiohook);
-	ast_audiohook_detach(&csth.whisper_audiohook);
-	ast_audiohook_unlock(&csth.whisper_audiohook);
-	ast_audiohook_destroy(&csth.whisper_audiohook);
-	
-	ast_audiohook_lock(&csth.bridge_whisper_audiohook);
-	ast_audiohook_detach(&csth.bridge_whisper_audiohook);
-	ast_audiohook_unlock(&csth.bridge_whisper_audiohook);
-	ast_audiohook_destroy(&csth.bridge_whisper_audiohook);
+	if (ast_test_flag(flags, OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
+		ast_audiohook_lock(&csth.whisper_audiohook);
+		ast_audiohook_detach(&csth.whisper_audiohook);
+		ast_audiohook_unlock(&csth.whisper_audiohook);
+		ast_audiohook_destroy(&csth.whisper_audiohook);
+	}
+
+	if (ast_test_flag(flags, OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
+		ast_audiohook_lock(&csth.bridge_whisper_audiohook);
+		ast_audiohook_detach(&csth.bridge_whisper_audiohook);
+		ast_audiohook_unlock(&csth.bridge_whisper_audiohook);
+		ast_audiohook_destroy(&csth.bridge_whisper_audiohook);
+	}
 
 	ast_audiohook_lock(&csth.spy_audiohook);
 	ast_audiohook_detach(&csth.spy_audiohook);

Modified: team/irroot/distrotech-customers-10/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/apps/app_confbridge.c?view=diff&rev=350937&r1=350936&r2=350937
==============================================================================
--- team/irroot/distrotech-customers-10/apps/app_confbridge.c (original)
+++ team/irroot/distrotech-customers-10/apps/app_confbridge.c Mon Jan 16 07:27:54 2012
@@ -57,6 +57,7 @@
 #include "confbridge/include/confbridge.h"
 #include "asterisk/paths.h"
 #include "asterisk/manager.h"
+#include "asterisk/test.h"
 
 /*** DOCUMENTATION
     <application name="ConfBridge" language="en_US">
@@ -464,6 +465,7 @@
 
 		chan = ast_channel_unref(chan);
 		pthread_join(thread, NULL);
+		ast_test_suite_event_notify("CONF_STOP_RECORD", "Message: stopped conference recording channel\r\nConference: %s", conference_bridge->b_profile.name);
 
 		ao2_lock(conference_bridge);
 	}
@@ -516,6 +518,7 @@
 		return -1;
 	}
 
+	ast_test_suite_event_notify("CONF_START_RECORD", "Message: started conference recording channel\r\nConference: %s", conference_bridge->b_profile.name);
 	ao2_unlock(conference_bridge);
 	return 0;
 }
@@ -867,7 +870,9 @@
 
 	if (conference_bridge->playback_chan) {
 		struct ast_channel *underlying_channel = conference_bridge->playback_chan->tech->bridged_channel(conference_bridge->playback_chan, NULL);
-		ast_hangup(underlying_channel);
+		if (underlying_channel) {
+			ast_hangup(underlying_channel);
+		}
 		ast_hangup(conference_bridge->playback_chan);
 		conference_bridge->playback_chan = NULL;
 	}
@@ -1148,7 +1153,7 @@
 	} else {
 		/* Channel was already available so we just need to add it back into the bridge */
 		underlying_channel = conference_bridge->playback_chan->tech->bridged_channel(conference_bridge->playback_chan, NULL);
-		ast_bridge_impart(conference_bridge->bridge, underlying_channel, NULL, NULL);
+		ast_bridge_impart(conference_bridge->bridge, underlying_channel, NULL, NULL, 0);
 	}
 
 	/* The channel is all under our control, in goes the prompt */
@@ -1541,6 +1546,7 @@
 	/* Mute or unmute yourself, note we only allow manipulation if they aren't waiting for a marked user or if marked users exist */
 	if (!ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_WAITMARKED) || conference_bridge->markedusers) {
 		conference_bridge_user->features.mute = (!conference_bridge_user->features.mute ? 1 : 0);
+		ast_test_suite_event_notify("CONF_MUTE", "Message: participant %s %s\r\nConference: %s\r\nChannel: %s", chan->name, conference_bridge_user->features.mute ? "muted" : "unmuted", conference_bridge_user->b_profile.name, chan->name);
 	}
 	return ast_stream_and_wait(chan, (conference_bridge_user->features.mute ?
 		conf_get_sound(CONF_SOUND_MUTED, conference_bridge_user->b_profile.sounds) :
@@ -1981,6 +1987,7 @@
 	}
 	ao2_lock(bridge);
 	bridge->locked = lock;
+	ast_test_suite_event_notify("CONF_LOCK", "Message: conference %s\r\nConference: %s", bridge->locked ? "locked" : "unlocked", bridge->b_profile.name);
 	ao2_unlock(bridge);
 	ao2_ref(bridge, -1);
 
@@ -2013,6 +2020,7 @@
 	}
 	if (participant) {
 		participant->features.mute = mute;
+		ast_test_suite_event_notify("CONF_MUTE", "Message: participant %s %s\r\nConference: %s\r\nChannel: %s", participant->chan->name, participant->features.mute ? "muted" : "unmuted", bridge->b_profile.name, participant->chan->name);
 	} else {
 		res = -2;;
 	}

Modified: team/irroot/distrotech-customers-10/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/apps/app_dial.c?view=diff&rev=350937&r1=350936&r2=350937
==============================================================================
--- team/irroot/distrotech-customers-10/apps/app_dial.c (original)
+++ team/irroot/distrotech-customers-10/apps/app_dial.c Mon Jan 16 07:27:54 2012
@@ -203,8 +203,8 @@
 					<para>Asterisk will ignore any forwarding requests it may receive on this dial attempt.</para>
 				</option>
 				<option name="I">
-					<para>Asterisk will ignore any connected line update requests or redirecting party update
-					requests it may receiveon this dial attempt.</para>
+					<para>Asterisk will ignore any connected line update requests or any redirecting party
+					update requests it may receive on this dial attempt.</para>
 				</option>
 				<option name="k">
 					<para>Allow the called party to enable parking of the call by sending
@@ -476,7 +476,7 @@
 			<para>If the <variable>OUTBOUND_GROUP</variable> variable is set, all peer channels created by this
 			application will be put into that group (as in Set(GROUP()=...).
 			If the <variable>OUTBOUND_GROUP_ONCE</variable> variable is set, all peer channels created by this
-			application will be put into that group (as in Set(GROUP()=...). Unlike OUTBOUND_GROUP,
+			application will be put into that group (as in Set(GROUP()=...). Unlike <variable>OUTBOUND_GROUP</variable>,
 			however, the variable will be unset after use.</para>
 
 			<para>This application sets the following channel variables:</para>

Modified: team/irroot/distrotech-customers-10/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/apps/app_followme.c?view=diff&rev=350937&r1=350936&r2=350937
==============================================================================
--- team/irroot/distrotech-customers-10/apps/app_followme.c (original)
+++ team/irroot/distrotech-customers-10/apps/app_followme.c Mon Jan 16 07:27:54 2012
@@ -67,30 +67,40 @@
 			<parameter name="followmeid" required="true" />
 			<parameter name="options">
 				<optionlist>
-					<option name="s">
-						<para>Playback the incoming status message prior to starting
-						the follow-me step(s)</para>
-					</option>
 					<option name="a">
 						<para>Record the caller's name so it can be announced to the
 						callee on each step.</para>
 					</option>
-					<option name="n">
-						<para>Playback the unreachable status message if we've run out
-						of steps to reach the or the callee has elected not to be reachable.</para>
-					</option>
-					<option name="N">
-						<para>Don't answer the incoming call until we're ready to
-						connect the caller or give up. This will disable all the other
-						options while implicitly turning on the 'd' option.</para>
-					</option>
 					<option name="d">
 						<para>Disable the 'Please hold while we try to connect your call' announcement.</para>
+					</option>
+					<option name="I">
+						<para>Asterisk will ignore any connected line update requests
+						it may receive on this dial attempt.</para>
 					</option>
 					<option name="l">
 						<para>Disable local call optimization so that applications with
 						audio hooks between the local bridge don't get dropped when the
 						calls get joined directly.</para>
+					</option>
+					<option name="N">
+						<para>Don't answer the incoming call until we're ready to
+						connect the caller or give up.</para>
+						<note>
+	 						<para>This option is ignored if the call is already answered.</para>
+ 						</note>
+						<note>
+							<para>If the call is not already answered, the 'a' and 's'
+							options are ignored while the 'd' option is implicitly enabled.</para>
+ 						</note>
+					</option>
+					<option name="n">
+						<para>Playback the unreachable status message if we've run out
+						of steps or the callee has elected not to be reachable.</para>
+					</option>
+					<option name="s">
+						<para>Playback the incoming status message prior to starting
+						the follow-me step(s)</para>
 					</option>
 				</optionlist>
 			</parameter>
@@ -140,13 +150,23 @@
 };
 
 struct fm_args {
+	/*! Inbound (caller) channel */
 	struct ast_channel *chan;
 	char *mohclass;
 	AST_LIST_HEAD_NOLOCK(cnumbers, number) cnumbers;
+	/*! Winning outbound (callee) channel */
+	struct ast_channel *outbound;
+	/*! Accumulated connected line information from inbound call. */
+	struct ast_party_connected_line connected_in;
+	/*! Accumulated connected line information from outbound call. */
+	struct ast_party_connected_line connected_out;
+	/*! TRUE if connected line information from inbound call changed. */
+	int pending_in_connected_update:1;
+	/*! TRUE if connected line information from outbound call is available. */
+	int pending_out_connected_update:1;
 	int status;
 	char context[AST_MAX_CONTEXT];
 	char namerecloc[AST_MAX_CONTEXT];
-	struct ast_channel *outbound;
 	char takecall[20];		/*!< Digit mapping to take a call */
 	char nextindp[20];		/*!< Digit mapping to decline a call */
 	char callfromprompt[PATH_MAX];	/*!< Sound prompt name and path */
@@ -160,12 +180,17 @@
 
 struct findme_user {
 	struct ast_channel *ochan;
+	/*! Accumulated connected line information from outgoing call. */
+	struct ast_party_connected_line connected;
+	long digts;
+	int ynidx;
 	int state;
 	char dialarg[256];
 	char yn[10];
-	int ynidx; 
-	long digts;
-	int cleared;
+	/*! TRUE if call cleared. */
+	int cleared:1;
+	/*! TRUE if connected line information is available. */
+	int pending_connected_update:1;
 	AST_LIST_ENTRY(findme_user) entry;
 };
 
@@ -176,15 +201,17 @@
 	FOLLOWMEFLAG_DISABLEHOLDPROMPT = (1 << 3),
 	FOLLOWMEFLAG_NOANSWER = (1 << 4),
 	FOLLOWMEFLAG_DISABLEOPTIMIZATION = (1 << 5),
+	FOLLOWMEFLAG_IGNORE_CONNECTEDLINE = (1 << 6),
 };
 
 AST_APP_OPTIONS(followme_opts, {
-	AST_APP_OPTION('s', FOLLOWMEFLAG_STATUSMSG ),
-	AST_APP_OPTION('a', FOLLOWMEFLAG_RECORDNAME ),
-	AST_APP_OPTION('n', FOLLOWMEFLAG_UNREACHABLEMSG ),
-	AST_APP_OPTION('d', FOLLOWMEFLAG_DISABLEHOLDPROMPT ),
-	AST_APP_OPTION('N', FOLLOWMEFLAG_NOANSWER ),
-	AST_APP_OPTION('l', FOLLOWMEFLAG_DISABLEOPTIMIZATION ),
+	AST_APP_OPTION('a', FOLLOWMEFLAG_RECORDNAME),
+	AST_APP_OPTION('d', FOLLOWMEFLAG_DISABLEHOLDPROMPT),
+	AST_APP_OPTION('I', FOLLOWMEFLAG_IGNORE_CONNECTEDLINE),
+	AST_APP_OPTION('l', FOLLOWMEFLAG_DISABLEOPTIMIZATION),
+	AST_APP_OPTION('N', FOLLOWMEFLAG_NOANSWER),
+	AST_APP_OPTION('n', FOLLOWMEFLAG_UNREACHABLEMSG),
+	AST_APP_OPTION('s', FOLLOWMEFLAG_STATUSMSG),
 });
 
 static int ynlongest = 0;
@@ -492,10 +519,12 @@
 
 	if (tmpuser && tmpuser->ochan && tmpuser->state >= 0) {
 		outbound = tmpuser->ochan;
+		ast_channel_lock(outbound);
 		if (!outbound->cdr) {
 			outbound->cdr = ast_cdr_alloc();
-			if (outbound->cdr)
+			if (outbound->cdr) {
 				ast_cdr_init(outbound->cdr, outbound);
+			}
 		}
 		if (outbound->cdr) {
 			char tmp[256];
@@ -506,11 +535,15 @@
 			ast_cdr_start(outbound->cdr);
 			ast_cdr_end(outbound->cdr);
 			/* If the cause wasn't handled properly */
-			if (ast_cdr_disposition(outbound->cdr, outbound->hangupcause))
+			if (ast_cdr_disposition(outbound->cdr, outbound->hangupcause)) {
 				ast_cdr_failed(outbound->cdr);
-		} else
+			}
+		} else {
 			ast_log(LOG_WARNING, "Unable to create Call Detail Record\n");
-		ast_hangup(tmpuser->ochan);
+		}
+		ast_channel_unlock(outbound);
+		ast_hangup(outbound);
+		tmpuser->ochan = NULL;
 	}
 }
 
@@ -532,13 +565,15 @@
 		if (!fmuser->cleared) {
 			clear_caller(fmuser);
 		}
+		ast_party_connected_line_free(&fmuser->connected);
 		ast_free(fmuser);
 	}
 	ast_free(findme_user_list);
 }
 
-static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_user_list, struct number *nm, struct ast_channel *caller, char *namerecloc, int *status, struct fm_args *tpargs) 
-{
+static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_user_list, struct number *nm, struct ast_channel *caller, char *namerecloc, struct fm_args *tpargs)
+{
+	struct ast_party_connected_line connected;
 	struct ast_channel *watchers[256];
 	int pos;
 	struct ast_channel *winner;
@@ -664,12 +699,21 @@
 		}
 		if (winner) {
 			/* Need to find out which channel this is */
-			dg = 0;
-			while ((winner != watchers[dg]) && (dg < 256))
-				dg++;
-			AST_LIST_TRAVERSE(findme_user_list, tmpuser, entry)
-				if (tmpuser->ochan == winner)
+			for (dg = 0; dg < ARRAY_LEN(watchers); ++dg) {
+				if (winner == watchers[dg]) {
 					break;
+				}
+			}
+			if (dg) {
+				/* The winner is an outgoing channel. */
+				AST_LIST_TRAVERSE(findme_user_list, tmpuser, entry) {
+					if (tmpuser->ochan == winner) {
+						break;
+					}
+				}
+			} else {
+				tmpuser = NULL;
+			}
 			f = ast_read(winner);
 			if (f) {
 				if (f->frametype == AST_FRAME_CONTROL) {
@@ -723,32 +767,73 @@
 						ast_verb(3, "%s is ringing\n", winner->name);
 						break;
 					case AST_CONTROL_PROGRESS:
-						ast_verb(3, "%s is making progress passing it to %s\n", winner->name, caller->name);
+						ast_verb(3, "%s is making progress\n", winner->name);
 						break;
 					case AST_CONTROL_VIDUPDATE:
-						ast_verb(3, "%s requested a video update, passing it to %s\n", winner->name, caller->name);
+						ast_verb(3, "%s requested a video update\n", winner->name);
 						break;
 					case AST_CONTROL_SRCUPDATE:
-						ast_verb(3, "%s requested a source update, passing it to %s\n", winner->name, caller->name);
+						ast_verb(3, "%s requested a source update\n", winner->name);
 						break;
 					case AST_CONTROL_PROCEEDING:
-						ast_verb(3, "%s is proceeding passing it to %s\n", winner->name,caller->name);
+						ast_verb(3, "%s is proceeding\n", winner->name);
 						break;
 					case AST_CONTROL_HOLD:
-						ast_verb(3, "Call on %s placed on hold\n", winner->name);
+						ast_verb(3, "%s placed call on hold\n", winner->name);
 						break;
 					case AST_CONTROL_UNHOLD:
-						ast_verb(3, "Call on %s left from hold\n", winner->name);
+						ast_verb(3, "%s removed call from hold\n", winner->name);
 						break;
 					case AST_CONTROL_OFFHOOK:
 					case AST_CONTROL_FLASH:
 						/* Ignore going off hook and flash */
 						break;
+					case AST_CONTROL_CONNECTED_LINE:
+						if (!tmpuser) {
+							/*
+							 * Hold connected line update from caller until we have a
+							 * winner.
+							 */
+							ast_verb(3,
+								"%s connected line has changed. Saving it until we have a winner.\n",
+								winner->name);
+							ast_party_connected_line_set_init(&connected, &tpargs->connected_in);
+							if (!ast_connected_line_parse_data(f->data.ptr, f->datalen, &connected)) {
+								ast_party_connected_line_set(&tpargs->connected_in,
+									&connected, NULL);
+								tpargs->pending_in_connected_update = 1;
+							}
+							ast_party_connected_line_free(&connected);
+							break;
+						}
+						if (ast_test_flag(&tpargs->followmeflags, FOLLOWMEFLAG_IGNORE_CONNECTEDLINE)) {
+							ast_verb(3, "Connected line update from %s prevented.\n",
+								winner->name);
+						} else {
+							ast_verb(3,
+								"%s connected line has changed. Saving it until answer.\n",
+								winner->name);
+							ast_party_connected_line_set_init(&connected, &tmpuser->connected);
+							if (!ast_connected_line_parse_data(f->data.ptr, f->datalen, &connected)) {
+								ast_party_connected_line_set(&tmpuser->connected,
+									&connected, NULL);
+								tmpuser->pending_connected_update = 1;
+							}
+							ast_party_connected_line_free(&connected);
+						}
+						break;
+					case AST_CONTROL_REDIRECTING:
+						/*
+						 * Ignore because we are masking the FollowMe search progress to
+						 * the caller.
+						 */
+						break;
 					case -1:
 						ast_verb(3, "%s stopped sounds\n", winner->name);
 						break;
 					default:
-						ast_debug(1, "Dunno what to do with control type %d\n", f->subclass.integer);
+						ast_debug(1, "Dunno what to do with control type %d from %s\n",
+							f->subclass.integer, winner->name);
 						break;
 					}
 				} 
@@ -769,36 +854,35 @@
 						}
 						if (!strcmp(tmpuser->yn, tpargs->nextindp)) {
 							ast_debug(1, "Next in dial plan step requested.\n");
-							*status = 1;
 							ast_frfree(f);
-							return NULL;
-						}
-
-					}
-				}
-
-				ast_frfree(f);
-			} else {
-				if (winner) {
-					ast_debug(1, "we didn't get a frame. hanging up. dg is %d\n",dg);					      
-					if (!dg) {
-						clear_calling_tree(findme_user_list);
-						return NULL;
-					} else {
-						tmpuser->state = -1;
-						ast_hangup(winner);  
-						livechannels--;
-						ast_debug(1, "live channels left %d\n", livechannels);
-						if (!livechannels) {
-							ast_verb(3, "no live channels left. exiting.\n");
 							return NULL;
 						}
 					}
 				}
-			}
-
-		} else
+
+				ast_frfree(f);
+			} else {
+				ast_debug(1, "we didn't get a frame. hanging up. dg is %d\n", dg);
+				if (!dg) {
+					/* Caller hung up. */
+					clear_calling_tree(findme_user_list);
+					return NULL;
+				} else {
+					/* Outgoing channel hung up. */
+					tmpuser->state = -1;
+					tmpuser->ochan = NULL;
+					ast_hangup(winner);
+					--livechannels;
+					ast_debug(1, "live channels left %d\n", livechannels);
+					if (!livechannels) {
+						ast_verb(3, "no live channels left. exiting.\n");
+						return NULL;
+					}
+				}
+			}
+		} else {
 			ast_debug(1, "timed out waiting for action\n");
+		}
 	}
 
 	/* --- WAIT FOR WINNER NUMBER END! -----------*/
@@ -818,7 +902,6 @@
 	struct findme_user *tmpuser;
 	struct findme_user *fmuser;
 	struct findme_user_listptr *findme_user_list;
-	int status;
 
 	findme_user_list = ast_calloc(1, sizeof(*findme_user_list));
 	AST_LIST_HEAD_INIT_NOLOCK(findme_user_list);
@@ -833,7 +916,7 @@
 	}
 
 	caller = tpargs->chan;
-	for (idx = 1; !winner && !ast_check_hangup(caller); ++idx) {
+	for (idx = 1; !ast_check_hangup(caller); ++idx) {
 		/* Find next followme numbers to dial. */
 		AST_LIST_TRAVERSE(&tpargs->cnumbers, nm, entry) {
 			if (nm->order == idx) {
@@ -890,6 +973,7 @@
 					AST_LIST_INSERT_TAIL(findme_user_list, tmpuser, entry);
 				} else {
 					ast_verb(3, "couldn't reach at this number.\n");
+					ast_channel_lock(outbound);
 					if (!outbound->cdr) {
 						outbound->cdr = ast_cdr_alloc();
 					}
@@ -909,6 +993,7 @@
 					} else {
 						ast_log(LOG_ERROR, "Unable to create Call Detail Record\n");
 					}
+					ast_channel_unlock(outbound);
 					ast_hangup(outbound);
 					ast_free(tmpuser);
 				}
@@ -922,16 +1007,29 @@
 			continue;
 		}
 
-		status = 0;
-		winner = wait_for_winner(findme_user_list, nm, caller, tpargs->namerecloc, &status, tpargs);
-
-		/* Clean up all calls but winner. */
+		winner = wait_for_winner(findme_user_list, nm, caller, tpargs->namerecloc, tpargs);
+		if (!winner) {
+			continue;
+		}
+
+		/* Destroy losing calls up to the winner.  The rest will be destroyed later. */
 		while ((fmuser = AST_LIST_REMOVE_HEAD(findme_user_list, entry))) {
-			if (!fmuser->cleared && fmuser->ochan != winner) {
-				clear_caller(fmuser);
-			}
-			ast_free(fmuser);
-		}
+			if (fmuser->ochan == winner) {
+				/* Pass any connected line info up. */
+				tpargs->connected_out = fmuser->connected;
+				tpargs->pending_out_connected_update = fmuser->pending_connected_update;
+				ast_free(fmuser);
+				break;
+			} else {
+				/* Destroy losing call. */
+				if (!fmuser->cleared) {
+					clear_caller(fmuser);
+				}
+				ast_party_connected_line_free(&fmuser->connected);
+				ast_free(fmuser);
+			}
+		}
+		break;
 	}
 	destroy_calling_tree(findme_user_list);
 	if (!winner) {
@@ -944,62 +1042,83 @@
 
 static struct call_followme *find_realtime(const char *name)
 {
-	struct ast_variable *var = ast_load_realtime("followme", "name", name, SENTINEL), *v;
+	struct ast_variable *var;
+	struct ast_variable *v;
 	struct ast_config *cfg;
 	const char *catg;
-	struct call_followme *new;
-	struct ast_str *str = ast_str_create(16);
-
+	struct call_followme *new_follower;
+	struct ast_str *str;
+
+	str = ast_str_create(16);
+	if (!str) {
+		return NULL;
+	}
+
+	var = ast_load_realtime("followme", "name", name, SENTINEL);
 	if (!var) {
+		ast_free(str);
 		return NULL;
 	}
 
-	if (!(new = alloc_profile(name))) {
+	if (!(new_follower = alloc_profile(name))) {
+		ast_variables_destroy(var);
+		ast_free(str);
 		return NULL;
 	}
 
 	for (v = var; v; v = v->next) {
 		if (!strcasecmp(v->name, "active")) {
 			if (ast_false(v->value)) {
-				ast_mutex_destroy(&new->lock);
-				ast_free(new);
+				ast_mutex_destroy(&new_follower->lock);
+				ast_free(new_follower);
+				ast_variables_destroy(var);
+				ast_free(str);
 				return NULL;
 			}
 		} else {
-			profile_set_param(new, v->name, v->value, 0, 0);
+			profile_set_param(new_follower, v->name, v->value, 0, 0);
 		}
 	}
 
 	ast_variables_destroy(var);
-	new->realtime = 1;
+	new_follower->realtime = 1;
 
 	/* Load numbers */
-	if (!(cfg = ast_load_realtime_multientry("followme_numbers", "ordinal LIKE", "%", "name", name, SENTINEL))) {
-		ast_mutex_destroy(&new->lock);
-		ast_free(new);
+	cfg = ast_load_realtime_multientry("followme_numbers", "ordinal LIKE", "%", "name",
+		name, SENTINEL);
+	if (!cfg) {
+		ast_mutex_destroy(&new_follower->lock);
+		ast_free(new_follower);
+		ast_free(str);
 		return NULL;
 	}
 
 	for (catg = ast_category_browse(cfg, NULL); catg; catg = ast_category_browse(cfg, catg)) {
-		const char *numstr, *timeoutstr, *ordstr;
+		const char *numstr;
+		const char *timeoutstr;
+		const char *ordstr;
 		int timeout;
 		struct number *cur;
+
 		if (!(numstr = ast_variable_retrieve(cfg, catg, "phonenumber"))) {
 			continue;
 		}
-		if (!(timeoutstr = ast_variable_retrieve(cfg, catg, "timeout")) || sscanf(timeoutstr, "%30d", &timeout) != 1 || timeout < 1) {
+		if (!(timeoutstr = ast_variable_retrieve(cfg, catg, "timeout"))
+			|| sscanf(timeoutstr, "%30d", &timeout) != 1
+			|| timeout < 1) {
 			timeout = 25;
 		}
 		/* This one has to exist; it was part of the query */
 		ordstr = ast_variable_retrieve(cfg, catg, "ordinal");
 		ast_str_set(&str, 0, "%s", numstr);
 		if ((cur = create_followme_number(ast_str_buffer(str), timeout, atoi(ordstr)))) {
-			AST_LIST_INSERT_TAIL(&new->numbers, cur, entry);
+			AST_LIST_INSERT_TAIL(&new_follower->numbers, cur, entry);
 		}
 	}
 	ast_config_destroy(cfg);
 
-	return new;
+	ast_free(str);
+	return new_follower;
 }
 
 static void end_bridge_callback(void *data)
@@ -1037,7 +1156,6 @@
 	int res = 0;
 	char *argstr;
 	char namerecloc[255];
-	int duration = 0;
 	struct ast_channel *caller;
 	struct ast_channel *outbound;
 	AST_DECLARE_APP_ARGS(args,
@@ -1104,27 +1222,36 @@
 	}
 	ast_mutex_unlock(&f->lock);
 
-	snprintf(namerecloc,sizeof(namerecloc),"%s/followme.%s",ast_config_AST_SPOOL_DIR,chan->uniqueid);
-	duration = 5;
-
-	if (!ast_fileexists(namerecloc, NULL, chan->language))
-		ast_copy_string(namerecloc, "", sizeof(namerecloc));
-
+	/* Forget the 'N' option if the call is already up. */
+	if (chan->_state == AST_STATE_UP) {
+		ast_clear_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER);
+	}
+
+	namerecloc[0] = '\0';
 	if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER)) {
-		if (chan->_state != AST_STATE_UP) {
-			ast_indicate(chan, AST_CONTROL_RINGING);
-		}
+		ast_indicate(chan, AST_CONTROL_RINGING);
 	} else {
 		/* Answer the call */
-		if (chan->_state != AST_STATE_UP)
+		if (chan->_state != AST_STATE_UP) {
 			ast_answer(chan);
+		}
 
 		if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_STATUSMSG)) 
 			ast_stream_and_wait(chan, targs.statusprompt, "");
 
-		if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_RECORDNAME)) 
-			if (ast_play_and_record(chan, "vm-rec-name", namerecloc, 5, "sln", &duration, NULL, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE), 0, NULL) < 0)
+		if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_RECORDNAME)) {
+			int duration = 5;
+
+			snprintf(namerecloc, sizeof(namerecloc), "%s/followme.%s",
+				ast_config_AST_SPOOL_DIR, chan->uniqueid);
+			if (ast_play_and_record(chan, "vm-rec-name", namerecloc, 5, "sln", &duration,
+				NULL, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE), 0, NULL) < 0) {
 				goto outrun;
+			}
+			if (!ast_fileexists(namerecloc, NULL, chan->language)) {
+				namerecloc[0] = '\0';
+			}
+		}
 
 		if (!ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_DISABLEHOLDPROMPT)) {
 			if (ast_streamfile(chan, targs.plsholdprompt, chan->language))
@@ -1138,6 +1265,9 @@
 	targs.status = 0;
 	targs.chan = chan;
 	ast_copy_string(targs.namerecloc, namerecloc, sizeof(targs.namerecloc));
+	ast_channel_lock(chan);
+	ast_connected_line_copy_from_caller(&targs.connected_in, &chan->caller);
+	ast_channel_unlock(chan);
 
 	findmeexec(&targs);
 
@@ -1147,15 +1277,15 @@
 	if (!ast_strlen_zero(namerecloc))
 		unlink(namerecloc);
 
-	if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER)) {
-		if (chan->_state != AST_STATE_UP) {
-			ast_answer(chan);
-		}
-	} else {
-		ast_moh_stop(chan);
-	}
-
 	if (targs.status != 100) {
+		if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER)) {
+			if (chan->_state != AST_STATE_UP) {
+				ast_answer(chan);
+			}
+		} else {
+			ast_moh_stop(chan);
+		}
+
 		if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_UNREACHABLEMSG)) 
 			ast_stream_and_wait(chan, targs.sorryprompt, "");
 		res = 0;
@@ -1171,6 +1301,21 @@
 		config.end_bridge_callback = end_bridge_callback;
 		config.end_bridge_callback_data = chan;
 		config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup;
+
+		/* Update connected line to caller if available. */
+		if (targs.pending_out_connected_update) {
+			if (ast_channel_connected_line_macro(outbound, caller, &targs.connected_out, 1, 0)) {
+				ast_channel_update_connected_line(caller, &targs.connected_out, NULL);
+			}
+		}
+
+		if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER)) {
+			if (caller->_state != AST_STATE_UP) {
+				ast_answer(caller);
+			}
+		} else {
+			ast_moh_stop(caller);
+		}
 
 		/* Be sure no generators are left on it */
 		ast_deactivate_generator(caller);
@@ -1181,12 +1326,21 @@
 			ast_hangup(outbound);
 			goto outrun;
 		}
+

[... 5216 lines stripped ...]



More information about the asterisk-commits mailing list