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

Modified Files:
        app_controlplayback.c 
Log Message:
Janitor project, app_controlplayback (bug #5610)


Index: app_controlplayback.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_controlplayback.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- app_controlplayback.c       3 Nov 2005 21:19:10 -0000       1.18
+++ app_controlplayback.c       6 Nov 2005 05:03:14 -0000       1.19
@@ -37,6 +37,7 @@
 #include "asterisk/module.h"
 #include "asterisk/translate.h"
 #include "asterisk/utils.h"
+#include "asterisk/options.h"
 
 static const char *tdesc = "Control Playback Application";
 
@@ -45,13 +46,18 @@
 static const char *synopsis = "Play a file with fast forward and rewind";
 
 static const char *descrip = 
-"ControlPlayback(filename[|skipms[|ffchar[|rewchar[|stopchar[|pausechar[|restartchar]]]]]]):\n"
+"ControlPlayback(filename[|skipms[|ffchar[|rewchar[|stopchar[|pausechar[|restartchar[|option]]]]]]]):\n"
 "  Plays  back  a  given  filename (do not put extension). Options may also\n"
 "  be included following a pipe symbol.  You can use * and # to rewind and\n"
 "  fast forward the playback specified. If 'stopchar' is added the file will\n"
 "  terminate playback when 'stopchar' is pressed. If 'restartchar' is added, 
the file\n"
 "  will restart when 'restartchar' is pressed. Returns -1 if the channel\n"
-"  was hung up. if the file does not exist jumps to n+101 if it present.\n\n"
+"  was hung up. \n\n"
+"  The option string may contain zero or the following character:\n"
+"       'j' -- jump to +101 priority if the file requested isn't found.\n"
+"  This application sets the following channel variable upon completion:\n"
+"     CPLAYBACKSTATUS       The status of the attempt to add a queue member as 
a text string, one of\n"
+"             SUCCESS | USERSTOPPED | ERROR\n"
 "  Example:  exten => 1234,1,ControlPlayback(file|4000|*|#|1|0|5)\n\n";
 
 STANDARD_LOCAL_USER;
@@ -65,12 +71,12 @@
 
 static int controlplayback_exec(struct ast_channel *chan, void *data)
 {
-       int res = 0;
+       int res = 0, priority_jump = 0;
        int skipms = 0;
        struct localuser *u;
        char *tmp;
        int argc;
-       char *argv[7];
+       char *argv[8];
        enum arg_ids {
                arg_file = 0,
                arg_skip = 1,
@@ -79,6 +85,7 @@
                arg_stop = 4,
                arg_pause = 5,
                arg_restart = 6,
+               options = 7,
        };
        
        if (ast_strlen_zero(data)) {
@@ -114,15 +121,28 @@
        if (argv[arg_restart] && !is_on_phonepad(*argv[arg_restart]))
                argv[arg_restart] = NULL;
 
+       if (argv[options]) {
+               if (strchr(argv[options], 'j'))
+                       priority_jump = 1;
+       }
+
        res = ast_control_streamfile(chan, argv[arg_file], argv[arg_fwd], 
argv[arg_rev], argv[arg_stop], argv[arg_pause], argv[arg_restart], skipms);
 
        /* If we stopped on one of our stop keys, return 0  */
-       if (argv[arg_stop] && strchr(argv[arg_stop], res)) 
+       if (argv[arg_stop] && strchr(argv[arg_stop], res)) {
                res = 0;
-
-       if (res < 0) {
-               if (ast_goto_if_exists(chan, chan->context, chan->exten, 
chan->priority + 101))
+               pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", 
"USERSTOPPED");
+       } else {
+               if (res < 0) {
+                       if (priority_jump || option_priority_jumping) {
+                               if (!ast_goto_if_exists(chan, chan->context, 
chan->exten, chan->priority + 101)) {
+                                       ast_log(LOG_WARNING, "ControlPlayback 
tried to jump to priority n+101 as requested, but priority didn't exist\n");
+                               }
+                       }
                        res = 0;
+                       pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", 
"ERROR");
+               } else
+                       pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", 
"SUCCESS");
        }
 
        LOCAL_USER_REMOVE(u);

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to