[Asterisk-cvs] asterisk/apps app_dial.c,1.142,1.143

markster at lists.digium.com markster at lists.digium.com
Thu Mar 17 16:43:45 CST 2005


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

Modified Files:
	app_dial.c 
Log Message:
Add 'G' option to dial (bug #3786)


Index: app_dial.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_dial.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- app_dial.c	28 Feb 2005 06:06:42 -0000	1.142
+++ app_dial.c	17 Mar 2005 22:39:04 -0000	1.143
@@ -89,6 +89,7 @@
 "      'C' -- reset call detail record for this call.\n"
 "      'P[(x)]' -- privacy mode, using 'x' as database if provided.\n"
 "      'g' -- goes on in context if the destination channel hangs up\n"
+"      'G(context^exten^pri)' -- If the call is answered transfer both parties to the specified exten.\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"  	
 "      'D([digits])'  -- Send DTMF digit string *after* called party has answered\n"
@@ -638,7 +639,8 @@
 	int digit = 0, result = 0;
 	time_t start_time, answer_time, end_time;
 	struct ast_app *app = NULL;
-	
+	char *dblgoto = NULL;
+
 	if (!data) {
 		ast_log(LOG_WARNING, "Dial requires an argument (technology1/number1&technology2/number2...|optional timeout|options)\n");
 		return -1;
@@ -800,7 +802,29 @@
 				announce = 0;
 			}
 		}
-		
+
+		/* Get the goto from the dial option string */
+		if ((mac = strstr(transfer, "G("))) {
+
+
+			dblgoto = ast_strdupa(mac + 2);
+			while (*mac && (*mac != ')'))
+				*(mac++) = 'X';
+			if (*mac)
+				*mac = 'X';
+			else {
+				ast_log(LOG_WARNING, "Could not find exten to which we should jump.\n");
+				dblgoto = NULL;
+			}
+			mac = strchr(dblgoto, ')');
+			if (mac)
+				*mac = '\0';
+			else {
+				ast_log(LOG_WARNING, "Goto flag set without trailing ')'\n");
+				dblgoto = NULL;
+			}
+		}
+
 		/* Get the macroname from the dial option string */
 		if ((mac = strstr(transfer, "M("))) {
 			hasmacro = 1;
@@ -1143,6 +1167,21 @@
 		} else
 			res = 0;
 
+		if (chan && peer && dblgoto) {
+			for (mac=dblgoto; *mac; mac++) {
+				if(*mac == '^') {
+					*mac = '|';
+				}
+			}
+			ast_parseable_goto(chan, dblgoto);
+			ast_parseable_goto(peer, dblgoto);
+			peer->priority++;
+			ast_pbx_start(peer);
+			hanguptree(outgoing, NULL);
+			LOCAL_USER_REMOVE(u);
+			return 0;
+		}
+
 		if (hasmacro && macroname) {
 			res = ast_autoservice_start(chan);
 			if (res) {




More information about the svn-commits mailing list