--- apps/app_dial.c.cvs 2005-02-14 00:31:13.316216160 -0500 +++ apps/app_dial.c 2005-02-14 00:34:34.843579344 -0500 @@ -66,6 +66,7 @@ " ${EXITCONTEXT} or the current context.\n" " 't' -- allow the called user to transfer the calling user by hitting #.\n" " 'T' -- allow the calling user to transfer the call by hitting #.\n" +" 'c(x) -- set the context on the outbound channel to 'x'.\n" " 'w' -- allow the called user to write the conversation to disk via app_monitor\n" " 'W' -- allow the calling user to write the conversation to disk via app_monitor\n" " 'f' -- Forces callerid to be set as the extension of the line \n" @@ -630,6 +631,8 @@ int digit = 0, result = 0; time_t start_time, answer_time, end_time; struct ast_app *app = NULL; + int hascontext = 0; + char forcecontext[256] = ""; if (!data) { ast_log(LOG_WARNING, "Dial requires an argument (technology1/number1&technology2/number2...|optional timeout|options)\n"); @@ -833,6 +836,28 @@ mohclass=NULL; } } + + /* Check if we should set a context on the outbound call */ + if ((s = strstr(transfer, "c("))) { + hascontext = 1; + strncpy(forcecontext, s + 2, sizeof(forcecontext) - 1); + while (*s && (*s != ')')) + *(s++) = 'X'; + if (*s) + *s = 'X'; + else { + ast_verbose(VERBOSE_PREFIX_3 "Setting a context\n"); + ast_log(LOG_WARNING, "Could not find context to set on outbound call.\n"); + hascontext = 0; + } + s = strchr(forcecontext, ')'); + if (s) + *s = '\0'; + else { + ast_log(LOG_WARNING, "Macro flag set without trailing ')'\n"); + hascontext = 0; + } + } /* Extract privacy info from transfer */ if ((s = strstr(transfer, "P("))) { privacy = 1; @@ -1013,6 +1038,9 @@ if (outbound_group) ast_app_group_set_channel(tmp->chan, outbound_group); + /* Set the requested context on the new outbound channel */ + if (hascontext) strcpy(tmp->chan->context, forcecontext); + /* Place the call, but don't wait on the answer */ res = ast_call(tmp->chan, numsubst, 0);