--- asterisk-1.2.14/apps/app_page.c 2006-09-11 16:47:23.000000000 -0500 +++ asterisk-1.2.14-dev/apps/app_page.c 2006-12-23 12:38:04.000000000 -0600 @@ -41,6 +41,7 @@ #include "asterisk/file.h" #include "asterisk/app.h" #include "asterisk/chanvars.h" +#include "asterisk/devicestate.h" static const char *tdesc = "Page Multiple Phones"; @@ -56,7 +57,8 @@ "caller is dumped into the conference as a speaker and the room is\n" "destroyed when the original caller leaves. Valid options are:\n" " d - full duplex audio\n" -" q - quiet, do not play beep to caller\n"; +" q - quiet, do not play beep to caller\n" +" s - skip channel if devicestate not equal to \"1 - Not in use\""; STANDARD_LOCAL_USER; @@ -65,11 +67,13 @@ enum { PAGE_DUPLEX = (1 << 0), PAGE_QUIET = (1 << 1), + PAGE_SKIP = (1 << 2), } page_opt_flags; AST_APP_OPTIONS(page_opts, { AST_APP_OPTION('d', PAGE_DUPLEX), AST_APP_OPTION('q', PAGE_QUIET), + AST_APP_OPTION('s', PAGE_SKIP), }); struct calloutdata { @@ -150,6 +154,8 @@ char *tmp; int res=0; char originator[AST_CHANNEL_NAME]; + int state = 0; + char name[32]; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n"); @@ -181,12 +187,25 @@ snprintf(meetmeopts, sizeof(meetmeopts), "%ud|%sqxdw(5)", confid, ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"); + if(ast_test_flag(&flags, PAGE_SKIP)) { + ast_log(LOG_DEBUG, "Testing Channel status\n"); + } + while ((tech = strsep(&tmp, "&"))) { /* don't call the originating device */ if (!strcasecmp(tech, originator)) continue; if ((resource = strchr(tech, '/'))) { + if (ast_test_flag(&flags, PAGE_SKIP)) { + state = ast_device_state(tech); + snprintf(name, sizeof(name), "%s", devstate2str(state)); + if (state != 1) { + ast_log(LOG_WARNING, "Channel %s, devicestate(%d)->%s skipping channel\n", tech, state, name); + continue; + } + } + ast_log(LOG_DEBUG, "Channel %s, devicestate(%i)->%s, Adding to meetme\n", tech, state, name); *resource++ = '\0'; launch_page(chan, meetmeopts, tech, resource); } else {