Index: apps/app_dial.c
===================================================================
--- apps/app_dial.c	(revision 32039)
+++ apps/app_dial.c	(working copy)
@@ -189,7 +189,8 @@
 "    k    - Allow the called party to enable parking of the call by sending\n"
 "           the DTMF sequence defined for call parking in features.conf.\n"
 "    K    - Allow the calling party to enable parking of the call by sending\n"
-"           the DTMF sequence defined for call parking in features.conf.\n";
+"           the DTMF sequence defined for call parking in features.conf.\n"
+"    I(x) - Wait x seconds before adding the next channel.\n";
 
 /* RetryDial App by Anthony Minessale II <anthmct@yahoo.com> Jan/2005 */
 static char *rapp = "RetryDial";
@@ -236,6 +237,7 @@
 	OPT_CALLEE_PARK =	(1 << 25),
 	OPT_CALLER_PARK =	(1 << 26),
 	OPT_IGNORE_FORWARDING = (1 << 27),
+	OPT_INCREMENT = (1 << 28),
 } dial_exec_option_flags;
 
 #define DIAL_STILLGOING			(1 << 30)
@@ -251,6 +253,7 @@
 	OPT_ARG_PRIVACY,
 	OPT_ARG_DURATION_STOP,
 	OPT_ARG_OPERMODE,
+	OPT_ARG_INCREMENT,
 	/* note: this entry _MUST_ be the last one in the enum */
 	OPT_ARG_ARRAY_SIZE,
 } dial_exec_option_args;
@@ -284,6 +287,7 @@
 	AST_APP_OPTION('W', OPT_CALLER_MONITOR),
 	AST_APP_OPTION('k', OPT_CALLEE_PARK),
 	AST_APP_OPTION('K', OPT_CALLER_PARK),
+	AST_APP_OPTION_ARG('I', OPT_INCREMENT, OPT_ARG_INCREMENT),
 });
 
 /* We define a custom "local user" structure because we
@@ -772,6 +776,7 @@
 	struct dial_localuser *outgoing = NULL;
 	struct ast_channel *peer;
 	int to;
+	int incto;
 	int numbusy = 0;
 	int numcongestion = 0;
 	int numnochan = 0;
@@ -834,6 +839,20 @@
 			ast_verbose(VERBOSE_PREFIX_3 "Setting operator services mode to %d.\n", opermode);
 	}
 	
+	if (ast_test_flag(&opts, OPT_INCREMENT)) {
+		if (ast_strlen_zero(opt_args[OPT_ARG_INCREMENT]))
+			incto = 0;
+		else incto = atoi(opt_args[OPT_ARG_INCREMENT]);
+		if (incto < 1) {
+			incto = 0;
+			if (option_verbose > 2)
+				ast_verbose(VERBOSE_PREFIX_3 "Disabling Incremental Dialing");
+		}
+	} else {
+		incto=0;
+	}
+	incto *= 1000;
+	
 	if (ast_test_flag(&opts, OPT_DURATION_STOP) && !ast_strlen_zero(opt_args[OPT_ARG_DURATION_STOP])) {
 		calldurationlimit = atoi(opt_args[OPT_ARG_DURATION_STOP]);
 		if (!calldurationlimit) {
@@ -1186,34 +1205,54 @@
 		/* If this line is up, don't try anybody else */
 		if (outgoing->chan->_state == AST_STATE_UP)
 			break;
+		if (incto && outgoing) {
+			strcpy(status, "NOANSWER");
+			if (ast_test_flag(outgoing, OPT_MUSICBACK)) {
+				moh=1;
+				ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK]);
+			} else if (ast_test_flag(outgoing, OPT_RINGBACK)) {
+				ast_indicate(chan, AST_CONTROL_RINGING);
+				sentringing++;
+			}
+			time(&start_time);
+			peer = wait_for_answer(chan, outgoing, &incto, peerflage, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, ast_test_flag(&opts, OPT_PRIORITY_JUMP), &result);
+			if (!peer) {
+				if (!result) 
+					break;
+			} else {
+				break;
+			}
+		}
 	}
 	
-	if (ast_strlen_zero(args.timeout)) {
-		to = -1;
-	} else {
-		to = atoi(args.timeout);
-		if (to > 0)
-			to *= 1000;
-		else
-			ast_log(LOG_WARNING, "Invalid timeout specified: '%s'\n", args.timeout);
-	}
+	if (!peer) {
+		if (ast_strlen_zero(args.timeout)) {
+			to = -1;
+		} else {
+			to = atoi(args.timeout);
+			if (to > 0)
+				to *= 1000;
+			else
+				ast_log(LOG_WARNING, "Invalid timeout specified: '%s'\n", args.timeout);
+		}
 
-	if (!outgoing) {
-		strcpy(status, "CHANUNAVAIL");
-	} else {
-		/* Our status will at least be NOANSWER */
-		strcpy(status, "NOANSWER");
-		if (ast_test_flag(outgoing, OPT_MUSICBACK)) {
-			moh=1;
-			ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK]);
-		} else if (ast_test_flag(outgoing, OPT_RINGBACK)) {
-			ast_indicate(chan, AST_CONTROL_RINGING);
-			sentringing++;
+		if (!outgoing) {
+			strcpy(status, "CHANUNAVAIL");
+		} else {
+			/* Our status will at least be NOANSWER */
+			strcpy(status, "NOANSWER");
+			if (ast_test_flag(outgoing, OPT_MUSICBACK)) {
+				moh=1;
+				ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK]);
+			} else if (ast_test_flag(outgoing, OPT_RINGBACK)) {
+				ast_indicate(chan, AST_CONTROL_RINGING);
+				sentringing++;
+			}
 		}
+
+		time(&start_time);
+		peer = wait_for_answer(chan, outgoing, &to, peerflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, ast_test_flag(&opts, OPT_PRIORITY_JUMP), &result);
 	}
-
-	time(&start_time);
-	peer = wait_for_answer(chan, outgoing, &to, peerflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, ast_test_flag(&opts, OPT_PRIORITY_JUMP), &result);
 	
 	if (!peer) {
 		if (result) {
