--- ../tmp/asterisk-1.2.11/pbx.c 2006-06-18 22:03:58.000000000 +0100 +++ pbx.c 2006-08-29 16:41:18.000000000 +0100 @@ -281,6 +281,9 @@ " n - don't answer the channel before playing the files\n" " m - only break if a digit hit matches a one digit\n" " extension in the destination context\n" + "This application sets the following channel variable upon completion:\n" + " BACKGROUNDSTATUS The status of the playback attempt as a text string, one of\n" + " SUCCESS | FAILED\n" }, { "Busy", pbx_builtin_busy, @@ -5766,6 +5769,7 @@ /* Answer if need be */ if (chan->_state != AST_STATE_UP) { if (ast_test_flag(&flags, BACKGROUND_SKIP)) { + pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", "SUCCESS"); return 0; } else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) { res = ast_answer(chan); @@ -5794,9 +5798,11 @@ } } ast_stopstream(chan); + pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", "SUCCESS"); } else { ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data); res = 0; + pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", "FAILED"); break; } front = back; @@ -5806,6 +5812,7 @@ snprintf(chan->exten, sizeof(chan->exten), "%c", res); ast_copy_string(chan->context, context, sizeof(chan->context)); chan->priority = 0; + pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", "SUCCESS"); return 0; } else { return res;