[svn-commits] eliel: branch group/appdocsxml r153264 - in /team/group/appdocsxml: ./ apps/ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Oct 31 16:08:36 CDT 2008


Author: eliel
Date: Fri Oct 31 16:08:35 2008
New Revision: 153264

URL: http://svn.digium.com/view/asterisk?view=rev&rev=153264
Log:
Fix conflicts and continue.

Modified:
    team/group/appdocsxml/   (props changed)
    team/group/appdocsxml/CHANGES
    team/group/appdocsxml/apps/app_dial.c
    team/group/appdocsxml/apps/app_followme.c
    team/group/appdocsxml/apps/app_page.c
    team/group/appdocsxml/apps/app_queue.c
    team/group/appdocsxml/include/asterisk/channel.h
    team/group/appdocsxml/include/asterisk/dial.h
    team/group/appdocsxml/main/dial.c
    team/group/appdocsxml/main/features.c

Propchange: team/group/appdocsxml/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/appdocsxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Oct 31 16:08:35 2008
@@ -1,1 +1,1 @@
-/trunk:1-153179
+/trunk:1-153260

Modified: team/group/appdocsxml/CHANGES
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/CHANGES?view=diff&rev=153264&r1=153263&r2=153264
==============================================================================
--- team/group/appdocsxml/CHANGES (original)
+++ team/group/appdocsxml/CHANGES Fri Oct 31 16:08:35 2008
@@ -685,6 +685,7 @@
      WaitForRing() now takes floating pt timeout arg.
      SpeechBackground() -- clarified in the docstrings that the timeout is an integer seconds.
   * Added 's' option to Page application.
+  * Added an optional timeout argument to the Page application.
   * Added 'E', 'V', and 'P' commands to ExternalIVR.
   * Added 'o' and 'X' options to Chanspy.
   * Added a new dialplan application, Bridge, which allows you to bridge the

Modified: team/group/appdocsxml/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/apps/app_dial.c?view=diff&rev=153264&r1=153263&r2=153264
==============================================================================
--- team/group/appdocsxml/apps/app_dial.c (original)
+++ team/group/appdocsxml/apps/app_dial.c Fri Oct 31 16:08:35 2008
@@ -1485,7 +1485,6 @@
 	int sentringing = 0, moh = 0;
 	const char *outbound_group = NULL;
 	int result = 0;
-	time_t start_time;
 	char *parse;
 	int opermode = 0;
 	AST_DECLARE_APP_ARGS(args,
@@ -1847,7 +1846,6 @@
 		}
 	}
 
-	time(&start_time);
 	peer = wait_for_answer(chan, outgoing, &to, peerflags, &pa, &num, &result);
 
 	/* The ast_channel_datastore_remove() function could fail here if the
@@ -1876,10 +1874,9 @@
 		/* almost done, although the 'else' block is 400 lines */
 	} else {
 		const char *number;
-		time_t end_time, answer_time = time(NULL);
-		char toast[80]; /* buffer to set variables */
 
 		strcpy(pa.status, "ANSWER");
+		pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
 		/* Ah ha!  Someone answered within the desired timeframe.  Of course after this
 		   we will always return with -1 so that it is hung up properly after the
 		   conversation.  */
@@ -2110,11 +2107,31 @@
 				res = ast_dtmf_stream(chan, peer, dtmfcalling, 250, 0);
 			}
 		}
-		
+
 		if (res) { /* some error */
 			res = -1;
-			end_time = time(NULL);
 		} else {
+			auto void end_bridge_callback(void);
+			void end_bridge_callback (void)
+			{
+				char buf[80];
+				time_t end;
+
+				time(&end);
+
+				ast_channel_lock(chan);
+				if (chan->cdr->answer.tv_sec) {
+					snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
+					pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+				}
+
+				if (chan->cdr->start.tv_sec) {
+					snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
+					pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
+				}
+				ast_channel_unlock(chan);
+			}
+
 			if (ast_test_flag64(peerflags, OPT_CALLEE_TRANSFER))
 				ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
 			if (ast_test_flag64(peerflags, OPT_CALLER_TRANSFER))
@@ -2138,6 +2155,8 @@
 			if (ast_test_flag64(peerflags, OPT_GO_ON))
 				ast_set_flag(&(config.features_caller), AST_FEATURE_NO_H_EXTEN);
 
+			config.end_bridge_callback = end_bridge_callback;
+
 			if (moh) {
 				moh = 0;
 				ast_moh_stop(chan);
@@ -2164,13 +2183,7 @@
 				ast_channel_setoption(chan, AST_OPTION_OPRMODE, &oprmode, sizeof(oprmode), 0);
 			}
 			res = ast_bridge_call(chan, peer, &config);
-			end_time = time(NULL);
-			snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
-			pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", toast);
-		}
-
-		snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
-		pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
+		}
 
 		if (res != AST_PBX_NO_HANGUP_PEER_PARKED && ast_test_flag64(&opts, OPT_PEER_H)) {
 			ast_log(LOG_NOTICE, "PEER context: %s; PEER exten: %s;  PEER priority: %d\n",

Modified: team/group/appdocsxml/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/apps/app_followme.c?view=diff&rev=153264&r1=153263&r2=153264
==============================================================================
--- team/group/appdocsxml/apps/app_followme.c (original)
+++ team/group/appdocsxml/apps/app_followme.c Fri Oct 31 16:08:35 2008
@@ -148,7 +148,6 @@
 });
 
 static int ynlongest = 0;
-static time_t start_time, answer_time, end_time;
 
 static const char *featuredigittostr;
 static int featuredigittimeout = 5000;		/*!< Feature Digit Timeout */
@@ -788,7 +787,6 @@
 	while (nm) {
 
 		ast_debug(2, "Number %s timeout %ld\n", nm->number,nm->timeout);
-		time(&start_time);
 
 		number = ast_strdupa(nm->number);
 		ast_debug(3, "examining %s\n", number);
@@ -964,7 +962,6 @@
 	int duration = 0;
 	struct ast_channel *caller;
 	struct ast_channel *outbound;
-	static char toast[80];
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(followmeid);
 		AST_APP_ARG(options);
@@ -1067,6 +1064,27 @@
 			ast_stream_and_wait(chan, targs.sorryprompt, "");
 		res = 0;
 	} else {
+		auto void end_bridge_callback(void);
+		void end_bridge_callback (void)
+		{
+			char buf[80];
+			time_t end;
+
+			time(&end);
+
+			ast_channel_lock(chan);
+			if (chan->cdr->answer.tv_sec) {
+				snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
+				pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+			}
+
+			if (chan->cdr->start.tv_sec) {
+				snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
+				pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
+			}
+			ast_channel_unlock(chan);
+		}
+
 		caller = chan;
 		outbound = targs.outbound;
 		/* Bridge the two channels. */
@@ -1075,6 +1093,7 @@
 		ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
 		ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
 		ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
+		config.end_bridge_callback = end_bridge_callback;
 
 		ast_moh_stop(caller);
 		/* Be sure no generators are left on it */
@@ -1086,13 +1105,7 @@
 			ast_hangup(outbound);
 			goto outrun;
 		}
-		time(&answer_time);
 		res = ast_bridge_call(caller, outbound, &config);
-		time(&end_time);
-		snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
-		pbx_builtin_setvar_helper(caller, "DIALEDTIME", toast);
-		snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
-		pbx_builtin_setvar_helper(caller, "ANSWEREDTIME", toast);
 		if (outbound)
 			ast_hangup(outbound);
 	}

Modified: team/group/appdocsxml/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/apps/app_page.c?view=diff&rev=153264&r1=153263&r2=153264
==============================================================================
--- team/group/appdocsxml/apps/app_page.c (original)
+++ team/group/appdocsxml/apps/app_page.c Fri Oct 31 16:08:35 2008
@@ -51,32 +51,44 @@
 		</synopsis>
 		<syntax>
 			<parameter name="Technology/Resource" required="true" argsep="&amp;">
+				<argument name="Technology/Resource" required="true">
+					<para>Specification of the device(s) to dial. These must be in the format of
+					<literal>Technology/Resource</literal>, where <replaceable>Technology</replaceable>
+					represents a particular channel driver, and <replaceable>Resource</replaceable> represents a resource
+					available to that particular channel driver.</para>
+				</argument>
 				<argument name="Technology2/Resource2" multiple="true">
 					<para>Optional extra devices to dial inparallel</para>
-					<para>If you need more then one enter them asTechnology2/Resource2&amp;Technology3/Resourse3&amp;.....</para>
+					<para>If you need more then one enter them as Technology2/Resource2&amp;
+					Technology3/Resourse3&amp;.....</para>
 				</argument>
-				<para>Specification of the device(s) to dial. 
-				These must be in the format of <literal>Technology/Resource</literal>, where <replaceable>Technology</replaceable>
-				represents a particular channel driver, and <replaceable>Resource</replaceable> represents a resource
-				available to that particular channel driver.</para>
 			</parameter>
-			<parameter name="d" required="false">
-				<para>Full duplex audio</para>
+			<parameter name="options">
+				<optionlist>
+					<option name="d">
+						<para>Full duplex audio</para>
+					</option>
+					<option name="q">
+						<para>Quiet, do not play beep to caller</para>
+					</option>
+					<option name="r">
+						<para>Record the page into a file (meetme option <literal>r</literal>)</para>
+					</option>
+					<option name="s">
+						<para>Only dial channel if devicestate says its <literal>notinuse</literal></para>
+					</option>
+				</optionlist>
 			</parameter>
-			<parameter name="q" required="false">
-				<para>Quiet, do not play beep to caller</para>
-			</parameter>
-			<parameter name="r" required="false">
-				<para>record the page into file (meetme option <literal>r</literal>)</para>
-			</parameter>
-			<parameter name="s" required="false">
-				<para>Only dial channel if devicestate says its <literal>notinuse</literal></para>
+			<parameter name="timeout">
+				<para>Specify the length of time that the system will attempt to connect a call.
+				After this duration, any intercom calls that have not been answered will be hung up by the
+				system.</para>
 			</parameter>
 		</syntax>
 		<description>
 			<para>Places outbound calls to the given <replaceable>technology</replaceable>/<replaceable>resource</replaceable>
 			and dumps them into a conference bridge as muted participants. The original
-			caller is dumped into conference as a speaker and the room is
+			caller is dumped into the conference as a speaker and the room is
 			destroyed when the original callers leaves.</para>
 		</description>
 	</application>
@@ -101,13 +113,21 @@
 
 static int page_exec(struct ast_channel *chan, void *data)
 {
-	char *options, *tech, *resource, *tmp;
+	char *tech, *resource, *tmp;
 	char meetmeopts[88], originator[AST_CHANNEL_NAME], *opts[0];
 	struct ast_flags flags = { 0 };
 	unsigned int confid = ast_random();
 	struct ast_app *app;
 	int res = 0, pos = 0, i = 0;
 	struct ast_dial *dials[MAX_DIALS];
+	int timeout = 0;
+	char *parse;
+
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(devices);
+		AST_APP_ARG(options);
+		AST_APP_ARG(timeout);
+	);
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n");
@@ -119,21 +139,28 @@
 		return -1;
 	};
 
-	options = ast_strdupa(data);
+	parse = ast_strdupa(data);
+
+	AST_STANDARD_APP_ARGS(args, parse);
 
 	ast_copy_string(originator, chan->name, sizeof(originator));
-	if ((tmp = strchr(originator, '-')))
+	if ((tmp = strchr(originator, '-'))) {
 		*tmp = '\0';
-
-	tmp = strsep(&options, ",");
-	if (options)
-		ast_app_parse_options(page_opts, &flags, opts, options);
+	}
+
+	if (!ast_strlen_zero(args.options)) {
+		ast_app_parse_options(page_opts, &flags, opts, args.options);
+	}
+
+	if (!ast_strlen_zero(args.timeout)) {
+		timeout = atoi(args.timeout);
+	}
 
 	snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe,%ud,%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
 		(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
 
 	/* Go through parsing/calling each device */
-	while ((tech = strsep(&tmp, "&"))) {
+	while ((tech = strsep(&args.devices, "&"))) {
 		int state = 0;
 		struct ast_dial *dial = NULL;
 
@@ -167,10 +194,17 @@
 		}
 
 		/* Append technology and resource */
-		ast_dial_append(dial, tech, resource);
+		if (ast_dial_append(dial, tech, resource) == -1) {
+			ast_log(LOG_ERROR, "Failed to add %s to outbound dial\n", tech);
+			continue;
+		}
 
 		/* Set ANSWER_EXEC as global option */
 		ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, meetmeopts);
+
+		if (timeout) {
+			ast_dial_set_global_timeout(dial, timeout * 1000);
+		}
 
 		/* Run this dial in async mode */
 		ast_dial_run(dial, chan, 1);

Modified: team/group/appdocsxml/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/apps/app_queue.c?view=diff&rev=153264&r1=153263&r2=153264
==============================================================================
--- team/group/appdocsxml/apps/app_queue.c (original)
+++ team/group/appdocsxml/apps/app_queue.c Fri Oct 31 16:08:35 2008
@@ -3384,6 +3384,13 @@
 	int callcompletedinsl;
 	struct ao2_iterator memi;
 	struct ast_datastore *datastore;
+	auto void end_bridge_callback(void);
+	void end_bridge_callback(void)
+	{
+		ao2_lock(qe->parent);
+		set_queue_variables(qe);
+		ao2_unlock(qe->parent);
+	}
 
 	ast_channel_lock(qe->chan);
 	datastore = ast_channel_datastore_find(qe->chan, &dialed_interface_info, NULL);
@@ -3453,6 +3460,8 @@
 			break;
 
 		}
+
+	bridge_config.end_bridge_callback = end_bridge_callback;
 
 	/* Hold the lock while we setup the outgoing calls */
 	if (use_weight)

Modified: team/group/appdocsxml/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/include/asterisk/channel.h?view=diff&rev=153264&r1=153263&r2=153264
==============================================================================
--- team/group/appdocsxml/include/asterisk/channel.h (original)
+++ team/group/appdocsxml/include/asterisk/channel.h Fri Oct 31 16:08:35 2008
@@ -584,6 +584,7 @@
 	const char *start_sound;
 	int firstpass;
 	unsigned int flags;
+	void (* end_bridge_callback)(void);   /*!< A callback that is called after a bridge attempt */
 };
 
 struct chanmon;

Modified: team/group/appdocsxml/include/asterisk/dial.h
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/include/asterisk/dial.h?view=diff&rev=153264&r1=153263&r2=153264
==============================================================================
--- team/group/appdocsxml/include/asterisk/dial.h (original)
+++ team/group/appdocsxml/include/asterisk/dial.h Fri Oct 31 16:08:35 2008
@@ -154,7 +154,7 @@
 
 /*! \brief Set the maximum time (globally) allowed for trying to ring phones
  * \param dial The dial structure to apply the time limit to
- * \param timeout Maximum time allowed
+ * \param timeout Maximum time allowed in milliseconds
  * \return nothing
  */
 void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout);
@@ -162,7 +162,7 @@
 /*! \brief Set the maximum time (per channel) allowed for trying to ring the phone
  * \param dial The dial structure the channel belongs to
  * \param num Channel number to set timeout on
- * \param timeout Maximum time allowed
+ * \param timeout Maximum time allowed in milliseconds
  * \return nothing
  */
 void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout);

Modified: team/group/appdocsxml/main/dial.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/dial.c?view=diff&rev=153264&r1=153263&r2=153264
==============================================================================
--- team/group/appdocsxml/main/dial.c (original)
+++ team/group/appdocsxml/main/dial.c Fri Oct 31 16:08:35 2008
@@ -1038,7 +1038,7 @@
 {
 	dial->timeout = timeout;
 
-	if (dial->timeout > 0 && dial->actual_timeout > dial->timeout)
+	if (dial->timeout > 0 && (dial->actual_timeout > dial->timeout || dial->actual_timeout == -1))
 		dial->actual_timeout = dial->timeout;
 
 	return;
@@ -1059,7 +1059,7 @@
 
 	channel->timeout = timeout;
 
-	if (channel->timeout > 0 && dial->actual_timeout > channel->timeout)
+	if (channel->timeout > 0 && (dial->actual_timeout > channel->timeout || dial->actual_timeout == -1))
 		dial->actual_timeout = channel->timeout;
 
 	return;

Modified: team/group/appdocsxml/main/features.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/features.c?view=diff&rev=153264&r1=153263&r2=153264
==============================================================================
--- team/group/appdocsxml/main/features.c (original)
+++ team/group/appdocsxml/main/features.c Fri Oct 31 16:08:35 2008
@@ -2178,6 +2178,7 @@
 	int diff;
 	int hasfeatures=0;
 	int hadfeatures=0;
+	int autoloopflag;
 	struct ast_option_header *aoh;
 	struct ast_bridge_config backup_config;
 	struct ast_cdr *bridge_cdr = NULL;
@@ -2438,11 +2439,16 @@
 
 	}
    before_you_go:
+	if (res != AST_PBX_KEEPALIVE && config->end_bridge_callback) {
+		config->end_bridge_callback();
+	}
 
 	/* run the hangup exten on the chan object IFF it was NOT involved in a parking situation 
 	 * if it were, then chan belongs to a different thread now, and might have been hung up long
      * ago.
 	 */
+	autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
+	ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
 	if (res != AST_PBX_KEEPALIVE && !ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) && ast_exists_extension(chan, chan->context, "h", 1, chan->cid.cid_num)) {
 		struct ast_cdr *swapper;
 		char savelastapp[AST_MAX_EXTENSION];
@@ -2486,6 +2492,7 @@
 		ast_copy_string(bridge_cdr->lastapp, savelastapp, sizeof(bridge_cdr->lastapp));
 		ast_copy_string(bridge_cdr->lastdata, savelastdata, sizeof(bridge_cdr->lastdata));
 	}
+	ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP);
 
 	/* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */
 	if (res != AST_PBX_KEEPALIVE) {




More information about the svn-commits mailing list