--- apps/app_dial.c.orig 2006-03-18 17:10:17.000000000 -0600 +++ apps/app_dial.c 2006-03-18 18:37:08.000000000 -0600 @@ -84,6 +84,9 @@ "DONTCALL if the called party chooses to send the calling party to the 'Go Away'\n" "script. The DIALSTATUS variable will be set to TORTURE if the called party\n" "wants to send the caller to the 'torture' script.\n" +" You can initialize the peer channel with variables by setting the variable\n" +" PEERVARIABLES before calling Dial(). PEERVARIABLES must be set to a list of\n " +" key=value pairs separated by ! like this: Set(PEERVARIABLES=var1=1!var2=other)\n" " This application will report normal termination if the originating channel\n" "hangs up, or if the call is bridged and either of the parties in the bridge\n" "ends the call.\n" @@ -1195,6 +1198,33 @@ if (!number) number = numsubst; pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number); + + /* if the caller set the variable PEERVARIABLES + * then we initialize the requested variables + * */ + char *pvars = pbx_builtin_getvar_helper(chan, "PEERVARIABLES"); + if ( pvars ) { + ast_log(LOG_DEBUG, "PEERVARIABLES is %s\n", pvars); + unsigned int vnum; + char *pv[255]; + char *vname; + char *vvalue; + int y; + vnum = ast_app_separate_args(pvars, '!', pv, sizeof(pv)/sizeof(pv[0])); + for ( y = 0; y < vnum; y++ ) { + if ( !pv[y] ) { + continue; + } + vname = vvalue = ast_strdupa(pv[y]); + strsep(&vvalue, "="); + if ( !vvalue || ast_strlen_zero(vname) ) { + continue; + } + ast_log(LOG_DEBUG, "Setting PEER variable %s=%s\n", vname, vvalue); + pbx_builtin_setvar_helper(peer, vname, vvalue); + } + } + if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) { ast_log(LOG_DEBUG, "app_dial: sendurl=%s.\n", args.url); ast_channel_sendurl( peer, args.url );