--- app_controlplayback.c.orig 2007-11-26 15:38:17.000000000 +0100 +++ app_controlplayback.c 2007-11-26 15:45:41.000000000 +0100 @@ -27,7 +27,7 @@ #include "asterisk.h" -ASTERISK_FILE_VERSION(__FILE__, "$Revision: 89519 $") +ASTERISK_FILE_VERSION(__FILE__, "$Revision: working copy $") #include "asterisk/pbx.h" #include "asterisk/app.h" @@ -55,7 +55,9 @@ " CPLAYBACKSTATUS - This variable contains the status of the attempt as a text\n" " string, one of: SUCCESS | USERSTOPPED | ERROR\n" " CPLAYBACKOFFSET - This contains the offset in ms into the file where\n" -" playback was at when it stopped. -1 is end of file.\n"; +" playback was at when it stopped. -1 is end of file.\n" +" CPLAYBACKSTOPKEY - If the playback is stoped by the user this variable contains\n" +" the key that was pressed.\n"; enum { OPT_OFFSET = (1 << 1), @@ -82,6 +84,7 @@ int skipms = 0; long offsetms = 0; char offsetbuf[20]; + char stopkey[2]; char *tmp; struct ast_flags opts = { 0, }; char *opt_args[OPT_ARG_ARRAY_LEN]; @@ -112,9 +115,9 @@ skipms = args.skip ? (atoi(args.skip) ? atoi(args.skip) : 3000) : 3000; if (!args.fwd || !is_on_phonepad(*args.fwd)) - args.fwd = "#"; + args.fwd = NULL; if (!args.rev || !is_on_phonepad(*args.rev)) - args.rev = "*"; + args.rev = NULL; if (args.stop && !is_on_phonepad(*args.stop)) args.stop = NULL; if (args.pause && !is_on_phonepad(*args.pause)) @@ -132,9 +135,12 @@ /* If we stopped on one of our stop keys, return 0 */ if (res > 0 && args.stop && strchr(args.stop, res)) { + snprintf(stopkey, sizeof(stopkey), "%c", res); + stopkey[sizeof(stopkey)-1] = '\0'; res = 0; pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "USERSTOPPED"); } else { + stopkey[0] = '\0'; if (res < 0) { res = 0; pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "ERROR"); @@ -142,6 +148,7 @@ pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "SUCCESS"); } + pbx_builtin_setvar_helper(chan, "CPLAYBACKSTOPKEY", stopkey); snprintf(offsetbuf, sizeof(offsetbuf), "%ld", offsetms); pbx_builtin_setvar_helper(chan, "CPLAYBACKOFFSET", offsetbuf);