[svn-commits] mmichelson: trunk r153223 - in /trunk: ./ apps/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Oct 31 15:05:46 CDT 2008


Author: mmichelson
Date: Fri Oct 31 15:05:46 2008
New Revision: 153223

URL: http://svn.digium.com/view/asterisk?view=rev&rev=153223
Log:
* Fixed timeout logic in the dialing API as setting timeouts
  had no effect
* Updated dialing API documentation to indicate that timeouts
  are specified in milliseconds
* Added a new timeout argument to the Page application. If time
  expires, any endpoints which have not answered will be hung up.


Modified:
    trunk/CHANGES
    trunk/apps/app_page.c
    trunk/include/asterisk/dial.h
    trunk/main/dial.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=153223&r1=153222&r2=153223
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Fri Oct 31 15:05:46 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: trunk/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_page.c?view=diff&rev=153223&r1=153222&r2=153223
==============================================================================
--- trunk/apps/app_page.c (original)
+++ trunk/apps/app_page.c Fri Oct 31 15:05:46 2008
@@ -49,7 +49,7 @@
 static const char *page_synopsis = "Pages phones";
 
 static const char *page_descrip =
-"Page(Technology/Resource&Technology2/Resource2[,options])\n"
+"Page(Technology/Resource&Technology2/Resource2[,options][,timeout])\n"
 "  Places outbound calls to the given technology / resource and dumps\n"
 "them into a conference bridge as muted participants.  The original\n"
 "caller is dumped into the conference as a speaker and the room is\n"
@@ -57,7 +57,10 @@
 "        d - full duplex audio\n"
 "        q - quiet, do not play beep to caller\n"
 "        r - record the page into a file (see 'r' for app_meetme)\n"
-"        s - only dial channel if devicestate says it is not in use\n";
+"        s - only dial channel if devicestate says it is not in use\n"
+"The timeout parameter specifies the length of time that the system\n"
+"will attempt to connect a call. After this duration, any intercom\n"
+"calls that have not been answered will be hung up by the system.\n";
 
 enum {
 	PAGE_DUPLEX = (1 << 0),
@@ -77,13 +80,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");
@@ -95,21 +106,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;
 
@@ -143,10 +161,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: trunk/include/asterisk/dial.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/dial.h?view=diff&rev=153223&r1=153222&r2=153223
==============================================================================
--- trunk/include/asterisk/dial.h (original)
+++ trunk/include/asterisk/dial.h Fri Oct 31 15:05:46 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: trunk/main/dial.c
URL: http://svn.digium.com/view/asterisk/trunk/main/dial.c?view=diff&rev=153223&r1=153222&r2=153223
==============================================================================
--- trunk/main/dial.c (original)
+++ trunk/main/dial.c Fri Oct 31 15:05:46 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;




More information about the svn-commits mailing list