Sun Jun 12 16:37:50 2011

Asterisk developer's documentation


app_url.c File Reference

App to transmit a URL. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/image.h"
#include "asterisk/options.h"

Include dependency graph for app_url.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Send URL Applications")
static int load_module (void)
static int sendurl_exec (struct ast_channel *chan, void *data)
static int unload_module (void)

Variables

static char * app = "SendURL"
static char * descrip
static char * synopsis = "Send a URL"


Detailed Description

App to transmit a URL.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_url.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Send URL Applications"   
)

static int load_module ( void   )  [static]

Definition at line 168 of file app_url.c.

References ast_register_application(), and sendurl_exec().

00169 {
00170    return ast_register_application(app, sendurl_exec, synopsis, descrip);
00171 }

static int sendurl_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 70 of file app_url.c.

References ast_channel_sendurl(), ast_channel_supports_html(), AST_FRAME_HTML, ast_frfree, ast_goto_if_exists(), AST_HTML_LDCOMPLETE, AST_HTML_NOSUPPORT, ast_log(), ast_module_user_add, ast_module_user_remove, ast_opt_priority_jumping, ast_read(), ast_strdupa, ast_strlen_zero(), ast_waitfor(), ast_channel::context, ast_channel::exten, f, ast_frame::frametype, LOG_WARNING, pbx_builtin_setvar_helper(), ast_channel::priority, strsep(), and ast_frame::subclass.

Referenced by load_module().

00071 {
00072    int res = 0;
00073    struct ast_module_user *u;
00074    char *tmp;
00075    char *options;
00076    int local_option_wait=0;
00077    int local_option_jump = 0;
00078    struct ast_frame *f;
00079    char *stringp=NULL;
00080    char *status = "FAILURE";
00081    
00082    if (ast_strlen_zero(data)) {
00083       ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n");
00084       pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
00085       return -1;
00086    }
00087 
00088    u = ast_module_user_add(chan);
00089 
00090    tmp = ast_strdupa(data);
00091 
00092    stringp=tmp;
00093    strsep(&stringp, "|");
00094    options = strsep(&stringp, "|");
00095    if (options && !strcasecmp(options, "wait"))
00096       local_option_wait = 1;
00097    if (options && !strcasecmp(options, "j"))
00098       local_option_jump = 1;
00099    
00100    if (!ast_channel_supports_html(chan)) {
00101       /* Does not support transport */
00102       if (local_option_jump || ast_opt_priority_jumping)
00103           ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
00104       pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED");
00105       ast_module_user_remove(u);
00106       return 0;
00107    }
00108    res = ast_channel_sendurl(chan, tmp);
00109    if (res == -1) {
00110       pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE");
00111       ast_module_user_remove(u);
00112       return res;
00113    }
00114    status = "SUCCESS";
00115    if (local_option_wait) {
00116       for(;;) {
00117          /* Wait for an event */
00118          res = ast_waitfor(chan, -1);
00119          if (res < 0) 
00120             break;
00121          f = ast_read(chan);
00122          if (!f) {
00123             res = -1;
00124             status = "FAILURE";
00125             break;
00126          }
00127          if (f->frametype == AST_FRAME_HTML) {
00128             switch(f->subclass) {
00129             case AST_HTML_LDCOMPLETE:
00130                res = 0;
00131                ast_frfree(f);
00132                status = "NOLOAD";
00133                goto out;
00134                break;
00135             case AST_HTML_NOSUPPORT:
00136                /* Does not support transport */
00137                status ="UNSUPPORTED";
00138                if (local_option_jump || ast_opt_priority_jumping)
00139                   ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
00140                res = 0;
00141                ast_frfree(f);
00142                goto out;
00143                break;
00144             default:
00145                ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass);
00146             };
00147          }
00148          ast_frfree(f);
00149       }
00150    } 
00151 out:  
00152    pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
00153    ast_module_user_remove(u);
00154    return res;
00155 }

static int unload_module ( void   )  [static]

Definition at line 157 of file app_url.c.

References ast_module_user_hangup_all, and ast_unregister_application().

00158 {
00159    int res;
00160 
00161    res = ast_unregister_application(app);
00162    
00163    ast_module_user_hangup_all();
00164 
00165    return res; 
00166 }


Variable Documentation

char* app = "SendURL" [static]

Definition at line 46 of file app_url.c.

char* descrip [static]

Definition at line 50 of file app_url.c.

char* synopsis = "Send a URL" [static]

Definition at line 48 of file app_url.c.


Generated on Sun Jun 12 16:37:50 2011 for Asterisk - the Open Source PBX by  doxygen 1.5.6