[Asterisk-cvs] asterisk/apps app_dial.c,1.53.2.4,1.53.2.5

markster at lists.digium.com markster at lists.digium.com
Thu Apr 15 12:00:45 CDT 2004


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv1236/apps

Modified Files:
      Tag: v1-0_stable
	app_dial.c 
Log Message:
Backport RINGING fixes from head


Index: app_dial.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_dial.c,v
retrieving revision 1.53.2.4
retrieving revision 1.53.2.5
diff -u -d -r1.53.2.4 -r1.53.2.5
--- app_dial.c	19 Mar 2004 00:09:14 -0000	1.53.2.4
+++ app_dial.c	15 Apr 2004 16:03:39 -0000	1.53.2.5
@@ -67,6 +67,7 @@
 "      'P[(x)]' -- privacy mode, using 'x' as database if provided.\n"
 "      'g' -- goes on in context if the destination channel hangs up\n"
 "      'A(x)' -- play an announcement to the called party, using x as file\n"
+"      'S(x)' -- hangup the call after x seconds AFTER called party picked up\n"  	
 "  In addition to transferring the call, a call may be parked and then picked\n"
 "up by another user.\n"
 "  The optional URL will be sent to the called party if the channel supports\n"
@@ -138,8 +139,8 @@
 			ast_moh_start(in, NULL);
 		} else if (outgoing->ringbackonly) {
 			ast_indicate(in, AST_CONTROL_RINGING);
-		}
 			sentringing++;
+		}
 	}
 	
 	while(*to && !peer) {
@@ -222,6 +223,12 @@
 							else
 								ast_log(LOG_WARNING, "Out of memory\n");
 						}
+						if (o->chan->rdnis) 
+							free(o->chan->rdnis);
+						if (strlen(in->macroexten))
+							o->chan->rdnis = strdup(in->macroexten);
+						else
+							o->chan->rdnis = strdup(in->exten);
 						if (ast_call(o->chan, tmpchan, 0)) {
 							ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);
 							o->stillgoing = 0;
@@ -380,9 +387,12 @@
 	struct varshead *headp, *newheadp;
 	struct ast_var_t *newvar;
 	int go_on=0;
+	unsigned int calldurationlimit=0;
+	char *cdl;
+	time_t now;
 	
 	if (!data) {
-		ast_log(LOG_WARNING, "Dial requires an argument (technology1/number1&technology2/number2...|optional timeout)\n");
+		ast_log(LOG_WARNING, "Dial requires an argument (technology1/number1&technology2/number2...|optional timeout|options)\n");
 		return -1;
 	}
 	
@@ -391,6 +401,7 @@
 	strncpy(info, (char *)data, sizeof(info) - 1);
 	peers = info;
 	if (peers) {
+		
 		timeout = strchr(info, '|');
 		if (timeout) {
 			*timeout = '\0';
@@ -419,6 +430,13 @@
 	
 
 	if (transfer) {
+		/* Extract call duration limit */
+		if ((cdl = strstr(transfer, "S("))) {
+			calldurationlimit=atoi(cdl+2);
+			if (option_verbose > 2)
+				ast_verbose(VERBOSE_PREFIX_3 "Setting call duration limit to %i seconds.\n",calldurationlimit);			
+		} 
+		
 		/* XXX ANNOUNCE SUPPORT */
 		if ((ann = strstr(transfer, "A("))) {
 			announce = 1;
@@ -650,9 +668,13 @@
 		cur = rest;
 	} while(cur);
 	
-	if (timeout && strlen(timeout))
-		to = atoi(timeout) * 1000;
-	else
+	if (timeout && strlen(timeout)) {
+		to = atoi(timeout);
+		if (to > 0)
+			to *= 1000;
+		else
+			ast_log(LOG_WARNING, "Invalid timeout specified: '%s'\n", timeout);
+	} else
 		to = -1;
 	peer = wait_for_answer(chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect);
 	if (!peer) {
@@ -702,6 +724,10 @@
 				res2 = ast_waitstream(peer,"");
 			// Ok, done. stop autoservice
 			res2 = ast_autoservice_stop(chan);
+		}
+		if (calldurationlimit > 0) {
+			time(&now);
+			chan->whentohangup = now + calldurationlimit;
 		}
 		res = ast_bridge_call(chan, peer, allowredir_in, allowredir_out, allowdisconnect);
 




More information about the svn-commits mailing list