Sat Aug 6 00:39:34 2011

Asterisk developer's documentation


app_hasnewvoicemail.c File Reference

HasVoicemail application. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/types.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/app.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 acf_vmcount_exec (struct ast_channel *chan, char *cmd, char *argsstr, char *buf, size_t len)
static int hasvoicemail_exec (struct ast_channel *chan, void *data)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Indicator for whether a voice mailbox has messages in a given folder." , .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, }
ast_custom_function acf_vmcount
static char * app_hasnewvoicemail = "HasNewVoicemail"
static char * app_hasvoicemail = "HasVoicemail"
static const struct ast_module_infoast_module_info = &__mod_info
static char * hasnewvoicemail_descrip
static char * hasnewvoicemail_synopsis = "Conditionally branches to priority + 101 with the right options set"
static char * hasvoicemail_descrip
static char * hasvoicemail_synopsis = "Conditionally branches to priority + 101 with the right options set"


Detailed Description

HasVoicemail application.

Author:
Todd Freeman <freeman@andrews.edu>
Note:
95% based on HasNewVoicemail by Tilghman Lesher <asterisk-hasnewvoicemail-app@the-tilghman.com>

Definition in file app_hasnewvoicemail.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 225 of file app_hasnewvoicemail.c.

static void __unreg_module ( void   )  [static]

Definition at line 225 of file app_hasnewvoicemail.c.

static int acf_vmcount_exec ( struct ast_channel chan,
char *  cmd,
char *  argsstr,
char *  buf,
size_t  len 
) [static]

Definition at line 155 of file app_hasnewvoicemail.c.

References AST_APP_ARG, ast_app_messagecount(), AST_DECLARE_APP_ARGS, ast_module_user_add, ast_module_user_remove, AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_module_user::chan, and context.

00156 {
00157    struct ast_module_user *u;
00158    char *context;
00159    AST_DECLARE_APP_ARGS(args,
00160       AST_APP_ARG(vmbox);
00161       AST_APP_ARG(folder);
00162    );
00163 
00164    if (ast_strlen_zero(argsstr))
00165       return -1;
00166 
00167    u = ast_module_user_add(chan);
00168 
00169    buf[0] = '\0';
00170 
00171    AST_STANDARD_APP_ARGS(args, argsstr);
00172 
00173    if (strchr(args.vmbox, '@')) {
00174       context = args.vmbox;
00175       args.vmbox = strsep(&context, "@");
00176    } else {
00177       context = "default";
00178    }
00179 
00180    if (ast_strlen_zero(args.folder)) {
00181       args.folder = "INBOX";
00182    }
00183 
00184    snprintf(buf, len, "%d", ast_app_messagecount(context, args.vmbox, args.folder));
00185 
00186    ast_module_user_remove(u);
00187    
00188    return 0;
00189 }

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

Definition at line 83 of file app_hasnewvoicemail.c.

References AST_APP_ARG, ast_app_messagecount(), AST_DECLARE_APP_ARGS, ast_goto_if_exists(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_opt_priority_jumping, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_module_user::chan, ast_channel::context, context, input(), LOG_WARNING, and pbx_builtin_setvar_helper().

Referenced by load_module().

00084 {
00085    struct ast_module_user *u;
00086    char *input, *varname = NULL, *vmbox, *context = "default";
00087    char *vmfolder;
00088    int vmcount = 0;
00089    static int dep_warning = 0;
00090    int priority_jump = 0;
00091    char tmp[12];
00092    AST_DECLARE_APP_ARGS(args,
00093       AST_APP_ARG(vmbox);
00094       AST_APP_ARG(varname);
00095       AST_APP_ARG(options);
00096    );
00097 
00098    if (!dep_warning) {
00099       ast_log(LOG_WARNING, "The applications HasVoicemail and HasNewVoicemail have been deprecated.  Please use the VMCOUNT() function instead.\n");
00100       dep_warning = 1;
00101    }
00102    
00103    if (!data) {
00104       ast_log(LOG_WARNING, "HasVoicemail requires an argument (vm-box[/folder][@context][|varname[|options]])\n");
00105       return -1;
00106    }
00107 
00108    u = ast_module_user_add(chan);
00109 
00110    input = ast_strdupa(data);
00111 
00112    AST_STANDARD_APP_ARGS(args, input);
00113 
00114    vmbox = strsep(&args.vmbox, "@");
00115 
00116    if (!ast_strlen_zero(args.vmbox))
00117       context = args.vmbox;
00118 
00119    vmfolder = strchr(vmbox, '/');
00120    if (vmfolder) {
00121       *vmfolder = '\0';
00122       vmfolder++;
00123    } else {
00124       vmfolder = "INBOX";
00125    }
00126 
00127    if (args.options) {
00128       if (strchr(args.options, 'j'))
00129          priority_jump = 1;
00130    }
00131 
00132    vmcount = ast_app_messagecount(context, vmbox, vmfolder);
00133    /* Set the count in the channel variable */
00134    if (varname) {
00135       snprintf(tmp, sizeof(tmp), "%d", vmcount);
00136       pbx_builtin_setvar_helper(chan, varname, tmp);
00137    }
00138 
00139    if (vmcount > 0) {
00140       /* Branch to the next extension */
00141       if (priority_jump || ast_opt_priority_jumping) {
00142          if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) 
00143             ast_log(LOG_WARNING, "VM box %s@%s has new voicemail, but extension %s, priority %d doesn't exist\n", vmbox, context, chan->exten, chan->priority + 101);
00144       }
00145    }
00146 
00147    snprintf(tmp, sizeof(tmp), "%d", vmcount);
00148    pbx_builtin_setvar_helper(chan, "HASVMSTATUS", tmp);
00149    
00150    ast_module_user_remove(u);
00151 
00152    return 0;
00153 }

static int load_module ( void   )  [static]

Definition at line 214 of file app_hasnewvoicemail.c.

References acf_vmcount, ast_custom_function_register(), ast_register_application(), and hasvoicemail_exec().

static int unload_module ( void   )  [static]

Definition at line 201 of file app_hasnewvoicemail.c.

References acf_vmcount, ast_custom_function_unregister(), ast_module_user_hangup_all, and ast_unregister_application().

00202 {
00203    int res;
00204    
00205    res = ast_custom_function_unregister(&acf_vmcount);
00206    res |= ast_unregister_application(app_hasvoicemail);
00207    res |= ast_unregister_application(app_hasnewvoicemail);
00208    
00209    ast_module_user_hangup_all();
00210 
00211    return res;
00212 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Indicator for whether a voice mailbox has messages in a given folder." , .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 225 of file app_hasnewvoicemail.c.

struct ast_custom_function acf_vmcount

Definition at line 191 of file app_hasnewvoicemail.c.

Referenced by load_module(), and unload_module().

char* app_hasnewvoicemail = "HasNewVoicemail" [static]

Definition at line 69 of file app_hasnewvoicemail.c.

char* app_hasvoicemail = "HasVoicemail" [static]

Definition at line 56 of file app_hasnewvoicemail.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 225 of file app_hasnewvoicemail.c.

char* hasnewvoicemail_descrip [static]

Definition at line 71 of file app_hasnewvoicemail.c.

char* hasnewvoicemail_synopsis = "Conditionally branches to priority + 101 with the right options set" [static]

Definition at line 70 of file app_hasnewvoicemail.c.

char* hasvoicemail_descrip [static]

Definition at line 58 of file app_hasnewvoicemail.c.

char* hasvoicemail_synopsis = "Conditionally branches to priority + 101 with the right options set" [static]

Definition at line 57 of file app_hasnewvoicemail.c.


Generated on Sat Aug 6 00:39:34 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7