Sat Aug 6 00:39:37 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"

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int load_module (void)
static int sendurl_exec (struct ast_channel *chan, void *data)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Send URL Applications" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, }
static char * app = "SendURL"
static const struct ast_module_infoast_module_info = &__mod_info
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

static void __reg_module ( void   )  [static]

Definition at line 173 of file app_url.c.

static void __unreg_module ( void   )  [static]

Definition at line 173 of file app_url.c.

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, f, LOG_WARNING, and pbx_builtin_setvar_helper().

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

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Send URL Applications" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static]

Definition at line 173 of file app_url.c.

char* app = "SendURL" [static]

Definition at line 46 of file app_url.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 173 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 Sat Aug 6 00:39:37 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7